Connect to second database
#3

I have GameMode with MySQL systems, i created new filterscript, which has a task to do - sending messages to shoutbox table on other server. Code fs:
Код:
#include <samp/a_samp>
#include <plugin/a_mysql>
#include <plugin/sscanf2>
#include <PTS/engine/izcmd>
#include <PTS/security/Cenzura>
#include <kolory>
#include <SAM/DataConvert>
#define MYSQL_HOST "ip...."
#define MYSQL_USER "user"
#define MYSQL_PASS "xxxx"
#define MYSQL_DB   "mybb"
new ConMySQL2;

public OnFilterScriptInit()
{
	new rConn2 = mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_DB,MYSQL_PASS);
	if(!rConn2 || !mysql_ping(rConn2)){
		printf(" Nie udalo sie polaczyc z baza danych2");
		SendClientMessageToAll(COLOR_ORANGE,"Nie działa");
		SendRconCommand("exit");
		return 0;
	}
	print("Zaladowano");
	SendClientMessageToAll(COLOR_ORANGE,"Działa");
	
	ConMySQL2 = rConn2;
    return 1;
}
public OnFilterScriptExit()
{

	mysql_close(ConMySQL2);
    return 1;
}



stock GetPlayerNick(playerid){
	new pnick[MAX_PLAYER_NAME];
	GetPlayerName(playerid,pnick,sizeof(pnick));
	return pnick;
}


CMD:shoutbox(playerid, params[])
{
	new text[200];
	new query[500];
	new string[500];
	if(IsPlayerAdmin(playerid))
	{
		if(sscanf(params,"s[256]",text))
		{
			return SendClientMessage(playerid,COLOR_WHITE,"Wpisz: /shoutbox [Tekst]");
		}
		else
		{
			format(query, sizeof(query), "INSERT INTO `mybb_dvz_shoutbox` (`uid`, `text`) VALUES ('0', '%s: %s');", GetPlayerNick(playerid), text); 
			mysql_query(query, ConMySQL2);
			format(string,sizeof(string),"Dodałeś wiadomość na shoutboxa: {FF0000}%s",text);
			SendClientMessage(playerid, COLOR_RED, string);
		}
	}
	else
	{
	SendClientMessage(playerid,COLOR_RED,"Nie jesteś godzien tej komendy");
	}
	return 1;
}
Reply


Messages In This Thread
Connect to second database - by Rufcio - 08.10.2017, 17:30
Re: Connect to second database - by Maximun - 08.10.2017, 17:43
Re: Connect to second database - by Rufcio - 08.10.2017, 18:17
Re: Connect to second database - by Abagail - 08.10.2017, 18:24
Re: Connect to second database - by Rufcio - 08.10.2017, 18:44
Re: Connect to second database - by ConnorHunter - 08.10.2017, 18:53
Re: Connect to second database - by Rufcio - 08.10.2017, 19:07
Re: Connect to second database - by Famalamalam - 08.10.2017, 19:10
Re: Connect to second database - by Jstylezzz - 08.10.2017, 19:25
Re: Connect to second database - by Rufcio - 08.10.2017, 20:49

Forum Jump:


Users browsing this thread: 1 Guest(s)