Raised This Month: $ Target: $400
 0% 

Prevent class change in TF2


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 02-28-2017 , 11:39   Re: Prevent class change in TF2
Reply With Quote #1

Snippet blocks all usage of jointeam no matter args
__________________
WildCard65 is offline
cidra
Junior Member
Join Date: Jun 2016
Location: Italy
Old 02-28-2017 , 13:43   Re: Prevent class change in TF2
Reply With Quote #2

Quote:
Originally Posted by WildCard65 View Post
Snippet blocks all usage of jointeam no matter args
I know, but if i add some controls before return Plugin_Handled; it should block the usage of the command only in specific circumstances, am i right? So what if someone select "auto-select team" (So basically types jointeam auto in console)?
Just asking: why can't i use HookEvent to prevent team changes while i can do that to prevent class changes?
cidra is offline
sdz
Senior Member
Join Date: Feb 2012
Old 02-28-2017 , 15:37   Re: Prevent class change in TF2
Reply With Quote #3

Quote:
Originally Posted by cidra View Post
I know, but if i add some controls before return Plugin_Handled; it should block the usage of the command only in specific circumstances, am i right? So what if someone select "auto-select team" (So basically types jointeam auto in console)?
Just asking: why can't i use HookEvent to prevent team changes while i can do that to prevent class changes?
Something people overlook way too often is that a command listener does work similar to a command in the idea that it can read arguments that are sent. Arguements do get sent in jointeam. teamid is usually one of these.
Using this obtuse information, we could further implement a case-by-case basis on how hard we want to bone people.

Soooo, something like this is what I use in one of my plugins. Clearly a modifimidicated version of jointeam. If this doesn't help you at all, then well sorry for wasting your time lol.
You'll see something like "teamJoinAuth" in the code. I use GetRandomInt to generate that at plugin start. Ideally a pseudo anti-bypass or something.

PHP Code:
public Action:joinListener(client, const String:command[], args)
{
    if(
g_bLive)
    {
        
CPrintToChat(client"%s You are currently unable to switch teams."CHATTAG);
        return 
Plugin_Handled;
    }

    if(!
g_bSwitch[client])
    {
        
decl String:sTeam[32];
        
GetCmdArg(1sTeamsizeof(sTeam));
        new 
newTeam StringToInt(sTeam);

        if(
args == 1)
        {
            new 
Handle:dataPack CreateDataPack();
            
WritePackCell(dataPackGetClientUserId(client));
            
WritePackCell(dataPacknewTeam);
            
g_bSwitch[client] = true;

            
CreateTimer(5.0teamJoindataPack);
            
CPrintToChat(client"%s Waiting five seconds to join another team..."CHATTAG);
            return 
Plugin_Handled;
        }    
        else if(
args == 2//Jointeam function
        
{
            
decl String:sAuth[32];
            
GetCmdArg(2sAuthsizeof(sAuth));
            if(
StringToInt(sAuth) == teamJoinAuth)
            {
                
g_bSwitch[client] = false;
                return 
Plugin_Changed;
            }
            else return 
Plugin_Handled;
        }
    }

    return 
Plugin_Handled;
}

public 
Action:teamJoin(Handle:timerHandle:dataPack)
{
    
ResetPack(dataPack);
    new 
client GetClientOfUserId(ReadPackCell(dataPack));
    new 
team ReadPackCell(dataPack);

    
ChangeClientTeam(clientteam);
    if(
IsPlayerAlive(client)) ForcePlayerSuicide(client);
    
ClientCommand(client"jointeam %i %i"teamteamJoinAuth);

    
decl String:teamFmt[16];
    switch(
team)
    {
        case 
01teamFmt "Spectator";
        case 
TEAM_COMBINEteamFmt "Blue";
        case 
TEAM_REBELteamFmt "Red";
    }

    
CPrintToChatAll("%s {white}%N{default} has joined team: {white}%s{default}."CHATTAGclientteamFmt);
    
g_bSwitch[client] = false;
    return 
Plugin_Handled;


Last edited by sdz; 02-28-2017 at 15:40.
sdz is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 02-28-2017 , 15:41   Re: Prevent class change in TF2
Reply With Quote #4

Quote:
Originally Posted by cidra View Post
Just asking: why can't i use HookEvent to prevent team changes while i can do that to prevent class changes?
The hook is fired AFTER the command has done it's job and switched the client's team.
__________________
WildCard65 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 21:34.


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