09.10.2015, 15:49
I'm working on a sort of weapon anti-cheat (weapons and ammo are stored server-side).
When players connect to the server, their saved weapons are loaded and given to them. The weapon and ammo in each slot is stored in an array. Most of the time this works fine. Some times however, their weapons are given etc., but GetPlayerWeaponData is reporting they have 0 ammo. This is incorrect, as you can see in the image below.
The text in chat shows what GetPlayerWeaponData reports. Slot 5 is reporting that I have an M4 (correct) with 0 ammo (not correct). You can clearly see I have 100 ammo in the HUD in the top-right corner.
So as you can see, GetPlayerWeaponData is reporting 0 ammo, when players actually have ammo. What could possibly cause this?
If I shoot a single bullet off, my ammo is then corrected and GetPlayerWeaponData reports 99.
One solution I am going to try is using SetPlayerAmmo after giving them their weapons. I assume that will update it and fix the problem. Would like to hear any other suggestions though. Or perhaps a way to properly fix it and not make a workaround? Perhaps this is just another unfixable bug.
When players connect to the server, their saved weapons are loaded and given to them. The weapon and ammo in each slot is stored in an array. Most of the time this works fine. Some times however, their weapons are given etc., but GetPlayerWeaponData is reporting they have 0 ammo. This is incorrect, as you can see in the image below.
The text in chat shows what GetPlayerWeaponData reports. Slot 5 is reporting that I have an M4 (correct) with 0 ammo (not correct). You can clearly see I have 100 ammo in the HUD in the top-right corner.
So as you can see, GetPlayerWeaponData is reporting 0 ammo, when players actually have ammo. What could possibly cause this?
If I shoot a single bullet off, my ammo is then corrected and GetPlayerWeaponData reports 99.
One solution I am going to try is using SetPlayerAmmo after giving them their weapons. I assume that will update it and fix the problem. Would like to hear any other suggestions though. Or perhaps a way to properly fix it and not make a workaround? Perhaps this is just another unfixable bug.