Raised This Month: $ Target: $400
 0% 

getting max number of teams?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 07-06-2010 , 00:56   getting max number of teams?
Reply With Quote #1

im trying to make a plugin that will generically balance teams for all game mods, but some games have more than two teams, is there some way to check how many max teams there are?
__________________
+|- KARMA Respectively

HLM is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-06-2010 , 02:31   Re: getting max number of teams?
Reply With Quote #2

Quote:
Originally Posted by HLM View Post
im trying to make a plugin that will generically balance teams for all game mods, but some games have more than two teams, is there some way to check how many max teams there are?
Not exactly an easy feat to attempt maybe not very logical either. Why would you need a single plugin for "all game mods"?
__________________
fysiks is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 07-06-2010 , 03:52   Re: getting max number of teams?
Reply With Quote #3

I dont, I just want to make AND release a plugin for once, lol
__________________
+|- KARMA Respectively

HLM is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 07-06-2010 , 07:43   Re: getting max number of teams?
Reply With Quote #4

Why don't you use http://www.amxmodx.org/funcwiki.php?go=func&id=248 ?
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-06-2010 , 20:57   Re: getting max number of teams?
Reply With Quote #5

Quote:
Originally Posted by Alucard^ View Post
Because he wants it to be dynamic. Your suggestion requires hard coding the info for each mod.
__________________
fysiks is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 07-06-2010 , 21:16   Re: getting max number of teams?
Reply With Quote #6

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <hamsandwich>

#define PLUGIN "Team Balance"
#define VERSION "1.0"
#define AUTHOR "Master"

/*new team1 = 0;
new team2 = 0;
new team3 = 0;
new team4 = 0;
new spectators = 0;*/

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
//RegisterHam(Ham_Spawn, "player", "user_spawn" 1)
    
register_clcmd("say !teams""check_teams", -1"checks how balanced the teams are.")
}

public 
check_teams()
{
    new 
team1team2team3team4spec
    
for(new i=0;i<33;i++)
    {
        new 
team get_user_team(i)
        switch(
team)
        {
            case 
1team1++
            case 
2team2++
            case 
3team3++
            case 
4team4++
            case 
0spec++
        }
    }
    if((
team3 == 0) && (team4 == 0))
    {
        if((
team1 team2) && (team1 team2+1))
        {
            
//team1 has too many people, do something about it.
        
}
        else if((
team2 team1) && (team2 team1+1))
        {
            
//team2 has too many people, do something about it.
        
}
    }
    else
    {
        if((
team1 team2) && (team1 team3) && (team1 team4) && (team1-team2) && (team1-team3) && (team1-team4)) // there HAS to be an easier way...
        
{
            
//team1 has too many people, damn, three more teams to do...
        
}
        else if((
team2 team1) && (team2 team3) && (team2 team4) && (team2-team1) && (team2-team3) && (team2-team4))
        {
            
//do stuff
        
}
        else if((
team3 team1) && (team3 team2) && (team3 team4) && (team3-team1) && (team3-team2) && (team3-team4))
        {
            
//do something cool
        
}
        else if((
team4 team1) && (team4 team2) && (team4 team3) && (team4-team1) && (team4-team2) && (team4-team3))
        {
            
//blah
        
}
    }

will this work as intended? I am assuming no, since there is the possibility that team1 could have 4 peopls team2 4 team3 5 team4 6 and it will probably be wrong..
__________________
+|- KARMA Respectively

HLM is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-06-2010 , 23:43   Re: getting max number of teams?
Reply With Quote #7

Well, when looping through the players, make sure to do
PHP Code:
new players[32], pnum
get_players
(playerspnum)
for(new 
ipnumi++)
{
        new 
tempid players[i]

The way you are doing it, it will loop through 33 times instead of just 32 as well.

Also, when doing this:
PHP Code:
        if((team1 team2) && (team1 team2+1))
        {
            
//team1 has too many people, do something about it.
        

There is no need for the first check because if the second one is true, the first one has to be true.
RedRobster is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-07-2010 , 00:51   Re: getting max number of teams?
Reply With Quote #8

Quote:
Originally Posted by HLM View Post
PHP Code:
// there HAS to be an easier way... 
will this work as intended? I am assuming no, since there is the possibility that team1 could have 4 peopls team2 4 team3 5 team4 6 and it will probably be wrong..
I'm sure there is a more dynamic way but it probably won't be easy. First of all, what mod has more than two team? And, I have a hard time believing that get_user_team() will return 0 for spectator on any mod. CS and DOD both have spec that are non-zero IIRC.

Quote:
Originally Posted by RedRobster View Post
Well, when looping through the players, make sure to do
PHP Code:
new players[32], pnum
get_players
(playerspnum)
for(new 
ipnumi++)
{
        new 
tempid players[i]

The way you are doing it, it will loop through 33 times instead of just 32 as well.
Note: You don't need to cache the player id if it is only used once. He could just as easily do switch(get_user_team(players[i])).
__________________

Last edited by fysiks; 07-07-2010 at 02:11.
fysiks is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-07-2010 , 00:59   Re: getting max number of teams?
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
Note: You don't need to cache the player id if it is only used once. He could just as easily do switch(get_user_team(i)).
Did not know that. Cool.
RedRobster is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-07-2010 , 02:11   Re: getting max number of teams?
Reply With Quote #10

Quote:
Originally Posted by RedRobster View Post
Did not know that. Cool.
Oops, typo. It should be: switch(get_user_team(players[i]))
__________________
fysiks 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 07:10.


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