SA-MP Forums Archive
warning 219: local variable "string" 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: warning 219: local variable "string" shadows a variable at a preceding level (/showthread.php?tid=583646)



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

PHP Code:
.pwn(25047) : warning 219: local variable "string" shadows a variable at a preceding level
.pwn(25064) : warning 219: local variable "string" shadows a variable at a preceding level
.pwn(25081) : warning 219: local variable "string" shadows a variable at a preceding level
.pwn(25098) : warning 219: local variable "string" shadows a variable at a preceding level
.pwn(25115) : warning 219: local variable "string" shadows a variable at a preceding level
.pwn(25132) : warning 219: local variable "string" shadows a variable at a preceding level 
PHP Code:
    if(dialogid == DIALOG_EX + 1)
    {
            if(
response)
            {
                if(
listitem == 0)
                {
                    new 
string[MAX_PLAYERS];
                    
//--------------------------------------------------------------
                    
if(Info[playerid][Harvest] == 1) return SendClientMessage(playerid, BRIGHT_RED, "You have been already started the harvest work.");
                    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) != 532) return SendClientMessage(playerid, BRIGHT_RED, "You must have enter the combine harvester [532].");
                    
//--------------------------------------------------------------
                    
SetPlayerCheckpoint(playerid, -484.5330, -1480.2612, 13.9457, 7);
                    
format(string, sizeof(string), "You must follow the red markers and you will recieve money.");
                    
SendClientMessage(playerid, LIME_GREEN, string);
                    
Info[playerid][Harvest] = 1;
                    
//--------------------------------------------------------------
                    
SetVehiclePos(GetPlayerVehicleID(playerid), -485.5200, -1449.1151, 15.7435);
                    
SetVehicleZAngle(GetPlayerVehicleID(playerid), 90);
                    
SetPlayerVirtualWorld(playerid, 0);
                    
SetPlayerInterior(playerid, 0);
                }
                if(
listitem == 1)
                {
                    new 
string[MAX_PLAYERS];
                    
//--------------------------------------------------------------
                    
if(Info[playerid][Pizzaboy] == 1) return SendClientMessage(playerid, BRIGHT_RED, "You have been already started the pizzaboy work.");
                    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) != 448) return SendClientMessage(playerid, BRIGHT_RED, "You must have enter the pizzaboy bike [448].");
                    
//--------------------------------------------------------------
                    
SetPlayerCheckpoint(playerid, 1231.7543, -1031.4081, 31.5527, 1);
                    
format(string, sizeof(string), "You must follow the red markers and you will recieve money.");
                    
SendClientMessage(playerid, LIME_GREEN, string);
                    
Info[playerid][Pizzaboy] = 1;
                    
//--------------------------------------------------------------
                    
SetVehiclePos(GetPlayerVehicleID(playerid), 2090.2952, -1796.7637, 12.9823);
                    
SetVehicleZAngle(GetPlayerVehicleID(playerid), 90);
                    
SetPlayerVirtualWorld(playerid, 0);
                    
SetPlayerInterior(playerid, 0);
                }
                if(
listitem == 2)
                {
                    new 
string[MAX_PLAYERS];
                    
//--------------------------------------------------------------
                    
if(Info[playerid][Sweeper] == 1) return SendClientMessage(playerid, BRIGHT_RED, "You have been already started the sweeper street work.");
                    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) != 574) return SendClientMessage(playerid, BRIGHT_RED, "You must have enter the sweeper [574].");
                    
//--------------------------------------------------------------
                    
SetPlayerCheckpoint(playerid, 1152.3113, -1643.7635, 13.5064, 2);
                    
format(string, sizeof(string), "You must follow the red markers and you will recieve money.");
                    
SendClientMessage(playerid, LIME_GREEN, string);
                    
Info[playerid][Sweeper] = 1;
                    
//--------------------------------------------------------------
                    
SetVehiclePos(GetPlayerVehicleID(playerid), 1192.9980, -1815.3284, 13.3070);
                    
SetVehicleZAngle(GetPlayerVehicleID(playerid), 0);
                    
SetPlayerVirtualWorld(playerid, 0);
                    
SetPlayerInterior(playerid, 0);
                }
                if(
listitem == 3)
                {
                    new 
string[MAX_PLAYERS];
                    
//--------------------------------------------------------------
                    
if(Info[playerid][Plumber1] == 1) return SendClientMessage(playerid, BRIGHT_RED, "You have been already started the plumber work.");
                    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) != 552) return SendClientMessage(playerid, BRIGHT_RED, "You must have enter the utility van [552].");
                    
//--------------------------------------------------------------
                    
SetPlayerCheckpoint(playerid, 923.2040, -1138.5660, 23.4273, 3);
                    
format(string, sizeof(string), "You must follow the red markers and you will recieve money.");
                    
SendClientMessage(playerid, LIME_GREEN, string);
                    
Info[playerid][Plumber1] = 1;
                    
//--------------------------------------------------------------
                    
SetVehiclePos(GetPlayerVehicleID(playerid), 1042.9666, -919.0737, 42.2275);
                    
SetVehicleZAngle(GetPlayerVehicleID(playerid), 0);
                    
SetPlayerVirtualWorld(playerid, 0);
                    
SetPlayerInterior(playerid, 0);
                }
                if(
listitem == 4)
                {
                    new 
string[MAX_PLAYERS];
                    
//--------------------------------------------------------------
                    
if(Info[playerid][Trash] == 1) return SendClientMessage(playerid, BRIGHT_RED, "You have been already started the trash master work.");
                    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) != 408) return SendClientMessage(playerid, BRIGHT_RED, "You must have enter the trashmaster [408].");
                    
//--------------------------------------------------------------
                    
SetPlayerCheckpoint(playerid, 1462.9373, -1492.9911, 14.0956, 4);
                    
format(string, sizeof(string), "You must follow the red markers and you will recieve money.");
                    
SendClientMessage(playerid, LIME_GREEN, string);
                    
Info[playerid][Trash] = 1;
                    
//--------------------------------------------------------------
                    
SetVehiclePos(GetPlayerVehicleID(playerid), 1622.3666, -1813.8547, 14.0602);
                    
SetVehicleZAngle(GetPlayerVehicleID(playerid), 180);
                    
SetPlayerVirtualWorld(playerid, 0);
                    
SetPlayerInterior(playerid, 0);
                }
                if(
listitem == 5)
                {
                    new 
string[MAX_PLAYERS];
                    
//--------------------------------------------------------------
                    
if(Info[playerid][Flight] == 1) return SendClientMessage(playerid, BRIGHT_RED, "You have been already started the flight (pilot) work.");
                    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) != 519) return SendClientMessage(playerid, BRIGHT_RED, "You must have enter the shamal [519].");
                    
//--------------------------------------------------------------
                    
SetPlayerCheckpoint(playerid, 1477.5029, 1787.5417, 11.7342, 10);
                    
format(string, sizeof(string), "You must follow the red markers and you will recieve money.");
                    
SendClientMessage(playerid, LIME_GREEN, string);
                    
Info[playerid][Flight] = 1;
                    
//--------------------------------------------------------------
                    
SetVehiclePos(GetPlayerVehicleID(playerid), 1521.8220, 1175.0295, 11.7344);
                    
SetVehicleZAngle(GetPlayerVehicleID(playerid), 0);
                    
SetPlayerVirtualWorld(playerid, 0);
                    
SetPlayerInterior(playerid, 0);
                }
            }
            return 
1;
        } 
Code:
all line :
new string[MAX_PLAYERS];



Re: warning 219: local variable "string" shadows a variable at a preceding level - SpikeSpigel - 29.07.2015

If I'm not wrong it's MAX_PLAYER, not MAX_PLAYERS


Re: warning 219: local variable "string" shadows a variable at a preceding level - s3ek - 29.07.2015

Quote:
Originally Posted by SpikeSpigel
View Post
If I'm not wrong it's MAX_PLAYER, not MAX_PLAYERS
wrong :/


Re: warning 219: local variable "string" shadows a variable at a preceding level - Dragonic - 29.07.2015

It shows that message when you'r already using a "string", try to rename it to like "string2" for an example and you should be fine!


Re: warning 219: local variable "string" shadows a variable at a preceding level - Vince - 29.07.2015

  1. Why are you using format if there's nothing to format? What a waste of resources. Just send a client message.
  2. There are places where MAX_PLAYERS is to be used, this is not one of them. The maximum chat output is 144 characters (cells) while MAX_PLAYERS is by default defined as being 1000 cells. Way over the top.



Re: warning 219: local variable "string" shadows a variable at a preceding level - s3ek - 29.07.2015

solved/ thanks guys +1
Dragonic + Vince