Witamy w Nieoficjalnym polskim support'cie AMX Mod X
Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
|
Dane sql w nowym pliku
#1
Napisano 22.03.2012 22:46
#2
Napisano 22.03.2012 22:58
amx_blabla_host
amx_blabla_user
amx_blabla_db
amx_blabla_pass
#3
Napisano 23.03.2012 08:48
Czyli jak mam tak wpisane
I po edycji pluginu to co mówileś wszystko powinno działąć ?
#4
Napisano 23.03.2012 09:11
#5
Napisano 23.03.2012 14:08
#6
Napisano 24.03.2012 08:52
#7
Napisano 24.03.2012 09:02
możesz je teraz dopisać do amxx.cfg a jak chcesz w odzielnnym pliku to kod do wczytania
new szPath[256]; formatex(szPath[ get_configsdir( szPath,charsmax( szPath ) ) ], charsmax( szPath ),"/nowysql.cfg"); server_cmd("exec %s",szPath); server_exec()dodajesz ten kod już po zarejestrowaniu cvarów
#8
Napisano 24.03.2012 21:23
zmieniasz nazwy cvarów w sma pluginu możesz je teraz dopisać do amxx.cfg
public check_sql() { new host[64], user[64], pass[64], db[64],errorcode get_cvar_string("rank_db_host", host, 63) get_cvar_string("rank_db_user", user, 63) get_cvar_string("rank_db_pass", pass, 63) get_cvar_string("rank_db_database", db, 63) g_SqlX = SQL_MakeDbTuple(host, user, pass, db) g_SqlConnection = SQL_Connect(g_SqlX,errorcode,g_error,511); if (!g_SqlConnection) { console_print(0,"Chat log SQL: Could not connect to SQL database.!") return log_amx("Chat log SQL: Could not connect to SQL database.") }
i jak SKOMPILOWALEM i dopisałem do amxx.cfg to nie trybi
#9
Napisano 25.03.2012 09:19
logi ?
sprawdź czy podałeś dobre dane do sql
#10
Napisano 25.03.2012 10:03
L 03/25/2012 - 10:35:20: [MySQL] Invalid handle: 0
L 03/25/2012 - 10:35:20: [AMXX] Run time error 10 (plugin "chat_logger_sq.amxx") (native "SQL_FreeHandle") - debug not enabled!
L 03/25/2012 - 10:35:20: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
logi z pliku tam gdzie sie zapisują logi startu prawidlowo dzialajacych pluginów
L 03/25/2012 - 10:35:23: [chat_logger_sq.amxx] Chat log SQL: Could not connect to SQL database.
Plugin sma skompilowałem podpialem pod te same dane co amxbans, tabela sie nie utworzyla w phpmyadmin.
oryginalny plik sma ( jest to plugin odpowiedzialny za zapis z say serwera )
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <sqlx>
#define PLUGINNAME "Chat Logger SQL"
#define VERSION "0.8b"
#define AUTHOR "naputtaja"
#define table "amx_chat_log"
#define MAXLEN 511
#define MAX_WORDS 150
// SQL Settings
new Handle:g_SqlX
new Handle:g_SqlConnection
new g_error[512]
new g_No_Save_Words[MAX_WORDS][20]
new g_No_Save_Num
new const TEAMNAME[_:CsTeams][] = {"*DEAD*", "(Terrorist)", "(Counter-Terrorist)", "*SPEC*"}
public check_sql()
{
new host[64], user[64], pass[64], db[64],errorcode
get_cvar_string("amx_sql_host", host, 63)
get_cvar_string("amx_sql_user", user, 63)
get_cvar_string("amx_sql_pass", pass, 63)
get_cvar_string("amx_sql_db", db, 63)
g_SqlX = SQL_MakeDbTuple(host, user, pass, db)
g_SqlConnection = SQL_Connect(g_SqlX,errorcode,g_error,511);
if (!g_SqlConnection) {
console_print(0,"Chat log SQL: Could not connect to SQL database.!")
return log_amx("Chat log SQL: Could not connect to SQL database.")
}
new query_create[1001]
format(query_create,1000,"CREATE TABLE IF NOT EXISTS `%s`(`id` int(11) NOT NULL auto_increment,`name` varchar(100) NOT NULL default '',`authid` varchar(100) NOT NULL default '',`ip` varchar(100) NOT NULL default '',`alive` int(11) NOT NULL default '0', `team` varchar(100) NOT NULL default '',`date` date NOT NULL default '0000-00-00',`time` time NOT NULL default '00:00:00',`cmd` varchar(100) NOT NULL default '',`message` text NOT NULL,PRIMARY KEY (`id`));",table)
SQL_ThreadQuery(g_SqlX,"QueryHandle",query_create)
console_print(0,"[AMXX SQL] Connected!")
return PLUGIN_CONTINUE
}
public chat_log_sql(id)
{
if(is_user_bot(id)) return
static datestr[11]
new authid[16],name[32],ip[16],timestr[9]
new cmd[9]
if(!is_user_connected(id)) return
read_argv(0,cmd,8)
new message[192]
read_args(message,191)
remove_quotes(message)
new i = 0
while ( i < g_No_Save_Num )
{
if ( containi ( message, g_No_Save_Words[i++] ) != -1 )return
}
new CsTeams:team = cs_get_user_team(id)
get_user_authid(id,authid,15)
get_user_name(id,name,31)
get_user_ip(id, ip, 15, 1)
get_time("%Y.%m.%d", datestr, 10)
get_time("%H:%M:%S", timestr, 8)
new query[1001]
format(query,1000,"INSERT into %s (name,authid,ip,alive,team,date,time,message,cmd) values ('%s','%s','%s','%d','%s','%s','%s','%s','%s')",table,name,authid,ip,is_user_alive(id),TEAMNAME[_:team],datestr,timestr,message,cmd)
SQL_ThreadQuery(g_SqlX,"QueryHandle",query)
}
public QueryHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
if(FailState == TQUERY_CONNECT_FAILED)
return log_amx("Chat log SQL: Could not connect to SQL database.")
else if(FailState == TQUERY_QUERY_FAILED)
return log_amx("Chat log SQL: Query failed")
if(Errcode)
return log_amx("Chat log SQL: Error on query: %s",Error)
new DataNum
while(SQL_MoreResults(Query))
{
DataNum = SQL_ReadResult(Query,0)
server_print("zomg, some data: %s",DataNum)
SQL_NextRow(Query)
}
return PLUGIN_CONTINUE
}
readList()
{
new Configsdir[64]
new NoSaveWords_file[64]
get_configsdir( Configsdir, 63 )
format(NoSaveWords_file, 63, "%s/ChatLoggerSQL_NoSaveWords.ini", Configsdir )
if ( !file_exists(NoSaveWords_file) )
{
return log_amx("Chat log SQL: ChatLoggerSQL_NoSaveWords.ini File not found")
server_print ( "====================================================================" )
server_print ( "[Chat Logger Sql] loaded ChatLoggerSQL_NoSaveWords.ini File not found", g_No_Save_Num )
server_print ( "====================================================================" )
}
new len, i=0
while( i < MAX_WORDS && read_file( NoSaveWords_file, i , g_No_Save_Words[g_No_Save_Num], 19, len ) )
{
i++
if( g_No_Save_Words[g_No_Save_Num][0] == ';' || len == 0 )
continue
g_No_Save_Num++
}
i=0
server_print ( "======================================================" )
server_print ( "[Chat Logger Sql] loaded %d No Save words", g_No_Save_Num )
server_print ( "======================================================" )
return PLUGIN_CONTINUE
}
public plugin_end()
{
SQL_FreeHandle(g_SqlConnection)
return
}
public plugin_init()
{
register_plugin(PLUGINNAME, VERSION, AUTHOR)
register_cvar("amx_chat_logger",VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
register_clcmd("say", "chat_log_sql")
register_clcmd("say_team", "chat_log_sql")
readList()
set_task(0.1, "check_sql")
return PLUGIN_CONTINUE
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1035\\ f0\\ fs16 \n\\ par }
*/
Plugin po przerobce
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <sqlx>
#define PLUGINNAME "Chat Logger SQL"
#define VERSION "0.8b"
#define AUTHOR "naputtaja"
#define table "amx_chat_log"
#define MAXLEN 511
#define MAX_WORDS 150
// SQL Settings
new Handle:g_SqlX
new Handle:g_SqlConnection
new g_error[512]
new g_No_Save_Words[MAX_WORDS][20]
new g_No_Save_Num
new const TEAMNAME[_:CsTeams][] = {"*DEAD*", "(Terrorist)", "(Counter-Terrorist)", "*SPEC*"}
public check_sql()
{
new host[64], user[64], pass[64], db[64],errorcode
get_cvar_string("rank_db_host", host, 63)
get_cvar_string("rank_db_user", user, 63)
get_cvar_string("rank_db_pass", pass, 63)
get_cvar_string("rank_db_database", db, 63)
g_SqlX = SQL_MakeDbTuple(host, user, pass, db)
g_SqlConnection = SQL_Connect(g_SqlX,errorcode,g_error,511);
if (!g_SqlConnection) {
console_print(0,"Chat log SQL: Could not connect to SQL database.!")
return log_amx("Chat log SQL: Could not connect to SQL database.")
}
new query_create[1001]
format(query_create,1000,"CREATE TABLE IF NOT EXISTS `%s`(`id` int(11) NOT NULL auto_increment,`name` varchar(100) NOT NULL default '',`authid` varchar(100) NOT NULL default '',`ip` varchar(100) NOT NULL default '',`alive` int(11) NOT NULL default '0', `team` varchar(100) NOT NULL default '',`date` date NOT NULL default '0000-00-00',`time` time NOT NULL default '00:00:00',`cmd` varchar(100) NOT NULL default '',`message` text NOT NULL,PRIMARY KEY (`id`));",table)
SQL_ThreadQuery(g_SqlX,"QueryHandle",query_create)
console_print(0,"[AMXX SQL] Connected!")
return PLUGIN_CONTINUE
}
public chat_log_sql(id)
{
if(is_user_bot(id)) return
static datestr[11]
new authid[16],name[32],ip[16],timestr[9]
new cmd[9]
if(!is_user_connected(id)) return
read_argv(0,cmd,8)
new message[192]
read_args(message,191)
remove_quotes(message)
new i = 0
while ( i < g_No_Save_Num )
{
if ( containi ( message, g_No_Save_Words[i++] ) != -1 )return
}
new CsTeams:team = cs_get_user_team(id)
get_user_authid(id,authid,15)
get_user_name(id,name,31)
get_user_ip(id, ip, 15, 1)
get_time("%Y.%m.%d", datestr, 10)
get_time("%H:%M:%S", timestr, 8)
new query[1001]
format(query,1000,"INSERT into %s (name,authid,ip,alive,team,date,time,message,cmd) values ('%s','%s','%s','%d','%s','%s','%s','%s','%s')",table,name,authid,ip,is_user_alive(id),TEAMNAME[_:team],datestr,timestr,message,cmd)
SQL_ThreadQuery(g_SqlX,"QueryHandle",query)
}
public QueryHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
if(FailState == TQUERY_CONNECT_FAILED)
return log_amx("Chat log SQL: Could not connect to SQL database.")
else if(FailState == TQUERY_QUERY_FAILED)
return log_amx("Chat log SQL: Query failed")
if(Errcode)
return log_amx("Chat log SQL: Error on query: %s",Error)
new DataNum
while(SQL_MoreResults(Query))
{
DataNum = SQL_ReadResult(Query,0)
server_print("zomg, some data: %s",DataNum)
SQL_NextRow(Query)
}
return PLUGIN_CONTINUE
}
readList()
{
new Configsdir[64]
new NoSaveWords_file[64]
get_configsdir( Configsdir, 63 )
format(NoSaveWords_file, 63, "%s/ChatLoggerSQL_NoSaveWords.ini", Configsdir )
if ( !file_exists(NoSaveWords_file) )
{
return log_amx("Chat log SQL: ChatLoggerSQL_NoSaveWords.ini File not found")
server_print ( "====================================================================" )
server_print ( "[Chat Logger Sql] loaded ChatLoggerSQL_NoSaveWords.ini File not found", g_No_Save_Num )
server_print ( "====================================================================" )
}
new len, i=0
while( i < MAX_WORDS && read_file( NoSaveWords_file, i , g_No_Save_Words[g_No_Save_Num], 19, len ) )
{
i++
if( g_No_Save_Words[g_No_Save_Num][0] == ';' || len == 0 )
continue
g_No_Save_Num++
}
i=0
server_print ( "======================================================" )
server_print ( "[Chat Logger Sql] loaded %d No Save words", g_No_Save_Num )
server_print ( "======================================================" )
return PLUGIN_CONTINUE
}
public plugin_end()
{
SQL_FreeHandle(g_SqlConnection)
return
}
public plugin_init()
{
register_plugin(PLUGINNAME, VERSION, AUTHOR)
register_cvar("amx_chat_logger",VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
register_clcmd("say", "chat_log_sql")
register_clcmd("say_team", "chat_log_sql")
readList()
set_task(0.1, "check_sql")
return PLUGIN_CONTINUE
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1035\\ f0\\ fs16 \n\\ par }
*/
#11
Napisano 25.03.2012 10:23
#12
Napisano 25.03.2012 13:31
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <sqlx>
#define PLUGINNAME "Chat Logger SQL"
#define VERSION "0.8b"
#define AUTHOR "naputtaja"
#define table "amx_chat_log"
#define MAXLEN 511
#define MAX_WORDS 150
// SQL Settings
new Handle:g_SqlX
new Handle:g_SqlConnection
new g_error[512]
new g_No_Save_Words[MAX_WORDS][20]
new g_No_Save_Num
#if defined SQL
#endif
new const TEAMNAME[_:CsTeams][] = {"*DEAD*", "(Terrorist)", "(Counter-Terrorist)", "*SPEC*"}
{
#if defined SQL
register_cvar("czat_db_host", "localhost");
register_cvar("czat_db_user", "root");
register_cvar("czat_db_pass", "root");
register_cvar("czat_db_database", "czat");
#endif
}
public check_sql()
{
new host[64], user[64], pass[64], db[64],errorcode
get_cvar_string("czat_db_host", host, 63)
get_cvar_string("czat_db_user", user, 63)
get_cvar_string("czat_db_pass", pass, 63)
get_cvar_string("czat_db_database", db, 63)
g_SqlX = SQL_MakeDbTuple(host, user, pass, db)
g_SqlConnection = SQL_Connect(g_SqlX,errorcode,g_error,511);
if (!g_SqlConnection) {
console_print(0,"Chat log SQL: Could not connect to SQL database.!")
return log_amx("Chat log SQL: Could not connect to SQL database.")
}
Użytkownicy przeglądający ten temat: 0
0 użytkowników, 0 gości, 0 anonimowych