Raised This Month: $ Target: $400
 0% 

Need fix "Teams Limiter"


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
okletsgo
Junior Member
Join Date: Aug 2011
Old 12-09-2011 , 09:37   Need fix "Teams Limiter"
Reply With Quote #1

Link : http://forums.alliedmods.net/showpos...3&postcount=12

This code null in HLDS 4554 , Need fix this.

PHP Code:
#include <amxmodx>

enum
{
    
TEAM_T 1,
    
TEAM_CT
};

new const 
TEAM_SPEC 6;

new 
Count[3];
new 
LimitPcvar;
new 
ChangedTeams[33]; // bypass double call.

public plugin_init()
{
    
register_plugin("Teams Limiter""1.0""Dores");
    
    
LimitPcvar register_cvar("teams_limit""5");
    
    
register_event("TeamInfo""moved_not_spec""a""2=TERRORIST""2=CT");
    
register_event("TeamInfo""moved_spectator""a""2=SPECTATOR");
    
    
register_clcmd("jointeam""Cmd_HookJoinTeam");
}

public 
client_disconnect(id)
{
    new 
team ChangedTeams[id];
    
    if (
team == TEAM_T || team == TEAM_CT)
        
Count[team]--;
    
    
ChangedTeams[id] = 0;
}

public 
server_changelevel(map[])
{
    
Count[TEAM_T] = 0;
    
Count[TEAM_CT] = 0;
}

public 
plugin_pause()
{
    
Count[TEAM_T] = 0;
    
Count[TEAM_CT] = 0;
}

public 
Cmd_HookJoinTeam(id)
{
    new 
arg[1], team;
    
    
read_argv(1arg1);
    
team str_to_num(arg);
    
    if(
team == TEAM_SPEC || team == 5)
        return 
PLUGIN_CONTINUE;
    
    if(
Count[team] == get_pcvar_num(LimitPcvar))
    {
        
client_print(idprint_center"[AMXX] This team has reached it's limit!");        
        return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
moved_not_spec()
{
    new 
team[1], Team;
    
read_data(2team1);
    
Team team[0] == 'C' TEAM_CT TEAM_T;
    
    new 
id read_data(1);
    
    if (
ChangedTeams[id] == Team)
        return 
PLUGIN_CONTINUE;
    
    
Count[Team]++;
    
ChangedTeams[id] = Team;
    
    new 
oppTeam Team// 3 - Team is the opposite team (if Team = 1(terror), the opposite team will be 2(CT)).
    
if (get_user_team(id) == oppTeam// changed teams. get_user_team() updates only after this event.
        
Count[oppTeam]--;
    
    return 
PLUGIN_CONTINUE;
}

public 
moved_spectator()
{
    new 
id read_data(1);
    
    new 
lastTeam ChangedTeams[id];
    if (
lastTeam == TEAM_T || lastTeam == TEAM_CT)
    {
        
Count[lastTeam]--;
        
ChangedTeams[id] = 0;
    }

Note: I tried to Team Limiter , have bug ,I would not look at such Team Limiter .
okletsgo is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:51.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode