Anti ammo hack
#21

Is not possible to increase ammo with my include.
Look at video:
https://www.youtube.com/watch?v=vGGTEn1EQOQ
Reply
#22

If you look at the video, you will see that you had 5 ammo before you spawn the cheated ammo, and after you shoot 5 ammo while you have the cheated ammo it removed the weapon.
Which basically means, if the player has 200 ammo and spawned more 200 (total 400 ammo), he still can shoot the first 200 ammo.

Also, your include had some crash reports in my console which I didn't bother fixing.
Reply
#23

Anyone?
Reply
#24

Why don't you debug?

may you try these codes and post the result?

PHP код:
GivePlayerWeaponEx(playeridweaponidammo) {
    new 
slot GetWeaponSlot(weaponid);
    
//SetPlayerArmedWeapon(playerid, weaponid); <- not necessary!
    
if(GetWeaponSlot(weaponid) == slot) { // o.o this should be weaponid D:
        
gPlayerWeapon[playerid][slot] = true;
        
gPlayerAmmo[playerid][slot] += ammo;
        
printf("Player already has the weapon and now has the ammmo -> %d",PlayerAmmo[playerid][slot]);
    }
    else {
        
gPlayerWeapon[playerid][slot] = true;
        
gPlayerAmmo[playerid][slot] = ammo;
        
printf("Player didn't have the weapon and now has the ammmo -> %d",PlayerAmmo[playerid][slot]);
    }
    return 
GivePlayerWeapon(playeridweaponidammo);

PHP код:
        new slot GetWeaponSlot(weaponid);
        
gPlayerAmmo[playerid][slot]--;
        new 
playerammo GetPlayerAmmo(playerid);
        
printf("player started shooting by the weapon %d and now has %d shots left | %d | "weaponidplayerammogPlayerAmmo[playerid][slot]);
        
        if(
playerammo && playerammo gPlayerAmmo[playerid][slot] + 15) {
            
printf("was true and kicked that mofo");
            
RemovePlayerWeapon(playeridweaponid);
            
format(stringsizeof string"{FF0000}<!> {CC6699}%s has been kicked for ammo hack"GetName(playerid));
            
SendClientMessageToAll(redstring);
            return 
DelayKick(playerid);
        }
        else 
gPlayerAmmo[playerid][slot] = playerammo
Reply
#25

OnPlayerWeaponShot is very accurate with weapons, my anti-cheat has had it since it ever got implemented, i can detect the slightest ammo cheat, just know how to prevent the wrong ammo checks on spraying with automatic guns and so.
Reply
#26

How will you handle the 'ammo' of the throwable weapons? I mean molotov, grenade, teargas
Reply
#27

I don't, my reply clearly state 'guns, weapons', those throwable stuff are auto banned on my server. The normal weapon cheating tracking sometimes takes care of some other calculations to make sure the weapon is valid anyway
Reply
#28

OnPlayerKeyStateChange for throwables.
100-200ms timer to check the ammo could do too. If synced > actual, force new ammo again with the server values, 2-3x => cheats.
Reply
#29

Код:
	new weaponid = GetPlayerFirearm(playerid);
	if(weaponid != WEAPON_TYPE_UNKNOWN) switch(GetWeaponType(weaponid))
	{
		case WEAPON_TYPE_THROWN:
		{
		    if(HOLDING(KEY_FIRE))
		    {
		    	if(wh_LastThrowTick[playerid] < GetTickCount())
		    	{
			    	if(GetPlayerFirearmAmmo(playerid) > 0)
			    	{
			    		PlayerWeapon[playerid][WeaponAmmo]--;
			    		wh_LastThrowTick[playerid] = GetTickCount() + 1000;
			    	}
		    	}
		    }
		}
	}
Reply
#30

I already debugged it, the gPlayerAmmo sometimes is less than the real ammo for like 100 .. I assume the issue is not from the GivePlayerWeaponEx function, it's something to do in OnPlayerWeaponShot. Because I also debugged the GivePlayerWeaponEx function and it seems to work how it's supposed to be.
Reply
#31

Here I'll share my Anti Ammo Hack in my Survival gamemode using OPWS. erm not perfect but it detects Unlimited Ammo and Ammo Hacking.
I haven't tried on desync players. if player is desync even though not hacking they will be detect as hacking. So good luck on improving.

every player shoots an ammo from their weapon OPWS will be called. So Basically I add subtraction code of especific ammo with ttheir weapons and check if the client side ammo is greater ethan the server side ammo 2x or 3x it means the player is cheating.

*note: the reason why I add +10 isi because the ammo of the client lose an ammo before it calls the opws.
(honestly I'm not sure aobut what I'm talking about lol but based on my experrience I try my best to explain )
Code:
switch(weaponid)
	{
		case 25..34:
		{
			PlayerData[playerid][pPrimaryAmmo]--;
			//format(szString, sizeof(szString), "Weapon: %s Ammo: %d", GetWeaponNameEx(PlayerData[playerid][pPrimaryGun]), PlayerData[playerid][pPrimaryAmmo]);
			//SendClientMessageEx(playerid, COLOR_WHITE, szString);
			if(GetPlayerAmmo(playerid) > PlayerData[playerid][pPrimaryAmmo]+10) // Add +10 or +5 it depends on how your server syncing performed.
			{
				SetPVarInt(playerid, "AmmoHacking", GetPVarInt(playerid, "AmmoHacking")+1);
				if(GetPVarInt(playerid, "AmmoHacking") > 2)
				{
					ServerSecurityMessage(GetPlayerNameEx(playerid), "Kick", "Ammo Hacking");
					KickEx(playerid);
					return 1;
				}
			}

			if(PlayerData[playerid][pPrimaryAmmo] <= 0) 
			{
				//SendClientMessage(playerid, COLOR_WHITE, "Out of Ammo");
				PlayerData[playerid][pPrimaryGun] = 0;
				//RemovePlayerAttachedObject(playerid, ATTACH_PRIMARYWEAPON);
			}

		}
		case 22..24:
		{
			PlayerData[playerid][pSecondaryAmmo]--;
			//format(szString, sizeof(szString), "Weapon: %s Ammo: %d", GetWeaponNameEx(PlayerData[playerid][pSecondaryGun]), PlayerData[playerid][pSecondaryAmmo]);
			//SendClientMessageEx(playerid, COLOR_WHITE, szString);
			if(GetPlayerAmmo(playerid) > PlayerData[playerid][pSecondaryAmmo]+10)
			{
				SetPVarInt(playerid, "AmmoHacking", GetPVarInt(playerid, "AmmoHacking")+1);
				if(GetPVarInt(playerid, "AmmoHacking") > 2)
				{
					ServerSecurityMessage(GetPlayerNameEx(playerid), "Kick", "Ammo Hacking");
					KickEx(playerid);
					return 1;
				}
			}
			if(PlayerData[playerid][pSecondaryAmmo] <= 0) 
			{
				//SendClientMessage(playerid, COLOR_WHITE, "Out of Ammo");
				PlayerData[playerid][pSecondaryGun] = 0;
				//RemovePlayerAttachedObject(playerid, ATTACH_SECONDARYWEAPON);
			}
		}
	}
Reply
#32

It's the same what I am doing currently.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)