SA-MP Forums Archive
[2 warnings] /hidenames - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [2 warnings] /hidenames (/showthread.php?tid=88831)



[2 warnings] /hidenames - Antonio [G-RP] - 29.07.2009

Hi, I recently made this code for a more roleplay experience, but I get 2 god damn warnings!

Код:
if(strcmp(cmd, "/hidenames", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] == 6)
{
new string[256];
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "AdmCmd: %s has disabled all player name tags!",playername);
SendClientMessageToAll(COLOR_YELLOW, string);
ShowNameTags( 0 );
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, " You are not authorised to use this command!");
return 1;
}
}
WARNINGS:
Код:
C:\Users\Lachlan\Desktop\Hosting Server\pawno\iGRP.pwn(9526) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Lachlan\Desktop\Hosting Server\pawno\iGRP.pwn(9527) : warning 219: local variable "playername" shadows a variable at a preceding level
Some help would be greatly appreciated


Re: [2 warnings] /hidenames - Daren_Jacobson - 29.07.2009

rename the variables you are using to something else, like this

pawn Код:
if(strcmp(cmd, "/hidenames", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] == 6)
{
new stringofdoom[256];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(stringofdoom, sizeof(stringofdoom), "AdmCmd: %s has disabled all player name tags!",playername3);
SendClientMessageToAll(COLOR_YELLOW, stringofdoom);
ShowNameTags( 0 );
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, " You are not authorised to use this command!");
return 1;
}
}



Re: [2 warnings] /hidenames - Antonio [G-RP] - 29.07.2009

It worked! Thanks man