SA-MP Forums Archive
Anti Weapon cheat - 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: Anti Weapon cheat (/showthread.php?tid=610005)



Anti Weapon cheat - TwinkiDaBoss - 18.06.2016

Alright so Im facing a problem with this.

Basically it will detect if the weapon is given by the server or spawned in by player but seems that Im doing something wrong

PHP код:
enum P_WEAPONS {
    
P_WeaponID,
    
P_Ammo
};
new 
PlayerWeapon[MAX_PLAYERS][13][P_WEAPONS]; 
13 represents the slots


PHP код:
stock GivePlayerWeaponEx(playeridweaponidammo) {
    new 
slot GetWeaponSlot(weaponid);
    
PlayerWeapon[playerid][slot][P_WeaponID] = weaponid;
    
PlayerWeapon[playerid][slot][P_Ammo] = ammo;
    
GivePlayerWeapon(playeridweaponidammo);
}
stock GetWeaponSlot(weaponid)
{
    new 
slot;
    switch(
weaponid){
        case 
01slot 0// No weapon
        
case .. 9slot 1// Melee
        
case 22 .. 24slot 2// Handguns
        
case 25 .. 27slot 3// Shotguns
        
case 282932slot 4// Sub-Machineguns
        
case 3031slot 5// Machineguns
        
case 3334slot 6// Rifles
        
case 35 .. 38slot 7// Heavy Weapons
        
case 161839slot 8// Projectiles
        
case 4243slot 9// Special 1
        
case 14slot 10// Gifts
        
case 44 .. 46slot 11// Special 2
        
case 40slot 12// Detonators
        
default: slot = -1// No slot
    
}
    return 
slot;

Now with a simple command, it wont work.
PHP код:
YCMD:check(playerid,params[],help) {
    new 
weapons[13][2];
    for (new 
0<= 12i++) {
        
GetPlayerWeaponData(playeridiweapons[i][0], weapons[i][1]);
        if(
weapons[i][0] != PlayerWeapon[playerid][i][P_WeaponID] || weapons[i][1] != PlayerWeapon[playerid][i][P_Ammo]) {
            
SCM(playerid,COLOR_RED,"Suspicious weapon: %i %i",weapons[i][0], weapons[i][1]);
        }
    }
    return 
true;

It will detect every weapon as suspicious no matter if it was server or player spawned



EDIT: for some reason it will give 2 weapons inside of 1 on spawn.
PHP код:
[22:13:55Weapon ID24 || Ammo10 || Slot2
[22:13:55Weapon ID24 || Ammo10 || Slot
and /check results are
PHP код:
[22:14:04Weapon ID|| Ammo154 || Slot0
[22:14:04Weapon ID24 || Ammo20 || Slot



Re: Anti Weapon cheat - Vince - 18.06.2016

Careful here:
PHP код:
PlayerWeapon[playerid][slot][P_Ammo] = ammo
The normal GivePlayerWeapon adds ammo, it doesn't set it. So that should be +=. I'm a bit confused by the unnecessary use of the array in the check command, but as far as I can tell it should work. As long as you don't fire the gun, at least. I don't think a hacker would purposely lower his ammunition so that is another case to look out for.


Re: Anti Weapon cheat - TwinkiDaBoss - 18.06.2016

Quote:
Originally Posted by Vince
Посмотреть сообщение
Careful here:
PHP код:
PlayerWeapon[playerid][slot][P_Ammo] = ammo
The normal GivePlayerWeapon adds ammo, it doesn't set it. So that should be +=. I'm a bit confused by the unnecessary use of the array in the check command, but as far as I can tell it should work. As long as you don't fire the gun, at least. I don't think a hacker would purposely lower his ammunition so that is another case to look out for.
That actually makes sense! Thanks a lot buddy.