SA-MP Forums Archive
Discord Bot Permissions - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Discord Bot Permissions (/showthread.php?tid=655977)



Discord Bot Permissions - OmerKhan - 04.07.2018

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,


Re: Discord Bot Permissions - kovac - 04.07.2018

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.


Re: Discord Bot Permissions - OmerKhan - 04.07.2018

Код:
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.


Re: Discord Bot Permissions - kovac - 04.07.2018

What's DiscordStats?


Re: Discord Bot Permissions - OmerKhan - 04.07.2018

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



Re: Discord Bot Permissions - kovac - 04.07.2018

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;




Re: Discord Bot Permissions - OmerKhan - 04.07.2018

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);



Re: Discord Bot Permissions - kovac - 04.07.2018

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


Re: Discord Bot Permissions - OmerKhan - 04.07.2018

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


Re: Discord Bot Permissions - Sasino97 - 04.07.2018

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.