[Tutorial] Anti Speed Hack
#1

I saw that noone actually made an easy to understand anti speed hack tutorial, so here it is. This is very simple tutorial for those who are new to PAWN and are looking for anti hack scripts. Please only comment if you find it useful, and don't forget to +1 my Rep if this helps you.


1.Put this code in OnPlayerConnect:

Код:
SetTimerEx("CheckSpeed", 100, true, "i", playerid);
This creates a timer which checks for the player's vehicle speed every 100ms.

2.Forward the function | Put this code under the OnPlayerConnect function:

Код:
forward CheckHacks(playerid);
For example:

Код:
public OnPlayerConnect(playerid){
    SetTimerEx("CheckSpeed", 100, true, "i", playerid);
}

forward CheckHacks(playerid);
3.Now again under the "forward CheckHacks(playerid)" put this code:

Код:
public CheckHacks(playerid){
   if(GetVehicleSpeed(GetPlayerVehicleID(playerid)) > 1000){
   Kick(playerid);
  }
}
This will check the vehicle speed using GetVehicleSpeed (we are going to create this function) and if the speed is more than 1000, then the player will be kicked.

4.Put this code anywhere in your script:

Код:
stock GetVehicleSpeed(vehicleid)
{
    new Float:xPos[3];
    GetVehicleVelocity(vehicleid, xPos[0], xPos[1], xPos[2]);
    return floatround(floatsqroot(xPos[0] * xPos[0] + xPos[1] * xPos[1] + xPos[2] * xPos[2]) * 170.00);
}
This function returns the vehicle speed for the given vehicle id, which we provide in step 3.


Hope this was useful to you in any way! Thank you, please +1 My reputation if I helped!
Reply
#2

Maybe I'm using it wrong, but I use "GetVehicleSpeed" in OnPlayerUpdate and when player is in a vehicle. What is better, using OPU or timer? xD
Reply
#3

Quote:
Originally Posted by Spotlight
Посмотреть сообщение
I saw that noone actually made an easy to understand anti speed hack tutorial, so here it is. This is very simple tutorial for those who are new to PAWN and are looking for anti hack scripts. Please only comment if you find it useful, and don't forget to +1 my Rep if this helps you.

Hope this was useful to you in any way! Thank you, please +1 My reputation if I helped!
Is this a joke?
Reply
#4

Quote:
Originally Posted by B-Matt
Посмотреть сообщение
Maybe I'm using it wrong, but I use "GetVehicleSpeed" in OnPlayerUpdate and when player is in a vehicle. What is better, using OPU or timer? xD
Timer is way better.
OPU gets called quite a few times / second.

I use a timer that gets called once a second to check the speed and that's enough.
Reply
#5

I like to user OnPlayerUpdate.

You should explain abit more or redirect(maybe) to wiki links, cause I don't think newbies will know what is a pubic function and a stock, and what's the difference. They won't know what does SetTimerEx do.

Quote:

This creates a timer which checks for the player's vehicle speed every 100ms.

A newbie won't know what is a timer.

You have to ident your code, so newbies know the proper way of writing codes, and cause if someone copies this and pastes it in his script, he will get loose identation errors.

Should tell the players what "playerid" means and is it a string or an integer.

Quote:

Forward the function | Put this code under the OnPlayerConnect function:

Tell them why do you have to forward a public function, not just put this here and put that there.


Quote:

new Float: xPos[3];

A newbie won't know that this is an Array.

You Could've said "You can use it like this too: new Float:Xpos, Float:Ypos, Float:Zpos;".

Should say why did you add "Float" before its name.
Reply
#6

Oh yeah, let's set a new repeating timer every time a new player connects and let's never destroy it. In the end you will have a ton of timers running and your server will be lagging like hell.
Reply
#7

Quote:
Originally Posted by im
Посмотреть сообщение
Timer is way better.
OPU gets called quite a few times / second.

I use a timer that gets called once a second to check the speed and that's enough.
Umm.. OPU is called everytime a player updates the server with their status? Detection time is not so important, the important thing is to catch a cheater.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)