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

Solved [CS:GO] Team ratio


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ivenuss
Junior Member
Join Date: Nov 2019
Location: Czech Republic
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);
            }
        }
        
    }

__________________
My website: https://jakubh.com/ Github: https://github.com/ivenuss Steam: https://steamcommunity.com/id/ivenuss/
Accepting private works in sourcepawn or web dev.

Last edited by ivenuss; 07-07-2020 at 17:52.
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
__________________
Taking small private requests (Free) and big private requests (Paid).
Contact me via Discord: WilDick#1524

My Plugins:
SSheriFF 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 20:02.


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