RaFaeLs

multi Private messages (v0.3) - RaFaeL

Sep 30th, 2012
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.88 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dutils>
  3. #include <sscanf2>
  4.  
  5. #pragma unused ret_memcpy
  6. #define SendClientFormat(%0,%1,%2,%3,%4) format(%2,sizeof(%2),%3,%4), SendClientMessage(%0,%1,%2)
  7.  
  8. /*
  9.     * Don't remove the credits!
  10.     ** Filter Script by RaFaeL - Multi private messages
  11.     *** Version: 0.3 [BETA]
  12.     **** Bags to: [email protected] - Thanks!
  13. */
  14.  
  15. public OnFilterScriptInit()
  16. {
  17.     print("[RaFaeL] multi Private messages V0.3 - Loaded...!");
  18.     return 1;
  19. }
  20. //==============================================================================
  21. public OnFilterScriptExit()
  22. {
  23.     print("[RaFaeL] multi Private messages V0.3 - unLoaded...!");
  24.     return 1;
  25. }
  26. //==============================================================================
  27. public OnPlayerCommandText(playerid, cmdtext[])
  28. {
  29.     new cmd[256], params[256], idx, str[128];
  30.     cmd = strtok(cmdtext, idx); params = strrest(cmdtext, idx);
  31.     //=-=-==-=-=-=-=-=-=-=--=-=-=-=-=--=-=-=---=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  32.     if(!strcmp(cmd, "/Pm", true))
  33.     {
  34.         new ids[24], text[128], sendids[5], SendedNames[128], SendedCount; //Veribles for the system
  35.         if(sscanf(params, "s[24]s[128]", ids, text)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /Pm [IDs] [Text]"); //Check if command typed correctly
  36.  
  37.         sscanf(ids, "p<,>A<i>(-1)[5]", sendids); //Splits the ids -> 1,2,3 will give an array
  38.  
  39.         for(new i; i<sizeof(sendids); i++) if(sendids[i] != INVALID_PLAYER_ID && IsPlayerConnected(sendids[i]) && sendids[i] != playerid) { //Create a loop to check ids and create names list
  40.             SendedCount++; //Add one to the names count
  41.             new sendid = sendids[i]; //Get the Id
  42.  
  43.             format(str, sizeof(str), "%s%s", GetName(sendid), (SendedCount > 1)? (", "):("")), strcat(SendedNames, str); //Add the name of the sender to string
  44.             SendClientFormat(sendid, 0xEAFF00FF, str, "[PM] %s(->To You): %s", GetName(playerid), text); //send formated message to players
  45.         }
  46.         return (SendedCount > 0)? (SendClientFormat(playerid, 0x0000FFFF, str, "[PM] %s(->To: %s): %s", GetName(playerid), SendedNames, text)):(SendClientMessage(playerid, 0xFF0000AA, "Wrong IDs!"));//send formated message to player
  47.     }
  48.     //=-=-==-=-=-=-=-=-=-=--=-=-=-=-=--=-=-=---=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  49.     return 0;
  50. }
  51. //==============================================================================
  52. stock strrest(const string[], index)
  53. {
  54.     new length = strlen(string),offset = index,result[256];
  55.     while((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r')) result[index - offset] = string[index],index++;
  56.     result[index - offset] = EOS;
  57.     if(result[0] == ' ' && string[0] != ' ') strdel(result,0,1);
  58.     return result;
  59. }
  60. stock GetName(playerid)
  61. {
  62.     new name[MAX_PLAYER_NAME];
  63.     GetPlayerName(playerid, name, sizeof(name));
  64.     return name;
  65. }
  66. //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment