17.02.2009, 17:27
i did this as an example:
i went ingame, and 'angle' (see code below) was 60.0
pawno does:
and says: angle = 60
ok everything works
then i calculated (with my own calculator and not pawno) the Px2 where the player will be placed:
cos(60)*1 = 0.5 //(because distance was 1.0)
0.5+0.0 = 0.5 //(because "x" was 0.0)
so Px2 should be 0.5
if pawno calculates it, Px2 is -0.88 -_-
wtf
what's wrong with this?
this is the code:
i went ingame, and 'angle' (see code below) was 60.0
pawno does:
Код:
format(text, sizeof text, "angle = %f", angle);
ok everything works
then i calculated (with my own calculator and not pawno) the Px2 where the player will be placed:
cos(60)*1 = 0.5 //(because distance was 1.0)
0.5+0.0 = 0.5 //(because "x" was 0.0)
so Px2 should be 0.5
if pawno calculates it, Px2 is -0.88 -_-
wtf
what's wrong with this?

this is the code:
Код:
new text[64];
format(text, sizeof text, "angle = %f", angle);
SendClientMessage(playerid, 0xFF3399AA, text);
new Float:Px2, Float:Py2;
Px2 = floatmul(floatcos(angle), distance);
Py2 = floatmul(floatsin(angle), distance);
if (Px > x && Py > y) //1
{
Px2 = floatadd(x, Px2);
Py2 = floatadd(y, Py2);
SendClientMessage(playerid, 0xFF3399AA, "1");
}
else if (Px <= x && Py >= y) //2
{
Px2 = floatsub(x, Px2);
Py2 = floatadd(y, Py2);
SendClientMessage(playerid, 0xFF3399AA, "2");
}
else if (Px >= x && Py <= y) //3
{
Px2 = floatadd(x, Px2);
Py2 = floatsub(y, Py2);
SendClientMessage(playerid, 0xFF3399AA, "3");
}
else if (Px < x && Py < y) //4
{
Px2 = floatsub(x, Px2);
Py2 = floatsub(y, Py2);
SendClientMessage(playerid, 0xFF3399AA, "4");
}
format(text, sizeof text, "Px2 = %f | Py2 = %f", Px2, Py2);
SendClientMessage(playerid, 0xFF3399AA, text);
SetPlayerPos(playerid, Px2, Py2, Pz);

