local variable "Name" shadows a variable at a preceding level
#1

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

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.
Reply
#3

pawn Код:
stock GetName(playerid)
{
    new retName[MAX_PLAYER_NAME] = "Disconnected/Nothing";
    if(IsPlayerConnected(playerid)) GetPlayerName(playerid, retName, sizeof(retName));
    return retName;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)