Raised This Month: $2 Target: $400
 0% 

[CS:GO] Team ratio


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ivenuss
Junior Member
Join Date: Nov 2019
Location: Czech
Old 06-11-2020 , 04:55   [CS:GO] Team ratio
Reply With Quote #1

Helllo I am trying to make simple ratio system, but I don't know how to avoid random team pick on map start, if you didn't choose team it automatically assign you to T/CT and ignores "jointeam", thanks for ideas.
PHP Code:
#define RATIO 1

public OnPluginStart()
{
    
AddCommandListener(Listener_JoinTeam"jointeam");
}

public 
Action jointeam(int clientint args)
{
    
int teamRatio RATIO;

    if (!
client || !IsClientInGame(client) || IsFakeClient(client))
    {
        return 
Plugin_Continue;
    }

    
char teamString[3];
    
GetCmdArg(1teamStringsizeof(teamString));
    
    
int newTeam StringToInt(teamString);
    
int oldTeam GetClientTeam(client);
    
    if (
newTeam == CS_TEAM_CT && oldTeam != CS_TEAM_CT)
    {
        
int countTs 0;
        
int countCTs 0;
        
        for (
int i 1<= MaxClientsi++)
        {
              if (
IsClientInGame(i))
              {
                 if (
GetClientTeam(i) == CS_TEAM_T)
                 {
                    
countTs++;
                 }
                 
                 if (
GetClientTeam(i) == CS_TEAM_CT)
                 {
                    
countCTs++;
                 }
              }
        }

        if (
countCTs < ((countTs) / teamRatio) || !countCTs)
        {
            return 
Plugin_Continue;
        }
        else
        {
            
ClientCommand(client"play ui/freeze_cam.wav");

            return 
Plugin_Handled;
        }
    }
    return 
Plugin_Continue;
}

public 
OnClientDisconnect(client)
{
    if (
GetClientTeam(client) == CS_TEAM_T)
    {        
        
int countTs 0;
        
int countCTs 0;
        
        
int lowestCTtime 0;
        
float timeCTs 0.0;
        for (
int i 1<= MaxClientsi++)
        {
              if (
IsClientInGame(i))
              {
                
float time GetClientTime(client);
                if (
GetClientTeam(i) == CS_TEAM_T)
                {
                        
countTs++;
                    }
                 
                if (
GetClientTeam(i) == CS_TEAM_CT)
                    {
                    if (
time timeCTs || timeCTs == 0.0)
                    {
                        
lowestCTtime i;
                        
timeCTs == time;
                    }
                         
countCTs++;
                    }
              }      
        }
        if (
countCTs > ((countTs ) / RATIO))
        {
            if(
lowestCTtime != 0)
            {
                
ChangeClientTeam(lowestCTtimeCS_TEAM_T);
            }
        }
        
    }


Last edited by ivenuss; 06-11-2020 at 04:56.
ivenuss is offline
SSheriFF
AlliedModders Donor
Join Date: May 2020
Location: Israel
Old 06-11-2020 , 07:01   Re: [CS:GO] Team ratio
Reply With Quote #2

Try
Quote:
mp_force_pick_time 9999
__________________
SSheriFF is offline
Reply


Thread Tools
Display Modes

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:37.


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