16.03.2010, 14:48
How can i make one BASIC and simple speedhack anti-cheat ?
stock Float:GetPlayerSpeed(playerid, bool:Z = true)
{
new Float:SpeedX, Float:SpeedY, Float:SpeedZ;
new Float:Speed;
if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid), SpeedX, SpeedY, SpeedZ);
else GetPlayerVelocity(playerid, SpeedX, SpeedY, SpeedZ);
if(Z) Speed = floatsqroot(floatadd(floatpower(SpeedX, 2.0), floatadd(floatpower(SpeedY, 2.0), floatpower(SpeedZ, 2.0))));
else Speed = floatsqroot(floatadd(floatpower(SpeedX, 2.0), floatpower(SpeedY, 2.0)));
return floatmul(Speed, 200.0);
}
if(GetPlayerSpeed(playerid, false) > 300.5) Kick(playerid);
Originally Posted by ¤Adas¤
Use this.
pawn Код:
pawn Код:
|
stock Float:GetPlayerSpeed(playerid, bool:Z = true) { new Float:SpeedX, Float:SpeedY, Float:SpeedZ; new Float:Speed; if(GetPlayerSpeed(playerid, false) > 300.5) Kick(playerid); if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid), SpeedX, SpeedY, SpeedZ); else GetPlayerVelocity(playerid, SpeedX, SpeedY, SpeedZ); if(Z) Speed = floatsqroot(floatadd(floatpower(SpeedX, 2.0), floatadd(floatpower(SpeedY, 2.0), floatpower(SpeedZ, 2.0)))); else Speed = floatsqroot(floatadd(floatpower(SpeedX, 2.0), floatpower(SpeedY, 2.0))); return floatmul(Speed, 200.0); }
stock Float:GetPlayerSpeed(playerid, bool:Z = true) { new Float:SpeedX, Float:SpeedY, Float:SpeedZ; new Float:Speed; if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid), SpeedX, SpeedY, SpeedZ); else GetPlayerVelocity(playerid, SpeedX, SpeedY, SpeedZ); if(Z) Speed = floatsqroot(floatadd(floatpower(SpeedX, 2.0), floatadd(floatpower(SpeedY, 2.0), floatpower(SpeedZ, 2.0)))); else Speed = floatsqroot(floatadd(floatpower(SpeedX, 2.0), floatpower(SpeedY, 2.0))); return floatmul(Speed, 200.0); }
public OnPlayerUpdate(playerid) { if(GetPlayerSpeed(playerid, false) > 325.0) { if(!IsPlayerAdmin(playerid)) { // Anything here you'll add for a ban or kick. return 1; } return 1; } return 1; }
Originally Posted by AK47KILLA
Код:
public OnPlayerUpdate(playerid) { if(GetPlayerSpeed(playerid, false) > 325.0) { if(!IsPlayerAdmin(playerid)) { // Anything here you'll add for a ban or kick. return 1; } return 1; } return 1; } |
//at top of script
forward AntiSpeedHack();
//under OnGamemodeInit() or OnFilterscriptInit()
SetTimer("AntiSpeedHack",2000,true);
//at bottom of script
public AntiSpeedHack()
{
for(new i; i < MAX_PLAYERS; i++)
{
if(GetPlayerSpeed(i, false) > 325.0)
{
//your code here, maybe remove the player from his vehicle or kick/ban him
return 1;
}
}
return 1;
}
Originally Posted by biltong
Quote:
pawn Код:
EDIT: Make sure you also add that stock function to the script. |