diff --git a/plugins/admin-sql-threaded.sp b/plugins/admin-sql-threaded.sp index 759df89f..60bc09c0 100644 --- a/plugins/admin-sql-threaded.sp +++ b/plugins/admin-sql-threaded.sp @@ -526,9 +526,7 @@ FetchUser(Handle:db, client) FetchUsersWeCan(Handle:db) { - new max_clients = GetMaxClients(); - - for (new i=1; i<=max_clients; i++) + for (new i=1; i<=MaxClients; i++) { if (PlayerAuth[i] && GetUserAdmin(i) == INVALID_ADMIN_ID) { diff --git a/plugins/adminmenu.sp b/plugins/adminmenu.sp index 77a3c804..6d131a2b 100644 --- a/plugins/adminmenu.sp +++ b/plugins/adminmenu.sp @@ -45,8 +45,6 @@ public Plugin:myinfo = url = "http://www.sourcemod.net/" }; -new g_maxPlayers; - /* Forwards */ new Handle:hOnAdminMenuReady = INVALID_HANDLE; new Handle:hOnAdminMenuCreated = INVALID_HANDLE; @@ -97,8 +95,6 @@ public OnConfigsExecuted() public OnMapStart() { - g_maxPlayers = GetMaxClients(); - ParseConfigs(); } @@ -215,14 +211,13 @@ public Action:Command_DisplayMenu(client, args) stock UTIL_AddTargetsToMenu2(Handle:menu, source_client, flags) { - new max_clients = GetMaxClients(); decl String:user_id[12]; decl String:name[MAX_NAME_LENGTH]; decl String:display[MAX_NAME_LENGTH+12]; new num_clients; - for (new i = 1; i <= max_clients; i++) + for (new i = 1; i <= MaxClients; i++) { if (!IsClientConnected(i) || IsClientInKickQueue(i)) { diff --git a/plugins/adminmenu/dynamicmenu.sp b/plugins/adminmenu/dynamicmenu.sp index 425a250c..5ac57402 100644 --- a/plugins/adminmenu/dynamicmenu.sp +++ b/plugins/adminmenu/dynamicmenu.sp @@ -512,7 +512,7 @@ public ParamCheck(client) new String:temp[4]; //loop through players. Add name as text and name/userid/steamid as info - for (new i=1; i<=g_maxPlayers; i++) + for (new i=1; i<=MaxClients; i++) { if (IsClientInGame(i)) { diff --git a/plugins/basecomm.sp b/plugins/basecomm.sp index d79dfc55..e27b280b 100644 --- a/plugins/basecomm.sp +++ b/plugins/basecomm.sp @@ -157,9 +157,8 @@ public Action:Command_Say(client, args) public ConVarChange_Alltalk(Handle:convar, const String:oldValue[], const String:newValue[]) { new mode = GetConVarInt(g_Cvar_Deadtalk); - new maxClients = GetMaxClients(); - for (new i = 1; i <= maxClients; i++) + for (new i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i)) { diff --git a/plugins/basecommands/who.sp b/plugins/basecommands/who.sp index af6d3502..2897d14b 100644 --- a/plugins/basecommands/who.sp +++ b/plugins/basecommands/who.sp @@ -189,10 +189,9 @@ public Action:Command_Who(client, args) } /* List all players */ - new maxClients = GetMaxClients(); decl String:flagstring[255]; - for (new i=1; i<=maxClients; i++) + for (new i=1; i<=MaxClients; i++) { if (!IsClientInGame(i)) { diff --git a/plugins/funcommands/beacon.sp b/plugins/funcommands/beacon.sp index 27890c91..5017641c 100644 --- a/plugins/funcommands/beacon.sp +++ b/plugins/funcommands/beacon.sp @@ -53,9 +53,7 @@ KillBeacon(client) KillAllBeacons() { - new maxclients = GetMaxClients(); - - for (new i = 1; i <= maxclients; i++) + for (new i = 1; i <= MaxClients; i++) { KillBeacon(i); } diff --git a/plugins/funcommands/drug.sp b/plugins/funcommands/drug.sp index 71a6e8b8..0c50e2da 100644 --- a/plugins/funcommands/drug.sp +++ b/plugins/funcommands/drug.sp @@ -74,8 +74,7 @@ KillDrugTimer(client) KillAllDrugs() { - new maxclients = GetMaxClients(); - for (new i = 1; i <= maxclients; i++) + for (new i = 1; i <= MaxClients; i++) { if (g_DrugTimers[i] != INVALID_HANDLE) { diff --git a/plugins/funcommands/fire.sp b/plugins/funcommands/fire.sp index 683bf3fd..f6667b44 100644 --- a/plugins/funcommands/fire.sp +++ b/plugins/funcommands/fire.sp @@ -58,9 +58,7 @@ KillFireBomb(client) KillAllFireBombs() { - new maxclients = GetMaxClients(); - - for (new i = 1; i <= maxclients; i++) + for (new i = 1; i <= MaxClients; i++) { KillFireBomb(i); } @@ -162,9 +160,8 @@ public Action:Timer_FireBomb(Handle:timer, any:value) if (GetConVarInt(g_Cvar_FireBombMode) > 0) { new teamOnly = ((GetConVarInt(g_Cvar_FireBombMode) == 1) ? true : false); - new maxClients = GetMaxClients(); - for (new i = 1; i <= maxClients; i++) + for (new i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i) || !IsPlayerAlive(i) || i == client) { diff --git a/plugins/funcommands/ice.sp b/plugins/funcommands/ice.sp index 54b0d37d..ba349b01 100644 --- a/plugins/funcommands/ice.sp +++ b/plugins/funcommands/ice.sp @@ -105,9 +105,7 @@ KillFreezeBomb(client) KillAllFreezes( ) { - new maxclients = GetMaxClients( ); - - for(new i = 1; i <= maxclients; i++) + for(new i = 1; i <= MaxClients; i++) { if (g_FreezeSerial[i] != 0) { @@ -254,9 +252,8 @@ public Action:Timer_FreezeBomb(Handle:timer, any:value) if (GetConVarInt(g_Cvar_FreezeBombMode) > 0) { new bool:teamOnly = ((GetConVarInt(g_Cvar_FreezeBombMode) == 1) ? true : false); - new maxClients = GetMaxClients( ); - for (new i = 1; i <= maxClients; i++) + for (new i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i) || !IsPlayerAlive(i) || i == client) { diff --git a/plugins/funcommands/timebomb.sp b/plugins/funcommands/timebomb.sp index 29e3c1f8..09ee125f 100644 --- a/plugins/funcommands/timebomb.sp +++ b/plugins/funcommands/timebomb.sp @@ -57,9 +57,7 @@ KillTimeBomb(client) KillAllTimeBombs() { - new maxclients = GetMaxClients(); - - for (new i = 1; i <= maxclients; i++) + for (new i = 1; i <= MaxClients; i++) { KillTimeBomb(i); } @@ -141,9 +139,8 @@ public Action:Timer_TimeBomb(Handle:timer, any:value) if (GetConVarInt(g_Cvar_TimeBombMode) > 0) { new teamOnly = ((GetConVarInt(g_Cvar_TimeBombMode) == 1) ? true : false); - new maxClients = GetMaxClients(); - for (new i = 1; i <= maxClients; i++) + for (new i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i) || !IsPlayerAlive(i) || i == client) { diff --git a/plugins/include/halflife.inc b/plugins/include/halflife.inc index 42dbb94c..e3d4e6e5 100644 --- a/plugins/include/halflife.inc +++ b/plugins/include/halflife.inc @@ -273,10 +273,9 @@ native PrintToChat(client, const String:format[], any:...); */ stock PrintToChatAll(const String:format[], any:...) { - new maxClients = GetMaxClients(); decl String:buffer[192]; - for (new i = 1; i <= maxClients; i++) + for (new i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { @@ -307,10 +306,9 @@ native PrintCenterText(client, const String:format[], any:...); */ stock PrintCenterTextAll(const String:format[], any:...) { - new maxClients = GetMaxClients(); decl String:buffer[192]; - for (new i = 1; i <= maxClients; i++) + for (new i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { @@ -341,10 +339,9 @@ native PrintHintText(client, const String:format[], any:...); */ stock PrintHintTextToAll(const String:format[], any:...) { - new maxClients = GetMaxClients(); decl String:buffer[192]; - for (new i = 1; i <= maxClients; i++) + for (new i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { diff --git a/plugins/include/helpers.inc b/plugins/include/helpers.inc index 106f0b64..a18535a8 100644 --- a/plugins/include/helpers.inc +++ b/plugins/include/helpers.inc @@ -99,7 +99,6 @@ stock Handle:FindPluginByFile(const String:filename[]) #pragma deprecated Use FindTarget() or ProcessTargetString() stock SearchForClients(const String:pattern[], clients[], maxClients) { - new maxclients = GetMaxClients(); new total = 0; if (maxClients == 0) @@ -113,7 +112,7 @@ stock SearchForClients(const String:pattern[], clients[], maxClients) if (!input) { decl String:name[65] - for (new i=1; i<=maxclients; i++) + for (new i=1; i<=MaxClients; i++) { if (!IsClientInGame(i)) { @@ -137,7 +136,7 @@ stock SearchForClients(const String:pattern[], clients[], maxClients) } decl String:name[65] - for (new i=1; i<=maxclients; i++) + for (new i=1; i<=MaxClients; i++) { if (!IsClientInGame(i)) { diff --git a/plugins/include/menus.inc b/plugins/include/menus.inc index 1d7d37d2..0250c89e 100644 --- a/plugins/include/menus.inc +++ b/plugins/include/menus.inc @@ -490,11 +490,10 @@ native bool:VoteMenu(Handle:menu, clients[], numClients, time, flags=0); */ stock VoteMenuToAll(Handle:menu, time, flags=0) { - new num = GetMaxClients(); new total; - decl players[num]; + decl players[MaxClients]; - for (new i=1; i<=num; i++) + for (new i=1; i<=MaxClients; i++) { if (!IsClientInGame(i)) { diff --git a/plugins/include/sdktools_sound.inc b/plugins/include/sdktools_sound.inc index a10e04b1..f262caf5 100644 --- a/plugins/include/sdktools_sound.inc +++ b/plugins/include/sdktools_sound.inc @@ -403,11 +403,10 @@ stock EmitSoundToAll(const String:sample[], bool:updatePos = true, Float:soundtime = 0.0) { - new maxClients = GetMaxClients(); new clients[maxClients]; new total = 0; - for (new i=1; i<=maxClients; i++) + for (new i=1; i<=MaxClients; i++) { if (IsClientInGame(i)) { diff --git a/plugins/include/sdktools_tempents.inc b/plugins/include/sdktools_tempents.inc index cd454d0b..fc741362 100644 --- a/plugins/include/sdktools_tempents.inc +++ b/plugins/include/sdktools_tempents.inc @@ -197,10 +197,9 @@ stock TE_WriteEncodedEnt(const String:prop[], value) */ stock TE_SendToAll(Float:delay=0.0) { - new maxClients = GetMaxClients(); new total = 0; - new clients[maxClients]; - for (new i=1; i<=maxClients; i++) + new clients[MaxClients]; + for (new i=1; i<=MaxClients; i++) { if (IsClientInGame(i)) { diff --git a/plugins/include/usermessages.inc b/plugins/include/usermessages.inc index d7c4a6b7..aa58297b 100644 --- a/plugins/include/usermessages.inc +++ b/plugins/include/usermessages.inc @@ -170,10 +170,9 @@ native UnhookUserMessage(UserMsg:msg_id, MsgHook:hook, bool:intercept=false); */ stock Handle:StartMessageAll(String:msgname[], flags=0) { - new maxClients = GetMaxClients(); new total = 0; - new clients[maxClients]; - for (new i=1; i<=maxClients; i++) + new clients[MaxClients]; + for (new i=1; i<=MaxClients; i++) { if (IsClientConnected(i)) { diff --git a/plugins/nextmap.sp b/plugins/nextmap.sp index 49510a19..9217327e 100644 --- a/plugins/nextmap.sp +++ b/plugins/nextmap.sp @@ -224,6 +224,4 @@ FormatTimeDuration(String:buffer[], maxlen, time) { return Format(buffer, maxlen, "%is", seconds); } - - return Plugin_Handled; } diff --git a/plugins/reservedslots.sp b/plugins/reservedslots.sp index eacbf1b1..176e6bc1 100644 --- a/plugins/reservedslots.sp +++ b/plugins/reservedslots.sp @@ -44,8 +44,6 @@ public Plugin:myinfo = url = "http://www.sourcemod.net/" }; -/* Maximum number of clients that can connect to server */ -new g_MaxClients; new g_adminCount = 0; new bool:g_isAdmin[MAXPLAYERS+1]; @@ -82,16 +80,14 @@ public OnPluginStart() public OnPluginEnd() { /* If the plugin has been unloaded, reset visiblemaxplayers. In the case of the server shutting down this effect will not be visible */ - SetConVarInt(sv_visiblemaxplayers, g_MaxClients); + SetConVarInt(sv_visiblemaxplayers, MaxClients); } public OnMapStart() { - g_MaxClients = GetMaxClients(); - if (GetConVarBool(sm_hide_slots)) { - SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots)); + SetVisibleMaxSlots(GetClientCount(false), MaxClients - GetConVarInt(sm_reserved_slots)); } } @@ -99,7 +95,7 @@ public OnConfigsExecuted() { if (GetConVarBool(sm_hide_slots)) { - SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots)); + SetVisibleMaxSlots(GetClientCount(false), MaxClients - GetConVarInt(sm_reserved_slots)); } } @@ -114,7 +110,7 @@ public Action:OnTimedKick(Handle:timer, any:client) if (GetConVarBool(sm_hide_slots)) { - SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots)); + SetVisibleMaxSlots(GetClientCount(false), MaxClients - GetConVarInt(sm_reserved_slots)); } return Plugin_Handled; @@ -127,7 +123,7 @@ public OnClientPostAdminCheck(client) if (reserved > 0) { new clients = GetClientCount(false); - new limit = g_MaxClients - reserved; + new limit = MaxClients - reserved; new flags = GetUserFlagBits(client); new type = GetConVarInt(sm_reserve_type); @@ -204,7 +200,7 @@ public OnClientDisconnect_Post(client) { if (GetConVarBool(sm_hide_slots)) { - SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots)); + SetVisibleMaxSlots(GetClientCount(false), MaxClients - GetConVarInt(sm_reserved_slots)); } if (g_isAdmin[client]) @@ -219,7 +215,7 @@ public SlotsChanged(Handle:convar, const String:oldValue[], const String:newValu /* Reserved slots or hidden slots have been disabled - reset sv_visiblemaxplayers */ if (StringToInt(newValue) == 0) { - SetConVarInt(sv_visiblemaxplayers, g_MaxClients); + SetConVarInt(sv_visiblemaxplayers, MaxClients); } } @@ -227,9 +223,9 @@ SetVisibleMaxSlots(clients, limit) { new num = clients; - if (clients == g_MaxClients) + if (clients == MaxClients) { - num = g_MaxClients; + num = MaxClients; } else if (clients < limit) { num = limit; } @@ -251,7 +247,7 @@ SelectKickClient() new Float:value; - for (new i=1; i<=g_MaxClients; i++) + for (new i=1; i<=MaxClients; i++) { if (!IsClientConnected(i)) {