[FilterScript] Speed cap - Limit the vehicle maxspeed!
#1

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

Looks nice.
Reply
#3

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!
Reply
#4

Nice. Also thought it'd be fun to make this possible :P. Great job, now RP servers can finally build speed-limiters in cars
Reply
#5

Really nice good work
Reply
#6

works perfect (like cruise control)
Reply
#7

Great work
Reply
#8

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

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.
Reply
#10

Great... for roleplay I guess :P
Reply
#11

Very nice but OnPlayerUpdate slows performance down majorly thats why i would like they make a Program-Side Function.
Reply
#12

What about making an include of this, that's a lot better.
Reply
#13

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.
Reply
#14

Really great idea.

OFFT: How did your name get changed?
Reply
#15

i can beta test im located in ocala,florida,usa est time im active in forums server anything
Reply
#16

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

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.
Reply
#18

Quote:
Originally Posted by Slice
Посмотреть сообщение
I believe he was referring to your signature.
Ah, :P

But how did you get your name changed?
Reply
#19

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!
Reply
#20

Useful!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)