iSphex

Private Messages By Sphex

Mar 24th, 2012
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.22 KB | None | 0 0
  1. /*
  2.  
  3.     Private Messages System By : Sphex
  4.    
  5.     ---
  6.         Creation Date : 24/03/2012 15:55
  7.         Version : 0.1
  8.     ---
  9.  
  10. */
  11.  
  12. //====================================================
  13. #include <a_samp>
  14. //====================================================
  15. #define VERSION "0.1"
  16.  
  17. #define COL_RED 0xE01B1BAA
  18. #define COL_YELLOW 0xFFFB00AA
  19. #define COL_GREEN 0x6FFF00AA
  20. //====================================================
  21. new str[128];
  22. //====================================================
  23. public OnFilterScriptInit()
  24. {
  25.     print("\n--------------------------------------");
  26.     print("\tPrivate Messages System By : Sphex\n");
  27.     printf("\tV%s Loaded!", VERSION);
  28.     print("--------------------------------------\n");
  29.     return 1;
  30. }
  31. //====================================================
  32. public OnFilterScriptExit()
  33. {
  34.     print("\n--------------------------------------");
  35.     print("\tPrivate Messages System By : Sphex\n");
  36.     printf("\tV%s Unloaded!", VERSION);
  37.     print("--------------------------------------\n");
  38.     return 1;
  39. }
  40. //====================================================
  41. public OnPlayerConnect(playerid)
  42. {
  43.     format(str, sizeof(str), "[PM V%s] Sphex ùøú æä îùúîù áîòøëú äåãòåú ôøèéåú ùðáðúä òì éãé", VERSION);
  44.     SendClientMessage(playerid, COL_YELLOW, str);
  45.     return 1;
  46. }
  47. //====================================================
  48. public OnPlayerCommandText(playerid, cmdtext[])
  49. {
  50.     new cmd[256], tmp[256], tmp2[256], idx;
  51.     cmd = strtok(cmdtext, idx);
  52.    
  53.     if (!strcmp(cmd, "/pm", true)) {
  54.         tmp = strtok(cmdtext, idx);
  55.         tmp2 = strrest(cmdtext, idx);
  56.         new id = strval(tmp);
  57.        
  58.         if (!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, COL_RED, "/PM [ID] [MSG] : ùéîåù");
  59.         if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COL_RED, ".äùç÷ï ùáçøú àéðå îçåáø");
  60.         format(str, sizeof(str), "[PM OUT] [%d | %s] >> %s", id, GetName(playerid), tmp2);
  61.         SendClientMessage(playerid, COL_GREEN, str);
  62.         format(str, sizeof(str), "[PM IN] [%d | %s] << %s", playerid, GetName(playerid), tmp2);
  63.         SendClientMessage(id, COL_GREEN, str);
  64.         return 1;
  65.     }
  66.     return 0;
  67. }
  68. //====================================================
  69. strtok(const string[], &index)
  70. {
  71.     new length = strlen(string);
  72.     while ((index < length) && (string[index] <= ' '))
  73.     {
  74.         index++;
  75.     }
  76.  
  77.     new offset = index;
  78.     new result[20];
  79.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  80.     {
  81.         result[index - offset] = string[index];
  82.         index++;
  83.     }
  84.     result[index - offset] = EOS;
  85.     return result;
  86. }
  87. //====================================================
  88. stock strrest(const string[], &index)
  89. {
  90.     new length = strlen(string);
  91.     while ((index < length) && (string[index] <= ' '))
  92.     {
  93.         index++;
  94.     }
  95.     new offset = index;
  96.     new result[128];
  97.     while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
  98.     {
  99.         result[index - offset] = string[index];
  100.         index++;
  101.     }
  102.     result[index - offset] = EOS;
  103.     return result;
  104. }
  105. //====================================================
  106. stock GetName(playerid) {
  107.     new pName[MAX_PLAYER_NAME];
  108.     GetPlayerName(playerid, pName, sizeof(pName));
  109.     return pName;
  110. }
  111. //====================================================
Advertisement
Add Comment
Please, Sign In to add comment