SA-MP Forums Archive
Speed ​​limiter - 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: Speed ​​limiter (/showthread.php?tid=256348)



Speed ​​limiter - Esmaelo - 20.05.2011

Hello, so here I put the radar in town for speed 70 not be flash but it's hot to ride less than 70 so I wondered if anyone would have a speed limiter as in the real car example:
I'm in town (do not roll + 70) I made ​​a menu and F5 says: Number of km / h?
I put 70 and then Ok and if I support a form on Z (roll) its not going over 70 *: cheers

That thank you. Good morning *


Re: Speed ​​limiter - LetsOWN[PL] - 20.05.2011

Emm. I don't know what you actually means, but:

pawn Код:
OnPlayerConnect(playerid){
SetTimerEx("speedCheck",1000,1,"d",playerid)
...
return 1;
}
Now let's make speedchecker (lool, cool nameee)
pawn Код:
stock GetPlayerSpeed(PlayerId)
{
    new Float:VehSpeed[3];
    GetVehicleVelocity(GetPlayerVehicleID(PlayerId), VehSpeed[0], VehSpeed[1], VehSpeed[2]);
    Player[PlayerId][VSpeed] = floatround((floatabs(VehSpeed[0]) + floatabs(VehSpeed[1])) * 150.0);
    return Player[PlayerId][VSpeed];
}
Now the business part

pawn Код:
forward speedCheck(playerid);
public speedCheck(playerid)
{
if(IsPlayerInAnyVehicle(playerid)) // Am I in vehicle?
{
new Spid = GetPlayerSpeed(playerid);
if(Spid >= 70)
{
// What you'd like to do, if player goes over 70 KM/H?
return 1;
}
return 1;
}
return 1;
}
As always, you can add your own conditions, like IsPlayerAdmin or whatever (Spid >= 70 && your condition).
Hope it works

~LetsOWN


Respuesta: Speed ​​limiter - admantis - 20.05.2011

^He doesn't want anything to be done, only a limitation of speed! You need the function SetPlayerSpeed, but with clevermind and SetPlayerVelocity it's possible aswell.