SHARE
TWEET

Discord Chat

Dayrion Jul 7th, 2018 390 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3. #define CHANNEL_ID "464114891645517834" // Change this to your channel id
  4. #include <discord-connector>
  5. #include <zcmd>
  6. #include <YSI\y_iterate>
  7.  
  8.  
  9. // ============================================================================================================
  10.  
  11.  
  12. new DCC_Channel:BotChannel,
  13.     Iterator:Player_DiscordChat<MAX_PLAYERS>;
  14.  
  15.  
  16. public OnFilterScriptInit()
  17. {
  18.     print("\n--------------------------------------");
  19.     print(" Discord Connector Filterscript ~ Inferno");
  20.     print("--------------------------------------\n");
  21.     return 1;
  22. }
  23.  
  24. public OnFilterScriptExit()
  25. {
  26.     return 1;
  27. }
  28.  
  29. // ============================================================================================================
  30.  
  31.  
  32. public OnPlayerConnect(playerid)
  33. {
  34.     Iter_Add(Player_DiscordChat, playerid);
  35.     return 1;
  36. }
  37.  
  38.  
  39. public DCC_OnChannelMessage(DCC_Channel:channel, DCC_User:author, const message[])
  40. {
  41.     if(channel != BotChannel)
  42.         return 0;
  43.    
  44.     new channel_name[100 + 1];
  45.     if(!DCC_GetChannelName(channel, channel_name))
  46.         return 0;
  47.  
  48.     new user_name[32 + 1];
  49.     if (!DCC_GetUserName(author, user_name))
  50.         return 0;
  51.  
  52.     new str[145];
  53.     format(str, sizeof str, "[Discord/%s] %s:{ffffff} %s", channel_name, user_name, message);
  54.  
  55.     foreach(new i : Player_DiscordChat)
  56.         SendClientMessage(i, 0x667acaFF, str);
  57.     return 1;
  58. }
  59.  
  60. CMD:dchat(playerid, params[])
  61. {
  62.     if(!Iter_Contains(Player_DiscordChat, playerid))
  63.         return SendClientMessage(playerid, -1, "Server: Your Discord Chat is off!");
  64.  
  65.     if(isnull(params))
  66.         return SendClientMessage(playerid, -1, "Usage: /dchat [message]");
  67.  
  68.     new buffer[140];
  69.     format(buffer, sizeof(buffer), "[chat] %s : %s", ReturnPlayerName(playerid), params);
  70.     DCC_SendChannelMessage(BotChannel, buffer);
  71.     return 1;
  72. }
  73.  
  74. CMD:dchaton(playerid, params[])
  75. {
  76.     if(Iter_Contains(Player_DiscordChat, playerid))
  77.         return SendClientMessage(playerid, -1, "Server: Discord Chat is already switched on!");
  78.  
  79.     Iter_Add(Player_DiscordChat, playerid);
  80.     SendClientMessage(playerid, -1, "Server: Discord Chat turned on.");
  81.     return 1;
  82. }
  83.  
  84. CMD:dchatoff(playerid, params[])
  85. {
  86.     if(!Iter_Contains(Player_DiscordChat, playerid))
  87.         return SendClientMessage(playerid, -1, "Server: Discord Chat is already switched on!");
  88.  
  89.     Iter_Remove(Player_DiscordChat, playerid);
  90.     SendClientMessage(playerid, -1, "Server: Discord Chat turned off.");
  91.     return 1;
  92. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top