Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. #include <YSI\y_va>
  2. #include <discord-connector>
  3. #define DCC_CMD:%0(%1,%2) \
  4. forward dcc_cmd_%0(%1[],%2[]); \
  5. public dcc_cmd_%0(%1[],%2[])
  6.  
  7.  
  8. forward OnDiscordCommand(arguments[], success);
  9.  
  10. if(channel == DCC_FindChannelByName("acmds")) // CHECKING THE CHANNEL WHERE MESSAGE WAS SENT (Should be added under public DCC_OnMessageCreate(DCC_Message:message))
  11. {
  12. new discordmsg[10][128];
  13.  
  14. ArguementCheck(dmsg, content, " ", 2); //Checking Arguments if they do exist next to the command or not ( have value or not)
  15.  
  16. new cmdused[10], arguments[128];
  17. sscanf(content, "s[10]s[128]", cmdused, arguments); // Seperating the command and the following argument)
  18. if(strfind(cmdused, "/", true) != -1) // Checking for a pre defined command prefix.
  19. {
  20. new dccfunc[128];
  21. strdel(cmdused, 0, 1);
  22. format(dccfunc, sizeof(dccfunc), "dc_cmd_%s", cmdused); // Format function.
  23.  
  24. if(isnull(discordmsg[1]))
  25. CallLocalFunction("OnDiscordCommand", "si", content, CallLocalFunction(dccfunc, "ss", username, "\1"));
  26. else
  27. CallLocalFunction("OnDiscordCommand", "si", content, CallLocalFunction(dccfunc, "ss", username, arguments));
  28.  
  29. }
  30. }
  31.  
  32. stock ArgumentCheck(aExplode[][], const sSource[], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[])
  33. {
  34. new
  35. iNode,
  36. iPointer,
  37. iPrevious = -1,
  38. iDelimiter = strlen(sDelimiter);
  39.  
  40. while(iNode < iVertices)
  41. {
  42. iPointer = strfind(sSource, sDelimiter, false, iPointer);
  43.  
  44. if(iPointer == -1)
  45. {
  46. strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
  47. break;
  48. }
  49. else
  50. {
  51. strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
  52. }
  53.  
  54. iPrevious = (iPointer += iDelimiter);
  55. ++iNode;
  56. }
  57.  
  58. return iPrevious;
  59. }
  60.  
  61. EXAMPLE CODE
  62.  
  63. DCC_CMD:unmute(user, arguments)
  64. {
  65. new pID;
  66.  
  67. if(sscanf(arguments, "u", pID))
  68. return SendUSG("Usage:/unmute [Player ID]");
  69.  
  70. if(!IsPlayerConnected(pID))
  71. return SendUSG("That player is not connected");
  72.  
  73. if(Player[pID][Mute] == false)
  74. return SendUSG("That player is not muted");
  75.  
  76. Player[pID][Mute] = false;
  77.  
  78. SCMToAllEx(-1,"A discord admin "COL_PRIM "has unmuted {FFFFFF}%s",Player[pID][Name]);
  79. SendUSG(sprintf("%s has been unmuted he can talk now", Player[pID][Name]));
  80.  
  81. return 1;
  82. }
  83.  
  84. new DCC_Channel:ACMDSChannel;
  85.  
  86. forward SendUSG(text[]);
  87. public SendUSG(text[])
  88. {
  89. if(_:ACMDSChannel == 0)
  90. ACMDSChannel = DCC_FindChannelByName("acmds"); // Discord channel ID
  91.  
  92. return DCC_SendChannelMessage(ACMDSChannel, text);
  93. }
  94.  
  95. stock SCMToAllEx(color, format[], va_args<>)
  96. {
  97. new sta[128];
  98. va_format(sta, sizeof(sta), format, va_start<2>);
  99. return SendClientMessageToAll(color, sta);
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement