Recoded IsClientPlayer, renamed to IsClientValid, replaced
GetMaxClients() with maxclients Ignore diff for zhp.inc and spawnprotect.inc
This commit is contained in:
parent
f39570205e
commit
872e41e6d2
@ -127,7 +127,6 @@ public OnLibraryAdded(const String:name[])
|
||||
|
||||
public OnMapStart()
|
||||
{
|
||||
maxclients = GetMaxClients();
|
||||
MapChangeCleanup();
|
||||
|
||||
LoadModelData();
|
||||
@ -226,13 +225,14 @@ MapChangeCleanup()
|
||||
AmbienceStopAll();
|
||||
AntiStickReset();
|
||||
|
||||
for (new client = 1; client <= maxclients; client++)
|
||||
// x = client index.
|
||||
for (new x = 1; x <= MaxClients; x++)
|
||||
{
|
||||
for (new x = 0; x < MAXTIMERS; x++)
|
||||
for (new y = 0; y < MAXTIMERS; y++)
|
||||
{
|
||||
if (tHandles[client][x] != INVALID_HANDLE)
|
||||
if (tHandles[x][y] != INVALID_HANDLE)
|
||||
{
|
||||
tHandles[client][x] = INVALID_HANDLE;
|
||||
tHandles[x][y] = INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -250,7 +250,7 @@ ZREnd()
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x <= maxplayers; x++)
|
||||
{
|
||||
if (!IsClientConnected(x) || !IsClientInGame(x))
|
||||
if (!IsClientInGame(x))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -97,9 +97,10 @@ AmbienceStop(client)
|
||||
|
||||
AmbienceStopAll()
|
||||
{
|
||||
for (new client = 1; client < maxclients; client++)
|
||||
// x = client index.
|
||||
for (new x = 1; x < MaxClients; x++)
|
||||
{
|
||||
AmbienceStop(client);
|
||||
AmbienceStop(x);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,9 +112,10 @@ AmbienceRestart(client)
|
||||
|
||||
AmbienceRestartAll()
|
||||
{
|
||||
for (new client = 1; client < maxclients; client++)
|
||||
// x = client index.
|
||||
for (new x = 1; x < MaxClients; x++)
|
||||
{
|
||||
AmbienceRestart(client);
|
||||
AmbienceRestart(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,48 +324,50 @@ id damage interval x_min y_min z_min x_max y_max z_max
|
||||
|
||||
UpdatePlayerLocations()
|
||||
{
|
||||
new client;
|
||||
for (client = 1; client <= maxclients; client++)
|
||||
// x = client index.
|
||||
for (new x = 1; x <= MaxClients; x++)
|
||||
{
|
||||
if (IsClientConnected(client) && IsClientInGame(client))
|
||||
// If client isn't in-game, then stop.
|
||||
if (!IsClientInGame(x))
|
||||
{
|
||||
GetClientAbsOrigin(client, player_loc[client]);
|
||||
return;
|
||||
}
|
||||
|
||||
GetClientAbsOrigin(x, player_loc[x]);
|
||||
}
|
||||
}
|
||||
|
||||
HurtPlayersInVolume(volume_index)
|
||||
{
|
||||
new client;
|
||||
new client_health;
|
||||
decl String:client_name[64];
|
||||
decl String:buffer[192];
|
||||
new anticamp_echo = GetConVarBool(gCvars[CVAR_ANTICAMP_ECHO]);
|
||||
|
||||
for (client = 1; client <= maxclients; client++)
|
||||
// x = client index.
|
||||
for (new x = 1; x <= MaxClients; x++)
|
||||
{
|
||||
if (IsClientConnected(client) &&
|
||||
IsClientInGame(client) &&
|
||||
IsPlayerAlive(client) &&
|
||||
IsPlayerHuman(client))
|
||||
if (IsClientInGame(x) &&
|
||||
IsPlayerAlive(x) &&
|
||||
IsPlayerHuman(x))
|
||||
{
|
||||
if (IsPlayerInVolume(client, volume_index))
|
||||
if (IsPlayerInVolume(x, volume_index))
|
||||
{
|
||||
ZR_PrintToChat(client, "Unfair camping");
|
||||
client_health = GetClientHealth(client) - volumes[volume_index][volume_damage];
|
||||
ZR_PrintToChat(x, "Unfair camping");
|
||||
client_health = GetClientHealth(x) - volumes[volume_index][volume_damage];
|
||||
if (client_health > 0)
|
||||
{
|
||||
SetEntityHealth(client, client_health);
|
||||
SetEntityHealth(x, client_health);
|
||||
}
|
||||
else
|
||||
{
|
||||
ForcePlayerSuicide(client);
|
||||
ForcePlayerSuicide(x);
|
||||
|
||||
GetClientName(client, client_name, sizeof(client_name));
|
||||
SetGlobalTransTarget(client);
|
||||
GetClientName(x, client_name, sizeof(client_name));
|
||||
SetGlobalTransTarget(x);
|
||||
Format(buffer, sizeof(buffer), "%T", "Unfair camper slayed", LANG_SERVER, client_name, volume_index);
|
||||
|
||||
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_ANTICAMP)) ZR_LogMessageFormatted(client, "anticamp", "kill", "%s", true, buffer);
|
||||
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_ANTICAMP)) ZR_LogMessageFormatted(x, "anticamp", "kill", "%s", true, buffer);
|
||||
if (anticamp_echo)
|
||||
{
|
||||
FormatTextString(buffer, sizeof(buffer));
|
||||
|
@ -250,7 +250,7 @@ public Action:Command_GetClassKnockback(client, argc)
|
||||
|
||||
public Action:Command_AdminMenu(client, argc)
|
||||
{
|
||||
if (IsClientPlayer(client))
|
||||
if (ZRIsValidClient(client))
|
||||
{
|
||||
ZRAdminMenu(client);
|
||||
}
|
||||
@ -264,7 +264,7 @@ public Action:Command_AdminMenu(client, argc)
|
||||
|
||||
public Action:Command_KnockbackMMenu(client, argc)
|
||||
{
|
||||
if (IsClientPlayer(client))
|
||||
if (ZRIsValidClient(client))
|
||||
{
|
||||
// Disabled, under construction.
|
||||
// ZRKnockbackMMenu(client);
|
||||
@ -279,7 +279,7 @@ public Action:Command_KnockbackMMenu(client, argc)
|
||||
|
||||
public Action:Command_TeleMenu(client, argc)
|
||||
{
|
||||
if (IsClientPlayer(client))
|
||||
if (ZRIsValidClient(client))
|
||||
{
|
||||
ZRZTeleMenu(client);
|
||||
}
|
||||
|
@ -24,11 +24,8 @@ new gHooks[MAXPLAYERS + 1][ZRHooks];
|
||||
|
||||
InitDmgControl()
|
||||
{
|
||||
/* It's case sensitive! */
|
||||
RegConsoleCmd("kill", Attempt_Suicide);
|
||||
RegConsoleCmd("KILL", Attempt_Suicide);
|
||||
RegConsoleCmd("jointeam", Attempt_Suicide);
|
||||
RegConsoleCmd("JOINTEAM", Attempt_Suicide);
|
||||
RegConsoleCmd("spectate", Attempt_Suicide);
|
||||
}
|
||||
|
||||
@ -48,7 +45,7 @@ public TraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
|
||||
{
|
||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||
|
||||
if (!attacker || !IsClientPlayer(attacker) || !IsClientInGame(attacker) || !enabled)
|
||||
if (!attacker || !ZRIsValidClient(attacker) || !IsClientInGame(attacker) || !enabled)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
@ -99,7 +96,7 @@ public OnTakeDamage(client, inflictor, attacker, damage, damagetype, ammotype)
|
||||
|
||||
if (damagetype & DMG_BLAST)
|
||||
{
|
||||
if (!IsPlayerHuman(client) || !IsClientPlayer(attacker) || !IsClientInGame(attacker))
|
||||
if (!IsPlayerHuman(client) || !ZRIsValidClient(attacker) || !IsClientInGame(attacker))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
@ -109,12 +106,12 @@ public OnTakeDamage(client, inflictor, attacker, damage, damagetype, ammotype)
|
||||
|
||||
if (damagetype & DMG_BULLET)
|
||||
{
|
||||
if (!client || !IsClientPlayer(client) || !IsClientInGame(client))
|
||||
if (!client || !ZRIsValidClient(client) || !IsClientInGame(client))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
if (!attacker || !IsClientPlayer(attacker) || !IsClientInGame(attacker))
|
||||
if (!attacker || !ZRIsValidClient(attacker) || !IsClientInGame(attacker))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
@ -220,11 +220,8 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
decl String:weapon[32];
|
||||
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
||||
|
||||
// Forward event to modules.
|
||||
KnockbackPlayerHurt(index, attacker, weapon, hitgroup, dmg_health);
|
||||
|
||||
// Check if the attacker is a player.
|
||||
if (attacker != 0)
|
||||
if (ZRIsValidClient(attacker))
|
||||
{
|
||||
// Check if a zombie attacks a human.
|
||||
if (IsPlayerHuman(index) && IsPlayerZombie(attacker))
|
||||
@ -265,6 +262,7 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
|
||||
// Forward event to modules.
|
||||
ClassAlphaUpdate(index);
|
||||
KnockbackPlayerHurt(index, attacker, weapon, hitgroup, dmg_health);
|
||||
ZHPOnPlayerHurt(index);
|
||||
}
|
||||
|
||||
@ -285,13 +283,13 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
if (StrEqual(weapon, "zombie_claws_of_death", false))
|
||||
{
|
||||
// Add a death count to the players score.
|
||||
if (index)
|
||||
if (ZRIsValidClient(index))
|
||||
{
|
||||
AddPlayerDeath(index, 1);
|
||||
}
|
||||
|
||||
// Give a point to the attacker.
|
||||
if (attacker)
|
||||
if (ZRIsValidClient(attacker))
|
||||
{
|
||||
AddPlayerScore(attacker, 1);
|
||||
|
||||
@ -317,14 +315,14 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
EmitSoundToAll(sound, index);
|
||||
|
||||
// Give kill bonus.
|
||||
if (attacker)
|
||||
if (ZRIsValidClient(attacker))
|
||||
{
|
||||
new bonus = ClassGetKillBonus(attacker);
|
||||
AddPlayerScore(attacker, bonus);
|
||||
}
|
||||
|
||||
// Check if the player was killed by world damage.
|
||||
if (!IsClientPlayer(attacker))
|
||||
if (!ZRIsValidClient(attacker))
|
||||
{
|
||||
gKilledByWorld[index] = true;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
MainMenu(client)
|
||||
{
|
||||
new Handle:menu_main = CreateMenu(MainMenuHandle);
|
||||
new itemdraw = (IsClientAdmin(client)) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
||||
new itemdraw = (ZRIsClientAdmin(client)) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
||||
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
|
@ -48,7 +48,7 @@ Admin mode is enabled!
|
||||
ClassMenuMain(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(ClassMenuMainHandle);
|
||||
new itemdraw = (IsClientAdmin(client)) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
||||
new itemdraw = (ZRIsClientAdmin(client)) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
||||
|
||||
SetGlobalTransTarget(client);
|
||||
SetMenuTitle(menu, "%t\n", "!zclass title");
|
||||
@ -83,7 +83,7 @@ ClassMenuMain(client)
|
||||
Format(humanselect, sizeof(humanselect), "%t\n %s", "!zclass human", humanclass);
|
||||
AddMenuItem(menu, "", humanselect);
|
||||
|
||||
if (IsClientAdmin(client))
|
||||
if (ZRIsClientAdmin(client))
|
||||
{
|
||||
// List admin class options.
|
||||
ClassGetName(ClassSelected[client][ZR_CLASS_TEAM_ADMINS], adminclass, sizeof(adminclass), ZR_CLASS_CACHE_MODIFIED);
|
||||
@ -134,7 +134,7 @@ public ClassMenuMainHandle(Handle:menu, MenuAction:action, client, slot)
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
ClassMenuToggleAdmin(client);
|
||||
// ClassMenuToggleAdmin(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -273,5 +273,4 @@ public ClassMenuSelectHandle(Handle:menu, MenuAction:action, client, slot)
|
||||
|
||||
ClassMenuToggleAdmin(client)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ bool:ClassReloadDataCache()
|
||||
bool:ClassReloadPlayerCache(client, classindex, cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
{
|
||||
// Validate indexes.
|
||||
if (!ClassValidateIndex(classindex) || !IsClientPlayer(client))
|
||||
if (!ClassValidateIndex(classindex) || !ZRIsValidClient(client))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ stock ZR_PrintToChat(client, any:...)
|
||||
{
|
||||
decl String:phrase[192];
|
||||
|
||||
if (client)
|
||||
if (ZRIsValidClient(client))
|
||||
{
|
||||
SetGlobalTransTarget(client);
|
||||
|
||||
@ -204,11 +204,13 @@ stock ZR_PrintToAdminChat(String:message[])
|
||||
{
|
||||
decl String:buffer[256];
|
||||
Format(buffer, sizeof(buffer), "[ZR] %s", message);
|
||||
for (new client = 1; client < maxclients; client++)
|
||||
|
||||
// x = client index.
|
||||
for (new x = 1; x < MaxClients; x++)
|
||||
{
|
||||
if (IsClientConnected(client) && IsClientInGame(client) && GetAdminFlag(GetUserAdmin(client), Admin_Generic))
|
||||
if (IsClientInGame(x) && ZRIsClientAdmin(x))
|
||||
{
|
||||
PrintToChat(client, buffer);
|
||||
PrintToChat(x, buffer);
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ new curMenuClass[MAXPLAYERS + 1];
|
||||
|
||||
bool:ZRAdminMenu(client)
|
||||
{
|
||||
if (!IsClientAdmin(client))
|
||||
if (!ZRIsClientAdmin(client))
|
||||
{
|
||||
ZR_PrintToChat(client, "Must be admin");
|
||||
return false;
|
||||
@ -417,7 +417,8 @@ public ZRInfectHandle(Handle:menu_infect, MenuAction:action, client, slot)
|
||||
|
||||
ZRSpawnAll(client)
|
||||
{
|
||||
for (new x = 1; x < maxclients; x++)
|
||||
// x = client index.
|
||||
for (new x = 1; x < MaxClients; x++)
|
||||
{
|
||||
if (IsClientInGame(x))
|
||||
{
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Zombie:Reloaded
|
||||
*
|
||||
* File: zhp.inc
|
||||
* Description: Displays
|
||||
* Description: Displays HP to zombies.
|
||||
* Author: Greyscale, Richard Helgeby
|
||||
*
|
||||
* ============================================================================
|
||||
|
@ -87,8 +87,6 @@ new Handle:ztele_startup_timer = INVALID_HANDLE;
|
||||
new Handle:ztele_countdown_timer[MAXPLAYERS + 1] = {INVALID_HANDLE, ...};
|
||||
new Handle:ztele_cooldown_timer[MAXPLAYERS + 1] = {INVALID_HANDLE, ...};
|
||||
|
||||
new maxclients;
|
||||
|
||||
new Handle:tRound = INVALID_HANDLE;
|
||||
new Handle:tInfect = INVALID_HANDLE;
|
||||
|
||||
@ -233,14 +231,22 @@ bool:IsPlayerInList(client)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool:IsClientPlayer(client)
|
||||
/**
|
||||
* Check if a client index is a valid player.
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param console True to include console (index 0), false if not.
|
||||
*/
|
||||
bool:ZRIsValidClient(client, bool:console = false)
|
||||
{
|
||||
if (!IsFakeClient(client) && client > 0 && client <= maxclients)
|
||||
// If index is greater than max number of clients, then return false.
|
||||
if (client > MaxClients)
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
// If console is true, return if client is >= 0, if not, then return client > 0.
|
||||
return console ? (client >= 0) : (client > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -249,12 +255,14 @@ bool:IsClientPlayer(client)
|
||||
* @param client The client index.
|
||||
* @return True if generic admin, false otherwise.
|
||||
*/
|
||||
bool:IsClientAdmin(client)
|
||||
bool:ZRIsClientAdmin(client)
|
||||
{
|
||||
if (IsClientPlayer(client) && GetAdminFlag(GetUserAdmin(client), Admin_Generic))
|
||||
// Check to make sure client is valid and has the Admin_Generic SourceMod admin flag.
|
||||
if (ZRIsValidClient(client) && GetAdminFlag(GetUserAdmin(client), Admin_Generic))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Client is not an admin.
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user