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

Solved Action on team change


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
maxolahird
Veteran Member
Join Date: Dec 2012
Old 06-13-2017 , 15:48   Action on team change
Reply With Quote #1

Hi, how can I execute a code when a player gets to Spectator?

I tried this but it didnt work, probably because its hooking player_death only I think.

PHP Code:
    HookEvent("player_death"Trails_PlayerDeath); 
Code:
public Action:Trails_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if(!IsPlayerAlive(client) && IsClientInGame(client) && GetClientTeam(client) == 3)
		for(new i=0;i<STORE_MAX_SLOTS;++i)
			RemoveTrail(client, i);
	return Plugin_Continue;
}

How can I do it properly? so it executes RemoveTrail once a player changes team to spectator?

Thanks

Last edited by maxolahird; 06-14-2017 at 00:37.
maxolahird is offline
midnight9
Senior Member
Join Date: Nov 2012
Old 06-13-2017 , 16:31   Re: Action on team change
Reply With Quote #2

HookEvent("player_team"... ?
midnight9 is offline
B3none
AlliedModders Donor
Join Date: Oct 2016
Location: United Kingdom
Old 06-13-2017 , 16:34   Re: Action on team change
Reply With Quote #3

You could possibly do...

PHP Code:
public void OnPluginStart()
{
     
HookEvent("round_start"Trails_RoundStart);
}

public 
Action Trails_RoundStart(Handle event, const char []namebool dontBroadcast)
{
    for (
int i 1<= MAXPLAYERS+1i++) {
        if (
GetClientTeam(i) == 3) {
            for (
int j 0STORE_MAX_SLOTS; ++j) {
                
RemoveTrail(clienti);
            }
        }
    }

Give it a test, any more questions just add me on steam.
__________________
B3none is offline
maxolahird
Veteran Member
Join Date: Dec 2012
Old 06-13-2017 , 19:02   Re: Action on team change
Reply With Quote #4

Quote:
Originally Posted by midnight9 View Post
HookEvent("player_team"... ?
That did it! Thanks a lot.

Quote:
Originally Posted by b3none View Post
You could possibly do...

PHP Code:
public void OnPluginStart()
{
     
HookEvent("round_start"Trails_RoundStart);
}

public 
Action Trails_RoundStart(Handle event, const char []namebool dontBroadcast)
{
    for (
int i 1<= MAXPLAYERS+1i++) {
        if (
GetClientTeam(i) == 3) {
            for (
int j 0STORE_MAX_SLOTS; ++j) {
                
RemoveTrail(clienti);
            }
        }
    }

Give it a test, any more questions just add me on steam.
Hey thanks but my intention is different, what I wanted to do is when I use /spec <name> it removes that player trail.

Thanks you both.
maxolahird is offline
B3none
AlliedModders Donor
Join Date: Oct 2016
Location: United Kingdom
Old 06-14-2017 , 02:28   Re: Action on team change
Reply With Quote #5

That one is also not too hard, I'm sure you'll be able to figure it out, if not then just private message me on here and I'll be able to help you with it
__________________
B3none 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 02:00.


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