01.08.2017, 12:45
(
Last edited by Xeon™; 05/11/2017 at 06:23 PM.
)
Nothing special:
Discord Command processor
Discord Command processor
PHP Code:
#define DDC_COMMAND_PREFIX '!'
#define DDCMD:%1(%2) \
forward ddcmd_%1(%2); \
public ddcmd_%1(%2)
#define ddcmd(%1,%2,%3) \
DDCMD:%1(%2, %3, %4)
static bool:DDC_g_OCM = false;
public OnGameModeInit()
{
DDC_g_OCM = funcidx("DDC_OCS") != -1;
if (funcidx("DDC_OnGameModeInit") != -1)
{
return CallLocalFunction("DDC_OnGameModeInit", "");
}
return 1;
}
#if defined _ALS_OnGameModeInit
#undef OnGameModeInit
#else
#define _ALS_OnGameModeInit
#endif
#define OnGameModeInit DDC_OnGameModeInit
forward DDC_OnGameModeInit();
public DDC_OnChannelMessage(DDC_Channel:channel, DDC_User:author, const message[])
{
if (message[0] == DDC_COMMAND_PREFIX)
{
new function[32], pos = 0;
while (message[++pos] > ' ')
{
function[pos - 1] = tolower(message[pos]);
if (pos > (sizeof(function) - 1))
{
break;
}
}
format(function, sizeof(function), "ddcmd_%s", function);
while (message[pos] == ' ')
{
pos++;
}
if (!message[pos])
{
CallLocalFunction(function, "dds", channel, author, "\1");
}
else
{
CallLocalFunction(function, "dds", channel, author, message[pos]);
}
}
if (DDC_g_OCM)
{
return CallLocalFunction("DCC_OCM", "dds", channel, author, message);
}
return 1;
}
#if defined _ALS_DDC_OnChannelMessage
#undef DCC_OnChannelMessage
#else
#define _ALS_DDC_OnChannelMessage
#endif
#define DDC_OnChannelMessage DDC_OCM
forward DDC_OCM(DCC_Channel:channel, DDC_User:author, const message[]);