Guest User

DChat - Discord IRC System by CyberH4wk

a guest
Apr 17th, 2020
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.27 KB | None | 0 0
  1. //DChat - Discord IRC System v1.0 by CyberH4wk
  2.  
  3. #include <a_samp>
  4. #include <discord-connector>
  5.  
  6. new DCC_Channel:g_Discord_Chat;
  7.  
  8. public OnFilterScriptInit()
  9. {
  10.     print("\n===================================");
  11.     print("|      DISCORD IRC SYSTEM V.1.0      |");
  12.     print("|   BY CYBERH4WK LOADED SUCCESFULL   |");
  13.     print("=====================================\n");
  14.     g_Discord_Chat = DCC_FindChannelById("YOUR_CHANNEL_ID"); // Discord channel ID
  15.     return 1;
  16. }
  17.  
  18. forward DCC_OnMessageCreate(DCC_Message:message);
  19.  
  20. public DCC_OnMessageCreate(DCC_Message:message)
  21. {
  22.     new realMsg[100];
  23.     DCC_GetMessageContent(message, realMsg, 100);
  24.     new bool:IsBot;
  25.     new DCC_Channel:channel;
  26.     DCC_GetMessageChannel(message, channel);
  27.     new DCC_User:author;
  28.     DCC_GetMessageAuthor(message, author);
  29.     DCC_IsUserBot(author, IsBot);
  30.     if(channel == g_Discord_Chat && !IsBot) //!IsBot will block BOT's message in game
  31.     {
  32.         new user_name[32 + 1], str[152];
  33.         DCC_GetUserName(author, user_name, 32);
  34.         format(str,sizeof(str), "{8a6cd1}[DISCORD] {aa1bb5}%s: {ffffff}%s",user_name, realMsg);
  35.         SendClientMessageToAll(-1, str);
  36.     }
  37.  
  38.     return 1;
  39. }
  40.  
  41. public OnPlayerText(playerid, text[])
  42. {
  43.  
  44.     new name[MAX_PLAYER_NAME + 1];
  45.     GetPlayerName(playerid, name, sizeof name);
  46.     new msg[128];
  47.     format(msg, sizeof(msg), "```%s: %s```", name, text);
  48.     DCC_SendChannelMessage(g_Discord_Chat, msg);
  49.     return 1;
  50. }
  51.  
  52.  
  53.  
  54. public OnPlayerConnect(playerid)
  55. {
  56.     new name[MAX_PLAYER_NAME + 1];
  57.     GetPlayerName(playerid, name, sizeof name);
  58.  
  59.     if (_:g_Discord_Chat == 0)
  60.     g_Discord_Chat = DCC_FindChannelById("YOUR_CHANNEL_ID"); // Discord channel ID
  61.  
  62.     new string[128];
  63.     format(string, sizeof string, " ```%s Joined The Server. :)```", name);
  64.     DCC_SendChannelMessage(g_Discord_Chat, string);
  65.     return 1;
  66. }
  67.  
  68. public OnPlayerDisconnect(playerid, reason)
  69. {
  70.     new name[MAX_PLAYER_NAME + 1];
  71.     GetPlayerName(playerid, name, sizeof name);
  72.  
  73.     if (_:g_Discord_Chat == 0)
  74.     g_Discord_Chat = DCC_FindChannelById("YOUR_CHANNEL_ID"); // Discord channel ID
  75.  
  76.     new string[128];
  77.     format(string, sizeof string, " ```%s Has Left The Server. :(```", name);
  78.     DCC_SendChannelMessage(g_Discord_Chat, string);
  79.     return 1;
  80. }
Add Comment
Please, Sign In to add comment