Guest User

XCMD v1.2

a guest
Dec 3rd, 2011
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.23 KB | None | 0 0
  1. /* XMCD Version 1.2 By MegaDreams
  2.     It's allowed to change things but it's not allowed to redistribute.
  3.     It's not recommended to make any changes without having the knownledge how this is working.
  4. */
  5.  
  6. #include <a_samp>
  7.  
  8. #if defined _X_CMD_included
  9.     #endinput
  10. #endif
  11. #define _X_CMD_included
  12. #pragma library X_CMD
  13.  
  14. #define XCMD:%1(%2)              \
  15.             forward XCMD_%1(%2); \
  16.             public XCMD_%1(%2) 
  17.  
  18. #define MAX_CMD_LENGTH 16
  19.  
  20. public OnPlayerCommandText(playerid, cmdtext[])
  21. {
  22.     new needle,
  23.         cmd[MAX_CMD_LENGTH];
  24.        
  25.     if(!CallLocalFunction("OnPlayerUseCommand", "is", playerid, cmdtext)) return 1;
  26.     if(strfind(cmdtext, " ") == -1)
  27.     {
  28.         format(cmd, MAX_CMD_LENGTH, "XCMD_%s", cmdtext[1]);
  29.         return CallLocalFunction("OnPlayerPerformedCommand", "isi", playerid, cmdtext, CallLocalFunction(cmd, "is", playerid, -1));
  30.     }
  31.     while(cmdtext[++needle]>' '){cmd[needle-1] = cmdtext[needle];}
  32.     while(cmdtext[needle] == ' ')needle++;
  33.    
  34.     format(cmd, MAX_CMD_LENGTH, "XCMD_%s", cmd);
  35.    
  36.     return CallLocalFunction("OnPlayerPerformedCommand", "isi", playerid, cmdtext, CallLocalFunction(cmd, "is", playerid, cmdtext[needle]));
  37. }
  38.  
  39. forward OnPlayerUseCommand(playerid, cmdtext[]);
  40. forward OnPlayerPerformedCommand(playerid, cmdtext[], success);
  41.  
Advertisement
Add Comment
Please, Sign In to add comment