Raised This Month: $114 Target: $400
 28% 

Limit the join in a team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lonely.
Junior Member
Join Date: Feb 2021
Old 02-27-2021 , 08:45   Limit the join in a team
Reply With Quote #1

Hello!

I searched on the google and in the search tool but i don't find something like what i want.

So what i want or what i don't find it's something like i want in the Terrorist Team to limit the join like if it's 3 CT just 1 player can join in the T team if it's 6 CT just 2 players can join in the T Team and if it's 9 CT or much more just 3 Players can join in the T Team like 1T-3Ct;2T-6CT 3T-9 or more CT (I have 32 slots in my server).
Lonely. is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 03-06-2021 , 10:36   Re: Limit the join in a team
Reply With Quote #2

Completely untested, should work though.

Comes with 2 ConVars:
Code:
sm_team_limit_enable - Enable/Disable the plugin
sm_team_limit_ratio - Ratio of CT's to T's
PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools_functions>

ConVar g_cvEnable null;
ConVar g_cvRatio  null;

public 
void OnPluginStart()
{
    
g_cvEnable CreateConVar("sm_team_limit_enable""1",   "Enable/Disable the plugin"_true0.0true1.0);
    
g_cvRatio  CreateConVar("sm_team_limit_ratio",  "3.0""Ratio of CT's to T's");

    
g_cvEnable.AddChangeHook(ConVar_Update);
    
g_cvRatio.AddChangeHook(ConVar_Update);

    
HookEvent("player_team"Event_PlayerTeam);
}

public 
void OnConfigsExecuted()
{
    if (
g_cvEnable.BoolValue && !CheckTeamRatio())
    {
        for (
int i 1<= MaxClientsi++)
        {
            if (
IsClientInGame(i) && GetClientTeam(i) == CS_TEAM_T)
            {
                
ChangeTeamToCT(i);

                if (
CheckTeamRatio())
                {
                    break;
                }
            }
        }
    }
}

public 
void ConVar_Update(ConVar cvar, const char[] sOldValue, const char[] sNewValue)
{
    
OnConfigsExecuted();
}

public 
void Event_PlayerTeam(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    if (
hEvent.GetInt("team") == CS_TEAM_T)
    {
        
RequestFrame(Frame_PlayerTeamhEvent.GetInt("userid"));
    }
}

public 
void Frame_PlayerTeam(any data)
{
    if (
g_cvEnable.BoolValue && !CheckTeamRatio())
    {
        
int iClient GetClientOfUserId(data);
        if (
iClient != && GetClientTeam(iClient) == CS_TEAM_T)
        {
            
ChangeTeamToCT(iClient);
        }
    }
}

stock int GetCTCount()
{
    return 
GetTeamClientCount(CS_TEAM_CT);
}

stock int GetTCount()
{
    return 
GetTeamClientCount(CS_TEAM_T);
}

stock float GetTeamRatio()
{
    return 
float(GetCTCount() / GetTCount());
}

stock bool CheckTeamRatio()
{
    return 
GetTeamRatio() >= g_cvRatio.FloatValue;
}

stock void ChangeTeamToCT(int iClient)
{
    
CS_SwitchTeam(iClientCS_TEAM_CT);

    if (
IsPlayerAlive(iClient))
    {
        
CS_RespawnPlayer(iClient);
    }

Attached Files
File Type: sp Get Plugin or Get Source (teamlimit.sp - 18 views - 1.8 KB)
ThatKidWhoGames is offline
Lonely.
Junior Member
Join Date: Feb 2021
Old 03-06-2021 , 11:54   Re: Limit the join in a team
Reply With Quote #3

Thank you so much for helping me i will test it next day!
Lonely. is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 03-07-2021 , 05:50   Re: Limit the join in a team
Reply With Quote #4

Quote:
Originally Posted by Lonely. View Post
Thank you so much for helping me i will test it next day!
You’re very welcome! Let me know how it goes!
ThatKidWhoGames 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 10:36.


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