Raised This Month: $ Target: $400
 0% 

[REQ] Team Restrictions w/ Percentages


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fang
Senior Member
Join Date: Nov 2007
Location: New Jersey
Old 04-02-2009 , 19:27   [REQ] Team Restrictions w/ Percentages
Reply With Quote #1

I'm requesting something that will lock a team if there's a certain amount of players on it.
Example:

10 players in game
3 on CT
7 on T

Ct team gets locked until at least 2 T join.

(Have it based off a percentage or set to X amount of players joined)
fang is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 04-03-2009 , 06:22   Re: [REQ] Team Restrictions w/ Percentages
Reply With Quote #2

Why can't you just balance the teams?

EDIT: Anyways, there is the code if you still need it(not tested).

PHP Code:
// This is not the same as Bmann_420's Teams Locker.

#include <amxmodx>

#define IsValidTeam(%1)    (Terrorists <= %1 <= CounterTerrorists)

enum
{
    
Terrorists 1,
    
CounterTerrorists
};

new const 
TeamsNames[3][] =
{
    
""// None.
    
"Terrorists",
    
"Counter-Terrorists"
};

new 
bool:Locked[3]; // Locked[0] = None.
new PlayersNum[3]; // PlayersNum[0] = None.

public plugin_init()
{
    
register_plugin("Team Locker""1.0""Dores");
    
    
register_event("TeamInfo""TeamInfo_Event""a""2&TERRORIST""2&CT");
    
register_clcmd("jointeam""Cmd_JoinTeam");
}

public 
TeamInfo_Event()
{
    new 
TeamName[1], MovedTeamidOldTeam;
    
    
read_data(2TeamName1);
    
    
MovedTeam GetTeamByChar(TeamName[0]);
    if (
IsValidTeam(MovedTeam))
    {
        
PlayersNum[MovedTeam]++;
    }
    
    
id read_data(1);
    
    
// the player's team data is only changed AFTER this event is called, and this is
    // a pre hook.
    
OldTeam get_user_team(id);
    
    if (
IsValidTeam(OldTeam))
    {
        
PlayersNum[OldTeam]--;
    }
    
    
CheckTeams();
}

public 
Cmd_JoinTeam(id)
{
    new 
Arg[1], Team;
    
read_argv(1Arg1);
    
Team str_to_num(Arg);
    
    if (!
IsValidTeam(Team))
    {
        return 
PLUGIN_CONTINUE;
    }
    
    if (
Locked[Team])
    {
        
client_print(idprint_center"%s team is currently locked. Try again later."TeamsNames[Team]);
        return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE;
}

CheckTeams()
{
    new 
CTNum PlayersNum[CounterTerrorists];
    new 
TNum PlayersNum[Terrorists];
    new 
diff;
    
    
diff abs(CTNum TNum);
    if (
diff 1)
    {
        if(
CTNum TNum)
        {
            
Locked[CounterTerrorists] = true;
        }
        
        else
        {
            
Locked[Terrorists] = true;
        }
    }
    
    else
    {
        
Locked[CounterTerrorists] = false;
        
Locked[Terrorists] = false;
    }
}

GetTeamByChar(ch)
{
    switch(
ch)
    {
        case 
'T':
        {
            return 
1;
        }
        
        case 
'C':
        {
            return 
2;
        }
    }
    
    return 
0;

__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 04-03-2009 at 07:41.
Dores is offline
fang
Senior Member
Join Date: Nov 2007
Location: New Jersey
Old 04-03-2009 , 14:33   Re: [REQ] Team Restrictions w/ Percentages
Reply With Quote #3

It's for when I'm not around to balance the teams. D: Tyvm dores ^^
fang is offline
DotPT
Member
Join Date: Feb 2009
Old 04-03-2009 , 15:18   Re: [REQ] Team Restrictions w/ Percentages
Reply With Quote #4

mp_autoteambalance 1 does the job pretty well
DotPT is offline
fang
Senior Member
Join Date: Nov 2007
Location: New Jersey
Old 04-03-2009 , 15:32   Re: [REQ] Team Restrictions w/ Percentages
Reply With Quote #5

Quote:
Originally Posted by DotPT View Post
mp_autoteambalance 1 does the job pretty well
I'm trying to not have it perfectly balanced. I want more T players than CT which is the complete opposite of what mp_autoteambalance does. mp_autoteambalance sets the teams so they're even. >.<
fang is offline
Reply



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


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