Speed cap - Limit the vehicle maxspeed! -
Slice - 25.09.2010
sup,
Basically, this will limit the vehicle max speed (per-player configuration). You can, for example, slow down the hydra or make fast boats.. not so fast.

I believe it works with any vehicle.
I did this just as a test thing, but I figured some people here might find it useful so I made a simple FS for it.
How do I get started with this?
First off,
Try it on to see if it works. Load the filterscript, go ingame, and log in with /rcon login.
Now, use the testing command /myspeedcap to see if it works. An example of a value that feels like 50 km/h is 0.3.
So.. simply:
/myspeedcap 0.3
Put the macros below in your other scripts and do this for example:
pawn Код:
SetPlayerSpeedCap( playerid, 0.3 );
Another example that enables speed cap only for the NRG:
pawn Код:
public OnPlayerEnterVehicle( playerid, vehicleid, ispassenger )
{
new modelid = GetVehicleModel( vehicleid );
if ( modelid == 522 ) // 522 - NRG-500
SetPlayerSpeedCap( playerid, 0.4 );
else
DisablePlayerSpeedCap( playerid );
}
Put this in other scripts so they can change the speed cap easily.
pawn Код:
#define SetPlayerSpeedCap(%0,%1) CallRemoteFunction( "SetPlayerSpeedCap", "if", %0, %1 )
#define DisablePlayerSpeedCap(%0) CallRemoteFunction( "DisablePlayerSpeedCap", "i", %0 )
Download!
Download filterscript version:
speedcap.pwn.
Download include version (by RealCop228):
speedcap.inc. Note that it requires the latest version of YSI.
Video
I can't upload videos from where I'm at (well I could, but it would take a lifetime). It'd be cool if anyone could make a quick video that demonstrates this in a good way.
Re: Speed cap - Limit the vehicle maxspeed! -
Basicz - 25.09.2010
Looks nice.
Re: Speed cap - Limit the vehicle maxspeed! -
playbox12 - 25.09.2010
LOL, I just had the same idea like one day ago, I was just getting started on scripting it lol. Nice idea, well made! Keep it up!
Re: Speed cap - Limit the vehicle maxspeed! -
Hiddos - 27.09.2010
Nice. Also thought it'd be fun to make this possible :P. Great job, now RP servers can finally build speed-limiters in cars
Re: Speed cap - Limit the vehicle maxspeed! -
vyper - 27.09.2010
Really nice

good work
Re: Speed cap - Limit the vehicle maxspeed! -
sander1312 - 27.09.2010
works perfect (like cruise control)
Re: Speed cap - Limit the vehicle maxspeed! -
royal_king - 20.10.2010
Great work
Re: Speed cap - Limit the vehicle maxspeed! -
••• ĤБĶБM ••• - 20.10.2010
Good for RPing servers. Especially that if they add GetVehicleHealth, etc. If the car is damaged alot, it'll reduce the max-speed.
Well done, and made in the professional way.
Re: Speed cap - Limit the vehicle maxspeed! -
Slice - 21.10.2010
Quote:
Originally Posted by ••• ĤБĶБM •••
Good for RPing servers. Especially that if they add GetVehicleHealth, etc. If the car is damaged alot, it'll reduce the max-speed.
Well done, and made in the professional way.
|
That's a good idea. I might make something like that when I get bored.
Re: Speed cap - Limit the vehicle maxspeed! -
Las Venturas CNR - 22.10.2010
Great... for roleplay I guess :P
Re: Speed cap - Limit the vehicle maxspeed! -
DeadAhead - 09.12.2010
Very nice but OnPlayerUpdate slows performance down majorly thats why i would like they make a Program-Side Function.
Re: Speed cap - Limit the vehicle maxspeed! -
Biesmen - 09.12.2010
What about making an include of this, that's a lot better.
Re: Speed cap - Limit the vehicle maxspeed! -
Slice - 09.12.2010
Quote:
Originally Posted by Biesmen
What about making an include of this, that's a lot better. 
|
Then I'd have to hook it into the OnPlayerUpdate function, which would require more libraries or code that would prevent other libraries from working properly, and other libraries could be hooking into it aswell causing havoc in the script.
Quote:
Originally Posted by DeadAhead
Very nice but OnPlayerUpdate slows performance down majorly thats why i would like they make a Program-Side Function.
|
The code I have there can be executed, I'm guessing, around 300 times/1 ms. There is no "major slow-down" caused by this, trust me.
I can do benchmarking on it later today when I get home.
Re: Speed cap - Limit the vehicle maxspeed! -
WillyP - 09.12.2010
Really great idea.
OFFT: How did your name get changed?
Re: Speed cap - Limit the vehicle maxspeed! -
diehard5225 - 09.12.2010
i can beta test im located in ocala,florida,usa est time im active in forums server anything
Re: Speed cap - Limit the vehicle maxspeed! -
WillyP - 09.12.2010
Quote:
Originally Posted by diehard5225
i can beta test im located in ocala,florida,usa est time im active in forums server anything
|
Why would you need to BETA test his code? It's already been tested... :S
Re: Speed cap - Limit the vehicle maxspeed! -
Slice - 09.12.2010
Quote:
Originally Posted by [FU]Victious
Why would you need to BETA test his code? It's already been tested... :S
|
I believe he was referring to your signature.
Re: Speed cap - Limit the vehicle maxspeed! -
WillyP - 09.12.2010
Quote:
Originally Posted by Slice
I believe he was referring to your signature.
|
Ah, :P
But how did you get your name changed?
Re: Speed cap - Limit the vehicle maxspeed! -
wups - 09.12.2010
Quote:
Originally Posted by Slice
Then I'd have to hook it into the OnPlayerUpdate function, which would require more libraries or code that would prevent other libraries from working properly, and other libraries could be hooking into it aswell causing havoc in the script.
The code I have there can be executed, I'm guessing, around 300 times/1 ms. There is no "major slow-down" caused by this, trust me.
I can do benchmarking on it later today when I get home.
|
Woah! I'd like to see that!
Re: Speed cap - Limit the vehicle maxspeed! -
Osviux - 01.01.2011
Useful!