GetPlayerIDFromName Problem
#1

pawn Код:
stock GetPlayerIDFromName(playername[])
{
    foreach(Player,i)
    {
        if(IsPlayerConnected(i))
        {
            if(strcmp(GetName(i), playername, false) == 0)
            {
                return i;
            }
        }
    }
    return -1;
}
pawn Код:
stock GetName(playerid)
{
    GetPlayerName(playerid,pName[playerid],24);
    return pName[playerid];
}
pawn Код:
if(GetPlayerIDFromName(inputtext) > -1) return SCM(playerid,red,"ERROR: This person is already connected in the server.");
So I wanted to wire transfer money to someone, his name was [xG]Max_Vido, he was also in the server. When i put [xG]Max_Vido, it shows he's in the server (thats good), but if i put [xg]max_vido, it takes me to my next dialog.
Reply
#2

You can have two players with the same name, once some case is different, thus [xG]Max_Vido and [xg]max_vido. If you want them to appear as the same, change ignorecase to true in the strcmp function you use to do the check.
Reply
#3

I see you're already using foreach (don't know what the useless IsPlayerConnected check is for, though), so why not use sscanf as well? You know it has the functionality to do this, right?
Reply
#4

Problem already fixed, what you mean also use sscanf? I use sscanf for commands.
Reply
#5

Sscanf is not meant to be solely used in commands. I don't know why so many people presume it is. Sscanf is a string splitting routine and can be used anywhere. Read the sscanf thread and check out the 'u' or 'r' parameter.
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
Sscanf is not meant to be solely used in commands. I don't know why so many people presume it is. Sscanf is a string splitting routine and can be used anywhere. Read the sscanf thread and check out the 'u' or 'r' parameter.
Thanks for telling me, i really never paid attention because i just download sscanf.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)