Boosting a vehicle?
#1

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;
    } 
Reply
#2

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);
Reply
#3

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)