frog163

fcmd v1.1

Nov 15th, 2012
213
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Командный процессор на основе rcmd(Romanius), который в свою очередь основан на zcmd(Zeex)
  2. //Автор: frog163
  3. //Skype: frog14.05
  4.  
  5. //native OnPlayerUseRusCommand(playerid, rus_cmd[], params[]);
  6. //native fcmd(playerid, params[]);
  7. #include a_samp
  8. #if defined fcmd_inc
  9.   #endinput
  10. #endif
  11. #define fcmd_inc
  12.  
  13. //#define rus_cmd_use//Раскомментировать для поддержки русских команд
  14.  
  15. public OnPlayerCommandText(playerid, cmdtext[]){
  16.     if(cmdtext[0] != '/')return true;
  17.     #if defined rus_cmd_use
  18.     if(0xbf < cmdtext[1] < 0x100 || cmdtext[1] == 0xb8 || cmdtext[1] == 0xa8){//проверка на русский символ
  19.         new command[14] = '/', f = 1;
  20.         for(; cmdtext[f] > 0x20; f++)command[f] = cmdtext[f];
  21.         if(funcidx("fcmd_OnPlayerCommandText") > 0){
  22.             if(!OnPlayerUseRusCommand(playerid, command, cmdtext[f]))return CallLocalFunction("fcmd_OnPlayerCommandText", "is", playerid, cmdtext);
  23.             CallLocalFunction("fcmd_OnPlayerCommandText", "is", playerid, cmdtext);
  24.             return true;
  25.         }
  26.         return OnPlayerUseRusCommand(playerid, command, cmdtext[f]);
  27.     }
  28.     #endif
  29.     if(funcidx("fcmd_OnPlayerCommandText") > 0){
  30.         if(!fcmd(playerid, cmdtext))return CallLocalFunction("fcmd_OnPlayerCommandText", "is", playerid, cmdtext);
  31.         CallLocalFunction("fcmd_OnPlayerCommandText", "is", playerid, cmdtext);
  32.         return true;
  33.     }
  34.     return fcmd(playerid, cmdtext);
  35. }
  36.  
  37. fcmd(playerid, fcmd_str[]){
  38.     new f = 1, command[14 char];
  39.     command{0} = '_';
  40.     for( ; fcmd_str[f] > 0x20; f++) command{f} = tolower(fcmd_str[f]);
  41.     if(funcidx(command) > 0){
  42.         if(fcmd_str[f+1])CallLocalFunction(command, "is", playerid, fcmd_str[f+1]);
  43.         else CallLocalFunction(command, "is", playerid, "\1");
  44.         return true;
  45.     }
  46.     return false;
  47. }
  48.  
  49. #define cmd::%0(%1,%2)                      forward _%0(%1,%2);public _%0(%1,%2)
  50. #define noparams                            params[0] == 1
  51. #define duplicate_cmd(%0,%1);               if(!strcmp(rus_cmd, %0, true)){strins(params, %1, 0, 64);return fcmd(playerid, params);}
  52. #define OnPlayerUseRusCommand()             OnPlayerUseRusCommand(playerid, rus_cmd[], params[])
  53.  
  54. forward fcmd_OnPlayerCommandText(playerid, cmdtext[]);
  55. #define OnPlayerCommandText fcmd_OnPlayerCommandText
RAW Paste Data