[2 warnings] /hidenames
#1

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
Reply
#2

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;
}
}
Reply
#3

It worked! Thanks man
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)