SA-MP Forums Archive
Boosting a vehicle? - 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: Boosting a vehicle? (/showthread.php?tid=606501)



Boosting a vehicle? - Dayrion - 05.05.2016

Hello there!
I want to create a "booster". When the player press Y, his speed is boosted.
What is the problem? The problem is when I set the vehicle's velocity.
Take a look : SetVehicleVelocity(GetPlayerVehicleID(playerid), x+0.5, y+0.5, z);
This depending which direction the driver is driving (I hope this means something). :/
So how can I solve the problem?

PHP код:
    if((newkeys KEY_YES) && (oldkeys KEY_SPRINT) && IsPlayerInAnyVehicle(playerid))
    {
         new 
Float:xFloat:yFloat:z;
        
SendClientMessage(playerid, -1"Boosting ...");
        
GetVehicleVelocity(GetPlayerVehicleID(playerid), xyz);
        
SetVehicleVelocity(GetPlayerVehicleID(playerid), x+0.5y+0.5z);
        return 
1;
    } 



Re: Boosting a vehicle? - CalvinC - 05.05.2016

Because the vehicle can be travelling South-West aswell, which results in negative X and Y speeds, so multiply it instead:
Код:
SetVehicleVelocity(GetPlayerVehicleID(playerid), x*0.5, y*0.5, z);



Re: Boosting a vehicle? - Dayrion - 05.05.2016

Oh.. I didn't think this way... So basic.. x)
Thanks'!

NB : x1.5 because x0.5 is like x/2. :P