Front car speed
#1

How can i make speed bost only for front side of car.If car is in any position, he will go front.

(this is like other speed bost scripts i know put it in command or onplayerkeystat.. just need help about front velocity)
Reply
#2

I don't think it's possible..
Reply
#3

onkeystate
if(newkeys == KEY_FIRE)
{
new Float: x,Float:y,Float:z;
GetVehicleVelocity(veh,x,y,z);
SetVehiclevelocity(veh,x*1.2,y*1.2,z);
}
Reply
#4

I really don't get what you are talking about. You want speedboost to be auto?
Reply
#5

I get what he asks for.
He wants that you only get speedboost in the forward direction. Not if you're driving backwards or sideways or whatever, but only in the direction the car is facing with front part. I think..
Reply
#6

I already answered what he asked, where is prob?
Reply
#7

To do this, you will have to use the new function GetVehicleRotationQuat. However, it works with quaternions, which is not an easy concept to understand. JernejL made some functions to project a vector depending on where the vehicle is facing, so you can then multiply it and use it as speed.

http://pastebin.com/7L2yi3gz

The front side of the car is the negative Y coord, so you can use a code similar to this:

pawn Код:
new Float:currspeed[3], Float:direction[3], Float:total;
GetVehicleVelocity(GetPlayerVehicleID(playerid), currspeed[0], currspeed[1], currspeed[2]);
total = floatsqroot((currspeed[0] * currspeed[0]) + (currspeed[1] * currspeed[1]) + (currspeed[2] * currspeed[2]));
total += 0.7;
new Float:invector[3] = {0.0, -1.0, 0.0};
RotatePointVehicleRotation(GetPlayerVehicleID(playerid), invector, direction[0], direction[1], direction[2]);
SetVehicleVelocity(GetPlayerVehicleID(playerid), direction[0] * total, direction[1] * total, direction[2] * total);
That code will, for example, add 0.7 speed to whatever position the vehicle that playerid is driving is facing.
This function is very powerful, you will be able to add side speeds (regardless if the car is going up a cliff or not), or even detect if the player's vehicle is flipped, among others.
Reply
#8

Quote:
Originally Posted by Zamaroht
Посмотреть сообщение
To do this, you will have to use the new function GetVehicleRotationQuat. However, it works with quaternions, which is not an easy concept to understand. JernejL made some functions to project a vector depending on where the vehicle is facing, so you can then multiply it and use it as speed.

http://pastebin.com/7L2yi3gz

The front side of the car is the negative Y coord, so you can use a code similar to this:

pawn Код:
new Float:currspeed[3], Float:direction[3], Float:total;
GetVehicleVelocity(GetPlayerVehicleID(playerid), currspeed[0], currspeed[1], currspeed[2]);
total = floatsqroot((currspeed[0] * currspeed[0]) + (currspeed[1] * currspeed[1]) + (currspeed[2] * currspeed[2]));
total += 0.7;
new Float:invector[3] = {0.0, -1.0, 0.0};
RotatePointVehicleRotation(GetPlayerVehicleID(playerid), invector, direction[0], direction[1], direction[2]);
SetVehicleVelocity(GetPlayerVehicleID(playerid), direction[0] * total, direction[1] * total, direction[2] * total);
That code will, for example, add 0.7 speed to whatever position the vehicle that playerid is driving is facing.
This function is very powerful, you will be able to add side speeds (regardless if the car is going up a cliff or not), or even detect if the player's vehicle is flipped, among others.
It works.Thanks.
Reply
#9

what this guy wants is if even the car is going backwards speedboost will push him to the front i think like the cleo mods for sa-mp
Reply
#10

Quote:
Originally Posted by FireCat
Посмотреть сообщение
what this guy wants is if even the car is going backwards speedboost will push him to the front i think like the cleo mods for sa-mp
The code I posted does exactly that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)