Raised This Month: $ Target: $400
 0% 

CT limit


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
QuickNet
Junior Member
Join Date: Jun 2010
Old 01-09-2011 , 13:55   CT limit
Reply With Quote #1

hello,

Someone can help me with a code?

I have this one:

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;
    }

As you see the code written by Dores...



And, what I would like you to do is:
to edit the code, and change the team limmit:

1 CT = 3 Terrorists

and if there is(are) 1/2/3 players so, only one can join to CT team
and the others will can join to Terrorist team only.

Thanks anyways.
QuickNet is offline
 



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 02:14.


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