Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weapon State Inaccuracy #43

Open
kylesmith0 opened this issue Jan 19, 2021 · 1 comment
Open

Weapon State Inaccuracy #43

kylesmith0 opened this issue Jan 19, 2021 · 1 comment

Comments

@kylesmith0
Copy link

kylesmith0 commented Jan 19, 2021

Hi there,

I'm using AIM_SYNC and detecting the weapon state to set an ammo variable to 0 when they no longer have any bullets, ie - when weapon state is WEAPONSTATE_NO_BULLETS.

For some reason it is reporting no bullets when it shouldn't.

Yes I use 'GetPlayerSyncWeapon' which is from YSF to get the current weapon. The reason I use that is because there is no weaponid for the PR_AimSync callback. Could it be GetPlayerSyncWeapon is picking up the new weapon instead of the old weapon that ran out of bullets?

I use this function:

new sync = GetPlayerSyncWeapon(playerid); if(aimData[PR_weaponState] == WEAPONSTATE_NO_BULLETS && sync != 0 && sync != 255) { new slot = GetWeaponSlot(sync); if(slot != 0 && slot != 1 && slot != 10 && slot != 11 && slot != 255) { WeaponInformation[playerid][slot][WeaponAmmo] = 0; if(UserInfo[playerid][DebugWeapon] == 10) { SendFormatMessage(playerid,COLOR_RED,"WEAPONSTATE_NO_BULLETS - ws hide - %d ", sync); } SetPlayerAmmo(playerid, GetPlayerSyncWeapon(playerid), 0); PlayerAmmo[playerid][slot] = 0; } }

@NexiusTailer
Copy link
Contributor

NexiusTailer commented Feb 8, 2021

It is known that recently added GetPlayerSyncWeapon from YSF sometimes return weird invalid values as weaponid (like 192, 64, 255 and so on which is greater than 46). You can store weaponid from OnFoot/Driver/Passenger/Spectating sync manually in some your array and test the whole code again without GetPlayerSyncWeapon being used anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants