/* bCMD - New Command Processor Creator: BlueX Version: 1.4 Last Update: 27/07/2012 */ #if defined _bcmd_include #endinput #endif #define _bcmd_include #include #define bCMD[%1]-(%2)\ forward bcmd_%1(%2);\ public bcmd_%1(%2) #define bcmd:%1(%2) \ bCMD[%1]-(%2) #if !defined isnull #define isnull(%1) \ ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1])))) #endif forward OnPlayerCallCommand(playerid,cmdtext[],sucess); forward bKey(playerid,_key[],cmdtext[]); const C_MAX_FUNC_NAME = 32; public bKey(playerid,_key[],cmdtext[]){ if(!strfind(cmdtext,_key,true)) OnPlayerCommandText(playerid,cmdtext); return 0; } public OnPlayerCommandText(playerid, cmdtext[]){ new _callback[32],_cmd[32],_params[255],_help = 0; for(new a; cmdtext[++a] > ' ';) _cmd[a-1] = tolower(cmdtext[a]); format(_callback,sizeof(_callback),"bcmd_%s",_cmd); format(_params,255,"%s",cmdtext); strdel(_params,0,strfind(_params," ",false)+1); if(!strcmp(_params,cmdtext,false)) _params[0] = EOS; else if(!strcmp(_params,"help",false)) _help = 1; return CallLocalFunction("OnPlayerCallCommand","dsd",playerid,_cmd,CallLocalFunction(_callback,"dsd",0,isnull(_params) ? ("\1") : (_params),_help ? (1) : (0))),1; } #if defined _ALS_OnPlayerCommandText #undef OnPlayerCommandText #else #define _ALS_OnPlayerCommandText #endif #define OnPlayerCommandText bcmd_OnPlayerCommandText forward bcmd_OnPlayerCommandText(playerid, cmdtext[]);