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

Quote:
Originally Posted by dylstew View Post
You cna just decrease the mapxplayercount to 12 and it would be the same thing.
OK I will try to do this thing instead. This is a code I wrote. I learn a lot from warmod, but it still not work. If anyone could see what the problem is, I really appreciate that.

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_hTeamLimit;
new 
Handle:g_hEnableTeamLimit;

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

public 
OnPluginStart()
{
    
g_hEnableTeamLimit CreateConVar("sm_enableteamlimit""1""1 (on) or 0 (off)");
    
g_hTeamLimit CreateConVar("sm_teamlimit""6""Limit teams to this value");
    
HookEvent("player_team"Event_Player_TeamEventHookMode_Pre);
}
public 
Action:Event_Player_Team(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
GetConVarBool(g_hEnableTeamLimit))
        return 
Plugin_Continue;
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
oldteam GetEventInt(event"oldteam");
    new 
newteam GetEventInt(event"team");
    
    if ((
newteam == TEAM_RED) || (newteam == TEAM_BLUE))
    {
        if (
GetTeamClientCount(newteam) > GetTeamLimit())
        {
            
PrintToChat(client"That team is full (%s/%s)!",g_hTeamLimitg_hTeamLimit);
            
ChangeClientTeam(clientoldteam);
            return 
Plugin_Handled;
        }
            
    }
    return 
Plugin_Continue;
}

public 
GetTeamLimit()
{
    return 
GetConVarInt(g_hTeamLimit);


Last edited by duydangle; 12-15-2011 at 10:04.
duydangle is offline