Saving Vehicle.Angle to database and loading while creating vehs.

Started by DilsonTB, Jan 30, 2017, 12:10 AM

Previous topic - Next topic

DilsonTB

Hi everyone, I've been inactive for a loooong time, so now I'm back and i've spend a hard time stuying much as I could the 0.4 features and such as those news, last time I was on vcmp,it was on 0.3z (Tell you this, to prevent you telling me that is already a post that explains my questions, I already Googled, search on differents vcmp forums, and still nothing exactly as the right angle like in 0.3 was, so please, and happy to be back with 0.4 (It's like 5 vcmp versions together :O ;) looks amazing.)

Well to the point.

I've been trying to get the exactly vehicle.Angle or vehicle.EulerAngle, but even the first function give me 4 parameters, the second one gives me 3.

Tried to test =

player.Vehicle.EulerAngle.x
player.Vehicle.EulerAngle.y
player.Vehicle.EulerAngle.z

also:

player.Vehicle.Angle.x
player.Vehicle.Angle.y
player.Vehicle.Angle.z

the "z" is the most that goes close to the right angle, but still I can't find a right angle as 0.3z had.

I'm developing an RP server, so my idea is to save the pos, angle to database, and them, Load vehicles and "save the pos ingame" as "parking".

trying to save angle to database and them while loading (creating) vehicles from database, make the saved angle work, I tried:

stats[player.ID].Example = player.Vehicle.Angle;then on another cmd;
player.Vehicle.Angle = stats[player.ID].Example; (and works)
but if I try to set it like a Vector, float, manually, doesn't works, just crash my svr.
Thanks for paying attention and help.

Out of topic: Why the 0.4 developers changed this function to 3 o 4 parameters?, do they have another intention, like another use those x,y,z,w angles?

vito

function CVehicle::GetRadiansAngle(){
local angle;
angle = ::asin( Rotation.z ) * -2;
return Rotation.w < 0 ? 3.14159 - angle : 6.28319 - angle;
}
local angle = player.Vehicle.GetRadiansAngle();
But I recommend to save whole Vehicle.Rotation because car's position can be saved on stairs/or something else not perpendicular.

DilsonTB

Quote from: vito on Jan 30, 2017, 06:37 AMfunction CVehicle::GetRadiansAngle(){
local angle;
angle = ::asin( Rotation.z ) * -2;
return Rotation.w < 0 ? 3.14159 - angle : 6.28319 - angle;
}
local angle = player.Vehicle.GetRadiansAngle();
But I recommend to save whole Vehicle.Rotation because car's position can be saved on stairs/or something else not perpendicular.

Perfectly worked!, Thanks a lot bro, Yes, I will be working on saving the whole rotation to prevent a car bugged on stairs xD, thanks a Lot mate.

NicusorN5

Quote from: DilsonTB on Jan 30, 2017, 12:10 AMOut of topic: Why the 0.4 developers changed this function to 3 o 4 parameters?, do they have another intention, like another use those x,y,z,w angles?

It's a Quartenion , not a Vector3...

Shadow

The reason angles don't work as you expect them to is because the euler angles are in radians and the angles that were used in 0.3z are probably in degrees.

The difference is noticeable but you can always use these formulas to switch from one to another:

angle in radians * 180 / PI = angle in degrees
angle in degrees * PI / 180 = angle in radians

just basic trigo
QuotePS:is trash is ur home language??

DilsonTB