AlliedModders

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

shuttle_wave 11-14-2010 16:43

CsTeams
 
I am so confused now.

new CsTeams:g_iTeam[33];

do i need to do g_iTeam[id] = cs_get_user_team(id)??

atm i did new CsTeams:g_iTeam[33];

and i start using g_iTeam without going = cs_get_user_team(id);

example. if(g_iTeam[id] == CS_TEAM_CT)

but it doesnt seem to work.

Bugsy 11-14-2010 16:53

Re: CsTeams
 
new CsTeams:g_iTeam[33]; will have all 0 (unassigned team) values.

You must use g_iTeam[ id ] = cs_get_user_team( id ) to retrieve the users team, you can then check if ( g_iTeam[ id ] == CS_TEAM_CT )

shuttle_wave 11-14-2010 16:54

Re: CsTeams
 
Quote:

Originally Posted by Bugsy (Post 1349536)
new CsTeams:g_iTeam[33]; will have all 0 (unassigned team) values.

You must use g_iTeam[ id ] = cs_get_user_team( id ) to retrieve the users team, you can then check if ( g_iTeam[ id ] == CS_TEAM_CT )

where is the best place to but cs_get_user_team(id) so i wouldnt need to do it again. So afta i can just use g_iTeam

Bugsy 11-14-2010 16:58

Re: CsTeams
 
Quote:

Originally Posted by shuttle_wave (Post 1349541)
where is the best place to but cs_get_user_team(id) so i wouldnt need to do it again. So afta i can just use g_iTeam

That is an array for all players currently on the server, you need to assign each element of the array for each individual player; each cs_get_user_team() call is only for a single player.

If you need to constantly have all player teams populated into the array then you can hook TeamInfo.

untested
PHP Code:

#include <amxmodx>
#include <cstrike>

new g_iOldTeam33 ];
new 
CsTeams:g_iTeam33 ];

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

public 
fw_EvTeamInfo()
{
    new 
szTeam] , iPlayer read_data);
    
    
read_dataszTeam charsmaxszTeam ) );
    
    if( 
szTeam] != g_iOldTeamiPlayer ] )
    {
        switch ( 
szTeam] )
        {
            case 
'U'g_iTeamiPlayer ] = CS_TEAM_UNASSIGNED;
            case 
'T'g_iTeamiPlayer ] = CS_TEAM_T;
            case 
'C'g_iTeamiPlayer ] = CS_TEAM_CT;
            case 
'S'g_iTeamiPlayer ] = CS_TEAM_SPECTATOR;
        }    
        
        
g_iOldTeamiPlayer ] = szTeam];
    }



Emp` 11-16-2010 17:55

Re: CsTeams
 
If you are not checking it very often though, you should just abandon the array altogether and simply do:
Code:

if ( cs_get_user_team( id ) == CS_TEAM_CT )

shuttle_wave 11-16-2010 21:58

Re: CsTeams
 
Quote:

Originally Posted by Bugsy (Post 1349544)
That is an array for all players currently on the server, you need to assign each element of the array for each individual player; each cs_get_user_team() call is only for a single player.

If you need to constantly have all player teams populated into the array then you can hook TeamInfo.

untested
PHP Code:

#include <amxmodx>
#include <cstrike>

new g_iOldTeam33 ];
new 
CsTeams:g_iTeam33 ];

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

public 
fw_EvTeamInfo()
{
    new 
szTeam] , iPlayer read_data);
    
    
read_dataszTeam charsmaxszTeam ) );
    
    if( 
szTeam] != g_iOldTeamiPlayer ] )
    {
        switch ( 
szTeam] )
        {
            case 
'U'g_iTeamiPlayer ] = CS_TEAM_UNASSIGNED;
            case 
'T'g_iTeamiPlayer ] = CS_TEAM_T;
            case 
'C'g_iTeamiPlayer ] = CS_TEAM_CT;
            case 
'S'g_iTeamiPlayer ] = CS_TEAM_SPECTATOR;
        }    
        
        
g_iOldTeamiPlayer ] = szTeam];
    }



Quote:

Originally Posted by Emp` (Post 1350894)
If you are not checking it very often though, you should just abandon the array altogether and simply do:
Code:

if ( cs_get_user_team( id ) == CS_TEAM_CT )


thank you very much


All times are GMT -4. The time now is 11:14.

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