Anti-Speedhack
#1

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
Reply
#2

Try taking a look at a random speed-o-meter script I'd say.
Reply
#3

https://sampwiki.blast.hk/wiki/GetPlayerVelocity
Reply
#4

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;
}
Reply
#5

Quote:
Originally Posted by [XST]O_x
View Post
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
Reply
#6

I used it in a lot of my speedometers,and I made a lot of them xD
Worked fine.
Reply
#7

wow weird i tried using it to get speed and in a speedometer it failed epicly for me D: owell
Reply
#8

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
Reply
#9

pawn Code:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == /*Plane model ID*/) {
// Is in a plane
} else {
// Isn't in a plane
}
Reply
#10

Quote:
Originally Posted by [XST]O_x
View Post
[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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)