shadows a variable
#1

Код:
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
Reply
#2

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

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

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)