10.12.2014, 17:37
Introduction
I have decided to make a working and non bugged Anti jetpack system. There are already a few out there but they mostly use OnPlayerUpdate which continues to run forever.
Lets start
We are going to start off by adding a timer variable to the top of our script, this will allow us to Kill the timer once the player has been kicked/banned
__________________________________________________ ____________________________________________
Now we are going to start the timer when the player connects so it can detect if they are using a jetpack. So under OnPlayerConnect,
The true means that the timer will not stop after 100 milliseconds have passed. We have assigned the Timer to the playerid when they connect to the server
__________________________________________________ ____________________________________________
In this callback, we are going to want to ban/kick the player and then kill the timer so it does not continue to run,
IMPORTANT: If you are thinking of using messages in your ban, remember to use a timer to ban the player around a second after the message has been sent.
If you do not kill the timer after the player has been banned, then it will continue to check if the player is using the jetpack. If you have added a message to send to everyone that the player has been banned, it will flood the chat with the message because it is still noticing that the player is using a jetpack.
Also, when using a MySQL Database to insert the ban, it will flood your database with many bans.
The reason I have not used OnPlayerUpdate is because the callback continues to run forever, and it cannot be stopped. So using a timer and then killing the timer after the player has been banned is a better idea.
I hope I have made this clear for you, Thanks.
I have decided to make a working and non bugged Anti jetpack system. There are already a few out there but they mostly use OnPlayerUpdate which continues to run forever.
Lets start
We are going to start off by adding a timer variable to the top of our script, this will allow us to Kill the timer once the player has been kicked/banned
pawn Код:
new CheatingTimer[MAX_PLAYERS];
Now we are going to start the timer when the player connects so it can detect if they are using a jetpack. So under OnPlayerConnect,
pawn Код:
CheatingTimer[ playerid ] = SetTimerEx( "AntiCheat", 100, true, "i", playerid);
__________________________________________________ ____________________________________________
We will now create a callback which is linked to the timer, 'AntiCheat'. So somewhere in your script you want to forward your callback and use it. Just like this,pawn Код:
forward AntiCheat( playerid );
public AntiCheat( playerid )
{
if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK) // This will detect if the player is using a jetpack
{
}
}
__________________________________________________ ____________________________________________
In this callback, we are going to want to ban/kick the player and then kill the timer so it does not continue to run,
pawn Код:
forward AntiCheat( playerid );
public AntiCheat( playerid )
{
if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK)
{
// Add your messages here
Ban(playerid);
KillTimer(CheatingTimer[playerid]);
}
}
IMPORTANT: If you are thinking of using messages in your ban, remember to use a timer to ban the player around a second after the message has been sent.
If you do not kill the timer after the player has been banned, then it will continue to check if the player is using the jetpack. If you have added a message to send to everyone that the player has been banned, it will flood the chat with the message because it is still noticing that the player is using a jetpack.
Also, when using a MySQL Database to insert the ban, it will flood your database with many bans.
The reason I have not used OnPlayerUpdate is because the callback continues to run forever, and it cannot be stopped. So using a timer and then killing the timer after the player has been banned is a better idea.
I hope I have made this clear for you, Thanks.