Raised This Month: $12 Target: $400
 3% 

Way to check changeteam on TF2


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 11-20-2017 , 02:05   Way to check changeteam on TF2
Reply With Quote #1

Hi friends, i need one way to hook changeteam on TF2 to remove some entities from player.

I try this ways:

PHP Code:
public void OnPluginStart()
{
    
AddCommandListener(OnJoinTeam"jointeam");
    
AddCommandListener(OnChangeTeam"changeteam");

And this way dont work on TF2:
PHP Code:
HookEvent("player_team"OnPlayerChangeTeam); 
Because this event dont exists on TF2.

I make several search on google and forum but dont found any work way.

Any can help me with this?

Regards.
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet

CZSBrasil TEAM

Last edited by rodrigo286; 11-20-2017 at 14:14.
rodrigo286 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-20-2017 , 02:33   Re: Way to check changeteam on TF2
Reply With Quote #2

Uh, what makes you think TF2 doesn't support player_team? It's a generic source event.

Edit: Besides which, there are even fields on player_team that were added specifically because TF2 used them. They're marked with "(OB only)"
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 11-20-2017 at 02:35. Reason: Added link and zelda
Powerlord is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 11-20-2017 , 03:12   Re: Way to check changeteam on TF2
Reply With Quote #3

Sorry, it was my mistake.

Thanks for generic source event list.

Done, plugin finished.

Regards.
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet

CZSBrasil TEAM
rodrigo286 is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 11-20-2017 , 14:16   Re: Way to check changeteam on TF2
Reply With Quote #4

Please i need reopen this issue.

I need make instant respawn on change team, this works on change class but dont work on change team.

I try two ways bellow:

PHP Code:
public Action OnPlayerChangeTeam(Event eventchar[] namebool dontBroadcast){
    
bool autoteam GetEventBool(event"autoteam");
    if(!
autoteam){
        
int client  GetClientOfUserId(GetEventInt(event"userid"));
        
TFTeam team view_as<TFTeam>(GetEventInt(event"team"));

        if(
IsValidClient(clientfalsefalse)){
            
SetEntProp(clientProp_Send"m_lifeState"2); 

            if(
team == TFTeam_Red)
                
TF2_ChangeClientTeam(clientTFTeam_Blue);
            else if(
team == TFTeam_Blue)
                
TF2_ChangeClientTeam(clientTFTeam_Red);

            
SetEntProp(clientProp_Send"m_lifeState"0);

            
TF2_RespawnPlayer(client);
            
TF2_RegeneratePlayer(client);
        }
    }
}

stock bool IsValidClient(int clientbool AllowBots falsebool AllowDead true)
{
    if(!(
<= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !AllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!AllowDead && !IsPlayerAlive(client)))
    {
        return 
false;
    }
    return 
true;

PHP Code:
public Action OnPlayerChangeTeam(Event eventchar[] namebool dontBroadcast){
    
bool autoteam GetEventBool(event"autoteam");
    if(!
autoteam){
        
int client  GetClientOfUserId(GetEventInt(event"userid"));

        if(
IsValidClient(clientfalsefalse)){
            
SetEntProp(clientProp_Send"m_lifeState"2); 

            
TF2_RespawnPlayer(client);
            
TF2_RegeneratePlayer(client);

            
SetEntProp(clientProp_Send"m_lifeState"0);
        }
    }
}

stock bool IsValidClient(int clientbool AllowBots falsebool AllowDead true)
{
    if(!(
<= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !AllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!AllowDead && !IsPlayerAlive(client)))
    {
        return 
false;
    }
    return 
true;

I do any thing wrong?

Regards.
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet

CZSBrasil TEAM

Last edited by rodrigo286; 11-20-2017 at 14:16.
rodrigo286 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 13:17.


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