Corrected it. Still the same error:
PHP Code:
#include <amxmodx>
#include <sqlx>
#include <ipci\ascend>
#include <esf_util>
#include <fun>
#include <fakemeta>
#include <fakemeta_const>
#include <hamsandwich>
new Handle:g_SqlTuple
new g_Error[512]
new iExp[32]
new Host[] = "127.0.0.1"
new User[] = "root"
new Pass[] = ""
new Db[] = "esf_data"
public plugin_init()
{
register_plugin("Database Data","1.0","")
register_clcmd("say steamid","plugintriggertest");
RegisterHam(Ham_Killed, "player", "fwdPlayerDeath", 0);
set_task(1.0, "MySql_Init")
}
public MySql_Init()
{
g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db)
new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,512)
if(SqlConnection == Empty_Handle)
set_fail_state(g_Error)
new Handle:Queries
Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS test (steamid varchar(32),pl INT(12))")
if(!SQL_Execute(Queries))
{
SQL_QueryError(Queries,g_Error,512)
set_fail_state(g_Error)
}
SQL_FreeHandle(Queries)
SQL_FreeHandle(SqlConnection)
}
public Load_MySql(id)
{
new szSteamId[32], szTemp[512]
get_user_authid(id, szSteamId, 32)
new Data[1]
Data[0] = id
format(szTemp,512,"SELECT * FROM test WHERE (test.steamid = '%s')", szSteamId)
SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
}
public register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
if(FailState == TQUERY_CONNECT_FAILED)
{
log_amx("Load - Could not connect to SQL database. [%d] %s", Errcode, Error)
}
else if(FailState == TQUERY_QUERY_FAILED)
{
log_amx("Load Query failed. [%d] %s", Errcode, Error)
}
new id
id = Data[0]
if(SQL_NumResults(Query) < 1)
{
new szSteamId[32]
get_user_authid(id, szSteamId, 32)
if (equal(szSteamId,"ID_PENDING"))
return PLUGIN_HANDLED
new szTemp[512]
format(szTemp,512,"INSERT INTO test ( steamid , pl)VALUES ('%s','0');",szSteamId)
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
}
else
{
// if there are results found
iExp[id] = SQL_ReadResult(Query, 1)
}
return PLUGIN_HANDLED
}
public Save_MySql(id)
{
new szSteamId[32], szName[32], szTemp[512]
get_user_authid(id, szSteamId, 32)
format(szTemp,512,"UPDATE test SET pl = '%i' WHERE test.steamid = '%s';",iExp[id], szSteamId)
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
}
public IgnoreHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
SQL_FreeHandle(Query)
return PLUGIN_HANDLED
}
public client_putinserver(id)
{
Load_MySql(id)
}
public client_disconnect(id)
{
Save_MySql(id)
}
//ignore this part
new steamid[32]
new username[40]
new powerlevel
new charactername[32]
new characterid
public plugintriggertest(id)
{
get_user_name(id,username,40)
get_user_authid( id, steamid, 32)
getClassDATAv( characterid, cxName, charactername, 32 );
}