Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************\
- | |
- | [Include] - Processador de comandos |
- | By Jeffrey_Hatrix |
- | Special thanks to: |
- | Y_Less - for spend your time chatting me |
- | Willian_Luigi - for speed ideas |
- | |
- \******************************************************************************/
- // Versão 2 - perdeu velocidade, ganhou funcionalidade mas está em testes.
- // A versão Original está mais rápida e mais funcional, só será lançada após a conclusão das ideias.
- // Obs: a nomenclatura está a risco de gerar conflitos, mas para os curiosos e espertos.
- // Sim, este problema já foi corrigido na versão original. A velocidade foi afetada um pouco
- // mas na versão original ela foi reconstituida.
- /* - Exemplos de comandos - *\
- | call<NOME>(playerid, params[]) |
- | { |
- | SendClientMessage(playerid, -1, "Você digitou o nome /NOME"); |
- | return 1; |
- | } |
- | |
- | |
- | with params: |
- | call<vida>(playerid,params[]) |
- | { |
- | if(isnull(params)) return false; |
- | SetPlayerHealth(playerid, strval(params)); |
- | SendClientMessage(playerid, -1, "você encheu sua vida..."); |
- | return true; |
- | } |
- \* */
- /*
- Features:
- - Processador totalmente atualizado do 0, isto é re-feito.
- - Case sensitive incluído(/CoMAnDo = /comando) !
- - Space params incluído(/comando param) !
- - Callback de gerenciamento OnPerformedCmd incluída(quando o comando é processado) !
- - Callback de gerenciamento OnReceivedCmd incluída(quando o comando é enviado, pré-processo) !
- - Velocidade e otimização em progresso(Somente na versão original) !
- */
- #if !defined isnull
- #define isnull(%0) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
- #endif
- #define call<%0>(%1) forward @%0(%1); public @%0(%1)
- forward OnPerformedCmd(playerid, cmdtext[], success);
- forward OnReceivedCmd(playerid,cmdtext[]);
- new bool:g_callback_OPC = false, bool:g_callback_OSC = false;
- public
- OnGameModeInit()
- {
- printf("GameMode Iniciado!");
- if (funcidx("OnPerformedCmd") != -1) g_callback_OPC = true;
- if (funcidx("OnReceivedCmd") != -1) g_callback_OSC = true;
- if (funcidx("gOnGameModeInit") != -1)
- {
- return CallLocalFunction ("gOnGameModeInit", "");
- }
- return 1 ;
- }
- #if defined _ALS_OnGameModeInit
- #undef OnGameModeInit
- #else
- #define _ALS_OnGameModeInit
- #endif
- #define OnGameModeInit gOnGameModeInit
- forward gOnGameModeInit();
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (g_callback_OSC && !CallLocalFunction("OnReceivedCmd", "is", playerid, cmdtext)) return 1;
- static g_nome[32], g_params[32];
- new g_index = strfind(cmdtext, " ");
- for (new g_sense = 0; ((g_index && (g_sense < g_index)) || (g_sense < strlen(cmdtext))); g_sense++) cmdtext[g_sense] = tolower(cmdtext[g_sense]);
- if (g_index != -1)
- {
- if ((cmdtext[g_index + 1]) == '\0') cmdtext[g_index] = '\0';
- else
- {
- g_params[0] = EOS;
- new g_idx = g_index;
- while (cmdtext[g_idx] == 0x20) g_idx ++;
- strmid(g_params, cmdtext, g_idx, strlen(cmdtext));
- g_nome[0] = EOS, cmdtext[0] = '@', cmdtext[g_index] = EOS;
- format (g_nome, 32, cmdtext);
- if (funcidx(g_nome) != -1)
- {
- return CallLocalFunction(g_nome, "is", playerid, g_params), g_callback_OPC?CallLocalFunction("OnPerformedCmd", "isi", playerid, cmdtext, 1):1;
- }
- }
- }
- g_nome[0] = EOS, cmdtext[0] = '@', cmdtext[g_index] = EOS;
- format(g_nome, 32, cmdtext);
- if (funcidx(g_nome) != -1)
- {
- printf("_%s_", g_nome);
- return CallLocalFunction(g_nome, "is", playerid, "\1"), g_callback_OPC?CallLocalFunction("OnPerformedCmd", "isi", playerid, cmdtext, 1):1;
- }
- return g_callback_OPC?CallLocalFunction("OnPerformedCmd", "isi", playerid, cmdtext, 0):1;
- }
Advertisement
Add Comment
Please, Sign In to add comment