[Tutorial] How to make a simple anti weapon hack
#1

How to make a simple anti weapon detector
Hello everyone, i will teach you in this tutorial how to make a simple anti weapon hack. You don't need any timers or anything, in this tutorial i will only use
pawn Code:
public OnPlayerUpdate(playerid)
and 3 defined items
pawn Code:
new weaponid = GetPlayerWeapon(playerid);
                        new Nam[MAX_PLAYER_NAME];
                        new str[128];
Ok everyone under OnPlayerUpdate if you want to add a bad list weapon just add this
pawn Code:
public OnPlayerUpdate(playerid)
{
            new weaponid = GetPlayerWeapon(playerid);//This will cause the "weaponid not defined" Error
                new Nam[MAX_PLAYER_NAME];
                new str[128];
            if(weaponid == 16) // The weapon ID
            {
            GetPlayerName(playerid,Nam,sizeof(Nam));
            format(str,sizeof(str),"ANTI WEAPON HACK: %s has been banned from server for spawning a bad weapon!",Nam);
            SendClientMessageToAll(0xFF0000FF,str);
            BanEx(playerid,"ANTI WEAPON HACK: Weapon Hack!");
            }
                        return 1;
}
This code above will ban people that spawns a gernade and i will tell why. On the line
pawn Code:
if(weaponid == 16) // The weapon ID
The number i add "16" is the weapon id of Gernade, check http://weedarr.wikidot.com/gunlist.
So if you wondering how to add another weapon just do this

pawn Code:
public OnPlayerUpdate(playerid)
{
            new weaponid = GetPlayerWeapon(playerid);//This will cause the "weaponid not defined" Error
                new Nam[MAX_PLAYER_NAME];
                new str[128];
            if(weaponid == 16) // The weapon ID
            {
            GetPlayerName(playerid,Nam,sizeof(Nam));
            format(str,sizeof(str),"ANTI WEAPON HACK: %s has been banned from server for spawning a bad weapon!",Nam);
            SendClientMessageToAll(0xFF0000FF,str);// Sends message to everyone
            BanEx(playerid,"ANTI WEAPON HACK: Weapon Hack!");
            }
//make another line
            if(weaponid == WEAPONID) // The weapon ID
            {
            GetPlayerName(playerid,Nam,sizeof(Nam));
            format(str,sizeof(str),"ANTI WEAPON HACK: %s has been banned from server for spawning a bad weapon!",Nam);
            SendClientMessageToAll(0xFF0000FF,str);// Sends message to everyone
            BanEx(playerid,"ANTI WEAPON HACK: Weapon Hack!");
            }
                        return 1;
}
on
pawn Code:
if(weaponid == WEAPONID) // The weapon ID
just replace the "WEAPON ID" to the weapon id you want to keep that is bad. The links are below for weapon list if you need help

Weapon ID'S: http://weedarr.wikidot.com/gunlist

Thank you for reading, if you have any other question just ask below.
Reply
#2

Nice job Tan
Reply
#3

Ty pj ford
Reply
#4

o.o
I dont get it... You just add from the one cod e to the other 10 fucking new things
Reply
#5

Very good tutorial
Reply
#6

Quote:
Originally Posted by Bosnian
View Post
o.o
I dont get it... You just add from the one cod e to the other 10 fucking new things
Lol what do you exactly mean?


Quote:
Originally Posted by ZzzzZ
View Post
Very good tutorial
Thank you
Reply
#7

There is an easier way of checking for different weapons instead of copy pasting it like 5 times
Ex:
pawn Code:
public OnPlayerUpdate(playerid)
{
            new weaponid = GetPlayerWeapon(playerid);//This will cause the "weaponid not defined" Error
                new Nam[MAX_PLAYER_NAME];
                new str[128];
            if( weaponid == 16 || weaponid == WEAPONID || weaponid == WEAPONID2 /* etc etc */)  // The weapon ID
            {
            GetPlayerName(playerid,Nam,sizeof(Nam));
            format(str,sizeof(str),"ANTI WEAPON HACK: %s has been banned from server for spawning a bad weapon!",Nam);
            SendClientMessageToAll(0xFF0000FF,str);
            BanEx(playerid,"ANTI WEAPON HACK: Weapon Hack!");
            }
                        return 1;
}
Reply
#8

https://sampforum.blast.hk/showthread.php?tid=65567
Reply
#9

Quote:
Originally Posted by Wesley221
View Post
There is an easier way of checking for different weapons instead of copy pasting it like 5 times
Ex:
pawn Code:
public OnPlayerUpdate(playerid)
{
            new weaponid = GetPlayerWeapon(playerid);//This will cause the "weaponid not defined" Error
                new Nam[MAX_PLAYER_NAME];
                new str[128];
            if( weaponid == 16 || weaponid == WEAPONID || weaponid == WEAPONID2 /* etc etc */)  // The weapon ID
            {
            GetPlayerName(playerid,Nam,sizeof(Nam));
            format(str,sizeof(str),"ANTI WEAPON HACK: %s has been banned from server for spawning a bad weapon!",Nam);
            SendClientMessageToAll(0xFF0000FF,str);
            BanEx(playerid,"ANTI WEAPON HACK: Weapon Hack!");
            }
                        return 1;
}
Oh my bad wesley, i forgot about that.
Reply
#10

This isn't an anti-weaponhack...
This just bans a player if he has a certain weapon.
What if I decide to hack a desert eagle? hows your script gonna detect that?
Reply
#11

Quote:
Originally Posted by Rob_Maate
View Post
This isn't an anti-weaponhack...
This just bans a player if he has a certain weapon.
What if I decide to hack a desert eagle? hows your script gonna detect that?
Just add the weapon id?
Reply
#12

he's right. you should put something to tell how much ammo they have, so if they have like, 9999+ ammo they'll get banned. and if you had deagle to the weapon id list then NOBODY can have a deagle without getting banned.
Reply
#13

Quote:
Originally Posted by PjFord
View Post
he's right. you should put something to tell how much ammo they have, so if they have like, 9999+ ammo they'll get banned. and if you had deagle to the weapon id list then NOBODY can have a deagle without getting banned.
Lol this will ban people if they have the gun in their HAND
Reply
#14

Yes Tan, meaning if you go to a store and buy it then you will get banned -_-
Reply
#15

Pj Ford, Why would someone add a bad weapon while they could buy that weapon at ammunation. Maybe they could disable the TEleports to ammu and do some next thing
Reply
#16

That's not what im saying. im saying let's say you blacklist minigun, rpg etc. but deagle isn't blacklisted. what if the hacker doesn't want to buy the ammo so he gives himself 9999 ammo. it wont ban him because deagle isn't blacklisted -_- and if you blacklist it, then anyone who buys one or gets one in their hand somehow will get banned.
Reply
#17

There is kinda a more accurate way how to write anticheats. Some months ago I've released an include, which calls callbacks, if the player is changed his/her holding weapons, weapon/ammo per slot, also weapon state, money, health, armour etc.
It could be very usefull at scripting accurate anticheats
Reply
#18

They still can buy gun with 1 ammo and make hundreds of them with cheat engine...
Reply
#19

Nice job.
Reply
#20

Good,but is better to put timer, OnPlayerUpdate will cause lagg
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)