SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 19/05/2017, 12:48 AM   #41
ISmokezU
Huge Clucker
 
Join Date: Aug 2016
Posts: 455
Reputation: 45
Default Re: Discord Connector

I've a problem where i see my bot messages ingame which is really annoying, for example if someone say something in the discord chat it would show like: ([discord: ServerBot]: test) if i say test ingame i will see the bot saying it ingame as well ([discord: Player]: test), Why is this happening, Has it happen to anyone else?

PHP Code:
public DCC_OnChannelMessage(DCC_Channel:channel, const author[], const message[])
{
    new 
tmp144 ];
    
format(tmpsizeof (tmp), "[discord: %s]: {FFFFFF}%s"authormessage);
    
SendClientMessageToAll(-1tmp);
    return 
true;

__________________
Don't PM me. PM Jelly23 Instead.
ISmokezU is offline   Reply With Quote
Old 19/05/2017, 04:20 AM   #42
Infra
Big Clucker
 
Infra's Avatar
 
Join Date: Feb 2014
Location: Germany
Posts: 77
Reputation: 8
Default Re: Discord Connector

Quote:
Originally Posted by ISmokezU View Post
I've a problem where i see my bot messages ingame which is really annoying, for example if someone say something in the discord chat it would show like: ([discord: ServerBot]: test) if i say test ingame i will see the bot saying it ingame as well ([discord: Player]: test), Why is this happening, Has it happen to anyone else?

PHP Code:
public DCC_OnChannelMessage(DCC_Channel:channel, const author[], const message[])
{
    new 
tmp144 ];
    
format(tmpsizeof (tmp), "[discord: %s]: {FFFFFF}%s"authormessage);
    
SendClientMessageToAll(-1tmp);
    return 
true;

Just skip it if it's the bot

Code:
if (!strcmp(author, "BOT-NAME", false)) return true;
Infra is offline   Reply With Quote
Old 19/05/2017, 07:36 PM   #43
ISmokezU
Huge Clucker
 
Join Date: Aug 2016
Posts: 455
Reputation: 45
Default Re: Discord Connector

Yeah, but as i said when i type something in the discord server while this code is in place it doesn't send the message ingame, idk why it seems that i'm the only one getting this problem.

PHP Code:
   if(!strcmp(author"Server BOT"true)) return true;
    else 
SendClientMessageToAll(-1tmp); 
__________________
Don't PM me. PM Jelly23 Instead.
ISmokezU is offline   Reply With Quote
Old 22/05/2017, 08:45 PM   #44
Michael@Belgium
High-roller
 
Michael@Belgium's Avatar
 
Join Date: Dec 2010
Location: Belgium
Posts: 3,046
Reputation: 982
Default Re: Discord Connector

The two things u need to check is if the name isn't the bots name and if the channel isn't the echo channel where stuff happens.

Code:
public OnGameModeInit()
{
	DCC_Connect("mytoken");
	Server[DiscordChannel] = DCC_FindChannelByName("echo_channel");
	return 1;
}

public DCC_OnChannelMessage(DCC_Channel:channel, const author[], const message[])
{
	if(!strcmp(author, "server-bot", true) || channel != Server[DiscordChannel]) return 0;
	new string[128];
        format(string,sizeof(string),"%s: %s", author, message);
        SendClientMessageToAll(-1,string);
}
Also you need to return false @ISmokezU when the author is the bots name, else - as you said - nobody can send msgs ingame, except the bot
__________________
Mah Github. - Mah Youtube
Interested in a full featured and cheap derby gamemode or need host-tab ? Contact me on skype: michael.belgium
Michael@Belgium is offline   Reply With Quote
Old 27/05/2017, 12:51 AM   #45
ISmokezU
Huge Clucker
 
Join Date: Aug 2016
Posts: 455
Reputation: 45
Default Re: Discord Connector

Quote:
Originally Posted by Michael@Belgium View Post
The two things u need to check is if the name isn't the bots name and if the channel isn't the echo channel where stuff happens.

Code:
public OnGameModeInit()
{
	DCC_Connect("mytoken");
	Server[DiscordChannel] = DCC_FindChannelByName("echo_channel");
	return 1;
}

public DCC_OnChannelMessage(DCC_Channel:channel, const author[], const message[])
{
	if(!strcmp(author, "server-bot", true) || channel != Server[DiscordChannel]) return 0;
	new string[128];
        format(string,sizeof(string),"%s: %s", author, message);
        SendClientMessageToAll(-1,string);
}
Also you need to return false @ISmokezU when the author is the bots name, else - as you said - nobody can send msgs ingame, except the bot

Ah, That's why i've been seeing text from other channels in game thanks!
__________________
Don't PM me. PM Jelly23 Instead.
ISmokezU is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] Teamspeak Connector maddinat0r Plugin Development 313 21/05/2017 05:34 PM
[FilterScript] 0.3.7 Tube Connector 1.10 (Matite tubes) adri1 Lanzamientos/Releases 9 01/07/2015 11:36 PM
Route Connector James_Braga Русский/Russian 9 15/05/2015 08:24 AM
[Map] Connector Gas Tellken Maps 4 01/06/2012 03:04 AM
PSU connector help! patchkinson Everything and Nothing 3 20/03/2010 09:24 PM


All times are GMT. The time now is 01:57 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.