Advertisement
Se8870

cusCMD.inc

Jul 29th, 2020
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.52 KB | None | 0 0
  1. /*
  2.     Custom Command (Improved version)
  3.     ---------------------------------
  4.    
  5.     Custom CMD, using OnPlayerText it's possible!
  6.     Don't know if this legit or not... who knows ¯\\_(ツ)_//¯
  7.     - Se8870
  8.  
  9.     Credits:
  10.     - Yashas (I took I-ZCMD algoritm and changing a bit)
  11.     - Zeex (For original idea)
  12. */
  13.  
  14. #if defined Se8870_CUSTOM_CMD_INCLUDED
  15.     #endinput
  16. #endif
  17.  
  18. #define Se8870_CUSTOM_CMD_INCLUDED
  19.  
  20. #define \
  21.     Process:%1(%2) \
  22.     forward onCmd_%1(%2); public onCmd_%1(%2)
  23.  
  24. //----------------------------------------
  25. // change it on your script!
  26. //----------------------------------------
  27. #if !defined CMD_PREFIX
  28.     #define CMD_PREFIX "!"
  29. #endif
  30.  
  31. #if !defined CMD_SENSITIVE
  32.     #define CMD_SENSITIVE (true)
  33. #endif
  34.  
  35. #if !defined MAX_FUNC_NAME
  36.     #define MAX_FUNC_NAME 32    
  37. #endif
  38. //----------------------------------------
  39.  
  40. public OnPlayerText(playerid, text[]) {
  41.     if (strfind(text, CMD_PREFIX) != -1) {
  42.  
  43.         static
  44.             pos = 1, tmp,
  45.             funcname[MAX_FUNC_NAME * 2] = "onCmd_";
  46.  
  47.         #if !CMD_SENSITIVE
  48.             while((tmp = text[pos]) > ' ')
  49.                 ('a' <= tmp <= 'Z') && (funcname[pos++ + 5] = tmp | 0x20) || (funcname[pos++ + 5] = tmp);
  50.  
  51.             funcname[pos + 5] = 0;
  52.             while (text[pos] == ' ') pos++;
  53.  
  54.             if(text[pos])
  55.             {
  56.                 CallLocalFunction(funcname, "is", playerid, text[pos]);
  57.                 return 0;  
  58.             }
  59.             CallLocalFunction(funcname, "is", playerid, "\1");
  60.             return 0;
  61.         #else
  62.             //truncate here so we can use it globally
  63.             funcname[6] = 0;
  64.  
  65.             if((pos = strfind(text, " ", false, 1)) == -1)
  66.             {
  67.                 strcat(funcname, text[1], MAX_FUNC_NAME - 6);
  68.                 CallLocalFunction(funcname, "is", playerid, "\1");
  69.                 return 0;
  70.             }
  71.             else
  72.             {
  73.                 strcat(funcname, text[1], pos + 6);
  74.                 while (text[pos] == ' ') pos++;
  75.  
  76.                 if(text[pos])
  77.                 {
  78.                     CallLocalFunction(funcname, "is", playerid, text[pos]);
  79.                     return 0;
  80.                 }
  81.                 CallLocalFunction(funcname, "is", playerid, "\1");
  82.                 return 0;
  83.             }  
  84.         #endif
  85.     }
  86.     return 1;
  87. }
  88. #if defined _ALS_OnPlayerText
  89.     #undef OnPlayerText
  90. #else
  91.     #define _ALS_OnPlayerText
  92. #endif
  93. #define OnPlayerText zcmd_OnPlayerText
  94. forward zcmd_OnPlayerText(playerid, text[]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement