Angles according to player positions
#2

Because you haven't specified what anglemode that Floatcos, Floatsin etc. will be using. So they are in 'radians' by default.

Код:
(Float:value, anglemode:mode=radian)
Float:value	The angle from which to get the cosine.
anglemode	The angle mode to use, depending on the value entered.
Quote:
Originally Posted by SA-MP Wiki
GTA/SA-MP use degrees for angles in most circumstances, for example GetPlayerFacingAngle. Therefore, it is most likely you'll want to use the 'degrees' angle mode, not radians.
Also note that angles in GTA are counterclockwise; 270° is East and 90° is West. South is still 180° and North still 0°/360°.
Example:
pawn Код:
new Float:x, Float:y, Float:x2, Float:y2, Float:AD, Float:angle, mess[128];
    GetPlayerPos(playerid, x, y, AD);
    GetPlayerPos(damagedid, x2, y2, AD);
    new Float:var = atan2((x2 - x), (y2 - y));
    GetPlayerFacingAngle(damagedid, AD);
    angle = (var + AD);
    if(angle >= 360) angle -= 360.0;
    if(90.0 <= angle < 180.0)
    {
        y = -(floatcos(angle - 90.0, degrees) * 200);
        x = -(floatsin(angle - 90.0, degrees) * 200);
    }
    else if(180.0 <= angle < 270.0)
    {
        y = -(floatcos(angle - 180.0, degrees) * 200);
        x = (floatsin(angle - 180.0, degrees) * 200);
    }
    else if(270.0 <= angle < 360.0)
    {
        y = (floatcos(angle - 270.0, degrees) * 200);
        x = (floatsin(angle - 270.0, degrees) * 200);
    }
    else
    {
        y = (floatcos(angle, degrees) * 200);
        x = -(floatsin(angle, degrees) * 200);
    }
    format(mess, sizeof(mess), "Original Angle: %f AD: %f Angle:%f py:%f px:%f", var, AD, angle, y, x);
    SendClientMessage(damagedid, White, mess);
Sources:
https://sampwiki.blast.hk/wiki/Floatcos
https://sampwiki.blast.hk/wiki/Floatsin
https://sampwiki.blast.hk/wiki/Floattan
Reply


Messages In This Thread
Angles according to player positions - by Kimossab - 16.06.2014, 22:09
Re: Angles according to player positions - by Threshold - 17.06.2014, 01:23
Re: Angles according to player positions - by Kimossab - 17.06.2014, 12:35

Forum Jump:


Users browsing this thread: 3 Guest(s)