Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <YSI\y_va>
- #include <discord-connector>
- #define DCC_CMD:%0(%1,%2) \
- forward dcc_cmd_%0(%1[],%2[]); \
- public dcc_cmd_%0(%1[],%2[])
- forward OnDiscordCommand(arguments[], success);
- if(channel == DCC_FindChannelByName("acmds")) // CHECKING THE CHANNEL WHERE MESSAGE WAS SENT (Should be added under public DCC_OnMessageCreate(DCC_Message:message))
- {
- new discordmsg[10][128];
- ArguementCheck(dmsg, content, " ", 2); //Checking Arguments if they do exist next to the command or not ( have value or not)
- new cmdused[10], arguments[128];
- sscanf(content, "s[10]s[128]", cmdused, arguments); // Seperating the command and the following argument)
- if(strfind(cmdused, "/", true) != -1) // Checking for a pre defined command prefix.
- {
- new dccfunc[128];
- strdel(cmdused, 0, 1);
- format(dccfunc, sizeof(dccfunc), "dc_cmd_%s", cmdused); // Format function.
- if(isnull(discordmsg[1]))
- CallLocalFunction("OnDiscordCommand", "si", content, CallLocalFunction(dccfunc, "ss", username, "\1"));
- else
- CallLocalFunction("OnDiscordCommand", "si", content, CallLocalFunction(dccfunc, "ss", username, arguments));
- }
- }
- stock ArgumentCheck(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;
- }
- EXAMPLE CODE
- DCC_CMD:unmute(user, arguments)
- {
- new pID;
- if(sscanf(arguments, "u", pID))
- return SendUSG("Usage:/unmute [Player ID]");
- if(!IsPlayerConnected(pID))
- return SendUSG("That player is not connected");
- if(Player[pID][Mute] == false)
- return SendUSG("That player is not muted");
- Player[pID][Mute] = false;
- SCMToAllEx(-1,"A discord admin "COL_PRIM "has unmuted {FFFFFF}%s",Player[pID][Name]);
- SendUSG(sprintf("%s has been unmuted he can talk now", Player[pID][Name]));
- return 1;
- }
- new DCC_Channel:ACMDSChannel;
- forward SendUSG(text[]);
- public SendUSG(text[])
- {
- if(_:ACMDSChannel == 0)
- ACMDSChannel = DCC_FindChannelByName("acmds"); // Discord channel ID
- return DCC_SendChannelMessage(ACMDSChannel, text);
- }
- stock SCMToAllEx(color, format[], va_args<>)
- {
- new sta[128];
- va_format(sta, sizeof(sta), format, va_start<2>);
- return SendClientMessageToAll(color, sta);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement