Advertisement
Guest User

PCMD

a guest
Apr 10th, 2013
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.80 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////////////////////////
  2. //      ///////////////     ////////////      ////              ////    ///////////////     //
  3. //      ///////////////     ////////////      /// ///       /// ////    ///////////////     //
  4. //      ////       ////     ////              ////  ///  ///    ////    ////        ///     //
  5. //      ///////////////     ////              ////     ///      ////    ////        ///     //
  6. //      ///////////////     ////              ////              ////    ////        ///     //
  7. //      ////                ////////////      ////              ////    ///////////////     //
  8. //      ////                ////////////      ////              ////    //////////////      //
  9. //                                  BY IPROTOTYPEI                                          //
  10. //////////////////////////////////////////////////////////////////////////////////////////////
  11.  
  12. #if !defined _PH_
  13.     forward public _PH_();
  14.     _PH_()<_PH_:unhooked>{}
  15.     _PH_()<_PH_:hooked>{}
  16.     _PH_()<>{}
  17. #endif
  18. #define CMD->%0(%1) forward%0_CMD(%1); public %0_CMD(%1)
  19. #define smalletter(%0) (((%0) >= 'A' && (%0) <= 'Z') ? ((%0) | 0x20) : (%0))
  20. public OnPlayerCommandText(playerid, cmdtext[])
  21. {
  22.     state _PH_:hooked;
  23.     new funcname[30],i=1;
  24.     for(;;){
  25.         if(cmdtext[i] == ' ' || cmdtext[i] == '\0')break;
  26.         funcname[i-1] = cmdtext[i];
  27.         funcname[i-1] = smalletter(funcname[i-1]);
  28.         ++i;
  29.     }
  30.     strcat(funcname,"_CMD");
  31.     new idx = funcidx(funcname);
  32.     if(idx == -1)return H_OnPlayerCommandText(playerid, cmdtext);
  33.     strdel(cmdtext,0,i+1);
  34.     new pointer;
  35.     #endif
  36.     #emit LCTRL       0x1
  37.     #emit NEG
  38.     #emit ADD.C       0x20
  39.     #emit STOR.S.pri  pointer
  40.     #emit LREF.S.alt  pointer
  41.     #emit LCTRL       0x1
  42.     #emit NEG
  43.     #emit ADD
  44.     #emit LOAD.S.alt  idx
  45.     #emit SHL.C.alt   0x3
  46.     #emit ADD
  47.     #emit STOR.S.pri  pointer
  48.     #emit LREF.S.pri  pointer
  49.     #emit STOR.S.pri  pointer
  50.     #emit PUSH.S cmdtext
  51.     #emit PUSH.S playerid
  52.     #emit PUSH.C      0x8
  53.     #emit LCTRL       0x6
  54.     #emit ADD.C       0x1C      
  55.     #emit PUSH.pri          
  56.     #emit LOAD.S.pri  pointer
  57.     #emit SCTRL       0x6      
  58.     #emit STACK       0x10
  59.     return 1;
  60. }
  61. forward H_OnPlayerCommandText(playerid, cmdtext[]);
  62. #if defined _PH_OnPlayerCommandText
  63.     #undef OnPlayerCommandText
  64. #else
  65.     #define _PH_OnPlayerCommandText
  66. #endif
  67. public H_OnPlayerCommandText(playerid, cmdtext[])<_PH_:unhooked> return 1;
  68. public H_OnPlayerCommandText(playerid, cmdtext[]) <> return 1;
  69. #define OnPlayerCommandText(%0,%1) H_OnPlayerCommandText(%0,%1)<_PH_:hooked>
  70.  
  71. ///////////////////////////////////////////////////////////////////////////
  72. //  Thanks to                                                            //
  73. //  @ Y_LESS #emit Tutorial and optimize version of tolower              //
  74. //  @ Zeex interessting emit stuff at github                             //
  75. //  @ BlackAce for testing                                               //
  76. //  @ SynonymousZ for testing                                            //
  77. ///////////////////////////////////////////////////////////////////////////
  78.  
  79.  
  80. //Example
  81. /*
  82. CMD-> test(playerid,params[])
  83. {
  84.     printf("Test");
  85.     printf("ausgegeben %d  |%s|",playerid,params);
  86.     return 1;
  87. }
  88. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement