SA-MP Forums Archive
little problem with my weapon anticheat - 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: little problem with my weapon anticheat (/showthread.php?tid=461617)



little problem with my weapon anticheat - caoraivoso3 - 02.09.2013

well i made a anticheat and i want that when the player lost his weapon by lost all the ammo he gets the variable off but that isnt hapening. every weapon i create is getting the variable and the script see the weapon as cheated.

the code:
if( GetPlayerWeaponState( playerid ) == WEAPONSTATE_NO_BULLETS )
{
new weap = GetPlayerWeapon(playerid);
Weapon[playerid][weap] = false;
return 1;
}

i put that in onplayerupdate.
sorry for my bad english


Re: little problem with my weapon anticheat - Konstantinos - 02.09.2013

You can use GetPlayerAmmo, it returns the ammo on their current weapon, but read the WIKI for an important note.
If it returns 0, then set the variable about the current weapon to false. Something like this:
pawn Код:
new
    weap = GetPlayerWeapon( playerid )
    ammo = GetPlayerAmmo( playerid )
;
if( ammo == 0 ) Weapon[ playerid ][ weap ] = false;
Even though, I'd suggest you not to use GetPlayerWeapon, but your own function that it registers the weapons to the server (server-side weapons). If the weapon is not registered, then return -1 and make it as weapon cheats detection.


Re: little problem with my weapon anticheat - caoraivoso3 - 02.09.2013

i made a good weapon system you need to get weapons by the server side functions and if you get in another way you get banned. i just found this "bug" i am trying to fix it. thanks for the idea i gonna do it right now.