OnPlayerWeaponShot - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerWeaponShot (
/showthread.php?tid=619168)
OnPlayerWeaponShot -
NeXoR - 14.10.2016
Hey, my Anti Cheat is kicking innocent players and now I think I understood why
That's the code
PHP Code:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
new string[24];
format(string, sizeof(string), "debug: %d, %d", GetPlayerAmmo(playerid), PlayerInfo[playerid][pWeaponAmmo][GetWeaponSlot(weaponid)]);
print(string);
PlayerInfo[playerid][pWeaponAmmo][GetWeaponSlot(weaponid)]--;
format(string, sizeof(string), "debug: %d, %d", GetPlayerAmmo(playerid), PlayerInfo[playerid][pWeaponAmmo][GetWeaponSlot(weaponid)]);
print(string);
return 1;
}
That's the anti hack code
PHP Code:
forward WeaponHack();
public WeaponHack()
{
new weaponid, ammo, keys, ud, lr;
foreach(new playerid : Player)
{
weaponid = GetPlayerWeapon(playerid); ammo = GetPlayerAmmo(playerid);
if(weaponid != PlayerInfo[playerid][pWeapon][GetWeaponSlot(weaponid)] || ammo != PlayerInfo[playerid][pWeaponAmmo][GetWeaponSlot(weaponid)]) Kick(playerid);
}
return 1;
}
Now, I think I got the problem
I debugged it, and I found out that first - It's decreased from the Array
PHP Code:
PlayerInfo[playerid][pWeaponAmmo][GetWeaponSlot(weaponid)]--;
And only after that, its decreased from my GetPlayerAmmo()
Here is the debug
(First line: debug: GetPlayerAmmo() || WeaponAmmo Array)
(Second line (After Array--

: debug: GetPlayerAmmo() || WeaponAmmo Array)
Code:
debug: 300, 300
debug: 300, 299