SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 19/05/2017, 07:36 PM   #41
ISmokezU
Gangsta
 
Join Date: Aug 2016
Posts: 533
Reputation: 58
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); 
ISmokezU is offline   Reply With Quote
Old 22/05/2017, 08:45 PM   #42
Michael@Belgium
High-roller
 
Michael@Belgium's Avatar
 
Join Date: Dec 2010
Location: Belgium
Posts: 3,052
Reputation: 1001
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   #43
ISmokezU
Gangsta
 
Join Date: Aug 2016
Posts: 533
Reputation: 58
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!
ISmokezU is offline   Reply With Quote
Old 06/06/2017, 01:40 PM   #44
Crystallize
High-roller
 
Join Date: Aug 2013
Posts: 1,477
Reputation: 283
Default Re: Discord Connector

It's possible yet to issue ban commands through discord?
__________________

Crystallize is offline   Reply With Quote
Old 17/06/2017, 09:48 AM   #45
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   #46
hotspicytaco
Huge Clucker
 
hotspicytaco's Avatar
 
Join Date: Dec 2011
Location: Taco Bell
Posts: 231
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
}
hotspicytaco is offline   Reply With Quote
Old 21/06/2017, 01:05 PM   #47
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   #48
justice96
Guest
 
Posts: n/a
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");
  Reply With Quote
Old 26/06/2017, 10:13 AM   #49
PRoleplay
Big Clucker
 
Join Date: Nov 2012
Posts: 123
Reputation: 0
Default Re: Discord Connector

First what is this thing? and how this thing helps on our Server? thanks I have no idea about this thanks
PRoleplay is offline   Reply With Quote
Old 26/06/2017, 11:51 AM   #50
Sew_Sumi
High-roller
 
Join Date: Jun 2008
Posts: 4,827
Reputation: 335
Default Re: Discord Connector

Allows you to send information from the script through a bot to a discord channel, who can also relay information back to the script from the channel.
Sew_Sumi 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
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 03:58 AM.


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