Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////////////////////////////////////////////
- // /////////////// //////////// //// //// /////////////// //
- // /////////////// //////////// /// /// /// //// /////////////// //
- // //// //// //// //// /// /// //// //// /// //
- // /////////////// //// //// /// //// //// /// //
- // /////////////// //// //// //// //// /// //
- // //// //////////// //// //// /////////////// //
- // //// //////////// //// //// ////////////// //
- // BY IPROTOTYPEI //
- //////////////////////////////////////////////////////////////////////////////////////////////
- #if !defined _PH_
- forward public _PH_();
- _PH_()<_PH_:unhooked>{}
- _PH_()<_PH_:hooked>{}
- _PH_()<>{}
- #endif
- #define CMD->%0(%1) forward%0_CMD(%1); public %0_CMD(%1)
- #define smalletter(%0) (((%0) >= 'A' && (%0) <= 'Z') ? ((%0) | 0x20) : (%0))
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- state _PH_:hooked;
- new funcname[30],i=1;
- for(;;){
- if(cmdtext[i] == ' ' || cmdtext[i] == '\0')break;
- funcname[i-1] = cmdtext[i];
- funcname[i-1] = smalletter(funcname[i-1]);
- ++i;
- }
- strcat(funcname,"_CMD");
- new idx = funcidx(funcname);
- if(idx == -1)return H_OnPlayerCommandText(playerid, cmdtext);
- strdel(cmdtext,0,i+1);
- new pointer;
- #endif
- #emit LCTRL 0x1
- #emit NEG
- #emit ADD.C 0x20
- #emit STOR.S.pri pointer
- #emit LREF.S.alt pointer
- #emit LCTRL 0x1
- #emit NEG
- #emit ADD
- #emit LOAD.S.alt idx
- #emit SHL.C.alt 0x3
- #emit ADD
- #emit STOR.S.pri pointer
- #emit LREF.S.pri pointer
- #emit STOR.S.pri pointer
- #emit PUSH.S cmdtext
- #emit PUSH.S playerid
- #emit PUSH.C 0x8
- #emit LCTRL 0x6
- #emit ADD.C 0x1C
- #emit PUSH.pri
- #emit LOAD.S.pri pointer
- #emit SCTRL 0x6
- #emit STACK 0x10
- return 1;
- }
- forward H_OnPlayerCommandText(playerid, cmdtext[]);
- #if defined _PH_OnPlayerCommandText
- #undef OnPlayerCommandText
- #else
- #define _PH_OnPlayerCommandText
- #endif
- public H_OnPlayerCommandText(playerid, cmdtext[])<_PH_:unhooked> return 1;
- public H_OnPlayerCommandText(playerid, cmdtext[]) <> return 1;
- #define OnPlayerCommandText(%0,%1) H_OnPlayerCommandText(%0,%1)<_PH_:hooked>
- ///////////////////////////////////////////////////////////////////////////
- // Thanks to //
- // @ Y_LESS #emit Tutorial and optimize version of tolower //
- // @ Zeex interessting emit stuff at github //
- // @ BlackAce for testing //
- // @ SynonymousZ for testing //
- ///////////////////////////////////////////////////////////////////////////
- //Example
- /*
- CMD-> test(playerid,params[])
- {
- printf("Test");
- printf("ausgegeben %d |%s|",playerid,params);
- return 1;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement