19.01.2014, 12:22
INTRODUCTION
Alright, so, basically, today i will show you how to script an Easy Anti-Health hack, which works pretty well.
It is also used in my game-mode.
---------------------------------------------------------------------------------------------------------------------
REQUIREMENTS
You will need this plugin:
Y_INI -> https://sampforum.blast.hk/showthread.php?tid=175565
---------------------------------------------------------------------------------------------------------------------
SCRIPTING
Alright, let's get started!
#1:
After you've added the Y_INI plugin, add this to the enum:
Then, you add this at "OnPlayerDisconnect"
And finally, at "Loaduser_data", add
That's about it i suppose.
----
#2:
Find the "OnPlayerTakeDamage" call-back, we will script it in there.
For you, it will probably look like this(At the start):
Alright, now add this:
It basically checks if the player is NOT an admin, so it looks like
Alright, now we will add this:
Under that;
That will get the players(Possible hackers) armour.
For now, it looks like this:
Now, we will add this line, under "GetPlayerArmour(....);"
As the comment says, it checks if the players(hackers) armour is 0!
Under the if(armour == 0), we will add these lines:
new string: We will need this to format a message to the admins
new name: We will get the players(hackers) name, so we can add it in the string, and so admins know WHO is actually hacking.
new Float:health, and the line below it: Will get the players(hackers) health.
So, for now, it should look something like this:
Alright, now we need to do this:
So, basically, if his ARMOUR is 0, and after all those shots, his health is 99 or more, then the ADMINS get warned.
Here's the FULL script:
----------
#3:
And to finish it, we need the "SendMessageToAdmins", and here it is:
Alright, so, basically, today i will show you how to script an Easy Anti-Health hack, which works pretty well.
It is also used in my game-mode.
---------------------------------------------------------------------------------------------------------------------
REQUIREMENTS
You will need this plugin:
Y_INI -> https://sampforum.blast.hk/showthread.php?tid=175565
---------------------------------------------------------------------------------------------------------------------
SCRIPTING
Alright, let's get started!
#1:
After you've added the Y_INI plugin, add this to the enum:
pawn Code:
enum pInfo
{
//other stuff
pAdmin,
pACDetected
}
pawn Code:
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
//other stuff here
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"ACDetected",PlayerInfo[playerid][pACDetected]);
INI_Close(File);
pawn Code:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
//other stuff here
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
//other stuff here
INI_Int("ACDetected",PlayerInfo[playerid][pACDetected]);
return 1;
}
----
#2:
Find the "OnPlayerTakeDamage" call-back, we will script it in there.
For you, it will probably look like this(At the start):
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
return 1;
}
pawn Code:
if(PlayerInfo[playerid][pAdmin] == 0) //if he isn't an admin
{
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(PlayerInfo[playerid][pAdmin] == 0) //if he isn't an admin
{
//script will be here
}
return 1;
}
pawn Code:
if(PlayerInfo[playerid][pACDetected] == 0) //Y_INI enum, if the player hasn't been detected by the anti-cheat
{
pawn Code:
new Float:armour;
GetPlayerArmour(playerid, armour);
For now, it looks like this:
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(PlayerInfo[playerid][pAdmin] == 0) //if he isn't an admin
{
if(PlayerInfo[playerid][pACDetected] == 0) //Y_INI enum, if the player hasn't been detected by the anti-cheat
{
new Float:armour;
GetPlayerArmour(playerid, armour);
}
}
return 1;
}
pawn Code:
if(armour == 0) //if his armour is 0
{
Under the if(armour == 0), we will add these lines:
pawn Code:
new string[94];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
new Float:health;
GetPlayerHealth(playerid,health);
new name: We will get the players(hackers) name, so we can add it in the string, and so admins know WHO is actually hacking.
new Float:health, and the line below it: Will get the players(hackers) health.
So, for now, it should look something like this:
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(PlayerInfo[playerid][pAdmin] == 0) //if he isn't an admin
{
if(PlayerInfo[playerid][pACDetected] == 0) //Y_INI enum, if the player hasn't been detected by the anti-cheat
{
new Float:armour;
GetPlayerArmour(playerid, armour);
if(armour == 0) //if his armour is 0
{
new string[94]; //String for a message
new name[MAX_PLAYER_NAME]; //Gets the hackers(players) name
GetPlayerName(playerid, name, sizeof(name));
new Float:health; //Gets the hackers(players) health
GetPlayerHealth(playerid,health);
}
}
}
return 1;
}
pawn Code:
if(health >= 99) //If his health is 99 or more
{
format(string, sizeof(string), "[ANTI-CHEAT] - %s[%d] is POSSIBLY using Health-Hacks!", name, playerid);
SendMessageToAdmins(COLOR_ORANGE, string); //Sends the message to admins
PlayerInfo[playerid][pACDetected] = 1; //Sets him as "Detected by Anti-Cheat", also avoids spam!
}
Here's the FULL script:
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(PlayerInfo[playerid][pAdmin] == 0) //if he isn't an admin
{
if(PlayerInfo[playerid][pACDetected] == 0) //Y_INI enum, if the player hasn't been detected by the anti-cheat
{
new Float:armour;
GetPlayerArmour(playerid, armour);
if(armour == 0) //if his armour is 0
{
new string[94]; //String for a message
new name[MAX_PLAYER_NAME]; //Gets the hackers(players) name
GetPlayerName(playerid, name, sizeof(name));
new Float:health; //Gets the hackers(players) health
GetPlayerHealth(playerid,health);
if(health >= 99) //If his health is 99 or more
{
format(string, sizeof(string), "[ANTI-CHEAT] - %s[%d] is POSSIBLY using Health-Hacks!", name, playerid);
SendMessageToAdmins(COLOR_ORANGE, string); //Sends the message to admins
PlayerInfo[playerid][pACDetected] = 1; //Sets him as "Detected by Anti-Cheat", also avoids spam!
return 1;
}
}
}
}
return 1;
}
#3:
And to finish it, we need the "SendMessageToAdmins", and here it is:
pawn Code:
stock SendMessageToAdmins(color, text[])
{
for(new i = 0; i < MAX_PLAYERS; i++) //loops trough all the players
{
if(PlayerInfo[i][pAdmin] >= 1) //if his(their) level 1 or more
{
SendClientMessage(i, color, text); //he(they) receive(s) the message
}
}
}
I've tested this 3 - 4x, and It worked 99%.