SA-MP Forums Archive
"string" shadows a variable... - 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: "string" shadows a variable... (/showthread.php?tid=400014)



"string" shadows a variable... - Racer99 - 16.12.2012

ERROR:

PHP код:
C:\Users\----\Desktop\Programs\NIS\SERVER\SERVER\filterscripts\LuxAdmin.pwn(593) : warning 219local variable "string" shadows a variable at a preceding level 
Script:

PHP код:
    if(AccInfo[playerid][Level] > 1)
    {
    new 
pname[MAX_PLAYER_NAME], string[100 MAX_PLAYER_NAME];
    {
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(stringsizeof(string), "{0xFFFFFFAA}Administrator {05B1F5}%s{FFFFFF} has joined the server."pname);
    
SendClientMessageToAll(0xFFFFFFAAstring);
    return 
0;
    }
    }
    if(
ServerInfo[ConnectMessages] == 1)
    {
        if(
AccInfo[playerid][Level] > 1)
    {
           new 
pAKA[256];
         
pAKA dini_Get("LuxAdmin/Config/aka.txt",tmp3);
        if (
strlen(pAKA) < 3)
        
format(str,sizeof(str),"*{0xFFFFFFAA}Administrator {007fff}%s {00007f}(Id:%d){FFFFFF}) has joined the server"PlayerName,playerid);
        for(new 
0MAX_PLAYERSi++)
        if(
IsPlayerConnected(i) && playerid != i)
    {
        if(
AccInfo[playerid][Level] > 1)
        
SendClientMessage(i,grey,str);
        else
        {
        
format(string,sizeof(string),"* {0xFFFFFFAA}Administrator {007fff}%s {00007f}(Id:%d){FFFFFF} has joined the server"PlayerNameplayerid);
         
SendClientMessage(i,grey,string);
        }
        }
        }
        } 



Re: "string" shadows a variable... - dr.lozer - 16.12.2012

you made two like this

pawn Код:
new string[128];
remove one


Re: "string" shadows a variable... - Mean - 16.12.2012

this line:
pawn Код:
new pname[MAX_PLAYER_NAME], string[100 + MAX_PLAYER_NAME];
should be
pawn Код:
new pname[MAX_PLAYER_NAME];
You already have string defined somewhere so you don't need it there.


Re: "string" shadows a variable... - Racer99 - 17.12.2012

Quote:
Originally Posted by Mean
Посмотреть сообщение
this line:
pawn Код:
new pname[MAX_PLAYER_NAME], string[100 + MAX_PLAYER_NAME];
should be
pawn Код:
new pname[MAX_PLAYER_NAME];
You already have string defined somewhere so you don't need it there.
Am getting these errors now:
Код:
C:\Users\----\Desktop\Programs\NIS\SERVER\SERVER\filterscripts\LuxAdmin.pwn(4636) : error 033: array must be indexed (variable "AccInfo")
C:\Users\----\Desktop\Programs\NIS\SERVER\SERVER\filterscripts\LuxAdmin.pwn(4638) : error 033: array must be indexed (variable "AccInfo")
C:\Users\----\Desktop\Programs\NIS\SERVER\SERVER\filterscripts\LuxAdmin.pwn(4641) : error 033: array must be indexed (variable "AccInfo")
C:\Users\----\Desktop\Programs\NIS\SERVER\SERVER\filterscripts\LuxAdmin.pwn(4643) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Lines:
Код:
dcmd_tg(playerid,params[])
{
    #pragma unused params
	if(AccInfo[playerid] == true)
	{
	    AccInfo[playerid] = false;
		return SendClientMessage(playerid,yellow,"|- You have disabled /goto, no one can teleport to you now -|");
	}
	else if(AccInfo[playerid] == false)
	{
	    AccInfo[playerid] = true;
		return SendClientMessage(playerid, yellow, "|- You have enabled /goto, anyone can teleport to you now -|");
	}
	return 1;
}



Re: "string" shadows a variable... - Buzzbomb - 17.12.2012

Show More Code


Re: "string" shadows a variable... - Racer99 - 17.12.2012

Which code lines do you want me too show?


Re: "string" shadows a variable... - Konstantinos - 17.12.2012

It's
pawn Код:
if(AccInfo[playerid][/* something_here about toggling goto (from your enum) */] == true)
{
    //code;
}
else if(AccInfo[playerid][/* something_here about toggling goto (from your enum) */] == false)
{
    //code;
}