AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Player out of range (0) [ERROR] (https://forums.alliedmods.net/showthread.php?t=204907)

bLacK-bLooD 01-04-2013 15:03

Player out of range (0) [ERROR]
 
Code:

L 01/04/2013 - 21:42:22: Start of error session.
L 01/04/2013 - 21:42:22: Info (map "ze_area51_lg") (file "addons/amxmodx/logs/error_20130104.log")
L 01/04/2013 - 21:42:22: [FUN] Player out of range (0)
L 01/04/2013 - 21:42:22: [AMXX] Run time error 10 (plugin "weaponmen.amxx") (native "give_item") - debug not enabled!
L 01/04/2013 - 21:42:22: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
L 01/04/2013 - 22:03:22: Start of error session.
L 01/04/2013 - 22:03:22: Info (map "ze_jurassickpark3_lg") (file "addons/amxmodx/logs/error_20130104.log")
L 01/04/2013 - 22:03:22: [FUN] Player out of range (0)
L 01/04/2013 - 22:03:22: [AMXX] Displaying debug trace (plugin "weaponmen.amxx")
L 01/04/2013 - 22:03:22: [AMXX] Run time error 10: native error (native "give_item")
L 01/04/2013 - 22:03:22: [AMXX]    [0] gunmenu.sma::roundstart (line 39)

PHP Code:

register_event"HLTV""roundstart""a""1=0""2=0" );

// stuff

public roundstart()
{
    static 
iPlayers32 ], iNumi;
    
get_playersiPlayersiNum );
    
    for( 
0iNumi++ )
    {
        if(( 
is_user_aliveiPlayers] ) ) )
        {
            
menu_displayiPlayers], g_Menu);
            
strip_user_weapons(iPlayers[i]);
            
give_itemiPlayers[i], "weapon_knife" ); // line 39
        
}
    }


Why is Player out of range (0) ?

Edit:

I have already searched for the problem but checking if is_user_connected didn't work.

AngeIII 01-04-2013 15:48

Re: Player out of range (0) [ERROR]
 
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \

so your id is incorrect... but is_user_alive check if ID is correct. so I should you to create new variable to store id

PHP Code:


public roundstart()
{
    static 
iPlayers32 ], iNumi;
    
get_playersiPlayersiNum );
    new 
player_id;
    for( 
0iNumi++ )
    {
        
player_id=iPlayers];
        if(( 
is_user_aliveplayer_id ) ) )
        {
            
menu_displayplayer_idg_Menu);
            
strip_user_weapons(player_id);
            
give_itemplayer_id"weapon_knife" ); // line 39
        
}
    }



bLacK-bLooD 01-04-2013 15:54

Re: Player out of range (0) [ERROR]
 
Got it, thanks. It's working now but for some reason because of this plugin some chat messages duplicate (it shows the same message twice) and i don't have any idea why.

AngeIII 01-04-2013 15:57

Re: Player out of range (0) [ERROR]
 
post sma

bLacK-bLooD 01-04-2013 16:00

Re: Player out of range (0) [ERROR]
 
Now i changed the map and everything is fine, no duplicate messages.

Do you mind if i add you on skype for further chatting?

AngeIII 01-04-2013 16:02

Re: Player out of range (0) [ERROR]
 
yes ok. this is offtopic.

fysiks 01-04-2013 22:02

Re: Player out of range (0) [ERROR]
 
Quote:

Originally Posted by AngeIII (Post 1867086)
so I should you to create new variable to store id

Not required and will not fix any errors. It is just an optimization. FYI.

twix_p 01-04-2013 23:01

Re: Player out of range (0) [ERROR]
 
PHP Code:

#include < hamsandwich >
public plugin_init()
    
RegisterHamHam_Spawn"player""OnSpawn");

public 
OnSpawniPlayer )
{
    if ( 
is_user_aliveiPlayer ) )
    {
            
menu_displayiPlayerg_Menu);
/* 
             You can strip weapons when he choice a gun from menu, if he do.

            strip_user_weapons(iPlayer);
            give_item( iPlayer "weapon_knife" ); */
    
}



LeeanAndNeka 01-05-2013 02:40

Re: Player out of range (0) [ERROR]
 
PHP Code:

#include < amxmodx >

#define is_valid_player(%1) (1 <= %1 <= g_maxplayers)

new g_maxplayers

public plugin_init() {

    
g_maxplayers get_players()
}

public 
roundstart()
{
    static 
iPlayers32 ], iNumi;
    
get_playersiPlayersiNum );
    
    for( 
0iNumi++ )
    {
        if( 
is_valid_playeriPlayers] ) )
        {
            
menu_displayiPlayers], g_Menu);
            
strip_user_weapons(iPlayers[i]);
            
give_itemiPlayers[i], "weapon_knife" )
        }
    }



bLacK-bLooD 01-05-2013 03:17

Re: Player out of range (0) [ERROR]
 
Quote:

Originally Posted by twix_p (Post 1867313)
PHP Code:

#include < hamsandwich >
public plugin_init()
    
RegisterHamHam_Spawn"player""OnSpawn");

public 
OnSpawniPlayer )
{
    if ( 
is_user_aliveiPlayer ) )
    {
            
menu_displayiPlayerg_Menu);
/* 
             You can strip weapons when he choice a gun from menu, if he do.

            strip_user_weapons(iPlayer);
            give_item( iPlayer "weapon_knife" ); */
    
}



Thank you, this is easier i think. I also took in consideration your advice and stripped weapons when the player chose them from the menu.


All times are GMT -4. The time now is 13:45.

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