I have a little question:how to get the quaternion of the player?I tried using something like
local W = player.Pos.W, X = player.Pos.x,Y = player.Pos.y, Z = player.Pos.z;
Message( "Your position: X:" + X + " Y: " + Y + " Z:" + Z + " W:" + W + "");
but it seems it doesn't work.Can anybody help me please? :'(
Unfortunately there is no such function for players. Only the position which returns a 3d Vector with just X, Y, Z components. So, you can't really get the rotation of the player AFAIK.
I'll still wait for more answers to get something similar to this
Quote from: marmota91 on Apr 01, 2015, 06:47 AMI'll still wait for more answers to get something similar to this
No problem. I just looked into the source of the scripting plugin and notified you that there is no such function. You are actually encouraged to wait for more answers, if possible from a staff member.
Alright
Not exactly what you're looking but I remembered about this topic (http://forum.vc-mp.org/?topic=252.0) and the .Angle member variable if rotation is what you need.
Oh... and also, manually (untested):
function VecToQuat(vec)
{
local c1 = cos(vec.z * 0.5), c2 = cos(vec.y * 0.5),
c3 = cos(vec.x * 0.5), s1 = sin(vec.z * 0.5),
s2 = sin(vec.y * 0.5), s3 = sin(vec.x * 0.5);
return Quaternion(
(c1*c2*s3 - s1*s2*c3).tofloat(),
(c1*s2*c3 + s1*c2*s3).tofloat(),
(s1*c2*c3 - c1*s2*s3).tofloat(),
(c1*c2*c3 + s1*s2*s3).tofloat()
);
}
function onPlayerSpawn(player)
{
local q = VecToQuat(player.Pos);
print(format("%f, %f, %f, %f", q.x, q.y, q.z, q.w));
}
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2Fcv1becK.png&hash=33fff1eefd0149c6e8f97113a585461ae897ff1f) it works thanks 8)