SA-MP Forums Archive
Still can't find any problem in this 2 functions - 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: Still can't find any problem in this 2 functions (/showthread.php?tid=361656)



Still can't find any problem in this 2 functions - Cypress - 21.07.2012

pawn Код:
stock GetClosestPlayer(playerid, Float:limit)
{
    new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
    GetPlayerPos(playerid, x1, y1, z1);
    new Float:Range = 999.9;
    new id = -1;
    foreach(Player,i)
    {
        if(playerid != i)
        {
            GetPlayerPos(i, x2, y2, z2);
            new Float:Dist = GetDistanceBetweenPoints(x1, y1, z1, x2, y2, z2);
            if(floatcmp(Range, Dist) == 1 && floatcmp(limit, Range) == 1)
            {
                Range = Dist;
                id = i;
            }
        }
    }
    return id;
}

stock Float:GetDistanceBetweenPoints(Float:rx1, Float:ry1, Float:rz1, Float:rx2, Float:ry2, Float:rz2)
{
    return floatadd(floatadd(floatsqroot(floatpower(floatsub(rx1,rx2),2)),floatsqroot(floatpower(floatsub(ry1,ry2),2))),floatsqroot(floatpower(floatsub(rz1,rz2),2)));
}
pawn Код:
function with tag result used before definition, forcing reparse
I get this warning on line stock:GetDistanceBetweenPoints..


AW: Still can't find any problem in this 2 functions - Nero_3D - 21.07.2012

Check pawn-lang.pdf
Search there for the warning / error number, in your case 208

Quote:
Originally Posted by pawn-lang.pdf
208 - function with tag result used before definition

When a function is “used” (invoked) before being declared, and that function returns a value with a tag name, the parser must make an extra pass over the source code, because the presence of the tag name may change the interpretation of operators (in the presence of user-defined operators). You can speed up the parsing/compilation process by declaring the relevant functions before using them



Re: Still can't find any problem in this 2 functions - Roko_foko - 21.07.2012

put stock:GetDistanceBetweenPoints function before functions in which you use it