local variable "Name" shadows a variable at a preceding level - 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)
+--- Thread: local variable "Name" shadows a variable at a preceding level (
/showthread.php?tid=330744)
local variable "Name" shadows a variable at a preceding level -
Meinstad - 02.04.2012
Hello I got a little problem with my script...
pawn Код:
local variable "Name" shadows a variable at a preceding level
and this is what I got on the error line:
pawn Код:
stock GetName(playerid)
{
new Name[MAX_PLAYER_NAME];
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, Name, sizeof(Name));
}
else
{
Name = "Disconnected/Nothing";
}
return Name;
}
Re: local variable "Name" shadows a variable at a preceding level -
antonio112 - 02.04.2012
Change Name to pName or anything else, like:
pawn Код:
stock GetName(playerid)
{
new pName[MAX_PLAYER_NAME];
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, pName, sizeof(pName));
}
else
{
pName = "Disconnected/Nothing";
}
return pName;
}
That should work.
Re: local variable "Name" shadows a variable at a preceding level -
MP2 - 02.04.2012
pawn Код:
stock GetName(playerid)
{
new retName[MAX_PLAYER_NAME] = "Disconnected/Nothing";
if(IsPlayerConnected(playerid)) GetPlayerName(playerid, retName, sizeof(retName));
return retName;
}