PDA

View Full Version : Help with this warning please !


Blackaslan
01/03/2018, 09:24 PM
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,ve hicleid;
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,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_PURPL E,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_PURPL E,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_PURPL E,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;
}

AdamsLT
01/03/2018, 09:26 PM
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.

Davidmkd123
01/03/2018, 09:26 PM
You already got defined the string

remove new string[128];

Blackaslan
01/03/2018, 10:16 PM
Thanks you both ! , +rep :)