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

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;
}
Reply
#2

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.
Reply
#3

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 :$
Reply
#4

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
Reply
#5

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!
Reply
#6

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;
}
Reply
#7

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


Forum Jump:


Users browsing this thread: 1 Guest(s)