warning 219: local variable "string" shadows a variable at a preceding level
#1

Hi guys, I just attached a roadblock system to my gamemode (credits to Michael@Belgium)

However, I have 128 WARNINGS of this = warning 219: local variable "string" shadows a variable at a preceding level

Here's the code.

Quote:
Код:
dcmd_roadblock(playerid,params[])
{
	new number, atrb = atblock[playerid];
	if(gTeam[playerid] == CIVILIAN)
	{
		SendClientMessage(playerid,COLOR_RED,"[ERROR] Only Law Enforcement and Medics can use this!");
		return 1;
	}
	if(sscanf(params,"d",number))
	{
		SendClientMessage(playerid,COLOR_BLUE,"USAGE: /roadblock <1/2/3/4/5/6/7>");
		SendClientMessage(playerid,COLOR_BLUE,"| 1: Small Roadblock");
		SendClientMessage(playerid,COLOR_BLUE,"| 2: Medium Roadblock");
		SendClientMessage(playerid,COLOR_BLUE,"| 3: Big Roadblock");
		SendClientMessage(playerid,COLOR_BLUE,"| 4: Traffic cone");
		SendClientMessage(playerid,COLOR_BLUE,"| 5: Detour sign");
		SendClientMessage(playerid,COLOR_BLUE,"| 6: Will be sign");
		SendClientMessage(playerid,COLOR_BLUE,"| 7: Line closed sign");
		SendClientMessage(playerid,COLOR_WHITE,"----------------------");
		format(string, sizeof string,"The roadblock will expire after %i minutes, or use /deleteall",EXPIRE_MINUTES);
		SendClientMessage(playerid,COLOR_BLUE,string);
		return 1;
	}

	switch(number)
	{
		case 1:
		{
			new Float:X, Float:Y, Float:Z, Float:A;
			GetPlayerPos(playerid, X, Y, Z);
			GetPlayerFacingAngle(playerid, A);
			if(atblock[playerid] < MAX_ROADBLOCKS)
			{
				block[atrb][playerid] = CreateObject(1459, X, Y+1, Z-0.5,0,0,A);
				GameTextForPlayer(playerid,"~w~Roadblock ~b~Placed!",3000,1);
				#if SEND == true
				GetPlayerName(playerid,pName,32);
				format(string,sizeof (string)," %s added a roadblock(%i).",pName,number);
				SendClientMessageToAll(COLOR_GREEN, string);
				#else
					SetTimerEx("ExpireRoadblock", EXPIRE_MINUTES*60000, false, "i", block[atrb][playerid]);
				atblock[playerid] += 1;
				#endif
				} else {
				format(string,sizeof string,"You cannot place more then %i Roadblocks!",MAX_ROADBLOCKS);
				SendClientMessage(playerid, COLOR_RED, string);
			}
			return 1;
		}


		case 2:
		{
			new Float:X, Float:Y, Float:Z, Float:A;
			GetPlayerPos(playerid, X, Y, Z);
			GetPlayerFacingAngle(playerid, A);
			if(atblock[playerid] < MAX_ROADBLOCKS)
			{
				block[atrb][playerid] = CreateObject(978, X, Y+1, Z,0,0,A);
				GameTextForPlayer(playerid,"~w~Roadblock ~b~Placed!",3000,1);
				#if SEND == true
				GetPlayerName(playerid,pName,32);
				format(string,sizeof string,"%s added a roadblock(%i).",pName,number);
				SendClientMessageToAll(COLOR_GREEN, string);
				#else
					SetTimerEx("ExpireRoadblock", EXPIRE_MINUTES*60000, false, "i", block[atrb][playerid]);
				atblock[playerid] += 1;
				#endif
				} else {
				format(string,sizeof string,"You cannot place more then %i Roadblocks!",MAX_ROADBLOCKS);
				SendClientMessage(playerid, COLOR_RED, string);
			}
			return 1;
		}

		case 3:
		{
			new Float:X, Float:Y, Float:Z, Float:A;
			GetPlayerPos(playerid, X, Y, Z);
			GetPlayerFacingAngle(playerid, A);
			if(atblock[playerid] < MAX_ROADBLOCKS)
			{
				block[atrb][playerid] = CreateObject(981, X, Y+1, Z,0,0,A);
				GameTextForPlayer(playerid,"~w~Roadblock ~b~Placed!",3000,1);
				#if SEND == true
				GetPlayerName(playerid,pName,32);
				format(string,sizeof string," %s added a roadblock(%i).",pName,number);
				SendClientMessageToAll(COLOR_GREEN,string);
				#else
					SetTimerEx("ExpireRoadblock", EXPIRE_MINUTES*60000, false, "i", block[atrb][playerid]);
				atblock[playerid] += 1;
				#endif
				} else {
				format(string,sizeof string,"You cannot place more then %i Roadblocks!",MAX_ROADBLOCKS);
				SendClientMessage(playerid, COLOR_RED, string);
			}
			return 1;
		}

		case 4:
		{
			new Float:X, Float:Y, Float:Z, Float:A;
			GetPlayerPos(playerid, X, Y, Z);
			GetPlayerFacingAngle(playerid, A);
			if(atblock[playerid] < MAX_ROADBLOCKS)
			{
				block[atrb][playerid] = CreateObject(1238, X, Y+1, Z-0.5, 0, 0.0,A);
				GameTextForPlayer(playerid,"~w~Cone ~b~Placed!",3000,1);
				#if SEND == true
				GetPlayerName(playerid,pName,32);
				format(string,sizeof string," %s added a roadblock(%i).",pName,number);
				SendClientMessageToAll(COLOR_GREEN, string);
				#else
					SetTimerEx("ExpireRoadblock", EXPIRE_MINUTES*60000, false, "i", block[atrb][playerid]);
				atblock[playerid] += 1;
				#endif
				} else {
				format(string,sizeof string,"You cannot place more then %i Roadblocks!",MAX_ROADBLOCKS);
				SendClientMessage(playerid, COLOR_RED, string);
			}
			return 1;
		}

		case 5:
		{
			new Float:X, Float:Y, Float:Z, Float:A;
			GetPlayerPos(playerid, X, Y, Z);
			GetPlayerFacingAngle(playerid, A);
			if(atblock[playerid] < MAX_ROADBLOCKS)
			{
				block[atrb][playerid] = CreateObject(1425, X, Y+1, Z-0.5, 0, 0.0,A,300);
				GameTextForPlayer(playerid,"~w~Sign ~b~Placed!",3000,1);
				#if SEND == true
				GetPlayerName(playerid,pName,32);
				format(string,sizeof string," %s added a roadblock(%i).",pName,number);
				SendClientMessageToAll(COLOR_GREEN, string);
				#else
					SetTimerEx("ExpireRoadblock", EXPIRE_MINUTES*60000, false, "i", block[atrb][playerid]);
				atblock[playerid] += 1;
				#endif
				} else {
				format(string,sizeof string,"You cannot place more then %i Roadblocks!",MAX_ROADBLOCKS);
				SendClientMessage(playerid, COLOR_RED, string);
			}
			return 1;
		}

		case 6:
		{
			new Float:X, Float:Y, Float:Z, Float:A;
			GetPlayerPos(playerid, X, Y, Z);
			GetPlayerFacingAngle(playerid, A);
			if(atblock[playerid] < MAX_ROADBLOCKS)
			{
				block[atrb][playerid] = CreateObject(3265, X, Y+1, Z-0.9, 0, 0.0,A);
				GameTextForPlayer(playerid,"~w~Sign ~b~Placed!",3000,1);
				#if SEND == true
				GetPlayerName(playerid,pName,32);
				format(string,sizeof string," %s added a roadblock(%i).",pName,number);
				SendClientMessageToAll(COLOR_GREEN, string);
				#else
					SetTimerEx("ExpireRoadblock", EXPIRE_MINUTES*60000, false, "i", block[atrb][playerid]);
				atblock[playerid] += 1;
				#endif
				} else {
				format(string,sizeof string,"You cannot place more then %i Roadblocks!",MAX_ROADBLOCKS);
				SendClientMessage(playerid, COLOR_RED, string);
			}
			return 1;
		}

		case 7:
		{
			new Float:X, Float:Y, Float:Z, Float:A;
			GetPlayerPos(playerid, X, Y, Z);
			GetPlayerFacingAngle(playerid, A);
			if(atblock[playerid] < MAX_ROADBLOCKS)
			{
				block[atrb][playerid] = CreateObject(3091, X, Y+1, Z-0.25, 0, 0.0,A);
				GameTextForPlayer(playerid,"~w~Sign ~b~Placed!",3000,1);
				#if SEND == true
				GetPlayerName(playerid,pName,32);
				format(string,sizeof string," %s added a roadblock(%i).",pName,number);
				SendClientMessageToAll(COLOR_GREEN, string);
				#else
					SetTimerEx("ExpireRoadblock",EXPIRE_MINUTES*60000, false, "i", block[atrb][playerid]);
				atblock[playerid] += 1;
				#endif
				} else {
				format(string,sizeof string,"You cannot place more then %i Roadblocks!",MAX_ROADBLOCKS);
				SendClientMessage(playerid, COLOR_RED, string);
			}
			return 1;
		}
	}
	return 1;
}
I have one question, what will happen if I ignore those warnings?

Btw, hope you guys can help me to fix this, thanks.
Reply
#2

try str[128] insteed of string
Reply
#3

Do you mean str2[128]?
Reply
#4

And after that what do I do.. please answer, bump
Reply
#5

****** what the warning means, and you'll quickly know how to fix it.
Reply
#6

http://*******/12cC4eO
Reply
#7

Okay, now they show errors.

I changed to str2[128] btw.

pawn Код:
format(str2, sizeof string,"The roadblock will expire after %i minutes, or use /deleteall",EXPIRE_MINUTES);
error 017: undefined symbol "string"
Reply
#8

Код:
format(str2, sizeof(str2),"The roadblock will expire after %i minutes, or use /deleteall",EXPIRE_MINUTES);
Reply
#9

Whoa, thanks alot... I try to fix these warnings like 2 hours.. now I'm starving for KFC, +rep given to you dominik, and also thanks to others
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)