17.08.2013, 05:45
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.
I have one question, what will happen if I ignore those warnings?
Btw, hope you guys can help me to fix this, thanks.
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;
}
|
Btw, hope you guys can help me to fix this, thanks.

