Raised This Month: $ Target: $400
 0% 

Run time error 10 (plugin "vcjb.amxx") (native "cs_get_user_team" )


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 08-03-2010 , 19:21   Run time error 10 (plugin "vcjb.amxx") (native "cs_get_user_team" )
Reply With Quote #1

Alright what could possibly be the problem? I wouldn't like to show any code, so if you could possibly just list some possibilities it would be greatly appreciated.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-03-2010 , 19:24   Re: Run time error 10 (plugin "vcjb.amxx") (native "cs_get_user_team" )
Reply With Quote #2

id < 1, id > get_maxplayers, player not connected.
Dunno what happend with HLTVs.

Anyway, put your plugin in debug mode to get detailed errors.


The following checks are made when you use that native :
Code:
#define CHECK_PLAYER(x) \
	if (x < 1 || x > gpGlobals->maxClients) { \
		MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
		return 0; \
	} else { \
		if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
			MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
			return 0; \
		} \
	}
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 08-03-2010 at 19:26.
ConnorMcLeod is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 08-03-2010 , 19:27   Re: Run time error 10 (plugin "vcjb.amxx") (native "cs_get_user_team" )
Reply With Quote #3

L 08/04/2010 - 07:28:08: [AMXX] [0] vcjb.sma::cmdCheck (line 72)

The block of code that line 72 is located:

PHP Code:
public cmdCheck(id)
{
    if( !
is_user_alive(id) )
        return 
PLUGIN_HANDLED;
    
    if( 
cs_get_user_team(id) != CS_TEAM_T )
        return 
PLUGIN_HANDLED;
    
    if( 
gLastRequest == true )
        return 
PLUGIN_HANDLED;
    
    new 
iPlayers[32] = 0;
    new 
iNum;
    new 
id;
    
get_playersiPlayersiNum"a" )
    
    for( new 
0gMaxClientsi++ )
    {
        
id iPlayers[i]
        
        if( !
is_user_alive(id) )
            continue;
        
        switch( 
cs_get_user_team(id) )
        {
            case 
CS_TEAM_T:
            {
                
Prisoners++
            }
            case 
CS_TEAM_CT:
            {
                
Guards++
            }
        }
    }
    
    if( 
cs_get_user_team(id) == CS_TEAM_CT )
    {
        
client_print_coloridBlue"^4[Jailbreak] ^1You aren't a prisoner^4." )
    }
    
    if( 
Prisoners )
    {
        
client_print_coloridBlue"^4[Jailbreak] ^1There are too many terrorists alive^4!" )
    } else {
        
cmdLastRequestid )
    }
    
    return 
PLUGIN_HANDLED;

__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 08-03-2010 , 19:40   Re: Run time error 10 (plugin "vcjb.amxx") (native "cs_get_user_team" )
Reply With Quote #4

Code:
for( new i = 0; i < iNum; i++ )

EDIT: You should really code more optimistically than pessimistically. What I mean by that is that you return after every if() to avoid faulty conditions, but you should just execute the following code when you check the inverted situation for the current if() condition.

That's kind of hard to explain, so here's an example:
Code:
if( is_user_alive( id ) )     return; // code

Code:
if( !is_user_alive( id ) ) {     // code }
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT

Last edited by wrecked_; 08-03-2010 at 19:43.
wrecked_ is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 08-03-2010 , 19:48   Re: Run time error 10 (plugin "vcjb.amxx") (native "cs_get_user_team" )
Reply With Quote #5

Quote:
Originally Posted by wrecked_ View Post
Code:
for( new i = 0; i < iNum; i++ )

EDIT: You should really code more optimistically than pessimistically. What I mean by that is that you return after every if() to avoid faulty conditions, but you should just execute the following code when you check the inverted situation for the current if() condition.

That's kind of hard to explain, so here's an example:
Code:
if( is_user_alive( id ) )     return; // code

Code:
if( !is_user_alive( id ) ) {     // code }
Thats how I used to code if statements. I have no idea why I changed.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 08-03-2010 , 19:54   Re: Run time error 10 (plugin "vcjb.amxx") (native "cs_get_user_team" )
Reply With Quote #6

Quote:
Originally Posted by GXLZPGX View Post
Thats how I used to code if statements. I have no idea why I changed.
I also recommend using the && (and) operator in your if() statements. You have 3 if()'s checking a different thing but returning the same value if each one is executed.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 08-03-2010 , 20:33   Re: Run time error 10 (plugin "vcjb.amxx") (native "cs_get_user_team" )
Reply With Quote #7

You also check if( !is_user_alive( id ) ) twice, once at the top and then again in the loop.
__________________
Hi.
Kreation is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 08-03-2010 , 21:16   Re: Run time error 10 (plugin "vcjb.amxx") (native "cs_get_user_team" )
Reply With Quote #8

Quote:
Originally Posted by Kreation View Post
You also check if( !is_user_alive( id ) ) twice, once at the top and then again in the loop.
He had 2 variables named id. We fixed that via PM.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ 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 00:06.


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