Raised This Month: $ Target: $400
 0% 

CsTeams


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 11-14-2010 , 16:43   CsTeams
Reply With Quote #1

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.
shuttle_wave is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-14-2010 , 16:53   Re: CsTeams
Reply With Quote #2

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 )
__________________
Bugsy is offline
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 11-14-2010 , 16:54   Re: CsTeams
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
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
shuttle_wave is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-14-2010 , 16:58   Re: CsTeams
Reply With Quote #4

Quote:
Originally Posted by shuttle_wave View Post
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];
    }

__________________

Last edited by Bugsy; 11-14-2010 at 17:07.
Bugsy is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-16-2010 , 17:55   Re: CsTeams
Reply With Quote #5

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 )
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 11-16-2010 , 21:58   Re: CsTeams
Reply With Quote #6

Quote:
Originally Posted by Bugsy View Post
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` View Post
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
shuttle_wave 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 11:14.


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