Jay_

/getid

Jan 11th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.01 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. public OnPlayerCommandText(playerid, cmdtext[])
  4. {
  5.     if(!strcmp(cmdtext, "/getid", true, 6))
  6.     {
  7.         new
  8.             foundNamesString[128];
  9.  
  10.         // Can't remember if this compiles in PAWN, might need to use format
  11.         //  new params[] = cmdtext[6];
  12.         new params[128];
  13.         format(params, sizeof(params), "%s", cmdtext[7]);
  14.  
  15.         if(!(3 < strlen(params) < MAX_PLAYER_NAME)) {
  16.             SendClientMessage(playerid, -1,"Use /getid [name]. Search length must be greater than 3.");
  17.             return 1;
  18.         }
  19.        
  20.         SendClientMessage(playerid, -1, "Results:");
  21.  
  22.         for(new i = 0; i < 200; i++) {
  23.             if(!IsPlayerConnected(i) || IsPlayerNPC(i)) {
  24.                 continue;
  25.             }
  26.             new name[24];
  27.             GetPlayerName(i,name,24);
  28.             if(strfind(params, name, true) == -1) {
  29.                 continue;
  30.             }
  31.             format(foundNamesString, sizeof(foundNamesString), "%s (ID:%i)",name, i);
  32.             SendClientMessage(playerid, -1, foundNamesString);
  33.         }
  34.         if(!strlen(foundNamesString)) {
  35.             SendClientMessage(playerid, -1, "No match found.");
  36.         }
  37.         return 1;
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment