Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: KAKAN on Feb 24, 2016, 05:12 PM

Title: How to get the Vehicle's Angle?
Post by: KAKAN on Feb 24, 2016, 05:12 PM
Okay, well, I tried this code:-
function onScriptLoad(){
CreateVehicle(205, 1, Vector(-1038.2107, 70.3865, 11.1406), 1.6069, 36, 17);
print( FindVehicle(1).Angle );

And I got the output as some Quaternion result. I want the angle which was used in CreateVehicle, i.e, 1.6069. So, how can I get it?
Title: Re: How to get the Vehicle's Angle?
Post by: KAKAN on Feb 24, 2016, 05:55 PM
Quote from: vito on Feb 24, 2016, 05:42 PMIs it not possbile use that quaternion for CreateVehicle?
Well, I was trying to save the angles in a database. And I want the angles as one quantity( or float ) and not a class. That's why I was asking. In the old 0.3z, the Angle returned a quantity, if I find no way, then I have to use Quaternion I think
Title: Re: How to get the Vehicle's Angle?
Post by: Thijn on Feb 24, 2016, 06:54 PM
Vehicle.EulerAngle.z should be close to what you want.
Title: Re: How to get the Vehicle's Angle?
Post by: KAKAN on Feb 25, 2016, 06:42 AM
Quote from: Thijn on Feb 24, 2016, 06:54 PMVehicle.EulerAngle.z should be close to what you want.
Hmm, then we can do some mathematical things to get the exact for all?
Will try though! Thanks!
Title: Re: How to get the Vehicle's Angle?
Post by: ysc3839 on Feb 25, 2016, 09:08 AM
Try this.function CVehicle::GetRadiansAngle()
{
local angle = ::asin(this.Rotation.z) * -2;
return this.Rotation.w < 0 ? 3.14159 - angle : 6.28319 - angle;
}
Title: Re: How to get the Vehicle's Angle?
Post by: KAKAN on Feb 25, 2016, 09:42 AM
Quote from: ysc3839 on Feb 25, 2016, 09:08 AMTry this.function CVehicle::GetRadiansAngle()
{
local angle = ::asin(this.Rotation.z) * -2;
return this.Rotation.w < 0 ? 3.14159 - angle : 6.28319 - angle;
}
It doesn't return same as that, but still then, the vehicle spawn at the required angle. Thanks!
If you can't understand what I mean, then: Well, I mean, suppose, the angle is 1, the function he provided returns 7 but still then the vehicle spawns at the correct angle!
Title: Re: How to get the Vehicle's Angle?
Post by: ysc3839 on Feb 25, 2016, 09:46 AM
Quote from: KAKAN on Feb 25, 2016, 09:42 AM
Quote from: ysc3839 on Feb 25, 2016, 09:08 AMTry this.function CVehicle::GetRadiansAngle()
{
local angle = ::asin(this.Rotation.z) * -2;
return this.Rotation.w < 0 ? 3.14159 - angle : 6.28319 - angle;
}
It doesn't return same as that, but still then, the vehicle spawn at the required angle. Thanks!
If you can't understand what I mean, then: Well, I mean, suppose, the angle is 1, the function he provided returns 7 but still then the vehicle spawns at the correct angle!
This function was who in this forum gave me long time ago. (May be more than 1 year.) And it works well.
Title: Re: How to get the Vehicle's Angle?
Post by: KAKAN on Feb 25, 2016, 09:47 AM
Quote from: ysc3839 on Feb 25, 2016, 09:46 AM
Quote from: KAKAN on Feb 25, 2016, 09:42 AM
Quote from: ysc3839 on Feb 25, 2016, 09:08 AMTry this.function CVehicle::GetRadiansAngle()
{
local angle = ::asin(this.Rotation.z) * -2;
return this.Rotation.w < 0 ? 3.14159 - angle : 6.28319 - angle;
}
It doesn't return same as that, but still then, the vehicle spawn at the required angle. Thanks!
If you can't understand what I mean, then: Well, I mean, suppose, the angle is 1, the function he provided returns 7 but still then the vehicle spawns at the correct angle!
This function was who in this forum gave me long time ago. (May be more than 1 year.) And it works well.
Hmm Okay! My problem has been solved! Thanks again! Topic locked.
 :edit:
Just found that @Gudio made that function: http://forum.vc-mp.org/?topic=252.msg1404#msg1404
Thanks to him for that extremely useful function!