PDA

View Full Version : Speedboost and bounce. :S


LeeXian99
01/11/2013, 06:15 PM
So, long time no script! When I'm here, means I got problem with scripting and there's no one around to help me so..

It's about speedboost and bounce. I did this.


if((newkeys & KEY_FIRE))
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new Float:Velocity[3];
if(Boost[playerid] == 1)
GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
SetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0]*2, Velocity[1]*2, Velocity[2]*2);
}
}
if((newkeys & KEY_CROUCH))
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new Float:Velocity[3];
if(Bounce[playerid] == 1)
GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
SetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]+0.39);
}
}


When I tested it, it doesn't look really good as i expected.

I expected speedboost will go straight and bounce will go jump without stopping (or just bounce and going forward a bit)

So, how can I fix this?

Konstantinos
01/11/2013, 06:23 PM
if(newkeys & KEY_FIRE)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(Boost[playerid])
{
new Float:Velocity[3];
GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
SetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0]*1.2, Velocity[1]*1.2, Velocity[2]*1.2);
}
}
}
if(newkeys & KEY_CROUCH)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(Bounce[playerid])
{
new Float:Velocity[3];
GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
SetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]+0.3);
}
}
}


The velocity * 2 makes it move too fast that you cannot control. 1.1-1.8 is pretty much fine.

LeeXian99
01/11/2013, 06:26 PM
if(newkeys & KEY_FIRE)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(Boost[playerid])
{
new Float:Velocity[3];
GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
SetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0]*1.2, Velocity[1]*1.2, Velocity[2]*1.2);
}
}
}
if(newkeys & KEY_CROUCH)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(Bounce[playerid])
{
new Float:Velocity[3];
GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
SetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]+0.3);
}
}
}


The velocity * 2 makes it move too fast that you cannot control. 1.1-1.8 is pretty much fine.

I mean, when I press LMB, it stops the car. When I press H, it bounce but it stopped the vehicle and bounced... Quite annoyed with this things around for an hour.

Konstantinos
01/11/2013, 06:31 PM
The code I posted shouldn't stop the car, I use pretty much the same for both speedboost/bounce and they work perfect.

LeeXian99
01/11/2013, 07:16 PM
Just weird, why it still stop my car although I used your code? o.0