Raised This Month: $ Target: $400
 0% 

Error on cs_get_user_team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iBrazilian
Senior Member
Join Date: May 2011
Old 04-19-2012 , 16:35   Error on cs_get_user_team
Reply With Quote #1

A little help please, I've marked line 78 with // LINE 78 ... Can't really think of anything up to this point..
PHP Code:
L 04/19/2012 15:00:41: [CSTRIKEInvalid player 10
L 04
/19/2012 15:00:41: [AMXXDisplaying debug trace (plugin "objectives.amxx")
L 04/19/2012 15:00:41: [AMXXRun time error 10native error (native "cs_get_user_team")
L 04/19/2012 15:00:41: [AMXX]    [0objectives.sma::bomb_explode (line 78
PHP Code:
public bomb_explode(planter,defuser)
    {
    if ( !
pluginactive || playercount minplayers ) return;
    
    new 
explode_bonus get_pcvar_num(PCVarDefusalMap);
    new 
iPlayers[32], iPlayeriNumplantteam _:cs_get_user_team(planter);
    
    
get_players(iPlayersiNum"ah");
    for( new 
iiNumi++ )
        {
        
iPlayer iPlayers[i];
        if ( 
_:cs_get_user_team(iPlayer) == plantteam // LINE 78
            
{
            
Poke_Give_XP(planter, -1explode_bonus)
            
set_hudmessage(127255420.600.1506.05.0)
            
show_hudmessage(planter"You recieved %d xp for exploding the bomb!"explode_bonus)            
        }
    }

__________________
Pokemod Season 5 [ |||||||||| Complete]
iBrazilian is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 04-19-2012 , 16:38   Re: Error on cs_get_user_team
Reply With Quote #2

You need check is_user_connected.
__________________
kramesa is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-19-2012 , 16:38   Re: Error on cs_get_user_team
Reply With Quote #3

Usage looks correct, probably a bug with get_players(). Try not using flags and manually check for alive\hltv and see if it still occurs.

Quote:
Originally Posted by kramesa View Post
You need check is_user_connected.
get_players() will only return connected players (when functioning properly)
__________________

Last edited by Bugsy; 04-19-2012 at 16:39.
Bugsy is offline
iBrazilian
Senior Member
Join Date: May 2011
Old 04-19-2012 , 17:14   Re: Error on cs_get_user_team
Reply With Quote #4

I've never used get_players before, gotta do some homework then:/ Thank you.
__________________
Pokemod Season 5 [ |||||||||| Complete]
iBrazilian is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-19-2012 , 19:22   Re: Error on cs_get_user_team
Reply With Quote #5

Just noticed something, which cs_get_user_team() is the error occurring on?

If it's the below then what is probably happening is the planter disconnects before the bomb explodes:
PHP Code:
plantteam _:cs_get_user_team(planter); 
So, add is_user_connected( planter ) condition before checking team OR record the planting team when the bomb is first planted.
__________________

Last edited by Bugsy; 04-19-2012 at 19:24.
Bugsy is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 04-19-2012 , 19:52   Re: Error on cs_get_user_team
Reply With Quote #6

Try this

Code:
if ( is_user_connected(id) && _:cs_get_user_team(iPlayer) == plantteam )
__________________
kramesa is offline
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 04-19-2012 , 19:57   Re: Error on cs_get_user_team
Reply With Quote #7

PHP Code:
public bomb_explode(planter,defuser)
{
    if ( !
pluginactive || playercount minplayers ) return;
    
    new 
explode_bonus get_pcvar_num(PCVarDefusalMap);
    new 
iPlayers[32], iPlayeriNumplantteam _:cs_get_user_team(planter);
    
    
get_players(iPlayersiNum);
    for( new 
iiNumi++ )
    {
        
iPlayer iPlayers[i];
        if (
is_user_alive(iPlayer) && _:cs_get_user_team(iPlayer) == plantteam)
        {
            
Poke_Give_XP(planter, -1explode_bonus)
            
set_hudmessage(127255420.600.1506.05.0)
            
show_hudmessage(planter"You recieved %d xp for exploding the bomb!"explode_bonus)            
        }
    }

thanks kramesa; my mistake xD
__________________

www.amxmodx-es.com

Steam: Luchokoldo

Last edited by rak; 04-19-2012 at 20:09.
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 04-19-2012 , 20:01   Re: Error on cs_get_user_team
Reply With Quote #8

Quote:
Originally Posted by rak View Post
PHP Code:
public bomb_explode(planter,defuser)
{
    if ( !
pluginactive || playercount minplayers ) return;
    
    new 
explode_bonus get_pcvar_num(PCVarDefusalMap);
    new 
iPlayers[32], iPlayeriNumplantteam _:cs_get_user_team(planter);
    
    
get_players(iPlayersiNum);
    for( new 
iiNumi++ )
    {
        
iPlayer iPlayers[i];
        if ( 
_:cs_get_user_team(iPlayer) == plantteam && is_user_alive(iPlayer))
        {
            
Poke_Give_XP(planter, -1explode_bonus)
            
set_hudmessage(127255420.600.1506.05.0)
            
show_hudmessage(planter"You recieved %d xp for exploding the bomb!"explode_bonus)            
        }
    }

You need check is_user_connected() before cs_get_user_team().
__________________
kramesa is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-19-2012 , 23:21   Re: Error on cs_get_user_team
Reply With Quote #9

Did either of you read my post? I doubt the error is happening on that native call, I think it's the one checking planter ream. And iBrazilian, use the CsTeams tag instead of detagging the function return.

With your code, the XP will only be awarded if the planter remains connected to the server when the bomb explodes (which is dumb), use this:
PHP Code:
new CsTeams:g_PlantTeam;

public 
bomb_plantedplanter 
{
    
g_PlantTeam cs_get_user_teamplanter );
}

public 
bomb_explodeplanter defuser )
{
    if ( !
pluginactive || playercount minplayers 
        return;
    
    new 
explode_bonus get_pcvar_num(PCVarDefusalMap);
    new 
iPlayers[32], iPlayeriNum;
    
    
get_players(iPlayersiNum "a" );

    for( new 
iNum i++ )
    {
        
iPlayer iPlayers];
        
        if ( 
cs_get_user_teamiPlayer ) == g_PlantTeam )
        {
            
Poke_Give_XP(planter, -1explode_bonus)
            
set_hudmessage(127255420.600.1506.05.0)
            
show_hudmessage(planter"You recieved %d xp for exploding the bomb!"explode_bonus)            
        }
    }

__________________

Last edited by Bugsy; 04-20-2012 at 19:13.
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-20-2012 , 00:48   Re: Error on cs_get_user_team
Reply With Quote #10

Can CTs plant the bomb ??

Bugsy, you have fotgotten flag "a".
Also, i think that in Poke_Give_XP(planter, -1, explode_bonus), planter should be replaced with iPlayer
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 04-20-2012 at 00:49.
ConnorMcLeod 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 07:44.


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