forward OnDCCommandPerformed(args[], success);
forward SendDC(channel[], const fmat[], va_args<>);
SendDC(CHANNEL_ID, "%s has joined the server.", name);
OnDCCommandPerformed(args[], success)
public OnDCCommandPerformed(args[], success)
{
if(!success) return SendDC(CHANNEL_ID, "```js\nInvalid command..!\n```");
return 1;
}
#define CMD_PREFIX "!"
#define BOT_CHANNEL ""
#define BOT_NAME ""
#define CHANNEL_ID ""
#include <dcc>
DC_CMD:m(user, args)
{
new msg[50];
if(sscanf(args, "s[50]", msg)) return SendDC(CHANNEL_ID, ""CMD_PREFIX"m [Msg]");
SendDC(CHANNEL_ID, "%s: %s", user, msg);
return 1;
}
[mention]Inn0cent[/mention], is there a way to check if a player uses this role? like for example:
if(PlayerInfo[playerid][DISCORD ROLE]) |
Awesome script, too sad not so many communities use discord, neither me myself ;/
|
I'm a bit confused.. is this for players from discord typing /command, or just a command parser from ingame that outputs to discord?
|
Код:
#define CMD_PREFIX "!" #define BOT_CHANNEL "" #define BOT_NAME "" #define CHANNEL_ID "" |
I'm a bit confused.. is this for players from discord typing /command, or just a command parser from ingame that outputs to discord?
|
when i type the commands in server or in discord channel it not gives me the syntax and also the cmds not works
|
#include <sscanf2> #include <YSI\y_va> #include <discord-connector> new DCC_Channel:BotChannel; #define DC_CMD:%0(%1,%2,%3) \ forward dc_cmd_%0(%1[],%2[],%3[]); \ public dc_cmd_%0(%1[],%2[],%3[]) //CallBacks forward OnDCCommandPerformed(args[], success, channel[]); forward SendDC(channel[], const fmat[], va_args<>); forward SendDCByName(channel[], const fmat[], va_args<>); //Functions public SendDC(channel[], const fmat[], va_args<>) { new str[145]; va_format(str, sizeof (str), fmat, va_start<2>); BotChannel = DCC_FindChannelById(channel); return DCC_SendChannelMessage(BotChannel, str); } public SendDCByName(channel[], const fmat[], va_args<>) { new str[145]; va_format(str, sizeof (str), fmat, va_start<2>); BotChannel = DCC_FindChannelByName(channel); return DCC_SendChannelMessage(BotChannel, str); } //CommandsSection public DCC_OnChannelMessage(DCC_Channel:channel, DCC_User:author, const message[]) { new channel_name[100 + 1]; if(!DCC_GetChannelName(channel, channel_name)) return 0; // invalid channel new user_name[32 + 1]; if (!DCC_GetUserName(author, user_name)) return 0; // invalid user new msgFx[1024]; format(msgFx, 1024, message); for(new s; s < strlen(msgFx); s++) { if (msgFx[s] == '%') { msgFx[s] = ' '; } } if(!strcmp(user_name, BOT_NAME, true)) return 1; if(strlen(user_name) > 0) // If user is bot then quit the callback. { new dmsg[10][128]; explode(dmsg, msgFx, " ", 2); // Used so we can see if the arguments next to command are empty or have value. new command[10], args[50]; sscanf(msgFx, "s[10]s[50]", command, args); // Sperate message in COMMAND and arguments. if(strfind(command, CMD_PREFIX, true) != -1) // Check if command have prefix defined above. { new funcdc[128]; strdel(command, 0, 1); format(funcdc, sizeof(funcdc), "dc_cmd_%s", command); // Format function. if(isnull(dmsg[1])) { CallLocalFunction("OnDCCommandPerformed", "sis", msgFx, CallLocalFunction(funcdc, "sss", user_name, "\1", channel_name), channel_name); } else CallLocalFunction("OnDCCommandPerformed", "sis", msgFx, CallLocalFunction(funcdc, "sss", user_name, args, channel_name), channel_name); } } return 1; } //Explode stock explode(aExplode[][], const sSource[], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[]) { new iNode, iPointer, iPrevious = -1, iDelimiter = strlen(sDelimiter); while(iNode < iVertices) { iPointer = strfind(sSource, sDelimiter, false, iPointer); if(iPointer == -1) { strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength); break; } else { strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength); } iPrevious = (iPointer += iDelimiter); ++iNode; } return iPrevious; }
DC_CMD:ban(author, params, channel) { if(strcmp(channel, "staff-bot")) return SendDCByName(CHANNEL_ALL_NAME, "```css\nERROR: You are not allowed to use this command!```"); new target, reason[128], hours; if(sscanf(params, "uds[127]", target, hours, reason)) return SendDCByName(CHANNEL_STAFF_NAME, "```css\nUSAGE: ban [playerid] [hours] [reason]```"); if(hours < 1 || hours > 8760) return SendDCByName(CHANNEL_STAFF_NAME, "```css\nBan time cannot be less than 1 or more than 8760 hours!```"); if(!IsPlayerConnected(target)) return SendDCByName(CHANNEL_STAFF_NAME, "```css\nERROR: Target is not connected```"); BanPlayer(sprintf("[DISCORD ADMIN] %s", author), target, reason, false, hours, false); if(PlayerInfo[target][LoggedIn] == true) AddToAdminRecord(target, sprintf("Banned by %s [DISCORD] for %s.", author, reason)); SendDCByName(CHANNEL_STAFF_NAME, "```css\nTarget banned```"); return 1; }
#if defined DISCORD_PLUGIN #include <discord-connector> #define BOT_NAME "botnamehere" // Btw this is used so the bot skips its own messages so if the bot would send !kick it would detect the command but skips it because its the bot itself. #define CHANNEL_STAFF_NAME "staff-bot" #define CHANNEL_ALL_NAME "ingame-bot" #define CMD_PREFIX "!" #include <dcc> #endif
public OnDCCommandPerformed(args[], success, channel[]) { SendDCByName(channel, "```css\nYou sent the command '%s'```", args); return 1; }