AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Way to check changeteam on TF2 (https://forums.alliedmods.net/showthread.php?t=303033)

rodrigo286 11-20-2017 02:05

Way to check changeteam on TF2
 
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.

Powerlord 11-20-2017 02:33

Re: Way to check changeteam on TF2
 
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)"

rodrigo286 11-20-2017 03:12

Re: Way to check changeteam on TF2
 
Sorry, it was my mistake.

Thanks for generic source event list.

Done, plugin finished.

Regards.

rodrigo286 11-20-2017 14:16

Re: Way to check changeteam on TF2
 
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.


All times are GMT -4. The time now is 10:07.

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