SA-MP Forums Archive
Warning Fix - 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: Warning Fix (/showthread.php?tid=567266)



Warning Fix - Trevor Gin - 12.03.2015

How to fix this warn??
Code:
./FGRP.pwn(3978) : warning 203: symbol is never used: "z"
Warn from this:
Code:
stock Get2DZoneFromCoordinates(Float:x, Float:y, Float:z, zone[], len = sizeof(zone))
{
    for(new i = 0; i != sizeof(gSAZones); i++ )
    {
        if(x >= gSAZones[i][SAZONE_AREA][0] && x <= gSAZones[i][SAZONE_AREA][3] && y >= gSAZones[i][SAZONE_AREA][1] && y <= gSAZones[i][SAZONE_AREA][4])
        {
            return format(zone, len, gSAZones[i][SAZONE_NAME], 0);
        }
    }
    return 0;
}
https://sampforum.blast.hk/showthread.php?tid=567255


Re: Warning Fix - Clarck - 12.03.2015

#pragma unused z


Re: Warning Fix - oliverrud - 12.03.2015

Quote:
Originally Posted by Clarck
View Post
#pragma unused z
That's pretty bad practice to do.

Best solution is to figure out if you actually need to use the z variable.
If not, then remove it from the script/function.
If you do, then ignore the warning until you actually have finished writing the code that actually utilizes the variable.

pawn Code:
stock Get2DZoneFromCoordinates(Float:x, Float:y, zone[], len = sizeof(zone))
{
    for(new i = 0; i != sizeof(gSAZones); i++ )
    {
        if(x >= gSAZones[i][SAZONE_AREA][0] && x <= gSAZones[i][SAZONE_AREA][3] && y >= gSAZones[i][SAZONE_AREA][1] && y <= gSAZones[i][SAZONE_AREA][4])
        {
            return format(zone, len, gSAZones[i][SAZONE_NAME], 0);
        }
    }
}
    return 0;
This would be the solution, if you aren't going to need the z variable, which you most likely wont considering its a 2D function.