help with anti cheat -
GeorgeMcReary - 29.05.2018
Hello i was making anti cheat for my script. Weapon Detection works completely. Only Ammo Detection is not working. Here is my code for ammo detection:
PHP код:
new weaponslot = GetWeaponSlotID(GetPlayerWeapon(playerid));
new ammo = GetPlayerAmmo(playerid);
printf("Gun :%d (%d)",GetPlayerWeapon(playerid),ammo); //For debugging
if(PlayerInfo[playerid][pAmmo][weaponslot] < ammo)
print("Ammo Hacked");
}
printf will give output like this:
[code]
Gun :31(50)
Gun :31(1500) [code]
That happens after I gave myself a M4 using admin command, which is clean. I gave myself 50 ammo and use some of it to test if it doesnt detect it false. It does not. Then I go and hack the same weapon, and hack gives me 1500 ammo.
On further debugging, I found out that, upon hacking the same weapon, For eg I had a server sided M4 with 50 ammo. I than hack same gun using my hack but hack will spawn a M4 with 1500 Ammo. Now Server sets, pAmmo variable for player when they get a server sided weapon. As seen in my code above, I have checked if the current ammo in hand matches with Player's stored variable or not and actually on using printf, I can see the variable was also changed. value of PlayerInfo[playerid][pAmmo][weaponslot] was equal to 1500 and that is why it was not able to tell that it was a hack. Sure I can put if value is above 200 than he hacked it but what about hacked ammo less than that amount. Hacking of ammo even 1, should be able to catch.
Please tell me whats wrong here. Thanks.
Re: help with anti cheat -
GeorgeMcReary - 30.05.2018
Someone Help?
Re: help with anti cheat -
Sew_Sumi - 30.05.2018
What is this on? a timer or a callback?
RogueDrifter would be someone who'd know about this sort of thing. Wait for him to see this thread.
Re: help with anti cheat -
GeorgeMcReary - 30.05.2018
This is under a function named, CheckAmmoHacks() which is called upon OnPlayerUpdate(). Interestingly, My pAmmo variable sets its value to hacked ammo idk why.
Re: help with anti cheat -
GeorgeMcReary - 31.05.2018
Bump..
Re: help with anti cheat -
Sew_Sumi - 31.05.2018
24 hour bumps as per forum rules man...
Re: help with anti cheat -
CodeStyle175 - 31.05.2018
what are you even doing, you have to explain this to yourself and think what this code does and how anticheat would work.
Re: help with anti cheat -
Sew_Sumi - 31.05.2018
It's actually rather straight forward what he's doing, it's just I don't do anti-cheat, so I'd not be confident in looking towards it and being sure that Ammo is actually track-able as last I knew it was dodgy.
Re: help with anti cheat -
DeathCore - 31.05.2018
Hope this thread will help you somehow.
https://sampforum.blast.hk/showthread.php?tid=642017&page=4
Re: help with anti cheat -
RogueDrifter - 31.05.2018
It really isn't that easy, although, take a look at this:
https://github.com/RogueDrifter/Anti...aster/rAgc.inc
This anti cheat takes care of the means that give you ammo in every possible way,
Basically you need to hook giveplayerweapon and setplayerammo and resetplayerammo to avoid having false positives, that's when you get a weapon with ammo on all cases you just reset that variable.
Furthermore, due to lag and delays you can get caught in a false detection so i suggest preventing detection with a variable whenever the 3^ functions above i listed are used, those methods are used in the link i gave above.
About ur function, you need to tell me where is this code used, your method for debugging is SO not decent, make it debug when its original ammo is < ammo and print both old ammo and new ammo!