I need help with this
#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_YELLOW, "There are multiple users, enter full playername.");
            else SendClientMessage(playerid, COLOR_RED, "Playername not found.");
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}

Stick this at the bottom if the script.
Reply


Messages In This Thread
I need help with this - by Ironboy - 24.12.2010, 08:49
Re: I need help with this - by <Weponz> - 24.12.2010, 09:15
Re: I need help with this - by Kaylux - 24.12.2010, 11:55
Re: I need help with this - by Ironboy - 24.12.2010, 12:01

Forum Jump:


Users browsing this thread: 1 Guest(s)