Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Speed Anticheat
- by XStormiest
- So how this script works, is very simple, it's based on some-kind of AI algorithm that detecks max Speed and checks for any anomally in the speed.
- */
- #define ANOMALLY 200
- #include <a_samp>
- new Float: MaxSpeed[MAX_PLAYERS][212][100];
- new K[MAX_PLAYERS][212];
- new Anomally = ANOMALLY;
- new CheckSpeedTimer;
- stock GetPlayerSpeed(playerid, bool:kmh) // by misco
- {
- new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
- if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
- rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
- return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
- }
- forward CheckVehicles();
- public CheckVehicles()
- {
- new vehicleid, modelid, Float: speed, bool: hack;
- new name[MAX_PLAYER_NAME], string[256];
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerInAnyVehicle(i))
- {
- hack = false;
- vehicleid = GetPlayerVehicleID(i);
- modelid = GetVehicleModel(vehicleid);
- speed = GetPlayerSpeed(i, true);
- if(speed > MaxSpeed[i][modelid-400][K[i][modelid-400]] && K[i][modelid-400] < 100)
- {
- MaxSpeed[i][modelid-400][K[i][modelid-400]++];
- }
- for(new j = 1; i < K[i][modelid-400]; i++)
- {
- if( (MaxSpeed[i][modelid][j] - MaxSpeed[i][modelid][j-1] ) >= Anomally )
- {
- hack = true;
- }
- }
- if(hack == true)
- {
- GetPlayerName(i, name, sizeof(name));
- format(string, sizeof(string), "Cheats: %s was detected using a car speed hack!!", name);
- SendClientMessageToAll(-1, string);
- BanEx(i, "Car Speed Hack");
- }
- }
- }
- return 1;
- }
- public OnFilterScriptInit()
- {
- CheckSpeedTimer = SetTimer("CheckVehicles", 1000, true);
- return 1;
- }
- public OnFilterScriptExit()
- {
- KillTimer(CheckSpeedTimer);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- for(new i = 0; i < 212; i++)
- {
- for(new j = 0; j < 100; j++)
- MaxSpeed[playerid][i][j] = 0;
- K[playerid][i] = 0;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement