SA-MP Forums Archive
Vehicle velocity - 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)
+--- Thread: Vehicle velocity (/showthread.php?tid=574778)



Vehicle velocity - Shazwan - 20.05.2015

Greetings i have a question about the SetVehicleVelocity.

Let just said that infernus top speed in game is 123km/h

In which SetVehicleVelocity(vehicleid, x, y, z); X Y or Z that can add 1 speed to infernus to be 124km/h?

Also how can we set it to auto mod without having using OnPlayerKeyStateChange to have 1 speed added?

Example, we keep driving without having to press any key to reach 124km/h, it will automatically 124 by it self.

Any ideas?


Re: Vehicle velocity - AnnaSB - 20.05.2015

1. Velocity setting is not bound to anything except the air friction and maybe the integer variable capacity.
2. The thing you're about to do is to increase the maximum speed of a vehicle, which cannot be done from the server side.
3. But still, you can speed up the vehicle when it reaches 123 km/h, imagine we have a timer which calls the function "ProcessVehicleVelocity":
PHP код:
public ProcessVehicleVelocity(vehicleid)
{
      new 
Float:xvFloat:yvFloat:zv;
      
GetVehicleVelocity(vehicleidxvyvzv);
      new 
Float:tv sqrt(floatpower(xv2.0) + floatpower(yv2.0) + floatpower(zv2.0)); // some triangular equations
      
if (tv 120.00SetVehicleVelocity(vehicleidxv 1.0yv 1.0zv 1.0); // however this might add more than 1 km/h

Hope it helped ^^


Re: Vehicle velocity - Vince - 20.05.2015

Velocity doesn't really work like that. You can only really multiply the current velocity. In your case you want the vehicle to be 1/124th (0.8%) faster, so try multiplying by 1.008 .


Re: Vehicle velocity - Shazwan - 21.05.2015

So, it means that it give more speed than 1? If you didn't multiply?


Re: Vehicle velocity - Pottus - 21.05.2015

You have to multiply or divide to increase velocity!


Re: Vehicle velocity - Shazwan - 21.05.2015

Is there an example that you can show me a bit? I need a little bit more detailed.