/* bCMD - New Command Processer Creator: BlueX Version: 1.1 Last Update: 19/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 UseCommandKey(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[C_MAX_FUNC_NAME],_cmd[C_MAX_FUNC_NAME],pos; while(cmdtext[++pos] > ' '){ _cmd[pos-1] = tolower(cmdtext[pos]); } format(_callback,sizeof(_callback),"bcmd_%s",_cmd); while(cmdtext[pos] == ' ') pos ++; strdel(cmdtext,0,pos); CallLocalFunction("OnPlayerCallCommand","dsd",playerid,_cmd,CallLocalFunction(_callback,"ds",0,isnull(cmdtext) ? ("\1") : (cmdtext))); return 1; } #if defined _ALS_OnPlayerCommandText #undef OnPlayerCommandText #else #define _ALS_OnPlayerCommandText #endif #define OnPlayerCommandText bcmd_OnPlayerCommandText forward bcmd_OnPlayerCommandText(playerid, cmdtext[]);