Help with this warning please !
#1

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;
            }
Reply
#2

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.
Reply
#3

You already got defined the string

remove
Код:
new string[128];
Reply
#4

Thanks you both ! , +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)