Anti-Speed hack

Started by (vG)DesTroYeR^, Aug 02, 2024, 04:12 PM

Previous topic - Next topic

(vG)DesTroYeR^

H3ll0 3v3ry0n3
In advance, I would like to publish this code for assistance purpose.
I've just made/finished my speed hack detection code.
The description is put within the code, so it guides you how to use it.
It's a ready-to-use code so you shouldn't play with it, because I measured the default velocity of a player in VC:MP.
Guess what? The velocity in VC:MP is variable due to much curved objects.
Sometimes, you run on a hill or on a stair, which they aren't straight objects.
The max speed that a player in VC:MP can run is between 15-17.4(if he ran on a complicated hill or something high) The default velocity is between 11-13. I saw habi's speed hack code, but it counts both x y z, and Z axis mustn't be calculated because if a player jumps down from a building, it will count his speed and consider it as speed hack.
-------------
I initially made this code for my explode the base server, so I am making client side HP hack detection and many anti-hacks including this one.
So, in conclusion, habi's code will calculate even if player was respawned so from class screen to his spawn pos it will be a crazy distance to calculate, I made a 'countnow' index to avoid this mistake.
Goodluck!
-------------------------------------------------------------------------------------------------------------
class PlayerStats
{
nowcount = false;
}

function onPlayerDeath(player, reason) {
stats[ player.ID ].nowcount = false;
}
function s(player)
{
local p = FindPlayer(player);
local ID = p.ID;
stats[ ID ].nowcount= true;
}
function onPlayerSpawn( player )
{
NewTimer("s", 1000, 1, player.ID); // just to make delay and calculate speed after player position is set
}

function speedhack(player)
{
local p = FindPlayer(player.ID), Pid = p.ID, x = p.Pos.x, y = p.Pos.y, countxi/* X initial*/, countyi;// Y initial
if(x < 0) x = x * -1; // if x is -5, so when you do this equation (-5 * -1) it will be 5 and we can count it easily with this way
if (y < 0) y = y * -1;
countxi = x;
countyi = y;
NewTimer("speedhack2", 1000, 1, Pid, countxi, countyi);
print("=VG=Zer0neX's anti-speedhack system is loaded");
}
function speedhack2(player, countxi, countyi)
{
    local p = FindPlayer(player);
    local Pid = p.ID;
    if (!p) {
        return;
    }
    local x = p.Pos.x, y = p.Pos.y, z = p.Pos.z, count, countx,  county, result, fresult;

    if (x < 0) x = x * -1; /* if x is -5, so when you do this equation (-5 * -1) it will be 5 and we can count it easily with this way */
    if (y < 0) y = y * -1;

    countx = (x - countxi) / 1; // I've put () to calculate the final result of x before calculating time
    county = (y - countyi) / 1; // In both calculations, '1' represents the time as in NewTimer()
    count = sqrt((countx * countx) + (county * county)); // count = countx^2 + county^2 inside a root in math
    fresult = count; // final result (Speed)
    if (count < 0) fresult = count * -1;
    else fresult = count;// to return it to an integer which is higher than '0', if result is -30, so it will be 30..
    if (fresult > 18.00000) // You can change if needed
    {
local P = GetPlayer(p.Name);
        print(fresult + "");
Message("[#FFF000]"+P+" [#FF0000]has been kicked for modifying his speed. ([#FFA540]"+fresult+"m/s[#FF0000])");
KickPlayer(P); 
}
    else {
        return onPlayerMove(player, x, y, z, a, b, c); // periodically analyzing speed of player
    }
}
-------------------------------------------------------------------------------------------------------------
function onPlayerMove(player, x, y, z, a, b, c)
{
   if(stats[ player.ID ].nowcount == true && player.IsSpawned == true) speedhack(player);
}
[INFO]: keep credits & if you were kicked and u weren't using hacks, so you can change the fresult
- how are my physics skills? ;)
XD

vitovc

also some people are using speed hack to slowdown shooting speed (rate, amount of bullets per second) of other (remote) players. since speed hack affects clientside timer/system time (?) it not so easy to detect it. also some people are having fps drops/freezes so it also can trigger false-positive. speed hacking detection is very intersting topic
...::: vice city :::...
Useful things for vcmp: Relative position and finding an angle (in 3d), 3d line (like laser)

(vG)DesTroYeR^

i've tested FPS Limiter (30), when there are stutters, your speed becomes lower but when you have static 30 FPS it is as when you are on 60.
So FPS doesn't even affect FPS only if there is FPS drops, and it lowers player speed so that isn't important.
there are many plrs like ottoman/hitler and many east asia ones who use speed hack and lower their fps to make it hard to be seen.
I will edit this code later and make it not counting when a player is doing fall animation to avoid expected mistakes.

(vG)DesTroYeR^

i went to complicated objects like weird streets and ran on them for seconds.
i observed your velocity becomes higher there, so [18] is the highest record that a normal player can record.
and those hackers will be caught if they edit their velocity a very little, like x1.1.
so this system will catch them when they run on such objects.
there are much of these ones

vitovc

there is alot of stuff can cause fast speed like jump stair railings, dymanics objects. one guy were banned (by similar script) in EC few years ago for standing at trashbin and shooting it by weapon that cause big jump
...::: vice city :::...
Useful things for vcmp: Relative position and finding an angle (in 3d), 3d line (like laser)

umar4911

A lot things to care of for example.

What if I enter a vehicle very quickly after spawning and drive it?
What if someone hits me a car and I am sent flying?

(vG)DesTroYeR^

Quote from: umar4911 on Aug 06, 2024, 09:23 AMA lot things to care of for example.

What if I enter a vehicle very quickly after spawning and drive it?
What if someone hits me a car and I am sent flying?
Idk, I have edited this code and made IsFlyingNow and IsFallingNow but didnt publish them