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: 476
Reputation: 50
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;

__________________
AFTER ALL
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: 476
Reputation: 50
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); 
__________________
AFTER ALL
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,047
Reputation: 986
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: 476
Reputation: 50
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!
__________________
AFTER ALL
ISmokezU is offline   Reply With Quote
Old 06/06/2017, 01:40 PM   #46
Crystallize
High-roller
 
Join Date: Aug 2013
Posts: 1,357
Reputation: 261
Default Re: Discord Connector

It's possible yet to issue ban commands through discord?
__________________
Quote:
Originally Posted by Meller View Post
I thought you were supposed to work at the job?
Crystallize is offline   Reply With Quote
Old 17/06/2017, 09:48 AM   #47
Hazliu
Big Clucker
 
Join Date: May 2015
Location: Romania
Posts: 62
Reputation: 4
Default Re: Discord Connector

How to send an message from server to discrod?
I'd try smth:

Code:
CMD:dsay(playerid, params[])
{
	if(PlayerInfo[playerid][pHelper] < 1 && PlayerInfo[playerid][pAdmin] < 1) return SSM(playerid, AdminOnly);
	DCC_FindChannelById("DISCORD CHANNEL ID"); // Discord channel ID
	new string1[256];
	if(sscanf(params, "s[256]", string1)) return ShowSyntax(playerid, "/dsay <Text>");
	format(strglobal, sizeof(strglobal), "[SERVER] %s: %s", GetName(playerid), string1);
	DCC_SendChannelMessage(DCC_FindChannelById, strglobal);
	return 1;
}
But i get this error: error 076: syntax error in the expression, or invalid function call... what should i do?
__________________
My Work:
Nothing!
Hazliu is offline   Reply With Quote
Old 21/06/2017, 03:58 AM   #48
LuiisRubio
Huge Clucker
 
LuiisRubio's Avatar
 
Join Date: Dec 2011
Location: Taco Bell
Posts: 221
Reputation: 37
Default Respuesta: Discord Connector

Server hangs when I try to use DCC_Connect, any ideas?

Code
Code:
#include <a_samp>
#include <discord-connector>

stock const BOT_KEY[] = "-----------";

new DCC_Channel:current_channel;


public OnFilterScriptInit()
{
	print("Connecting...");
	
	DCC_Connect(BOT_KEY);

	// This one doesn't get sent
	print("Connected, hopefully.");

	return true;
}
Logs (Windows)
Code:
[22:40:06] [INFO] changed log level from 'warning, error' to 'debug, info, warning, error'
[22:40:10] [DEBUG] DCC_Connect("*****") (C:\Program Files\SA-MP Server\filterscripts\discord_bot.pwn:14)
[22:40:11] [DEBUG] CCallback::Create(amx=0x28c58f8, name='DCC_OnChannelMessage')
[22:40:11] [DEBUG] CNetwork::Initialize
[22:40:11] [DEBUG] CNetwork::HttpConnect
[22:40:13] [DEBUG] CNetwork::HttpGet
[22:40:13] [DEBUG] CNetwork::HttpSendRequest
[22:40:13] [DEBUG] CNetwork::HttpPrepareRequest
[22:40:13] [DEBUG] CNetwork::HttpSendRequest(/api/v5/gateway) (actual send)
[22:40:13] [DEBUG] CNetwork::HttpWriteRequest
[22:40:13] [DEBUG] CNetwork::WsConnect
[22:40:14] [DEBUG] CNetwork::WsRead
[22:40:14] [DEBUG] CNetwork::WsIdentify
[22:40:14] [DEBUG] CNetwork::OnWsRead
[22:40:14] [DEBUG] OnWsRead: {
    "d": {
        "_trace": [
            "discord-gateway-prd-1-2"
        ],
        "heartbeat_interval": 41250
    },
    "op": 10,
    "s": null,
    "t": null
}
[22:40:14] [DEBUG] CNetwork::DoHeartbeat
[22:40:14] [DEBUG] sending heartbeat
[22:40:14] [DEBUG] CNetwork::WsRead
[22:40:15] [DEBUG] CNetwork::OnWsRead
[22:40:15] [DEBUG] OnWsRead: {
    "d": null,
    "op": 11,
    "s": null,
    "t": null
}
[22:40:15] [DEBUG] heartbeat ACK
[22:40:15] [DEBUG] CNetwork::WsRead
[22:40:15] [DEBUG] CNetwork::OnWsRead
[22:40:15] [DEBUG] OnWsRead: {
    "d": {
        "_trace": [
            "discord-gateway-prd-1-2",
            "discord-sessions-prd-1-12"
        ],
        "guilds": [],
        "presences": [],
        "private_channels": [],
        "relationships": [],
        "session_id": "d59b64f5d58604174247234704306fff",
        "user": {
            "avatar": "fdc5f2db778dfa503da60e5a819afbd3",
            "bot": true,
            "discriminator": "0634",
            "email": null,
            "id": "326851078840647682",
            "mfa_enabled": false,
            "username": "BOT_NAME",
            "verified": true
        },
        "user_settings": {},
        "v": 5
    },
    "op": 0,
    "s": 1,
    "t": "READY"
}
[22:40:15] [DEBUG] CNetwork::WsRead
Ubuntu 14.04 using Linux/Centos release

Code:
23:16:29] [INFO] changed log level from 'warning, error' to 'debug, info, warning, error'
[23:16:30] [DEBUG] DCC_Connect("*****") (C:\Program Files\SA-MP Server\gamemodes\disbot.pwn:14)
[23:16:30] [DEBUG] CCallback::Create(amx=0x9f7bb08, name='DCC_OnChannelMessage')
[23:16:30] [DEBUG] CCallback::Create - callback index for 'DCC_OnChannelMessage': 0
[23:16:30] [INFO] Callback 'DCC_OnChannelMessage' set up for delayed execution.
[23:16:30] [DEBUG] CNetwork::Initialize
[23:16:30] [DEBUG] CNetwork::HttpConnect
[23:16:30] [DEBUG] CNetwork::HttpGet
[23:16:30] [DEBUG] CNetwork::HttpSendRequest
[23:16:30] [DEBUG] CNetwork::HttpPrepareRequest
[23:16:30] [DEBUG] CNetwork::HttpSendRequest(/api/v5/gateway) (actual send)
[23:16:30] [DEBUG] CNetwork::HttpWriteRequest
[23:16:30] [DEBUG] CNetwork::WsConnect
[23:16:30] [DEBUG] CNetwork::WsRead
[23:16:30] [DEBUG] CNetwork::WsIdentify
[23:16:30] [DEBUG] CNetwork::OnWsRead
[23:16:30] [DEBUG] OnWsRead: {
    "d": {
        "_trace": [
            "discord-gateway-prd-1-15"
        ],
        "heartbeat_interval": 41250
    },
    "op": 10,
    "s": null,
    "t": null
}
[23:16:30] [DEBUG] CNetwork::DoHeartbeat
[23:16:30] [DEBUG] sending heartbeat
[23:16:30] [DEBUG] CNetwork::WsRead
[23:16:30] [DEBUG] CNetwork::OnWsRead
[23:16:30] [DEBUG] OnWsRead: {
    "d": null,
    "op": 11,
    "s": null,
    "t": null
}
[23:16:30] [DEBUG] heartbeat ACK
[23:16:30] [DEBUG] CNetwork::WsRead
[23:16:30] [DEBUG] CNetwork::OnWsRead
[23:16:30] [DEBUG] OnWsRead: {
    "d": {
        "_trace": [
            "discord-gateway-prd-1-15",
            "discord-sessions-prd-1-3"
        ],
        "guilds": [],
        "presences": [],
        "private_channels": [],
        "relationships": [],
        "session_id": "2853abc5d5b49f55e412915dbad519ea",
        "user": {
            "avatar": "fdc5f2db778dfa503da60e5a819afbd3",
            "bot": true,
            "discriminator": "0634",
            "email": null,
            "id": "326851078840647682",
            "mfa_enabled": false,
            "username": "BOTNAME",
            "verified": true
        },
        "user_settings": {},
        "v": 5
    },
    "op": 0,
    "s": 1,
    "t": "READY"
}
[23:16:30] [DEBUG] CNetwork::WsRead
[23:16:52] [DEBUG] CNetwork::DoHeartbeat
[23:16:52] [DEBUG] sending heartbeat
[23:16:52] [DEBUG] CNetwork::OnWsRead
[23:16:52] [DEBUG] OnWsRead: {
    "d": null,
    "op": 11,
    "s": null,
    "t": null
}
[23:16:52] [DEBUG] heartbeat ACK
[23:16:52] [DEBUG] CNetwork::WsRead
[23:17:12] [DEBUG] CNetwork::DoHeartbeat
[23:17:12] [DEBUG] sending heartbeat
[23:17:12] [DEBUG] CNetwork::OnWsRead
[23:17:12] [DEBUG] OnWsRead: {
    "d": null,
    "op": 11,
    "s": null,
    "t": null
}
LuiisRubio is offline   Reply With Quote
Old 21/06/2017, 01:05 PM   #49
Advait
Little Clucker
 
Join Date: Mar 2017
Posts: 29
Reputation: 0
Default Re: Discord Connector

No idea
Advait is offline   Reply With Quote
Old 22/06/2017, 12:00 AM   #50
justice96
Huge Clucker
 
Join Date: Nov 2014
Location: Indonesia
Posts: 364
Reputation: 42
Default Re: Respuesta: Discord Connector

Quote:
Originally Posted by LuiisRubio View Post
Server hangs when I try to use DCC_Connect, any ideas?

Code
Code:
#include <a_samp>
#include <discord-connector>

stock const BOT_KEY[] = "-----------";

new DCC_Channel:current_channel;


public OnFilterScriptInit()
{
	print("Connecting...");
	
	DCC_Connect(BOT_KEY);

	// This one doesn't get sent
	print("Connected, hopefully.");

	return true;
}
Logs (Windows)
Code:
[22:40:06] [INFO] changed log level from 'warning, error' to 'debug, info, warning, error'
[22:40:10] [DEBUG] DCC_Connect("*****") (C:\Program Files\SA-MP Server\filterscripts\discord_bot.pwn:14)
[22:40:11] [DEBUG] CCallback::Create(amx=0x28c58f8, name='DCC_OnChannelMessage')
[22:40:11] [DEBUG] CNetwork::Initialize
[22:40:11] [DEBUG] CNetwork::HttpConnect
[22:40:13] [DEBUG] CNetwork::HttpGet
[22:40:13] [DEBUG] CNetwork::HttpSendRequest
[22:40:13] [DEBUG] CNetwork::HttpPrepareRequest
[22:40:13] [DEBUG] CNetwork::HttpSendRequest(/api/v5/gateway) (actual send)
[22:40:13] [DEBUG] CNetwork::HttpWriteRequest
[22:40:13] [DEBUG] CNetwork::WsConnect
[22:40:14] [DEBUG] CNetwork::WsRead
[22:40:14] [DEBUG] CNetwork::WsIdentify
[22:40:14] [DEBUG] CNetwork::OnWsRead
[22:40:14] [DEBUG] OnWsRead: {
    "d": {
        "_trace": [
            "discord-gateway-prd-1-2"
        ],
        "heartbeat_interval": 41250
    },
    "op": 10,
    "s": null,
    "t": null
}
[22:40:14] [DEBUG] CNetwork::DoHeartbeat
[22:40:14] [DEBUG] sending heartbeat
[22:40:14] [DEBUG] CNetwork::WsRead
[22:40:15] [DEBUG] CNetwork::OnWsRead
[22:40:15] [DEBUG] OnWsRead: {
    "d": null,
    "op": 11,
    "s": null,
    "t": null
}
[22:40:15] [DEBUG] heartbeat ACK
[22:40:15] [DEBUG] CNetwork::WsRead
[22:40:15] [DEBUG] CNetwork::OnWsRead
[22:40:15] [DEBUG] OnWsRead: {
    "d": {
        "_trace": [
            "discord-gateway-prd-1-2",
            "discord-sessions-prd-1-12"
        ],
        "guilds": [],
        "presences": [],
        "private_channels": [],
        "relationships": [],
        "session_id": "d59b64f5d58604174247234704306fff",
        "user": {
            "avatar": "fdc5f2db778dfa503da60e5a819afbd3",
            "bot": true,
            "discriminator": "0634",
            "email": null,
            "id": "326851078840647682",
            "mfa_enabled": false,
            "username": "BOT_NAME",
            "verified": true
        },
        "user_settings": {},
        "v": 5
    },
    "op": 0,
    "s": 1,
    "t": "READY"
}
[22:40:15] [DEBUG] CNetwork::WsRead
Ubuntu 14.04 using Linux/Centos release

Code:
23:16:29] [INFO] changed log level from 'warning, error' to 'debug, info, warning, error'
[23:16:30] [DEBUG] DCC_Connect("*****") (C:\Program Files\SA-MP Server\gamemodes\disbot.pwn:14)
[23:16:30] [DEBUG] CCallback::Create(amx=0x9f7bb08, name='DCC_OnChannelMessage')
[23:16:30] [DEBUG] CCallback::Create - callback index for 'DCC_OnChannelMessage': 0
[23:16:30] [INFO] Callback 'DCC_OnChannelMessage' set up for delayed execution.
[23:16:30] [DEBUG] CNetwork::Initialize
[23:16:30] [DEBUG] CNetwork::HttpConnect
[23:16:30] [DEBUG] CNetwork::HttpGet
[23:16:30] [DEBUG] CNetwork::HttpSendRequest
[23:16:30] [DEBUG] CNetwork::HttpPrepareRequest
[23:16:30] [DEBUG] CNetwork::HttpSendRequest(/api/v5/gateway) (actual send)
[23:16:30] [DEBUG] CNetwork::HttpWriteRequest
[23:16:30] [DEBUG] CNetwork::WsConnect
[23:16:30] [DEBUG] CNetwork::WsRead
[23:16:30] [DEBUG] CNetwork::WsIdentify
[23:16:30] [DEBUG] CNetwork::OnWsRead
[23:16:30] [DEBUG] OnWsRead: {
    "d": {
        "_trace": [
            "discord-gateway-prd-1-15"
        ],
        "heartbeat_interval": 41250
    },
    "op": 10,
    "s": null,
    "t": null
}
[23:16:30] [DEBUG] CNetwork::DoHeartbeat
[23:16:30] [DEBUG] sending heartbeat
[23:16:30] [DEBUG] CNetwork::WsRead
[23:16:30] [DEBUG] CNetwork::OnWsRead
[23:16:30] [DEBUG] OnWsRead: {
    "d": null,
    "op": 11,
    "s": null,
    "t": null
}
[23:16:30] [DEBUG] heartbeat ACK
[23:16:30] [DEBUG] CNetwork::WsRead
[23:16:30] [DEBUG] CNetwork::OnWsRead
[23:16:30] [DEBUG] OnWsRead: {
    "d": {
        "_trace": [
            "discord-gateway-prd-1-15",
            "discord-sessions-prd-1-3"
        ],
        "guilds": [],
        "presences": [],
        "private_channels": [],
        "relationships": [],
        "session_id": "2853abc5d5b49f55e412915dbad519ea",
        "user": {
            "avatar": "fdc5f2db778dfa503da60e5a819afbd3",
            "bot": true,
            "discriminator": "0634",
            "email": null,
            "id": "326851078840647682",
            "mfa_enabled": false,
            "username": "BOTNAME",
            "verified": true
        },
        "user_settings": {},
        "v": 5
    },
    "op": 0,
    "s": 1,
    "t": "READY"
}
[23:16:30] [DEBUG] CNetwork::WsRead
[23:16:52] [DEBUG] CNetwork::DoHeartbeat
[23:16:52] [DEBUG] sending heartbeat
[23:16:52] [DEBUG] CNetwork::OnWsRead
[23:16:52] [DEBUG] OnWsRead: {
    "d": null,
    "op": 11,
    "s": null,
    "t": null
}
[23:16:52] [DEBUG] heartbeat ACK
[23:16:52] [DEBUG] CNetwork::WsRead
[23:17:12] [DEBUG] CNetwork::DoHeartbeat
[23:17:12] [DEBUG] sending heartbeat
[23:17:12] [DEBUG] CNetwork::OnWsRead
[23:17:12] [DEBUG] OnWsRead: {
    "d": null,
    "op": 11,
    "s": null,
    "t": null
}
Code:
stock const BOT_KEY[] = "-----------";
It doesn't needed, you can just do this
Code:
DCC_Connect("botkey here");
justice96 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 314 09/06/2017 07:46 AM
[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 07:03 PM.


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