AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   Limit the join in a team (https://forums.alliedmods.net/showthread.php?t=330929)

Lonely. 02-27-2021 08:45

Limit the join in a team
 
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).

ThatKidWhoGames 03-06-2021 10:36

Re: Limit the join in a team
 
1 Attachment(s)
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);
    }



Lonely. 03-06-2021 11:54

Re: Limit the join in a team
 
Thank you so much for helping me i will test it next day!

ThatKidWhoGames 03-07-2021 05:50

Re: Limit the join in a team
 
Quote:

Originally Posted by Lonely. (Post 2739491)
Thank you so much for helping me i will test it next day!

You’re very welcome! Let me know how it goes! :)


All times are GMT -4. The time now is 03:11.

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