Raised This Month: $ Target: $400
 0% 

Invalid player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-17-2010 , 16:32   Invalid player
Reply With Quote #1

Hi,

I have a problem with a plugin, it always gives errors about invalid players.
I check max players and is_user_connected(id) and is_user_alive(id) but still i get errors.

Could someone take a look at this and learn me how to fix these errors.
(I'm not really experienced at using stocks, maybe i use it the wrong way)

The error
Code:
L 03/17/2010 - 16:20:11: Start of error session.
L 03/17/2010 - 16:20:11: Info (map "jail_sanctuary") (file "addons/amxmodx/logs/error_20100317.log")
L 03/17/2010 - 16:20:11: [CSTRIKE] Invalid player 2
L 03/17/2010 - 16:20:12: [AMXX] Displaying debug trace (plugin "jailbreak_main.amxx")
L 03/17/2010 - 16:20:12: [AMXX] Run time error 10: native error (native "cs_get_user_team")
L 03/17/2010 - 16:20:12: [AMXX]    [0] handgunmenu.inl::gun_spawn (line 12)
L 03/17/2010 - 16:20:12: [AMXX]    [1] jailbreak_main.sma::PlayerSpawn (line 100)
L 03/17/2010 - 16:25:48: [CSTRIKE] Player out of range (0)
L 03/17/2010 - 16:25:48: [AMXX] Displaying debug trace (plugin "jailbreak_main.amxx")
L 03/17/2010 - 16:25:48: [AMXX] Run time error 10: native error (native "cs_get_user_team")
L 03/17/2010 - 16:25:48: [AMXX]    [0] jail_addons.inl::rebeldeath (line 54)
And there is a lot more where that came from.

The plugin:
handgunmenu part
PHP Code:
public gun_spawn(id)
{
    new 
players[32], pnum
    get_players
(playerspnum"a");
    for( new 
ii<pnumi++ )
    {
        
check_user(id)
        if(
cs_get_user_team(id) == CS_TEAM_CT)
        {
            
handgun_menu(id)
        }
        
got_gun[id] = false
    
}
    return 
PLUGIN_HANDLED

PlayerSpawn(id) part:
PHP Code:
public PlayerSpawn(id)

    for( new 
1<= g_iMaxPlayers i++ )
    {
        
check_user(id)
        if(
is_user_alive(id))
        {
            
set_user_rendering(idkRenderFxGlowShell000kRenderNormal20)
            
strip_weapons(id)
        }
    }
    
    if(
gravityday)
    {
        
check_user(id)
        if(
is_user_alive(id)
        ||(
cs_get_user_team(id) == CS_TEAM_T))
        {
            
set_user_gravity(id1.0)
        }
    }
    
check_lr(id)
    
gun_spawn(id)
    
is_user_wanted[id] = false
    
return PLUGIN_HANDLED

jail_addons part:
PHP Code:
public rebeldeath()
{
    new 
attacker read_data(1)
    new 
victim read_data(2)
    new 
headshot read_data(3)
    
    new 
AttackerName[32]
    new 
VictimName[32]

    
check_user(attacker)
    
check_user(victim)
    
    if( 
cs_get_user_team(attacker) == CS_TEAM_CT && cs_get_user_team(victim) == CS_TEAM_T)
    {
        if(
is_user_wanted[victim])
        {
            
get_user_name(attackerAttackerName31)
            
get_user_name(victimVictimName,31)
    
            
client_print(0print_chat"Guard %s killed wanted prisoner %s!"AttackerNameVictimName)
        }
        
        else if(!
is_user_wanted[victim])
        {
            
get_user_name(attackerAttackerName31)
            
get_user_name(victimVictimName,31)
    
            
client_print(0print_chat"Guard %s killed unwanted prisoner %s!"AttackerNameVictimName)
        }
    }
    
    if( 
cs_get_user_team(attacker) == CS_TEAM_T && cs_get_user_team(victim) == CS_TEAM_CT)
    {
        
playerpoints[attacker] += get_pcvar_num(cvar_killpoints)
        
        if(
headshot)
            
playerpoints[attacker] += get_pcvar_num(cvar_headshotpoints);
        
    }
    
//SaveData(attacker)

And the stock: check_user(id):
PHP Code:
stock check_user(index)
{
    if(!
is_user_connected(index)
    ||(
is_user_bot(index)))
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE

I hope you guys can show me how it works, so i can fix my plugin.
Thanks in advance
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-17-2010 , 16:36   Re: Invalid player
Reply With Quote #2

Quote:
Originally Posted by drekes View Post
stuff
In the .inl you're checking the team of the original passed index, rather than the player in the for loop.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-17-2010 , 16:41   Re: Invalid player
Reply With Quote #3

I don't understand what you mean, could you make an example of my mistake and a solution, so i can see my mistake?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-17-2010 , 17:00   Re: Invalid player
Reply With Quote #4

Quote:
Originally Posted by drekes View Post
I don't understand what you mean, could you make an example of my mistake and a solution, so i can see my mistake?
PHP Code:
new players[32], pnum
    get_players
(playerspnum"a");
    for( new 
ii<pnumi++ )
    {
        
check_user(id)
        if(
cs_get_user_team(id) == CS_TEAM_CT)
        {
            
handgun_menu(id)
        }
        
got_gun[id] = false
    


Code:
new players[32], pnum, tempid     get_players(players, pnum, "a");     for( new i; i<pnum; i++ )     {         tempid = players[i]         check_user(tempid)         if(cs_get_user_team(tempid) == CS_TEAM_CT)         {             handgun_menu(tempid)         }         got_gun[tempid] = false     }
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-17-2010 , 17:01   Re: Invalid player
Reply With Quote #5

ow, i think i get it.

so i need to keep the id of the player, and then check his team and such.

And instead of tempid, can i use id?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-17-2010 , 17:02   Re: Invalid player
Reply With Quote #6

Quote:
Originally Posted by drekes View Post
ow, i think i get it.

so i need to keep the id of the player, and then check his team and such.
The way you were doing it, it was checking the team of one player x amount of times.

This one checks each player individually.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-17-2010 , 17:04   Re: Invalid player
Reply With Quote #7

can i use id instead of tempid, or does this bug the plugin?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-17-2010 , 17:10   Re: Invalid player
Reply With Quote #8

Quote:
Originally Posted by drekes View Post
can i use id instead of tempid, or does this bug the plugin?
You'd need to rename the index passed in the function.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-17-2010 , 17:12   Re: Invalid player
Reply With Quote #9

ok, thanks wrecked_, for all the times you helped me out.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-17-2010 , 17:15   Re: Invalid player
Reply With Quote #10

and do i rename the index of another function to?
like so
PHP Code:
public handgun_menu(tempid)
{
    
check_user(tempid)
    {
    
        new 
handgunmenu menu_create("\yChoose your handgun:""sub_handgun_menu")

        
menu_additem(handgunmenu"\wUsp""1"0);
        
menu_additem(handgunmenu"\wGlock""2"0);
        
menu_additem(handgunmenu"\wDual Elites""3"0);
        
menu_additem(handgunmenu"\wDeagle""4"0)
        
        
menu_setprop(handgunmenuMPROP_EXITMEXIT_ALL);
        
menu_display(idhandgunmenu0);
    }
    return 
PLUGIN_HANDLED

or like this, without renaming that
PHP Code:
public handgun_menu(id)
{
    
check_user(id)
    {
    
        new 
handgunmenu menu_create("\yChoose your handgun:""sub_handgun_menu")

        
menu_additem(handgunmenu"\wUsp""1"0);
        
menu_additem(handgunmenu"\wGlock""2"0);
        
menu_additem(handgunmenu"\wDual Elites""3"0);
        
menu_additem(handgunmenu"\wDeagle""4"0)
        
        
menu_setprop(handgunmenuMPROP_EXITMEXIT_ALL);
        
menu_display(idhandgunmenu0);
    }
    return 
PLUGIN_HANDLED

and how do i use it in a death event?
like this
PHP Code:
public PlayerDeath()
{
    new 
attacker read_data(1)
    new 
victim read_data(2)

    if( 
cs_get_user_team(attacker) == CS_TEAM_T && cs_get_user_team(victim) == CS_TEAM_CT)
    {
        
lr_started false
    
}
    if(
spray_on)
    {
        
server_cmd("decalfrequency 20")
        
spray_on false
    
}

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 03-17-2010 at 17:26.
drekes is offline
Send a message via MSN to drekes
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 08:48.


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