SA-MP Forums Archive
Float:Angle2D(Float:PointA[], Float:PointB[]) warning but I don't get it why... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Float:Angle2D(Float:PointA[], Float:PointB[]) warning but I don't get it why... (/showthread.php?tid=425537)



Float:Angle2D(Float:PointA[], Float:PointB[]) warning but I don't get it why... - Scrillex - 26.03.2013

pawn Code:
warning 208: function with tag result used before definition, forcing reparse

pawn Code:
Float:Angle2D(Float:PointA[], Float:PointB[])
{
    new bool:A_LS_B[2], Float:Dist[2], Float:Angle;

    for (new i = 0; i < 2; i++)
    {
        A_LS_B[i] = PointA[i] < PointB[i];
        Dist[i] = A_LS_B[i] ? PointB[i] - PointA[i] : PointA[i] - PointB[i];
    }

    Angle = atan2(Dist[1],Dist[0]);
    Angle = A_LS_B[0] ? 270.0 + Angle : 90.0 - Angle;
    Angle = A_LS_B[1] ? Angle : 180.0 - Angle;

    return Angle;
}



Re: Float:Angle2D(Float:PointA[], Float:PointB[]) warning but I don't get it why... - iggy1 - 26.03.2013

When you put a tag on a function (Float: in this case) the definition of the function must come before the function is called, IE put it at the very top or in an include.

I don't exactly know why this happens, I'm sure someone who knows the compiler can tell you why but, for now the above will fix the warning.


Re: Float:Angle2D(Float:PointA[], Float:PointB[]) warning but I don't get it why... - kamzaf - 26.03.2013

If im not wrong you cant use a new function with the starter a Float:

isnt it supposed to be like:

pawn Code:
stock Angle2D(Float:PointA[], Float:PointB[])
EDIT: nvm i was wrong :$


Re: Float:Angle2D(Float:PointA[], Float:PointB[]) warning but I don't get it why... - iggy1 - 26.03.2013

Quote:
Originally Posted by kamzaf
View Post
If im not wrong you cant use a new function with the starter a Float:

isnt it supposed to be like:

pawn Code:
stock Angle2D(Float:PointA[], Float:PointB[])
You can put tags on functions, but they must be defined before they are called. You can't have a function with a tag at the bottom of your code and call it in OnGameModeInit w/o this warning for example.

EDIT: Just saw your edit


Re: Float:Angle2D(Float:PointA[], Float:PointB[]) warning but I don't get it why... - Scrillex - 26.03.2013

Just it's strange why it's happening.. Now I puted on top ofthe script.. lets see if it will work just it's in yom buttons.. I don't want to mess include up!


Re : Float:Angle2D(Float:PointA[], Float:PointB[]) warning but I don't get it why... - DaTa[X] - 26.03.2013

i'm not sure but try this

pawn Code:
Float:Angle2D(Float:PointA[], Float:PointB[])
{
    new bool:A_LS_B[2], Float:Dist[2], Float:Angle;

    for (new i = 0; i < 2; i++)
    {
        A_LS_B[i] = PointA[i] < PointB[i];
        Dist[i] = A_LS_B[i] ? PointB[i] - PointA[i] : PointA[i] - PointB[i];
    }

    Angle = atan2(Dist[1],Dist[0]);
    if(Angle = A_LS_B[0]) ? 270.0 + Angle : 90.0 - Angle;
    if(Angle = A_LS_B[1]) ? Angle : 180.0 - Angle;

    return Angle;
}



Re: Float:Angle2D(Float:PointA[], Float:PointB[]) warning but I don't get it why... - Scrillex - 26.03.2013

Everything worked when I puted in top of the script but it's just interesting why its like that!