Anti-Speedhack - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Anti-Speedhack (
/showthread.php?tid=166177)
Anti-Speedhack -
ScottCFR - 07.08.2010
I have the basics down but, I don't know the equation.
Anyone give me the proper way to detect speed (km/h)?
Thanks,
ScottCFR
Re: Anti-Speedhack -
Hiddos - 07.08.2010
Try taking a look at a random speed-o-meter script I'd say.
Re: Anti-Speedhack -
Stepashka - 07.08.2010
https://sampwiki.blast.hk/wiki/GetPlayerVelocity
Re: Anti-Speedhack -
[XST]O_x - 07.08.2010
pawn Code:
stock GetPlayerSpeed(playerid)
{
new Float:ST[4];
if(IsPlayerInAnyVehicle(playerid))
GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 179.28625;
return floatround(ST[3]);
}
pawn Code:
public OnPlayerUpdate(playerid)
{
if(GetPlayerSpeed > /*your speed limit*/) return Kick(playerid);
return 1;
}
Re: Anti-Speedhack -
Kar - 07.08.2010
Quote:
Originally Posted by [XST]O_x
pawn Code:
stock GetPlayerSpeed(playerid) { new Float:ST[4]; if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]); else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]); ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 179.28625; return floatround(ST[3]); }
pawn Code:
public OnPlayerUpdate(playerid) { if(GetPlayerSpeed > /*your speed limit*/) return Kick(playerid); return 1; }
|
are you sure that getplayerspeed works for you?
i swear i tried that and it never worked. Anyways I'd Use This One
pawn Code:
stock GetPlayerSpeed(playerid,bool:kmh)
{
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);
}
kmhp^^ btw
Re: Anti-Speedhack -
[XST]O_x - 07.08.2010
I used it in a lot of my speedometers,and I made a lot of them xD
Worked fine.
Re: Anti-Speedhack -
Kar - 07.08.2010
wow weird i tried using it to get speed and in a speedometer it failed epicly for me D: owell
Re: Anti-Speedhack -
ScottCFR - 07.08.2010
Okay, is there a function that sees if the player is in a plane or not? I've looked and all I can find is the VehicleID. Which is cool, but I allow players to spawn any car in San Andreas. So it's hard to keep track of vehicle IDs
Re: Anti-Speedhack -
Conroy - 07.08.2010
pawn Code:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == /*Plane model ID*/) {
// Is in a plane
} else {
// Isn't in a plane
}
Re: Anti-Speedhack -
DiddyBop - 07.08.2010
Quote:
Originally Posted by [XST]O_x
[pawn]
pawn Code:
public OnPlayerUpdate(playerid) { if(GetPlayerSpeed > /*your speed limit*/) return Kick(playerid); return 1; }
|
Know how often OnPlayerUpdate gets called..?
Just make a timer!