Guest User

BlackBank Discord

a guest
Apr 14th, 2019
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.63 KB | None | 0 0
  1. new DCC_Channel:discord_channel_id;
  2.  
  3. public OnGameModeInit()
  4. {
  5.     discord_channel_id = DCC_FindChannelByName("samp-server"); // The channel name you want the bot to listen to.
  6.     return 1;
  7. }
  8.  
  9. public OnPlayerConnect(playerid)
  10. {
  11.     new
  12.         string[50 + MAX_PLAYER_NAME],
  13.         playerName[MAX_PLAYER_NAME]
  14.     ;
  15.  
  16.     GetPlayerName(playerid, playerName, sizeof(playerName));
  17.  
  18.     if (discord_channel_id) {
  19.         format(string, sizeof(string), "``[CONNECTION] %s has connected to the server.``", playerName);
  20.         DCC_SendChannelMessage(discord_channel_id, string);
  21.     }
  22.     return 1;
  23. }
  24.  
  25. public OnPlayerText(playerid, text[])
  26. {
  27.     new
  28.         string[128 + MAX_PLAYER_NAME],
  29.         playerName[MAX_PLAYER_NAME]
  30.     ;
  31.     if (discord_channel_id) {
  32.         format(string, sizeof(string), "``%s(%d): %s``", playerName, playerid, text);
  33.         DCC_SendChannelMessage(discord_channel_id, string); // Send player message to discord server.
  34.     }
  35.     return 1;
  36. }
  37.  
  38. public DCC_OnChannelMessage(DCC_Channel:channel, DCC_User:author, const message[])
  39. {
  40.     if (channel != discord_channel_id) { // If channel is not 'samp-server', skip it.
  41.         return 0;
  42.     }
  43.    
  44.     new bool:is_bot;
  45.     DCC_IsUserBot(author, is_bot); // Check if a bot sends a message, if so, ignore it.
  46.     if (is_bot) {
  47.         return 0;
  48.     }
  49.    
  50.     new username[33];
  51.     if (!DCC_GetUserName(author, username)) { // Get username of discord user.
  52.         return 0;
  53.     }
  54.  
  55.     format(string, sizeof(string), "[DISCORD] %s: %s", username, message); // Send Discord message to samp server.
  56.     SendClientMessageToAll(-1, string);
  57.     return 1;
  58. }
Add Comment
Please, Sign In to add comment