Raised This Month: $51 Target: $400
 12% 

Help with balance algorithm


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 09-22-2015 , 08:08   Help with balance algorithm
Reply With Quote #1

I can't figure it out.
I set autojoin only for CT team (Team Join Management). And want make balance-plugin, which transfer some CT player to Terrorists. I want play: [T] 3 vs. 9 [CT], 2 vs. 6, 4 vs. 12, 9 vs. 24, etc. (33,3% Players for Terrorists, rest — 67% for CTs).

I make this code:
PHP Code:
public check_players()
{
    new 
players[32], plrsnumpltscts
    get_players
(playersplrsnum"h")
    for(new 
jj<plrsnumj++)
    {
        
pl players[j]
        new 
CsTeams:team
        team 
cs_get_user_team(pl)
        if(
team == CS_TEAM_T)
        {
            
ts++
        } else if(
team == CS_TEAM_CT) {
            
cts++
        }
    }
    
    new 
Float:ts_required_f
    ts_required_f 
cts get_pcvar_float(g_cvar_t_count_div)
    new 
ts_required floatround(ts_required_f)
    
    if(
ts <= ts_required)
    {
        
move_player(2// CT to T
    
} else {
        
move_player(1// T to CT
    
}
}

public 
move_player(team)
{
    new 
players[32], plrsnumpl
    
if(team == 1)
    {
        
get_players(playersplrsnum"he""TERRORIST")
    } else {
        
get_players(playersplrsnum"he""CT")
    }

    if(
team == 1)
    {
        
cs_set_user_team(players[plrsnum 1], CS_TEAM_CT)
    } else {
        
cs_set_user_team(players[plrsnum 1], CS_TEAM_T)
    }

But it's ugly and buggy. This code forever move "last" player to opposite team (9 vs. 23 — 8 vs. 24).
Maybe anyone have better solution?
Phant is offline
Send a message via ICQ to Phant
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 05:52.


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