SA-MP Forums Archive
local variable shadows a variable at a preceding 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)
+--- Thread: local variable shadows a variable at a preceding level (/showthread.php?tid=633864)



local variable shadows a variable at a preceding level - NBass - 08.05.2017

Hello,
i'm getting a warning "local variable "OnDutyPD" shadows a variable at a preceding level".

Global:
PHP код:
new OnDutyPD[MAX_PLAYERS] = 1
Function:
PHP код:
SendMessageToCopsBackup(OnDutyPD,Float:xbackFloat:ybackFloat:zback,COLOR,msg); 
PHP код:
stock SendMessageToCopsBackup(OnDutyPD,Float:xbackFloat:ybackFloat:zback,color,text[]) // This line i'm getting a warning
{
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
playerDB[i][job]==1)
            {
                if(
OnDutyPD[i]==1)
                   {
                    
SendClientMessage(i,color,text);
                    
SetPlayerCheckpoint(ixbackybackzback3.0);
                    return 
1;
                }
            }    
        }
    }

Thanks a Lot.


Re: local variable shadows a variable at a preceding level - DRIFT_HUNTER - 08.05.2017

You probably have OnDutyPD as a global variable or maybe as enumerator name/element...


Re: local variable shadows a variable at a preceding level - NBass - 08.05.2017

Yes,
Quote:

new OnDutyPD[MAX_PLAYERS] = 1;




Re: local variable shadows a variable at a preceding level - AjaxM - 08.05.2017

Try this.

PHP код:
stock SendMessageToCopsBackup(Float:xbackFloat:ybackFloat:zback,color,text[]) // This line i'm getting a warning 

    for(new 
i=0i<MAX_PLAYERSi++) 
    { 
        if(
IsPlayerConnected(i)) 
        { 
            if(
playerDB[i][job]==1
            { 
                if(
OnDutyPD[i]==1
                   { 
                    
SendClientMessage(i,color,text); 
                    
SetPlayerCheckpoint(ixbackybackzback3.0); 
                    return 
1
                } 
            }     
        } 
    } 




Re: local variable shadows a variable at a preceding level - NBass - 08.05.2017

Thanks, but getting a:
Quote:

undefined symbol "OnDutyPD"

on:
PHP код:
if(OnDutyPD[i]==1// THIS LINE
{
       
SendClientMessage(i,color,text);
       
SetPlayerCheckpoint(ixbackybackzback3.0);
       return 
1;




Re: local variable shadows a variable at a preceding level - Oelhins - 08.05.2017

On Global
Quote:

new OnDutyPD[MAX_PLAYERS] = 1;




Re: local variable shadows a variable at a preceding level - NBass - 08.05.2017

I'm already have under Global defined.