08.10.2017, 18:17
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; }