Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new DCC_Channel:discord_channel_id;
- public OnGameModeInit()
- {
- discord_channel_id = DCC_FindChannelByName("samp-server"); // The channel name you want the bot to listen to.
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new
- string[50 + MAX_PLAYER_NAME],
- playerName[MAX_PLAYER_NAME]
- ;
- GetPlayerName(playerid, playerName, sizeof(playerName));
- if (discord_channel_id) {
- format(string, sizeof(string), "``[CONNECTION] %s has connected to the server.``", playerName);
- DCC_SendChannelMessage(discord_channel_id, string);
- }
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- new
- string[128 + MAX_PLAYER_NAME],
- playerName[MAX_PLAYER_NAME]
- ;
- if (discord_channel_id) {
- format(string, sizeof(string), "``%s(%d): %s``", playerName, playerid, text);
- DCC_SendChannelMessage(discord_channel_id, string); // Send player message to discord server.
- }
- return 1;
- }
- public DCC_OnChannelMessage(DCC_Channel:channel, DCC_User:author, const message[])
- {
- if (channel != discord_channel_id) { // If channel is not 'samp-server', skip it.
- return 0;
- }
- new bool:is_bot;
- DCC_IsUserBot(author, is_bot); // Check if a bot sends a message, if so, ignore it.
- if (is_bot) {
- return 0;
- }
- new username[33];
- if (!DCC_GetUserName(author, username)) { // Get username of discord user.
- return 0;
- }
- format(string, sizeof(string), "[DISCORD] %s: %s", username, message); // Send Discord message to samp server.
- SendClientMessageToAll(-1, string);
- return 1;
- }
Add Comment
Please, Sign In to add comment