Top Speed
#1

Hey guys, i found a speed boost code around here, and it works like a charm, but im trying to figure out how to make a top speed code or something similar, that wont let the speed boost just let everything just fly off the charts... you know what i mean if you keep the button pressed long enough, my speedo cought a top of 956 km/h (my speedo shows km/h, dunno real speed in gtaa ) so if anyone could help me with a code using get and setvehiclevelocity, it would be great!
Reply
#2

Quote:
Originally Posted by Seif_
I don't understand.
I'm pretty sure what he means is that he wants his speedboost to stop working once you are above a certain speed.

If that's true, then make it such that when your speedboost code is called (in OnPlayerKeyStateChange or whereever) it first works out the players speed (in the same way as with your speedo) and compare it to the maximum speed you want and then take action based upon that; for example, first work out their speed and store it in a variable speed then do something like this:

pawn Код:
if(speed > 900) return;
This will make it such that if their speed is above 900km/h (or whatever your units are) the code to boost their speed won't run (the code above must be before the bit that causes the players speed to be boosted).
Reply
#3

Or use clamp() on the values you set in SetVehicleVelocity.
Reply
#4

um sorry if i was not clear i tried already a few days ago with the if speed > etc... it stops the boost, but lets say, i set the if at 130 and the speed boost kicks in at 129 then your flying ~300, is it possible to literaly stop the speed rising more than 130? with and without speedboost?
Reply
#5

As a simple and very unrefined solution you could set the speedboost to cut out lower than 130 so that the fastest you will get with it will be 130 (you will have to experiment to find the cut off point).

I suppose another method would be to reduce their speed by multiplying their velocities by something between 0 and 1 if their speed is above 130, but I have no idea whether this would even work and if it did, how you would decide what value to multiply the velocities by.
Reply
#6

i have even tried that too, but that makes the vehicle suddenly loose speed, and start going again, so it is not an option, lets consider this, lets forget the speedboost at all, is there a way to not let a vhicle go faster than lets say 50 units? just stick on 50 and thats it? litteraly put a limit on how fast anything can goe, even if it can go faster in the original GTA:SA. god i hate mornings, i cant even make a proper sentence O_o
Reply
#7

For speedboost.
Код:
if(speed > 50)
	DisableSpeedBoost(playerid, 1000); //1000 MiliSecond (Depending how long you want the player to not have speed boost)
	SendClientMessage(playerid, 0xFFFFFFFF, Speed boost disabled for 1 second);


Reply
#8

Or use clamp() on the values you set in SetVehicleVelocity.
Reply
#9

clamp? what exactly do you mean? i just started up with 0.3 maybe i missed something
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)