AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] How to Catch Change Team Event (https://forums.alliedmods.net/showthread.php?t=147739)

Stylaa 01-13-2011 09:07

[Solved] How to Catch Change Team Event
 
How i can catch the Change Team Event?

i store the Teams in a Variable

And how to catch the Teamchange and not just hook jointeam

i need cs_set_user_team too

Greetings


:My Code:

PHP Code:

public catch_team(id)
{
    if ( 
cs_get_user_team id ) == CS_TEAM_T )
    {
        
PlayerInfo[id][p_team] = 1
    
}
    else if( 
cs_get_user_team id ) == CS_TEAM_CT )
    {
        
PlayerInfo[id][p_team] = 2
    
}
    else if( 
cs_get_user_team id ) == CS_TEAM_SPECTATOR )
    {
        
PlayerInfo[id][p_team] = 3
    
}
    else if( 
cs_get_user_team id ) == CS_TEAM_UNASSIGNED )
    {
        
PlayerInfo[id][p_team] = 4
    
}



SpeeDeeR 01-13-2011 09:09

Re: How to Catch Change Team Event
 
Registering jointeam in your case is a way.

Elusive138 01-13-2011 09:26

Re: How to Catch Change Team Event
 
http://wiki.alliedmods.net/Half-Life...vents#TeamInfo

Use with register_event. TeamInfo is sent to all players (I think) to let themknow someone has changed teams. Use read_data(1) to get id, and read_data(2) to get team name.

Also, you should be using a switch instead of if...else if. Definitely do not call cs_get_user_team 4 times...

abdul-rehman 01-13-2011 09:36

Re: How to Catch Change Team Event
 
Code:
public catch_team(id) {     if ( cs_get_user_team ( id ) == CS_TEAM_T )     {         PlayerInfo[id][p_team] = 1     }     else if( cs_get_user_team ( id ) == CS_TEAM_CT )     {         PlayerInfo[id][p_team] = 2     }     else if( cs_get_user_team ( id ) == CS_TEAM_SPECTATOR )     {         PlayerInfo[id][p_team] = 3     }     else if( cs_get_user_team ( id ) == CS_TEAM_UNASSIGNED )     {         PlayerInfo[id][p_team] = 4     } }
You can simply do this instead:
Code:
public catch_team(id) {     PlayerInfo[id][p_team] = _:cs_get_user_team ( id ) }

Stylaa 01-13-2011 11:17

Re: How to Catch Change Team Event
 
Thanks this works now


All times are GMT -4. The time now is 02:13.

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