Raised This Month: $32 Target: $400
 8% 

Non-player entity 0 out of range


Post New Thread Reply   
 
Thread Tools Display Modes
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-26-2017 , 10:47   Re: Non-player entity 0 out of range
Reply With Quote #11

Quote:
Originally Posted by CrazY. View Post
I think the is_user_alive automatically check if the player is connected.
100 % correct. no need for using both together.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
PartialCloning
Senior Member
Join Date: Dec 2015
Old 04-26-2017 , 10:52   Re: Non-player entity 0 out of range
Reply With Quote #12

When using forwards like cmdstart you're better off using a variable to store when the player is alive or dead than calling is_user_alive every time.

You should check "!g_had_at4cs[id]" before "get_user_weapon(id) != CSW_AT4CS" as get_user_weapon wouldn't be called when it's not needed.
PartialCloning is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 04-26-2017 , 13:39   Re: Non-player entity 0 out of range
Reply With Quote #13

Show weapon_at4cs variable. You can replace entity searching with just getting m_pActiveItem (or cs_get_user_weapon_entity in amxx 1.8.3), but this error is weird if weapon_at4cs is logically correct.
Maybe this can be bugged get_user_weapon which updates current weapon not immediately, better to replace it with m_pActiveItem + cs_get_weapon_id check (or cs_get_user_weapon in amxx 1.8.3).

Quote:
Originally Posted by HamletEagle View Post
You should always put sanity checks around each value that you retrieve by a native. You never know when things go wrong.
No, some things are guaranteed to be valid and correct, but in this situation there can be a problem with get_user_weapon, because it isn't updated immediately after weapon changing.
__________________

Last edited by PRoSToTeM@; 04-26-2017 at 13:51.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 04-26-2017 , 14:04   Re: Non-player entity 0 out of range
Reply With Quote #14

Quote:
Originally Posted by PRoSToTeM@ View Post
Show weapon_at4cs variable. You can replace entity searching with just getting m_pActiveItem (or cs_get_user_weapon_entity in amxx 1.8.3), but this error is weird if weapon_at4cs is logically correct.
Maybe this can be bugged get_user_weapon which updates current weapon not immediately, better to replace it with m_pActiveItem + cs_get_weapon_id check (or cs_get_user_weapon in amxx 1.8.3).


No, some things are guaranteed to be valid and correct, but in this situation there can be a problem with get_user_weapon, because it isn't updated immediately after weapon changing.
Do you ask for this variable?

#define weapon_at4cs "weapon_m249"
#define CSW_AT4CS CSW_M249
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 , 14:58   Re: Non-player entity 0 out of range
Reply With Quote #15

Quote:
No, some things are guaranteed to be valid and correct, but in this situation there can be a problem with get_user_weapon, because it isn't updated immediately after weapon changing.
Good luck explaining to a beginner when to and when to not. It's better to add a check than mess things up. Also you did not take into account other plugins that may be doing weird things.
__________________

Last edited by HamletEagle; 04-26-2017 at 15:00.
HamletEagle is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 04-26-2017 , 15:02   Re: Non-player entity 0 out of range
Reply With Quote #16

Yup, there is a problem with get_user_weapon, you can test it with this code (problem appears on weapon change, on weapon drop and maybe on weapon strip):
PHP Code:
    register_forward(FM_CmdStart"CmdStarted", ._post=true);
}

public 
CmdStarted(playerucmdHandlerandomSeed) {
    if (!
is_user_alive(player)) {
        return;
    }
    
    new 
amxmodxWeaponId get_user_weapon(player);
    const 
m_pActiveItem 373;
    new 
cstrikeWeaponId cs_get_weapon_id(get_pdata_cbase(playerm_pActiveItem));
    
    if (
amxmodxWeaponId != cstrikeWeaponId) {
        new 
weaponName[32];
        
get_weaponname(amxmodxWeaponIdweaponNamecharsmax(weaponName));
        new 
actualWeaponName[32];
        
get_weaponname(cstrikeWeaponIdactualWeaponNamecharsmax(actualWeaponName));
        
client_print(playerprint_chat"get_user_weapon = %s, but actual weapon is %s"weaponNameactualWeaponName);
    }

Quote:
Originally Posted by HamletEagle View Post
Good luck explaining to a beginner when to and when to not. It's better to add a check than mess things up.
These checks can hide an actual problem and create another problems. AmxModX and Engine API should be better to avoid some of these problems.
Quote:
Originally Posted by HamletEagle View Post
Also you did not take into account other plugins that may be doing weird things.
This is problem of these weird plugins. Don't make workarounds for plugins with weird behaviour.
__________________

Last edited by PRoSToTeM@; 04-26-2017 at 15:10.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 04-27-2017 , 13:31   Re: Non-player entity 0 out of range
Reply With Quote #17

So, you can just change:
PHP Code:
get_user_weapon(id) != CSW_AT4CS 
To:
PHP Code:
cs_get_user_weapon(id) != CSW_AT4CS 
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 04-27-2017 , 14:17   Re: Non-player entity 0 out of range
Reply With Quote #18

Hello one more time.
I dont get this error anymore,but it often happens when I reload bazooka,I dont get bullet and can not shot.
Then I have to reload few more time or to drop bazooka on ground and pickup.

Which inc I need for cs_get_user_weapon ?

Last edited by Krtola; 04-27-2017 at 14:22.
Krtola is offline
Send a message via Skype™ to Krtola
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 04-27-2017 , 14:34   Re: Non-player entity 0 out of range
Reply With Quote #19

cstrike, but this is for amxx 1.8.3.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
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 23:37.


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