Raised This Month: $344 Target: $400
 86%   Almost there!

Seems to be no plugin that restricts teamchange during round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jillchang917
Member
Join Date: Dec 2017
Old 07-09-2018 , 20:51   Seems to be no plugin that restricts teamchange during round
Reply With Quote #1

Has anyone see a plugin that restricts teamchange on round start? And allows team change on round end?
This one seemed to have it but it doesn't let me set it to "0" and only lets me set 1 team change per round. (Can't even find the plugin anymore on google sigh)

This one blocks changing teams but this goes forever and doesn't let player change teams on roundend or before round starts. https://forums.alliedmods.net/showthread.php?t=172052
jillchang917 is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 07-09-2018 , 23:30   Re: Seems to be no plugin that restricts teamchange during round
Reply With Quote #2

Don't know about other people, but I would do like this.
PHP Code:
#include <sourcemod>

#pragma semicolon 1

bool g_bRestrict;

int g_iTeam[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
HookEvent("round_start"Event_Start);
    
    
HookEvent("round_end"Event_End);
    
    
HookEvent("player_team"Event_Team);
}

methodmap Restrict
{
    public static 
int Check(int iClient)
    {
        if (
g_bRestrict)
        {
            if (
IsValidClient(iClient))
            {
                if (
g_iTeam[iClient] > 1)
                {
                    if (
g_iTeam[iClient] != GetClientTeam(iClient))
                    {
                        
ChangeClientTeam(iClientg_iTeam[iClient]);
                    }
                }
            }
        }
    }
}

public 
Action Event_Start(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    
g_bRestrict = !g_bRestrict;
    
    for (
int i 1<= MaxClientsi++)
        
Restrict.Check(i);
}

public 
Action Event_End(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    
g_bRestrict = !g_bRestrict;
    
    for (
int i 1<= MaxClientsi++)
        
Restrict.Check(i);
}

public 
Action Event_Team(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    
int iClient GetClientOfUserId(hEvent.GetInt("userid"));
    
    if (!
g_bRestrict)
        
g_iTeam[iClient] = GetClientTeam(iClient);
}

stock bool IsValidClient(int iClient)
{
    if (!(
iClient <= MaxClients) || !IsClientInGame(iClient) || IsFakeClient(iClient))
    {
        return 
false;
    }
    
    return 
true;

mug1wara is offline
jillchang917
Member
Join Date: Dec 2017
Old 07-10-2018 , 22:40   Re: Seems to be no plugin that restricts teamchange during round
Reply With Quote #3

Hi mug1wara,
Thank you for helping but that plugin doesn't work. Tried it multiple times too and even used the correct round events for TF2, yet it lets me change teams. Any chance we can try implementing something like this?
https://forums.alliedmods.net/showpo...60&postcount=7

Last edited by jillchang917; 07-10-2018 at 22:41.
jillchang917 is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 07-11-2018 , 05:11   Re: Seems to be no plugin that restricts teamchange during round
Reply With Quote #4

It's for cs:go xD
You should've mentioned tf2 :/
mug1wara is offline
jillchang917
Member
Join Date: Dec 2017
Old 07-11-2018 , 20:30   Re: Seems to be no plugin that restricts teamchange during round
Reply With Quote #5

Any chance you can give it a try for TF2?
jillchang917 is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 07-11-2018 , 23:05   Re: Seems to be no plugin that restricts teamchange during round
Reply With Quote #6

PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

bool gB_Restrict;

public 
void OnMapStart()
{
    
HookEvent("teamplay_round_start"Event_RoundStartEventHookMode_Post);
    
HookEvent("teamplay_win_panel"Event_RoundEndEventHookMode_Post);
    
    
AddCommandListener(CL_JoinTeam"jointeam");
}

public 
void Event_RoundStart(Event hEvent, const char[] sEventNamebool bDontBroadcast) { 
    
gB_Restrict true;


public 
void Event_RoundEnd(Event hEvent, const char[] sEventNamebool bDontBroadcast) { 
    
gB_Restrict false;


public 
Action CL_JoinTeam(int client, const char[] sCmdint args
{
    if (
gB_Restrict)
        return 
Plugin_Handled;
    return 
Plugin_Continue;

Untested
__________________


Currently accepting private requests.
LenHard is offline
Ermert1992
Member
Join Date: Jan 2012
Location: Germany
Old 07-12-2018 , 09:01   Re: Seems to be no plugin that restricts teamchange during round
Reply With Quote #7

I edited this code snippet a little bit. Now it's fine for me. Thank you.
__________________
Mfg Jonas


Ermert1992 is offline
jillchang917
Member
Join Date: Dec 2017
Old 07-14-2018 , 23:58   Re: Seems to be no plugin that restricts teamchange during round
Reply With Quote #8

Quote:
Originally Posted by Ermert1992 View Post
I edited this code snippet a little bit. Now it's fine for me. Thank you.
Can you post what you did?

Last edited by jillchang917; 07-15-2018 at 00:48.
jillchang917 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 21:52.


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