07.03.2020, 23:19
(
Last edited by l0gic; 07/03/2020 at 11:53 PM.
)
Well you could just compare distance what is travaled with 1 second, when distance is too big, just ban player.
Vehicle speed checking can be avoided when hack teleports vehicle very fast forward, vehicle velocity doesn't change then.
example of vehicle anticheat
Vehicle speed checking can be avoided when hack teleports vehicle very fast forward, vehicle velocity doesn't change then.
example of vehicle anticheat
PHP Code:
// easy timer creation
#include <YSI_Coding\y_timers>
// definitons
#define MAX_WARNINGS 3
#define MAX_VEHICLE_DISTANCE 60.0
enum eAnticheat{
Float:LastPos[4],
LastWarning,
WarningCount
};
new Anticheat[MAX_PLAYERS][eAnticheat];
public OnPlayerConnect(playerid){
Anticheat[playerid][WarningCount] = 0;
return 1;
}
Float:GetDistance(Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2){
return VectorSize(x - x2, y - y2, z - z2);
}
ptask CheckPlayerMovement[1000](pid){
if(GetPlayerState(pid) == PLAYER_STATE_DRIVER && Anticheat[pid][WarningCount] != MAX_WARNINGS){
// get vehicle current position
new Float:x, Float:y, Float:z;
GetVehiclePos(GetPlayerVehicleID(pid), x, y, z);
// checks traveled distance
new Float:dis = GetDistance(x, y, z, Anticheat[pid][LastPos][0], Anticheat[pid][LastPos][1], Anticheat[pid][LastPos][2]);
if(dis > MAX_VEHICLE_DISTANCE){
// warning counter, because of many false-positives
new time = gettime();
if(time - Anticheat[pid][LastWarning] > 10){
Anticheat[pid][WarningCount] = 0;
}
Anticheat[pid][WarningCount] += 1;
Anticheat[pid][LastWarning] = time;
if(Anticheat[pid][WarningCount] == MAX_WARNINGS){
DisablePlayerAccount(pid, "Vehicle teleport/speed hacking!");
}
}
// saves current position
Anticheat[pid][LastPos][0] = x;
Anticheat[pid][LastPos][1] = y;
Anticheat[pid][LastPos][2] = z;
}
return 1;
}
DisablePlayerAccount(pid, const msg[]){
/// ...
return 1;
}