SA-MP Forums Archive
Front car speed - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Front car speed (/showthread.php?tid=173026)



Front car speed - Dime - 01.09.2010

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)


Re: Front car speed - LarzI - 01.09.2010

I don't think it's possible..


Re: Front car speed - Voldemort - 01.09.2010

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);
}


Re: Front car speed - [HiC]TheKiller - 01.09.2010

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


Re: Front car speed - LarzI - 01.09.2010

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..


Re: Front car speed - Voldemort - 01.09.2010

I already answered what he asked, where is prob?


Re: Front car speed - Zamaroht - 01.09.2010

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.


Re: Front car speed - Dime - 01.09.2010

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.


Re: Front car speed - FireCat - 01.09.2010

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


Re: Front car speed - Zamaroht - 01.09.2010

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.