Fixed a million bugs in reserved slots plugin - should be perfect now (I hope)
authorScott Ehlert <ds@alliedmods.net>
Fri Jun 22 03:43:00 2007 +0000 (2007-06-22)
changeset 998b26df4dd8187
parent 997 2fc3152c3118
child 999 8d7e956f996d
Fixed a million bugs in reserved slots plugin - should be perfect now (I hope)
Finalized KickClient native
core/smn_player.cpp
plugins/reservedslots.sp
     1.1 --- a/core/smn_player.cpp	Thu Jun 21 23:06:37 2007 +0000
     1.2 +++ b/core/smn_player.cpp	Fri Jun 22 03:43:00 2007 +0000
     1.3 @@ -933,9 +933,7 @@
     1.4  
     1.5  	if (pPlayer->IsFakeClient())
     1.6  	{
     1.7 -		char kickcmd[64];
     1.8 -
     1.9 -		/* :TODO: Define BotKickCmd in core.games.txt so that "bot_kick" can be used in CS:S */
    1.10 +		char kickcmd[40];
    1.11  		UTIL_Format(kickcmd, sizeof(kickcmd), "kick %s\n", pPlayer->GetName());
    1.12  
    1.13  		engine->ServerCommand(kickcmd);
     2.1 --- a/plugins/reservedslots.sp	Thu Jun 21 23:06:37 2007 +0000
     2.2 +++ b/plugins/reservedslots.sp	Fri Jun 22 03:43:00 2007 +0000
     2.3 @@ -59,7 +59,7 @@
     2.4  {
     2.5  	if (GetConVarBool(sm_hide_slots))
     2.6  	{
     2.7 -		SetConVarInt(sv_visiblemaxplayers, g_MaxClients - GetConVarInt(sm_reserved_slots));
     2.8 +		SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots));
     2.9  	}	
    2.10  }
    2.11  
    2.12 @@ -73,28 +73,39 @@
    2.13  		new limit = g_MaxClients - reserved;
    2.14  		new flags = GetUserFlagBits(client);
    2.15  		
    2.16 -		if (flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION || clients <= limit)
    2.17 +		if (clients <= limit || IsFakeClient(client) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
    2.18  		{
    2.19  			if (GetConVarBool(sm_hide_slots))
    2.20  			{
    2.21 -				SetConVarInt(sv_visiblemaxplayers, (clients == g_MaxClients) ? g_MaxClients : ++limit);
    2.22 +				SetVisibleMaxSlots(clients, limit);
    2.23  			}
    2.24  			
    2.25  			return;
    2.26  		}
    2.27 -		
    2.28 +
    2.29  		/* Kick player because there are no public slots left */
    2.30  		KickClient(client, "%T", "Slot reserved", client);
    2.31  	}
    2.32  }
    2.33  
    2.34 -public OnClientDisconnect(client)
    2.35 +public OnClientDisconnect_Post(client)
    2.36  {
    2.37  	if (GetConVarBool(sm_hide_slots))
    2.38 -	{
    2.39 -		new clients = GetClientCount(false);
    2.40 -		new limit = g_MaxClients - GetConVarInt(sm_reserved_slots);
    2.41 -		
    2.42 -		SetConVarInt(sv_visiblemaxplayers, (clients == g_MaxClients) ? g_MaxClients : limit);
    2.43 +	{		
    2.44 +		SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots));
    2.45  	}
    2.46  }
    2.47 +
    2.48 +SetVisibleMaxSlots(clients, limit)
    2.49 +{
    2.50 +	new num = clients + 1;
    2.51 +	
    2.52 +	if (clients == g_MaxClients || clients > limit)
    2.53 +	{
    2.54 +		num = g_MaxClients;
    2.55 +	} else if (clients < limit) {
    2.56 +		num = limit;
    2.57 +	}
    2.58 +	
    2.59 +	SetConVarInt(sv_visiblemaxplayers, num);
    2.60 +}