21.03.2015, 15:04
how to create anti speed hack with car and without car
new LastHackReported[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
LastHackReported[playerid] = 0;
}
public OnPlayerUpdate(playerid)
{
if(IsPlayerInAnyVehicle(playerid) && GetVehicleSpeed(GetPlayerVehicleID(playerid)) >= 1000 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
LastHackReported[playerid]++;
if(LastHackReported[playerid] == 5)
{
CallLocalFunction("OnPlayerVehicleSpeedHack", "dd", playerid, GetPlayerVehicleID(playerid), GetVehicleSpeed(GetPlayerVehicleID(playerid));
LastHackReported[playerid] = 0;
}
}
return 1;
}
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);
}
forward OnPlayerVehicleSpeedHack(playerid, vehicleid, Float: MPH);