AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Exec command ONCE after chosing a team (https://forums.alliedmods.net/showthread.php?t=182921)

DeLiriuM 04-15-2012 08:21

Exec command ONCE after chosing a team
 
Hey,

I'm trying to exec a say command after a player joins the server and chooses a team.

Currently i'm using this method:

PHP Code:

public client_infochanged(id
{     
    if (
get_user_team(id) > 0client_cmd(id"say /rules")
    return 
PLUGIN_CONTINUE 


Problem is, that even if the player changes his team, the commands executes again. I need it to execute ONLY once after the first teamjoin.

BeeFighter 04-15-2012 08:31

Re: Exec command ONCE after chosing a team
 
Use TextMsg event,

And to prevent from showing again when he changes team make a bool, to do a check.

DeLiriuM 04-15-2012 08:57

Re: Exec command ONCE after chosing a team
 
Ahm. Example please.

BeeFighter 04-15-2012 09:02

Re: Exec command ONCE after chosing a team
 
PHP Code:

register_event("TextMsg""AtJoinTeam""a""1=1""2&Game_join_te""2&Game_join_ct")

public 
AtJoinTeam()
{
    new 
iPlayers[32], iNumtempid
    get_players
(iPlayersiNum)
        
    for(new 
iiNumi++)
    {
        
tempid iPlayers[i]
                 
        if(
MyCheck[tempid] == true)
        {
            return 
PLUGIN_HANDLED
        
}
        
        
//Your rules here
    
}



DeLiriuM 04-15-2012 12:12

Re: Exec command ONCE after chosing a team
 
Still doesn't work. Command still executes after team change.

Bugsy 04-15-2012 12:48

Re: Exec command ONCE after chosing a team
 
Untested
PHP Code:

#include <amxmodx>

enum TeamSelect
{
    
None,
    
Team,
    
Model
}

new 
TeamSelect:g_tsJoinedTeam33 ];

public 
plugin_init() 
{
    
register_event"TeamInfo" "fw_EvTeamInfo" "a" );
}

public 
client_disconnectid )
{
    
g_tsJoinedTeamid ] = None;
}

public 
fw_EvTeamInfo()
{
    new 
iPlayer read_data);

    if ( 
g_tsJoinedTeamiPlayer ] < Model )
    {
        new 
szTeam];
        
read_dataszTeam charsmaxszTeam ) );
        
        switch ( 
szTeam] )
        {
            case 
'T' 'C'
            {
                if ( ++
g_tsJoinedTeamiPlayer ] == Model )
                {
                    
//Your code goes here
                
}
            }
        }    
    }



DeLiriuM 04-15-2012 13:19

Re: Exec command ONCE after chosing a team
 
Quote:

Originally Posted by Bugsy (Post 1689711)
Untested
PHP Code:


#include <amxmodx>

new bool:g_bJoinedTeam33 ];

public 
plugin_init() 
{
    
register_event"TeamInfo" "fw_EvTeamInfo" "a" );
}

public 
client_disconnectid )
{
    
g_bJoinedTeamid ] = false;
}

public 
fw_EvTeamInfo()
{
    new 
iPlayer read_data);
    
    if ( !
g_bJoinedTeamiPlayer ] )
    {
        new 
szTeam];
        
read_dataszTeam charsmaxszTeam ) );
        
        switch ( 
szTeam] )
        {
            case 
'T' 'C'
            {
                
//Put your code here, add 'S' if you also want to hook Spectator join
                
                
g_bJoinedTeamiPlayer ] = true;
            }
        }    
    }



Works like a charm. Only problem is that it doesn't wait to choose a skin.

Bugsy 04-15-2012 13:39

Re: Exec command ONCE after chosing a team
 
Quote:

Originally Posted by DeLiriuM (Post 1689736)
Works like a charm. Only problem is that it doesn't wait to choose a skin.

Edited above code.


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

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