08.05.2014, 08:36
(
Last edited by newbie scripter; 08/05/2014 at 01:38 PM.
)
i've got a weird problem in Floatcos, floatsin.
the code i use is:
and Rajat suggested my to try this code:
Both codes gave the same result.
The objects spawned in different direction, the first spawn in my right side and after i moved some place and looked at a different place, it spawned the object in my left side and so on. it spawned the object infront of my when i was looking in the North-East.
GetXYInFrontOfPlayer:
EDIT: Fixed. rX should be floatsin and vice versa.
EDIT2:
Is there anyway i can check whether the player has pressed the Jump Key other than in OnPlayerKeyChangeState (im planning the check it in a timer)
the code i use is:
pawn Code:
CMD:test1(playerid, params[])
{
new Float:X, Float:Y, Float:Z, Float:ang, obj, Float:Xx, Float:Yy, Float:Zz, Float:fX, Float:fY, str[128];
GetPlayerFacingAngle(playerid, ang);
GetPlayerPos(playerid, X, Y, Z);
GetXYInFrontOfPlayer(playerid, 45, fX, fY);
obj = CreateObject(345, fX, fY, Z, 0, 0, 0);
GetObjectPos(obj, Xx, Yy, Zz);
format(str, sizeof str, "X = %f, Y = %f, Z=%f Your pos : %f ,%f, %f", Xx, Yy, Zz, X, Y, Z);
SendClientMessage(playerid, -1, str);
return 1;
}
pawn Code:
CMD:spawntest(playerid)
{
new Float: fX, Float: fY, Float: fZ, ob;
GetXYInFrontOfPlayer(playerid, 45.1, fX, fY);
MapAndreas_FindZ_For2DCoord(fX, fY, fZ);
ob = CreateObject(345, fX, fY, fZ, 0, 0, 0);
return 1;
}
The objects spawned in different direction, the first spawn in my right side and after i moved some place and looked at a different place, it spawned the object in my left side and so on. it spawned the object infront of my when i was looking in the North-East.
GetXYInFrontOfPlayer:
pawn Code:
GetXYInFrontOfPlayer(playerid, Float: distance, &Float: rX, &Float: rY)
{
new Float: x, Float: y, Float: z, Float: angle;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, angle);
rX = (x + (distance * floatcos(-angle, degrees)));
rY = (y + (distance * floatsin(-angle, degrees)));
}
EDIT2:
Is there anyway i can check whether the player has pressed the Jump Key other than in OnPlayerKeyChangeState (im planning the check it in a timer)

