Raised This Month: $ Target: $400
 0% 

problem with balancer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kubad
Senior Member
Join Date: Sep 2015
Location: Czech Republic
Old 12-29-2017 , 10:50   problem with balancer
Reply With Quote #1

hello i have problem with this code because this crash server i dont know why i using this in round end

PHP Code:
public teambalancer()
{
    new 
maximumplayerscts 0ts 0;
    
maximumplayers GetMaxClients();int last 0,int lastguard 0;
    for (new 
idx 1idx <= maximumplayersidx++)
    {
        if(!
IsValidClient(idx))
        {
        continue;
        }
        if (!
IsClientConnected(idx))
        {
        continue;
        }
        
        if(
GetClientTeam(idx) == 2)
        {
            
ts++;
        }
        if(
GetClientTeam(idx) == 3)
        {
            
cts++;
            if(
lastguard guard[idx])//guard number
            
{
                
lastguard guard[idx];
                
last GetClientOfUserId(idx);
            }
        }
    }    
    
    if(
cts >= 2)
    {
        if(
cts*ts+1)
        {
            
CreateTimer(0.1,SwitchToTlast);
        }
    }
}

public 
Action:SwitchToT(Handletimeranyclient)
{
    if(
GetClientTeam(client) == 3)
    {
        
ChangeClientTeam(client,2);
        
PrintToChat(client,"%s you are moved to prisoners",SMJAIL);
    }


Last edited by Kubad; 12-29-2017 at 10:54.
Kubad is offline
pride95
Senior Member
Join Date: Aug 2015
Old 12-30-2017 , 13:56   Re: problem with balancer
Reply With Quote #2

PHP Code:
HookEvent("round_prestart"Event_RoundPreStart);

public 
Action Event_RoundPreStart(Event event, const char[] namebool dontBroadcast)
{

    
int iTerrorists 0iCounterTerrorists 0vTerrorists[MAXPLAYERS 1], vCounterTerrorists[MAXPLAYERS 1];
    
    for(
int iClient 1iClient <= MaxClientsiClient++)
    {
        if(
IsClientInGame(iClient))
        {
            if(
GetClientTeam(iClient) == CS_TEAM_T)
            {
                
vTerrorists[iTerrorists++] = iClient;
            }    
            else if(
GetClientTeam(iClient) == CS_TEAM_CT)
            {
                
vCounterTerrorists[iCounterTerrorists++] = iClient;
            }
        }
    }
    
    if(
iTerrorists iCounterTerrorists 2)
    {
        
int iMoveTerrorist vTerrorists[GetRandomInt(0iTerrorists 1)];
        
CS_SwitchTeam(iMoveTerrorist CS_TEAM_T);
        
CS_UpdateClientModel(iMoveTerrorist );
    }
    else if(
iCounterTerrorists iTerrorist 2)
    {
        
int iMoveCounterTerrorist vCounterTerrorists[GetRandomInt(0iCounterTerrorists 1)];
        
CS_SwitchTeam(iMoveCounterTerrorist CS_TEAM_T);
        
CS_UpdateClientModel(iMoveCounterTerrorist );
    }

just an example of team balancer. check the code and use with your guard system.

Last edited by pride95; 12-30-2017 at 14:01.
pride95 is offline
Kubad
Senior Member
Join Date: Sep 2015
Location: Czech Republic
Old 12-31-2017 , 22:21   Re: problem with balancer
Reply With Quote #3

thank you for this but i fix it i found the mistake but thank you again
Kubad 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 04:12.


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