SA-MP Forums Archive
Help with this warning please ! - 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: Help with this warning please ! (/showthread.php?tid=650534)



Help with this warning please ![Solved] - Blackaslan - 01.03.2018

Quote:

C:\x.pwn(29799) : warning 219: local variable "string" shadows a variable at a preceding level
Код:
else if(strcmp(params[0],"auto",true) == 0)
                    {
                    if(Ganzuas[playerid] == 0) return SendClientMessageEx(playerid, COLOR_WHITE, "No tienes alambres.");
                    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessageEx(playerid, COLOR_WHITE, "{FFFF00}[ERROR]:{FFFFFF} No eres el conductor.");
                    if(IsPlayerInAnyVehicle(playerid))
                   {
                   new string[128]; /// Line: 29799
                  new engine,lights,alarm,doors,bonnet,boot,objective,vehicleid;
                  vehicleid = GetPlayerVehicleID(playerid);
                  GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
                  if(engine == VEHICLE_PARAMS_OFF)
                  format(string, sizeof(string), "* %s toma unos alambres de su bolsillo y los introduce en el tambor.", GetPlayerNameEx(playerid));
                  ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                  format(string, sizeof(string), "* %s hace fuerza con las manos y gira los alambres del tambor.", GetPlayerNameEx(playerid));
                  ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                  format(string, sizeof(string), "* %s comienza a robar el vehнculo.", GetPlayerNameEx(playerid));
                  ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                  GameTextForPlayer(playerid, "~p~Robando vehiculo",10000,3);
                  SetTimerEx("SetVehicleEngine", 10000, 0, "dd", vehicleid, playerid);
                  }
               else SendClientMessageEx(playerid, COLOR_WHITE, "No estбs en un vehнculo.");
                return 1;
            }



Re: Help with this warning please ! - AdamsLT - 01.03.2018

Instead of new string[128];
Try something like new _string[128]; or new TempString[128]; or something else.
Then replace everywhere where you used string with your new variable name.

This warning is telling you that you have another variable with the same name in the same scope and problems may occur.


Re: Help with this warning please ! - Davidmkd123 - 01.03.2018

You already got defined the string

remove
Код:
new string[128];



Re: Help with this warning please ! - Blackaslan - 01.03.2018

Thanks you both ! , +rep