View Single Post
duydangle
Senior Member
Join Date: May 2010
Old 12-15-2011 , 10:14   Re: [REQ] TF2 Limit players' number per team
Reply With Quote #4

This is the code I rewrite from warmod to limit 12 players. Please look at this @@.

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <tf2>

#define TEAM_SPEC    1
#define TEAM_RED     2
#define TEAM_BLUE     3

new Handle:g_h_max_players;

public 
Plugin:myinfo 
{
    
name "TF2 Limit 12 Players",
    
author "duydangle, noobcannonlol",
    
description "For use on competitive server",
    
version "1.0",
    
url "Xtremezone.VN"
}

public 
OnPluginStart()
{
    
g_h_max_players CreateConVar("sm_maxplayers""12""Limit max players to this value");
    
RegConsoleCmd("jointeam"ChooseTeam);
    
RegConsoleCmd("spectate"ChooseTeam);
}
public 
Action:ChooseTeam(clientargs)
{
        
    if (
client == 0)
    {
        return 
Plugin_Continue;
    }
    
    new 
max_players GetConVarInt(g_h_max_players);
    if (
max_players != && GetClientTeam(client) <= && CS_GetPlayingCount() >= max_players)
    {
        
PrintToChat(client"%s players already!"max_players);
        
ChangeClientTeam(clientTEAM_SPEC);
        return 
Plugin_Stop;
    }
    
    return 
Plugin_Continue;
}

stock CS_GetPlayingCount()
{
    new 
count;
    new 
max_clients GetMaxClients();
    for (new 
1<= max_clientsi++)
    {
        if (
IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) > 1)
        {
            
count++;
        }
    }
    return 
count;


Last edited by duydangle; 12-15-2011 at 11:22.
duydangle is offline