ReturnUser.
#3

pawn Код:
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
    new pos = 0;
    while (text[pos] < 0x21)
    {
        if (text[pos] == 0) return INVALID_PLAYER_ID;
        pos++;
    }

    new userid = INVALID_PLAYER_ID;
    if (IsNumeric(text[pos]))
    {
        userid = strval(text[pos]);
        if (userid >=0 && userid < MAX_PLAYERS)
        {
            if(!IsPlayerConnected(userid))
            userid = INVALID_PLAYER_ID;
            else return userid;
        }
    }

    new len = strlen(text[pos]);
    new count = 0;
    new pname[MAX_PLAYER_NAME];

    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, pname, sizeof (pname));
            if (strcmp(pname, text[pos], true, len) == 0)
            {
                if (len == strlen(pname)) return i;
                else
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
   
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count) SendClientMessage(playerid, COLOR_WHITE, "Enter the full name of the user.");
            else SendClientMessage(playerid, COLOR_GREY, "No results found for the specified phrase.");
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}
Reply


Messages In This Thread
ReturnUser. - by TheSy - 23.05.2014, 21:14
Re: ReturnUser. - by Jefff - 24.05.2014, 00:12
Re: ReturnUser. - by DerickClark - 24.05.2014, 00:35
Re: ReturnUser. - by TheSy - 24.05.2014, 11:49
Re: ReturnUser. - by SKAzini - 24.05.2014, 13:14
Re: ReturnUser. - by TheSy - 24.05.2014, 13:34
Re: ReturnUser. - by RajatPawar - 24.05.2014, 13:36
Re: ReturnUser. - by TheSy - 24.05.2014, 13:39
Re: ReturnUser. - by SKAzini - 24.05.2014, 13:44
Re: ReturnUser. - by TheSy - 24.05.2014, 14:03

Forum Jump:


Users browsing this thread: 1 Guest(s)