Advertisement
Guest User

Untitled

a guest
Apr 11th, 2012
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.04 KB | None | 0 0
  1. ReturnUser(text[], playerid = INVALID_PLAYER_ID)
  2. {
  3.     new pos = 0;
  4.     while (text[pos] < 0x21)
  5.     {
  6.         if (text[pos] == 0) return INVALID_PLAYER_ID;
  7.         pos++;
  8.     }
  9.     new userid = INVALID_PLAYER_ID;
  10.     if (IsNumeric(text[pos]))
  11.     {
  12.         userid = strval(text[pos]);
  13.         if (userid >=0 && userid < MAX_PLAYERS)
  14.         {
  15.             if(!IsPlayerConnected(userid)) { userid = INVALID_PLAYER_ID; }
  16.             else { return userid; }
  17.         }
  18.     }
  19.     new len = strlen(text[pos]);
  20.     new count = 0;
  21.     new name[MAX_PLAYER_NAME];
  22.     for (new i = 0; i < MAX_PLAYERS; i++)
  23.     {
  24.         if (IsPlayerConnected(i))
  25.         {
  26.             GetPlayerName(i, name, sizeof (name));
  27.             if (strcmp(name, text[pos], true, len) == 0)
  28.             {
  29.                 if (len == strlen(name)) { return i; }
  30.                 else { count++; userid = i; }
  31.             }
  32.         }
  33.     }
  34.     if (count != 1)
  35.     {
  36.         if (playerid != INVALID_PLAYER_ID)
  37.         {
  38.             if (count) { SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow earch"); }
  39.             else { SendClientMessage(playerid, 0xFF0000AA, "No matching user found"); }
  40.         }
  41.         userid = INVALID_PLAYER_ID;
  42.     }
  43.     return userid;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement