well i dont understand, why this dont works
Code:
/*
Hello world, v0.1
By JGHG
*/
#include <amxmodx>
#include <amxmisc>
#include <mysql>
//-------------------------------------------------------------------------------------------
//declare mysql variables
new mysql = 0
new mysql_test = 0
new mhost[64], muser[32], mpass[32], mdb[32], merror[128]
//declare input variables
new wonid[32]
new clientname[64]
new mysqltime[32]
new monat[10]
//-------------------------------------------------------------------------------------------
//save time into mysql
public client_disconnect(id){
if (mysql_test) //si la connexion à la base est ok
{
//declare fonction var
//get commands
get_user_name(id,clientname,32)
get_user_authid(id,wonid,32)
new newplaytime = get_user_time(id,1)
get_time("%m",monat,10)
new qd[513]
format(qd,513,"SELECT * FROM amx_logtime WHERE name='%s' and monat='%s'",clientname,monat)
mysql_query(mysql,qd)
num_to_str(newplaytime,mysqltime,32)
if (mysql_nextrow(mysql) > 0){
format(qd,513,"UPDATE amx_logtime SET game_time=game_time+%s, wonid=%s WHERE name='%s' and monat='%s'",mysqltime,wonid,clientname,monat)
mysql_query(mysql,qd)
client_cmd(id, "echo ^"updating your info^"")
//client_print(id,print_chat,"%s,%s,%s,%s",wonid,clientname,mysqltime,monat)
}else{
format(qd,513,"INSERT INTO amx_logtime (name,wonid,game_time,monat) VALUES ('%s','%s','%s','%s')",clientname,wonid,mysqltime,monat)
mysql_query(mysql,qd)
}
}
return PLUGIN_CONTINUE
}
//-------------------------------------------------------------------------------------------
//initiating mysql connect
public start()
{
get_cvar_string("amx_mysql_host",mhost,63)
get_cvar_string("amx_mysql_user",muser,31)
get_cvar_string("amx_mysql_pass",mpass,31)
get_cvar_string("amx_mysql_db",mdb,31)
mysql=mysql_connect(mhost,muser,mpass,mdb,merror,127)
if (mysql > 0)
{
server_print("[AMX] Playtime Mysql : Connection established to the database")
mysql_test = 1
} else {
server_print("[AMX] Playtime MySQL error : could not connect to the database : '%s'",merror)
}
return PLUGIN_CONTINUE
}
//-------------------------------------------------------------------------------------------
//baisc plugin stuff ^_^
public plugin_init()
{
register_plugin("playtime mysql","0.1","Neosheep")
register_cvar("amx_mysql_host","")
register_cvar("amx_mysql_user","")
register_cvar("amx_mysql_pass","")
register_cvar("amx_mysql_db","")
server_cmd("exec addons/amxx/configs/mysql.cfg")
set_task(5.0,"start")
return PLUGIN_HANDLED
}
i have changed the path to the mysql.cfg and replaced the var month (as i got an shadow error).
if i install the plugin and restart the server, amx is getting "freezed" or something in this way..
if i type amx_plugins in the konsole there is no result.. and all other plugins aren't working anymore.. :'(
if i comment public start() all other plugins work well again.
whats wrong about this start function?