Raised This Month: $51 Target: $400
 12% 

Non-player entity 0 out of range


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 04-26-2017 , 02:47   Non-player entity 0 out of range
Reply With Quote #1

I have this problem and I need help because dont know how to fix this.
It often happens that after a reload actually I dont get bullet and can not shot.When this happen I have to repeat reload few times,and sometimes help when I drop bazooka on the floor and then pick up them again.
This is the error:
PHP Code:
L 04/25/2017 12:11:12: [AMXXRun time error 10native error (native "cs_get_weapon_ammo")
L 04/25/2017 12:11:12: [AMXX]    [0amx_bazooka.sma::fw_CmdStart (line 278)
L 04/25/2017 12:11:12: [CSTRIKENon-player entity 0 out of range 
PHP Code:
public fw_CmdStart(iduc_handleseed)
{
    if(!
is_user_alive(id) || !is_user_connected(id))
        return 
FMRES_IGNORED

    
if(get_user_weapon(id) != CSW_AT4CS || !g_had_at4cs[id])
        return 
FMRES_IGNORED
        
    
static CurButton
    CurButton 
get_uc(uc_handleUC_Buttons)
    
    if(
CurButton IN_ATTACK)
    {
        static 
Float:CurTime
        CurTime 
get_gametime()
        
        static 
at4cs
        at4cs 
fm_find_ent_by_owner(-1weapon_at4csid)        
        
        if(
cs_get_weapon_ammo(at4cs) > && !is_reloading[id])
        {
            if(
CurTime 4.5 g_lastfire[id])
            {
                
set_weapon_anim(id1)                            
                
                
create_rocket(id)

                                
make_punch(id500)
                                                
                static 
Float:Punch_Angles[3]
                
                
Punch_Angles[0] =-20.0
                Punch_Angles
[1] = 0.0
                Punch_Angles
[2] = 0.0
                
                set_pev
(idpev_punchanglePunch_Angles)
                
cs_set_weapon_ammo(at4cscs_get_weapon_ammo(at4cs) - 1)
                
                if(
cs_get_weapon_ammo(at4cs) <= && !is_reloading[id])
                {
                    if(
cs_get_user_bpammo(idCSW_AT4CS) > 0)
                    {
                        
set_task(0.5"at4cs_reload"id)
                    }
                }
                
                
                
                
g_lastfire[id] = CurTime
            
}
        } else {
            if(!
is_reloading[id])
            {
                if(
cs_get_user_bpammo(idCSW_AT4CS) > 0)
                {
                    if(
CurTime 1.0 g_lastfire[id])
                    {
                        
at4cs_reload(id)
                        
g_lastfire[id] = CurTime
                    
}
                }
            }
        }
    }
    
    if(
CurButton IN_ATTACK2)
    {
        static 
Float:CurTime
        CurTime 
get_gametime()
        
        if((
CurTime 0.5 g_lastaim[id]) && !is_reloading[id])
        {
            if(!
g_aiming[id])
            {
                
g_aiming[id] = 1
            
} else {
                
g_aiming[id] = 0
            
}
            
            
g_lastaim[id] = CurTime
        
}
    }
    
    
CurButton &= ~IN_ATTACK
    set_uc
(uc_handleUC_ButtonsCurButton)
    
    
CurButton &= ~IN_RELOAD
    set_uc
(uc_handleUC_ButtonsCurButton)

    return 
FMRES_HANDLED

This is line 278
PHP Code:
if(cs_get_weapon_ammo(at4cs) > && !is_reloading[id]) 

Last edited by Krtola; 04-26-2017 at 02:49.
Krtola is offline
Send a message via Skype™ to Krtola
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-26-2017 , 03:17   Re: Non-player entity 0 out of range
Reply With Quote #2

Make sure at4cs is actually a valid entity before calling cs_get_weapon_ammo. You should always put sanity checks around each value that you retrieve by a native. You never know when things go wrong.
__________________
HamletEagle is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 04-26-2017 , 05:58   Re: Non-player entity 0 out of range
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
Make sure at4cs is actually a valid entity before calling cs_get_weapon_ammo. You should always put sanity checks around each value that you retrieve by a native. You never know when things go wrong.
Is this ok:
PHP Code:
public fw_CmdStart(iduc_handleseed)
{
        if(!
is_valid_ent(id))
                return 
FMRES_IGNORED 
Krtola is offline
Send a message via Skype™ to Krtola
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-26-2017 , 06:02   Re: Non-player entity 0 out of range
Reply With Quote #4

NO.
Quote:
Make sure at4cs is actually a valid entity.
This means to add an if(is_valid_ent(at4cs)). The error is about a native in which at4cs is used, the error tells you that entity index is invalid, so why would you check "id" now?
__________________

Last edited by HamletEagle; 04-26-2017 at 06:04.
HamletEagle is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 04-26-2017 , 06:06   Re: Non-player entity 0 out of range
Reply With Quote #5

Ok. Take a look on this please:

PHP Code:
static at4cs
at4cs 
fm_find_ent_by_owner(-1weapon_at4csid)

if(!
is_valid_ent(at4cs))
         return 
FMRES_IGNORED        
if(cs_get_weapon_ammo(at4cs) > && !is_reloading[id])


Last edited by Krtola; 04-26-2017 at 06:07.
Krtola is offline
Send a message via Skype™ to Krtola
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 04-26-2017 , 06:20   Re: Non-player entity 0 out of range
Reply With Quote #6

Better use this stock: https://forums.alliedmods.net/showthread.php?t=278123
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-26-2017 , 06:28   Re: Non-player entity 0 out of range
Reply With Quote #7

Yeah.
__________________
HamletEagle is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 04-26-2017 , 06:30   Re: Non-player entity 0 out of range
Reply With Quote #8

#Hamlet Yeah Better use this stock or Yeah my last post?
Krtola is offline
Send a message via Skype™ to Krtola
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-26-2017 , 07:23   Re: Non-player entity 0 out of range
Reply With Quote #9

Your last post.
__________________
HamletEagle is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-26-2017 , 10:42   Re: Non-player entity 0 out of range
Reply With Quote #10

I think the is_user_alive automatically check if the player is connected.
__________________








CrazY. 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 02:43.


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