Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Custom Command (Improved version)
- ---------------------------------
- Custom CMD, using OnPlayerText it's possible!
- Don't know if this legit or not... who knows ¯\\_(ツ)_//¯
- - Se8870
- Credits:
- - Yashas (I took I-ZCMD algoritm and changing a bit)
- - Zeex (For original idea)
- */
- #if defined Se8870_CUSTOM_CMD_INCLUDED
- #endinput
- #endif
- #define Se8870_CUSTOM_CMD_INCLUDED
- #define \
- Process:%1(%2) \
- forward onCmd_%1(%2); public onCmd_%1(%2)
- //----------------------------------------
- // change it on your script!
- //----------------------------------------
- #if !defined CMD_PREFIX
- #define CMD_PREFIX "!"
- #endif
- #if !defined CMD_SENSITIVE
- #define CMD_SENSITIVE (true)
- #endif
- #if !defined MAX_FUNC_NAME
- #define MAX_FUNC_NAME 32
- #endif
- //----------------------------------------
- public OnPlayerText(playerid, text[]) {
- if (strfind(text, CMD_PREFIX) != -1) {
- static
- pos = 1, tmp,
- funcname[MAX_FUNC_NAME * 2] = "onCmd_";
- #if !CMD_SENSITIVE
- while((tmp = text[pos]) > ' ')
- ('a' <= tmp <= 'Z') && (funcname[pos++ + 5] = tmp | 0x20) || (funcname[pos++ + 5] = tmp);
- funcname[pos + 5] = 0;
- while (text[pos] == ' ') pos++;
- if(text[pos])
- {
- CallLocalFunction(funcname, "is", playerid, text[pos]);
- return 0;
- }
- CallLocalFunction(funcname, "is", playerid, "\1");
- return 0;
- #else
- //truncate here so we can use it globally
- funcname[6] = 0;
- if((pos = strfind(text, " ", false, 1)) == -1)
- {
- strcat(funcname, text[1], MAX_FUNC_NAME - 6);
- CallLocalFunction(funcname, "is", playerid, "\1");
- return 0;
- }
- else
- {
- strcat(funcname, text[1], pos + 6);
- while (text[pos] == ' ') pos++;
- if(text[pos])
- {
- CallLocalFunction(funcname, "is", playerid, text[pos]);
- return 0;
- }
- CallLocalFunction(funcname, "is", playerid, "\1");
- return 0;
- }
- #endif
- }
- return 1;
- }
- #if defined _ALS_OnPlayerText
- #undef OnPlayerText
- #else
- #define _ALS_OnPlayerText
- #endif
- #define OnPlayerText zcmd_OnPlayerText
- forward zcmd_OnPlayerText(playerid, text[]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement