[CitizenFX/.NET] HasWeapon(WeaponHash) always returns false on first call

So the way I’m testing this currently, is printing the weapons I have and the ammo they have in an event handler for onPlayerDied.

First call to LocalPlayer.Character.Weapons.HasWeapon(weapHash) returns false on each event trigger

First call to Weapon.Ammo returns 0 after resource init. All calls after the initial (even in separate events) seem to return correctly.

First Death

Second Death

The expected results should be (True) for each weapon and the ammo counts should be identical in the first death to the counts in the second.

1 Like

:confused: well now its not always false, but it is false half the time even if im holding the weapon.

Well im getting inconsistent results so I’ll need to do more testing before making a more detailed report.

updated main post with more info

Maybe try using them on key press or in another event handler just to test it.
The only thing I can think of is that it’s possible the ped is still dead during the first call and would cause it to return false.
I could be way off but I can’t think of another reason why it would do that, and be inconsistent.

Get rid of Enhanced Reborn since that also has replace weapons on respawn functions.

@Cosmo

Maybe try using them on key press or in another event handler just to test it.
The only thing I can think of is that it’s possible the ped is still dead during the first call and would cause it to return false.
I could be way off but I can’t think of another reason why it would do that, and be inconsistent.

This is not the case. The ped IS dead when this is being called and is how I intend it

@Boss

Get rid of Enhanced Reborn since that also has replace weapons on respawn functions.

Did this, but the issue persists. I’m not doing this on respawn though. I’m printing the weapons I have when I die so that later I can store them for respawn.

1 Like

See class Bug_AmmoHasWeapFalse

i have the same bug but for spawning weapon , half of time weapon isn’t created, and half of time it’s in inventory , i don’t understand these results i have.