SA-MP Forums Archive
Varible shown at a proceeding level - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Varible shown at a proceeding level (/showthread.php?tid=259496)



Varible shown at a proceeding level - Snowman12 - 04.06.2011

ok ive een somone fix this error yesterday but i didnt watch how he did it anyway today i got this error for the first time in scripting what do it do

warning 219: local variable "string" shadows a variable at a preceding level


Re: Varible shown at a proceeding level - Backwardsman97 - 04.06.2011

It means that you've declared a variable named 'string' earlier before that declaration. You can just remove the 2nd declaration. Example.

pawn Код:
public MyFunction(playerid)
{
    new string[128];
    /*
        CODE HERE
    */

    new string[128];
    /*
        MORE CODE
    */

    return 1;
}
Would give a warning. This however...

pawn Код:
public MyFunction(playerid)
{
    new string[128];
    /*
        CODE HERE
    */

    return 1;
}

public MyOtherFunction(playerid)
{
    new string[128];
    /*
        CODE HERE
    */

    return 1;
}
Would not. The variable 'string's scope is limited to that function. Unless, of course you made it global by declaring outside any function.


Re: Varible shown at a proceeding level - Snowman12 - 04.06.2011

Lol i have like 30 of these im going to the script now ive found one thanks mate


Re: Varible shown at a proceeding level - Snowman12 - 04.06.2011

mate you are the very very very very very very best found all of them now thanks for your help