Thread: maxplayers
View Single Post
Author Message
Saint Sinner
Senior Member
Join Date: Feb 2016
Old 01-06-2018 , 04:18   maxplayers
Reply With Quote #1

I Have 2 players

1 Team CT
1 Team T

If i have 3 players i want to get command only for last player which comes!

But player 3 can be player 1,2

Someone can show me how to do that?

Code:
public client_PreThink(id)
{
	if(!task_exists(TASK_ID) || !is_user_alive(id)) 
	{
		g_ProtectionTime[id] = -1
		g_InTheZone[id] = false
		
		return PLUGIN_CONTINUE
	}
	
	if(!check_players(id))
	{
		g_InTheZone[id] = false
		g_ProtectionTime[id] = -1
		
		return PLUGIN_CONTINUE
	}

	if(!check_origin(id))
	{
		g_InTheZone[id] = false
		g_ProtectionTime[id] = -1
		
		return PLUGIN_CONTINUE
	}
	
	new protectionDelay = get_pcvar_num(cvar_delay)
	if(g_ProtectionTime[id] < protectionDelay)
	{
		if(g_fDelay[id] + 1.0 < get_gametime())
		{
			g_ProtectionTime[id] += 1
			g_fDelay[id] = get_gametime()
		}
		
		set_hudmessage(255, 0, 0, -1.0, -1.0, _, _, 0.5, _, _, 4)
		show_hudmessage(id, "Protection in %d...", (protectionDelay - g_ProtectionTime[id]))
	}
	else if(g_ProtectionTime[id] >= protectionDelay)
		g_InTheZone[id] = true
	
	new tmp[2], weap = get_user_weapon(id, tmp[0], tmp[1])
	if(weap != CSW_KNIFE) client_cmd(id, "weapon_knife")
            set_pev( id, pev_velocity, g_toucheR_velocity[ id ] );
            g_toucheR_velocity[ id ][ 0 ] = 0.0;
            g_toucheR_velocity[ id ][ 1 ] = 0.0;
            g_toucheR_velocity[ id ][ 2 ] = 0.0;
            velocity_by_aim( id, PLAYER_PUSH_FORCE, g_toucheR_velocity[ id ] )

	    return PLUGIN_CONTINUE
}

stock check_players()
{
	new iNum[2];
	for(new i = 1 ; i >= g_iMaxPlayers ; i++)
	{
		if(!is_user_alive(i))
			continue;
		
		if(get_user_team(i) == 1)
			++iNum[0];
		else if(get_user_team(i) == 2)
			++iNum[1];
	}
	if((iNum[0] == 1) && (iNum[1] == 1))
		return true;
	
	return false;
}

Last edited by Saint Sinner; 01-06-2018 at 06:10.
Saint Sinner is offline