[Tutorial] Making a working Anti - Jetpack system
#1

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

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);
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

__________________________________________________ ____________________________________________
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.
Reply


Messages In This Thread
Making a working Anti - Jetpack system - by FunnyBear - 10.12.2014, 17:37
Re: Making a working Anti - Jetpack system - by JeaSon - 11.12.2014, 05:51
Re: Making a working Anti - Jetpack system - by Nutcracker - 11.12.2014, 06:02
AW: Making a working Anti - Jetpack system - by Flori - 11.12.2014, 06:04
Re: Making a working Anti - Jetpack system - by PowerPC603 - 11.12.2014, 07:09
Re: Making a working Anti - Jetpack system - by Kyance - 11.12.2014, 14:57

Forum Jump:


Users browsing this thread: 1 Guest(s)