Discord Bot Permissions
#1

Whenever I type any command on Discord, the output (which Is sent by the bot) is shown in game chat, Along with Connect and Disconnect Messages. I only want player messages, the ones which players input, to be seen in game and not the bot messages. Is there any way to do so? If Yes, Kindly tell me. Also, Is there any way to make specific permissions for each Discord role, like for e.g Connect messages are only sent to Ones having a role "admins or owners" and not to someone else. Thanks.

Regards,
Reply
#2

An example how to disable bot messages:

PHP код:
#define BOT_NAME "YourBotName"
public DCC_OnChannelMessage(DCC_Channel:channelDCC_User:author, const message[])
{
    new 
channel_name[100 1], user_name[32 1], user[24];
    if(!
DCC_GetChannelName(channelchannel_name)) return 0// invalid channel
    
if(!DCC_GetUserName(authoruser_name)) return 0// invalid user
    
DCC_GetUserName(DCC_User:authoruser24);
    if(!
strcmp(userBOT_NAME)) return 0// Don't show bot messages in chat

You can make a different channel and restric it's access to admins only and send messages to that channel.
Reply
#3

Код:
public DCC_OnChannelMessage(DCC_Channel:channel, DCC_User:author, const message[])
{
	new channel_name[100 + 1];
	if(!DCC_GetChannelName(channel, channel_name))
		return 0;

	new user_name[32 + 1];
	if (!DCC_GetUserName(author, user_name))
		return 0;

    if(channel != BotChannel) return 0;
	new str[145];
	format(str, sizeof str, "{667aca}[Discord]%s:{ffffff} %s", user_name, message);
    for(new i = 0; i < MAX_PLAYERS; i++) {
    if (DiscordStats[i]==0) continue;
    SendClientMessage(i, -1, str); }

    return 1;
}
Thanks for the quick response, However, It would be highly appreciated if you make another code according wise.
Reply
#4

What's DiscordStats?
Reply
#5

I don't know.
Код:
new DCC_Channel:BotChannel;
new DiscordStats[MAX_PLAYERS];
new Spawned[MAX_PLAYERS];
Reply
#6

It could be a disable option for messages or something similar.
Anyways..

PHP код:
#define BOT_NAME "YourBotName"
public DCC_OnChannelMessage(DCC_Channel:channelDCC_User:author, const message[])
{
    new 
channel_name[100 1];
    if(!
DCC_GetChannelName(channelchannel_name)) return 0// invalid channel
    
new user_name[32 1];
    if (!
DCC_GetUserName(authoruser_name)) return 0// invalid user
    
if(!strcmp(user_nameBOT_NAME)) return 0// Don't show bot messages in chat
        
    
new str[128];
    
format(strsizeof str"{667ACA}[Discord]%s:{FFFFFF} %s"user_namemessage);
    for(new 
0MAX_PLAYERSi++)
    {
        if(
DiscordStats[i] != 0);
            
SendClientMessage(i, -1str);
    }
    return 
1;

Reply
#7

Getting the Following Error:
Код:
D:\SAMP BP 2\scriptfiles\0Admin\DConnect.pwn(90) : error 036: empty statement
D:\SAMP BP 2\scriptfiles\0Admin\DConnect.pwn(91) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Line 90 and 91:
Код:
 if(DiscordStats[i] != 0);
          SendClientMessage(i, -1, str);
Reply
#8

Move SendClientMessage(i, -1, str); one tab left
Reply
#9

Didn't work.
Код:
D:\SAMP BP 2\scriptfiles\0Admin\DConnect.pwn(90) : error 036: empty statement
Line 90 is the Discord Stats one.
Reply
#10

Quote:
Originally Posted by OmerKhan
Посмотреть сообщение
Getting the Following Error:
Код:
D:\SAMP BP 2\scriptfiles\0Admin\DConnect.pwn(90) : error 036: empty statement
D:\SAMP BP 2\scriptfiles\0Admin\DConnect.pwn(91) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Line 90 and 91:
Код:
 if(DiscordStats[i] != 0);
          SendClientMessage(i, -1, str);
For those wondering about that problem: apart from removing the extra tabulation from SendClientMessage, remove the semicolon (;) after the if statement.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)