shadows a variable - 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: shadows a variable (
/showthread.php?tid=662197)
shadows a variable -
enzulikeS - 25.12.2018
Код:
CMD:vipwwheels(playerid, params[])
{
if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to log in first.");
if(!IsPlayerInAnyVehicle(playerid)) return SS(playerid, COLOR_LIGHTGREEN3, "Nu esti intr-un vehicul!", "You are not in a vehicle!");
new carid = GetPlayerVehicleID(playerid),idcar=-1;
for(new vv; vv < MAX_PERSONAL_VEHICLES; vv++)
{
if(carid == PlayerInfo[playerid][pCarID][vv])
{
idcar = vv;
}
}
if(idcar == -1) return SS(playerid, COLOR_LIGHTGREEN3, "Poti folosi aceasta comanda doar pe vehicule VIP.", "You can add custom wheels on VIP vehicles.");
if(IsPlayerConnected(playerid))
{
new wheels;
if(sscanf(params, "v",wheels)) return SendClientMessage(playerid, COLOR_GREY, "Syntax: /vipwheels <dollar> <trance> <x>");
switch(wheels)
{
case 1: AddVehicleComponent(GetPlayerVehicleID(playerid), 1080); CarMod[playerid][idcar][15] = 1080;
}
}
return 1;
}
D:\server\gamemodes\ExtremeGame.pwn(40907) : warning 219: local variable "wheels" shadows a variable at a preceding level
D:\server\gamemodes\ExtremeGame.pwn(40911) : error 002: only a single statement (or expression) can follow each "case"
D:\server\gamemodes\ExtremeGame.pwn(40911) : error 029: invalid expression, assumed zero
D:\server\gamemodes\ExtremeGame.pwn(40911) : warning 215: expression has no effect
D:\server\gamemodes\ExtremeGame.pwn(40911) : error 001: expected token: ";", but found "]"
D:\server\gamemodes\ExtremeGame.pwn(40911) : fatal error 107: too many error messages on one line
lines of errors marked with red
Re: shadows a variable -
NaS - 25.12.2018
The shadowing is probably just a warning that results of your actual error.
That error tells you pretty clearly what you did wrong - you placed multiple statements after a case label.
Quote:
error 002: only a single statement (or expression) can follow each "case"
|
You need to use brackets {} after a case if you want to place multiple statements into it.
Re: shadows a variable -
RogueDrifter - 25.12.2018
What NaS said, also, the whole 'shadows a variable at a preceding level' warnings is all in regards for a multiple use of a variable with the same name globally and locally.
Re: shadows a variable -
enzulikeS - 25.12.2018
error 002: only a single statement (or expression) can follow each "case"
this one was fixed, but the shadowing is still here
FIXED, ty u both guys