SA-MP Forums Archive
Help warning - 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 warning (/showthread.php?tid=569124)



Help warning - KingPersona - 28.03.2015

hello

i have problem , i get warning in this command , i added this define :
Код:
static VehicleID[MAX_PLAYERS];
about crasher, and i get warn in this cmd , /fvr, i don't get warning in this cmd before.


warning
Код:
warning 219: local variable "VehicleID" shadows a variable at a preceding level
Line :
Код:
new VehicleID = GetPlayerVehicleID(playerid);
full code
pawn Код:
CMD:fv(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_BLUE, "You are not in a vehicle");
    {
        if(playerVariables[playerid][pAdminLevel] >= 1)
        {
            new VehicleID = GetPlayerVehicleID(playerid);
            RepairVehicle(VehicleID);
            SendClientMessage(playerid, COLOR_BLUE, "Vehicle repaired succesfull!");
        }
        else return SendClientMessage(playerid, COLOR_WHITE, AdminOnly);
    }
     return 1;
}



Re: Help warning - Konstantinos - 28.03.2015

You declared it globally as an array and then you declare it again (the same variable name) in the command as an integer.

If you do not want to store it anywhere, just use it directly:
pawn Код:
RepairVehicle(GetPlayerVehicleID(playerid));
and remove the rest.


Re: Help warning - KingPersona - 28.03.2015

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You declared it globally as an array and then you declare it again (the same variable name) in the command as an integer.

If you do not want to store it anywhere, just use it directly:
pawn Код:
RepairVehicle(GetPlayerVehicleID(playerid));
and remove the rest.
Thanks bro for help.


Re: Help warning - Luca12 - 28.03.2015

That warning means that you have twice the same defined VehicleID put one vehicleid and the other VehicleID and it will work

static VehicleID[MAX_PLAYERS]; new VehicleID = GetPlayerVehicleID(playerid); // this you have defined beacuse of that you get warning warning 219: local variable "VehicleID" shadows a variable at a preceding level


Re: Help warning - KingPersona - 28.03.2015

Quote:
Originally Posted by Luca12
Посмотреть сообщение
That warning means that you have twice the same defined VehicleID put one vehicleid and the other VehicleID and it will work

static VehicleID[MAX_PLAYERS]; new VehicleID = GetPlayerVehicleID(playerid); // this you have defined beacuse of that you get warning warning 219: local variable "VehicleID" shadows a variable at a preceding level
Thanks bro for help.