AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detect Jointeam (https://forums.alliedmods.net/showthread.php?t=216716)

piepie 05-24-2013 17:37

Detect Jointeam
 
Can someone give me an example how to detect jointeam?

11922911 05-25-2013 00:27

Re: Detect Jointeam
 
If you are talking about in CS, and you want detect only T/CT,
I suggest you to hook client 'joinclass' command.
Here's an example of how to detect jointeam by hooking joinclass command. (correct me if i'm wrong)
PHP Code:

#include amxmodx
#include fakemeta

#define m_iTeam 114
#define m_iMenu 205

#define CSMENU_JOINCLASS 3

public plugin_init()
{
    
register_clcmd"joinclass""ClCmd_joinclass" )
    
register_clcmd"menuselect""ClCmd_joinclass" // for old style text menu
}

public 
ClCmd_joinclassid )
{
    if( 
get_pdata_intidm_iMenu ) == CSMENU_JOINCLASS )
    {
        new 
iTeam get_pdata_intidm_iTeam // get team
        // log_amx( "Detect Jointeam [TEAM ID %d]", iTeam )
    
}


Else, you can try the following method.
PHP Code:

#include amxmodx

public plugin_init()
{
    
register_logevent"LogEvent_JoinTeam"3"1=joined team" )
}

public 
LogEvent_JoinTeam()
{
    new 
id GetLogUserIndex()
    
    static 
szTeam[2], iTeam
    read_logargv
2szTeam)
    switch( 
szTeam[0] )
    {
        case 
'T'iTeam 1;
        case 
'C'iTeam 2;
        case 
'S'iTeam 3;
    }
    
    
//log_amx( "Detect Jointeam [TEAM ID %d]", iTeam )
}

stock GetLogUserIndex()
{
    static 
szLogUser[80], szName[32]
    
read_logargv0szLogUsercharsmaxszLogUser ) )
    
parse_loguserszLogUserszNamecharsmaxszName ) )
    return 
get_user_indexszName )


For more examples, please search the forum.

piepie 05-25-2013 05:17

Re: Detect Jointeam
 
Quote:

Originally Posted by 11922911 (Post 1957941)
If you are talking about in CS, and you want detect only T/CT,
I suggest you to hook client 'joinclass' command.
Here's an example of how to detect jointeam by hooking joinclass command. (correct me if i'm wrong)
PHP Code:

#include amxmodx
#include fakemeta

#define m_iTeam 114
#define m_iMenu 205

#define CSMENU_JOINCLASS 3

public plugin_init()
{
    
register_clcmd"joinclass""ClCmd_joinclass" )
    
register_clcmd"menuselect""ClCmd_joinclass" // for old style text menu
}

public 
ClCmd_joinclassid )
{
    if( 
get_pdata_intidm_iMenu ) == CSMENU_JOINCLASS )
    {
        new 
iTeam get_pdata_intidm_iTeam // get team
        // log_amx( "Detect Jointeam [TEAM ID %d]", iTeam )
    
}


Else, you can try the following method.
PHP Code:

#include amxmodx

public plugin_init()
{
    
register_logevent"LogEvent_JoinTeam"3"1=joined team" )
}

public 
LogEvent_JoinTeam()
{
    new 
id GetLogUserIndex()
    
    static 
szTeam[2], iTeam
    read_logargv
2szTeam)
    switch( 
szTeam[0] )
    {
        case 
'T'iTeam 1;
        case 
'C'iTeam 2;
        case 
'S'iTeam 3;
    }
    
    
//log_amx( "Detect Jointeam [TEAM ID %d]", iTeam )
}

stock GetLogUserIndex()
{
    static 
szLogUser[80], szName[32]
    
read_logargv0szLogUsercharsmaxszLogUser ) )
    
parse_loguserszLogUserszNamecharsmaxszName ) )
    return 
get_user_indexszName )


For more examples, please search the forum.

What is the best way?

ConnorMcLeod 05-25-2013 07:49

Re: Detect Jointeam
 
What you want to do with join team detection ?

11922911 05-25-2013 08:09

Re: Detect Jointeam
 
It depends on what you need,
if you want to accurately detect when a player selects a skin, the first one is better.

piepie 05-25-2013 08:47

Re: Detect Jointeam
 
Quote:

Originally Posted by ConnorMcLeod (Post 1958097)
What you want to do with join team detection ?

Quote:

Originally Posted by 11922911 (Post 1958114)
It depends on what you need,
if you want to accurately detect when a player selects a skin, the first one is better.

When user joins a team (only T or CT) i want to set a task to function.

11922911 05-25-2013 10:01

Re: Detect Jointeam
 
In this case, i also think the first one is better for you.
Because if you use the second one i gave you, it will only detects when you are joining a team. After you have joined team, you also have to choosing a class now, if you didn't choose anything, so it's not really joined the team, because you still stay in "Select your appearance" menu until you have selected your class.


All times are GMT -4. The time now is 16:18.

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