Raised This Month: $32 Target: $400
 8% 

[CSGO] Limit team changning


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
trzmielu
Member
Join Date: Aug 2016
Old 03-11-2018 , 12:53   [CSGO] Limit team changning
Reply With Quote #1

Hello,

could some1 make plugin that will allow that only one time player could change team

Best regards
trzmielu is offline
potatoz
AlliedModders Donor
Join Date: Nov 2016
Old 03-11-2018 , 16:12   Re: [CSGO] Limit team changning
Reply With Quote #2

Untested but should work

PHP Code:
#pragma semicolon 1
#include <sourcemod>

#define VERSION "1.0"

int teamchangecount[MAXPLAYERS+1];
ConVar cvar_teamchangelimit,
    
cvar_excludespec;

public 
Plugin:myinfo =
{
    
name "Team Change Limit",
    
author "Potatoz",
    
description "Limits the times of which a player can change team",
    
version VERSION,
    
url ""
};

public 
OnPluginStart()
{
    
cvar_teamchangelimit CreateConVar("sm_teamchange_limit""1""Sets how many times a player may switch between teams. Default = 1");
    
cvar_excludespec CreateConVar("sm_teamchange_excludespec""1""Should we exclude counting team changes to spectators? 0 = Disable");
    
    
AddCommandListener(OnJoinTeam"jointeam");
}

public 
OnClientPutInServer(int client
{
    if(!
IsFakeClient(client) && IsClientInGame(client))
        
teamchangecount[client] = 0;
}

public 
Action OnJoinTeam(int clientchar[] commandsint args)
{
    if(!
IsClientInGame(client) || IsFakeClient(client))
        return 
Plugin_Continue;
        
    if(
teamchangecount[client] == cvar_teamchangelimit.IntValue)
    {
        
PrintToChat(client"[SM] You have reached the limit for amount of times which you may switch teams.");
        return 
Plugin_Handled;
    }
        
    
char arg1[3];
    
GetCmdArg(1arg1sizeof(arg1));
    new 
target_team StringToInt(arg1);
    new 
current_team GetClientTeam(client);
    
    if(
target_team == current_team)
        return 
Plugin_Handled;
    else if(
target_team && cvar_excludespec.IntValue >= 1)
        
teamchangecount[client]++;
    else if(
cvar_excludespec.IntValue 1)
        
teamchangecount[client]++;
    
    return 
Plugin_Continue;

Attached Files
File Type: sp Get Plugin or Get Source (teamchangelimits.sp - 194 views - 1.6 KB)
__________________

Last edited by potatoz; 03-11-2018 at 16:13.
potatoz is offline
trzmielu
Member
Join Date: Aug 2016
Old 03-20-2018 , 19:38   Re: [CSGO] Limit team changning
Reply With Quote #3

Working well, thank you!
trzmielu is offline
djded
Member
Join Date: Jul 2019
Location: Czech Republic
Old 05-18-2023 , 05:06   Re: [CSGO] Limit team changning
Reply With Quote #4

that plugin limits a team change per round, map,or???
djded is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 05-20-2023 , 03:13   Re: [CSGO] Limit team changning
Reply With Quote #5

djded, per map (because the counter is reset only when player rejoin to the server)
__________________
Grey83 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 19:19.


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