Anti ammo hack -
oMa37 - 23.09.2017
Howdy,
I have made an anti spawn ammo hack in my server, which basically kicks the player who spawn AMMO not weapon.
Like you already have the weapon but you spawn ammo for it.
So yeah, It's not working fine in the host at all, I'm using OnPlayerWeaponShot and it keeps kicking the players whenever they shot.
Here's my custom GivePlayerWeapon function:
PHP код:
new gPlayerAmmo[MAX_PLAYERS][12];
GivePlayerWeaponEx(playerid, weaponid, ammo) {
if(!weaponid) return 0;
gPlayerAmmo[playerid][GetWeaponSlot(weaponid)] = ammo;
return GivePlayerWeapon(playerid, weaponid, ammo);
}
Here's my OnPlayerWeaponShot:
PHP код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(weaponid != 0 && weaponid != 46)
{
if(GetPlayerAmmo(playerid) < gPlayerAmmo[playerid][GetWeaponSlot(weaponid)]) {
gPlayerAmmo[playerid][GetWeaponSlot(weaponid)] = GetPlayerAmmo(playerid);
}
if(!InEvent[playerid] && !InDerby[playerid] && !InTDM[playerid] && !InParkour[playerid] && !InSkydive[playerid] && !InDuel[playerid] && !Info[playerid][InDM] && !InShooter[playerid]) {
if(GetPlayerAmmo(playerid) > 1 && GetPlayerAmmo(playerid) > gPlayerAmmo[playerid][GetWeaponSlot(weaponid)] && GetPlayerVirtualWorld(playerid) == 0) {
RemovePlayerWeapon(playerid, weaponid);
gPlayerWeapon[playerid][GetWeaponSlot(weaponid)] = false;
gPlayerAmmo[playerid][GetWeaponSlot(weaponid)] = 0;
format(string, sizeof string, "{FF0000}<!> {CC6699}%s has been kicked for ammo hack", GetName(playerid));
SendClientMessageToAll(red, string);
return DelayKick(playerid);
}
}
}
return 1;
}
Any help would be appreciated.
Thanks in advance.
Re: Anti ammo hack -
Logic_ - 23.09.2017
OPWS is inaccurate.
Re: Anti ammo hack -
oMa37 - 23.09.2017
I already know that .. I'm not decreasing/increasing anything with the weapon's ammo.
You ain't helping me actually.
Re: Anti ammo hack -
GoldenLion - 23.09.2017
I believe it's something to do with GetPlayerAmmo as it returns the old ammo so you need to subtract 1 from GetPlayerAmmo to get the new ammo. Also you should create a variable for the ammo and weapon slot instead of repeating the functions and these weaponid checks are not necessary because OnPlayerWeaponShot is only called when you shoot a gun, but I suggest you to check if the weaponid is not the minigun because it's fire rate is so fast that it will kick you whenever you shoot it and I also suggest you to create a variable for warnings. Everytime player shoots and has cheated ammo add 1 to the warnings variable and when it reaches 3 kick the player for example, but when player hasn't cheated ammo then subtract 1 from the warnings variable if there's something to subtract. That's what I do because this will prevent false kicks most of the time.
Re: Anti ammo hack -
NaS - 24.09.2017
You should use GetPlayerWeaponData for this, it is more accurate than GetPlayerAmmo. That way you can check the ammo for a specific weapon, instead of getting the ammo for the current weapon (which could change even though OPWS is still calling for another weapon).
Also I would not do this in OnPlayerWeaponShot, weapon data is not synced with every shot. There is no need to check this as often as any gun actually shoots (best example would be minigun, or UZI).
Re: Anti ammo hack -
oMa37 - 24.09.2017
What about this way? using OnPlayerUpdate:
PHP код:
public OnPlayerUpdate(playerid) {
new player_weapon = GetPlayerWeapon(playerid);
if(player_weapon)
DetectAmmoCheats(playerid, player_weapon);
return 1;
}
DetectAmmoCheats(playerid, weaponid) {
new weapon_id, weapon_ammo;
GetPlayerWeaponData(playerid, GetWeaponSlot(weaponid), weapon_id, weapon_ammo);
if(Info[playerid][Logged] && !InEvent[playerid] && !InDerby[playerid] && !InTDM[playerid] && !InParkour[playerid] && !InSkydive[playerid] && !InDuel[playerid] && !Info[playerid][InDM] && !InShooter[playerid]) {
if(weapon_ammo > 0 && weapon_ammo > gPlayerAmmo[playerid][GetWeaponSlot(weaponid)] + 10 && GetPlayerVirtualWorld(playerid) == 0) {
RemovePlayerWeapon(playerid, weaponid);
Info[playerid][Logged] = 0;
format(string, sizeof string, "{FF0000}<!> {CC6699}%s has been kicked for ammo hack", GetName(playerid));
SendClientMessageToAll(red, string);
return DelayKick(playerid);
}
else gPlayerAmmo[playerid][GetWeaponSlot(weaponid)] = weapon_ammo;
}
return 1;
}
I've tested it in localhost and as far as I can see it works flawless, debugged it and the values seems accurate.
Will it work the same in the VPS? with +20 players?
Re: Anti ammo hack -
Kane - 24.09.2017
My opinion, don't kick people. Send out admin warnings. It's better for a player to be banned by an administrator then a faulty anti cheat system. If you think your system doesn't perform well then that's a cause to not ban anyone based on the results provided.
https://sampforum.blast.hk/showthread.php?tid=30938&page=442
I asked about a similar system. This isn't fully tested but what seems like a plausible way of doing an anti ammo hack is:
PHP код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(PlayerHasWeapon(playerid, weaponid))
UpdatePlayerWeapon(playerid, weaponid);
return 1;
}
It would check if the player has the weapon scriptwise. There's room for an anti-weapon cheat in there as well.
When UpdatePlayerWeapons is called just --gPlayerAmmo.
Then if GetPlayerAmmo != gPlayerAmmo, possible cheat detected? This requires you update the variable on every instance of an ammo change (if the player gains more, et cetera...). I guess this is basically what you're doing. I don't see why it wouldn't work.
Re: Anti ammo hack -
oMa37 - 24.09.2017
I think checking if the current ammo > gPlayerAmmo is more accurate than checking if the current ammo != gPlayerAmmo, isn't it?
Also, kicking the player would be better, in case there are no admins online or they're AFK.
I'm going to test the last code I posted in the VPS and share here if it worked or not, if there is anything you guys would recommend me to do to improve the code, tell me please.
Re: Anti ammo hack -
Paulice - 24.09.2017
OPU is even worse. Create your own shoot detection system.
Re: Anti ammo hack -
AbyssMorgan - 27.09.2017
Try with this (server side: weapons, health, armour, damage):
ADM_Guard.inc
Re: Anti ammo hack -
oMa37 - 27.09.2017
I don't see where in your include prevent ammo hack, could you explain to me how this works exactly?
Re: Anti ammo hack -
AbyssMorgan - 27.09.2017
If weaponid in slot is different than server side weapon -> kick
If server side ammo is 0 -> remove weapon (when player increase ammo for current weapon, not working)
e.g.
player weapon in slot 5 is:
0 - server side
31 - player game (added M4 by Weapon Hack)
0 != 31 -> kick
Re: Anti ammo hack -
oMa37 - 27.09.2017
Quote:
Originally Posted by AbyssMorgan
when player increase ammo for current weapon, not working
|
Well, I'm searching for a way to prevent this hack, increasing ammo for the current weapon.
Re: Anti ammo hack -
AbyssMorgan - 27.09.2017
Quote:
Originally Posted by oMa37
Well, I'm searching for a way to prevent this hack, increasing ammo for the current weapon.
|
ammo:
15 - server side
350 - game
when server side ammo is 0 -> remove weapon -> set server side ammo 0, weaponid 0
next shot -> kick
Re: Anti ammo hack -
AbyssMorgan - 27.09.2017
Anti Weapon Hack:
https://www.youtube.com/watch?v=vGGTEn1EQOQ
Re: Anti ammo hack -
oMa37 - 27.09.2017
I have improved it a little bit and removed some stuff that I already have in my gamemode, I will test it and share what happens here.
Thank you.
Re: Anti ammo hack -
jlalt - 27.09.2017
Hello sir Oma37.
at the first do you assign weapons to players using the AddPlayerClass last 6 parameters?
if yes then you need to hook this function to give this weapons to the player in his gPlayerAmmo var too.
also the next mistake is gPlayerAmmo[playerid][GetWeaponSlot(weaponid)] = ammo;
when you give a weapon to player in samp if he already has it the ammo will increase, so you have to "increase" the ammo rather than setting its value.
gPlayerAmmo[playerid][GetWeaponSlot(weaponid)] += ammo;
Re: Anti ammo hack -
oMa37 - 27.09.2017
Quote:
Originally Posted by jlalt
also the next mistake is gPlayerAmmo[playerid][GetWeaponSlot(weaponid)] = ammo;
when you give a weapon to player in samp if he already has it the ammo will increase, so you have to "increase" the ammo rather than setting its value.
gPlayerAmmo[playerid][GetWeaponSlot(weaponid)] += ammo;
|
Ahh .. Yeah .. I didn't think about that lol.
Thank you for pointing that out for me, I will try the both methods. Yours and AbyssMorgan's method.
Re: Anti ammo hack -
GaByM - 27.09.2017
Quote:
Originally Posted by Logic_
OPWS is inaccurate.
|
What do you mean? Why is inaccurate?
Re: Anti ammo hack -
oMa37 - 01.10.2017
I still can't find out an effective way to get this done, I tried OnPlayerWeaponShot, OnPlayerUpdate, repeating timer, Abyss's include. I really can't find out anything working effectively, hackers are still able to increase the weapon's ammo.
This is my new code under OnPlayerWeaponShot:
PHP код:
new slot = GetWeaponSlot(weaponid);
gPlayerAmmo[playerid][slot]--;
if(GetPlayerAmmo(playerid) > 0 && GetPlayerAmmo(playerid) > gPlayerAmmo[playerid][slot] + 15) {
RemovePlayerWeapon(playerid, weaponid);
format(string, sizeof string, "{FF0000}<!> {CC6699}%s has been kicked for ammo hack", GetName(playerid));
SendClientMessageToAll(red, string);
return DelayKick(playerid);
}
else gPlayerAmmo[playerid][slot] = GetPlayerAmmo(playerid);
My custom GivePlayerWeapon function:
PHP код:
GivePlayerWeaponEx(playerid, weaponid, ammo) {
new slot = GetWeaponSlot(weaponid);
SetPlayerArmedWeapon(playerid, weaponid);
if(GetWeaponSlot(GetPlayerWeapon(playerid)) == slot) {
gPlayerWeapon[playerid][slot] = true;
gPlayerAmmo[playerid][slot] += ammo;
}
else {
gPlayerWeapon[playerid][slot] = true;
gPlayerAmmo[playerid][slot] = ammo;
}
return GivePlayerWeapon(playerid, weaponid, ammo);
}
These codes sometimes works sometimes not, mostly not.
Any idea how to make it effective enough to prevent ammo hack and false kicks?