Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <..\compiler\includes\a_samp>
- #include "zcmd"
- #define C_TICK 50000
- #define ncmd(%0,%1,%2) \
- if(!strcmp(%0,#/%1,true,%2) && ((%0[%2+1] == ' ') || (%0[%2+1] == 0))) \
- return ncmd_%1(playerid,%0[%2+1+1])
- #define dcmd(%1,%2,%3) \
- if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) \
- return 1
- main()
- {
- new tick;
- // ----------
- tick = GetTickCount();
- for (new i=0;i<C_TICK;i++)
- {
- CallRemoteFunction("OnPlayerCommandText","is",0,"/test_zcmd 0 param1");
- }
- printf("zcmd: %d",GetTickCount() - tick);
- // ----------
- tick = GetTickCount();
- for (new i=0;i<C_TICK;i++)
- {
- CallRemoteFunction("old_OnPlayerCommandText","is",0,"/test_old 0 param1");
- }
- printf("old: %d",GetTickCount() - tick);
- // ----------
- tick = GetTickCount();
- for (new i=0;i<C_TICK;i++)
- {
- CallRemoteFunction("new_OnPlayerCommandText","is",0,"/test_new 0 param1");
- }
- printf("new: %d",GetTickCount() - tick);
- // ----------
- tick = GetTickCount();
- for (new i=0;i<C_TICK;i++)
- {
- CallRemoteFunction("dcmd_OnPlayerCommandText","is",0,"/test_dcmd 0 param1");
- }
- printf("dcmd: %d",GetTickCount() - tick);
- }
- // ----------
- forward OnPlayerCommandText(playerid,cmdtext[]);
- public OnPlayerCommandText(playerid,cmdtext[])
- {
- zcmd_OnPlayerCommandText(playerid,cmdtext);
- return 0;
- }
- COMMAND:test_zcmd(playerid, params[])
- {
- return 1;
- }
- // ----------
- forward old_OnPlayerCommandText(playerid,cmdtext[]);
- public old_OnPlayerCommandText(playerid,cmdtext[])
- {
- if(!strcmp(cmdtext,"/test_old",true,9))
- {
- return 1;
- }
- return 0;
- }
- // ----------
- forward new_OnPlayerCommandText(playerid,cmdtext[]);
- public new_OnPlayerCommandText(playerid,cmdtext[])
- {
- ncmd(cmdtext,test_new,8);
- return 0;
- }
- #define NCMD:%1(%2) \
- forward ncmd_%1(%2); \
- public ncmd_%1(%2)
- NCMD:test_new(playerid,params[])
- {
- return 1;
- }
- // ----------
- forward dcmd_OnPlayerCommandText(playerid,cmdtext[]);
- public dcmd_OnPlayerCommandText(playerid,cmdtext[])
- {
- dcmd(test_dcmd,9,cmdtext);
- return 1;
- }
- forward dcmd_test_dcmd(playerid,params[]);
- public dcmd_test_dcmd(playerid,params[])
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment