Közben rájöttem a hibára. Túl sok adatot akartam egy táblába menteni (szám szerint 36-ot).
Megpróbáltam két táblába menteni, de nem nagyok sikerült...
Létrehozza őket, de a mentés már nem jó (ebből kifolyólag a betöltést nem tudom, jó-e).
public MySql_Init()
{
g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db)
new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
if(SqlConnection == Empty_Handle)
set_fail_state(g_Error)
new Handle:Queries
Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS Alapanyag (steamid varchar(32) PRIMARY KEY,\
PlayerLevel INT(11),\
PlayerXP INT(11),\
PlayerClass INT(11),\
Vas INT(11),\
Polimer INT(11),\
Aram INT(11),\
Otvozet INT(11),\
Karbon INT(11),\
Floxgem INT(11),\
Blessium INT(11),\
Kontrol INT(11),\
Energia INT(11),\
Szenzor INT(11),\
Bloxy INT(11))")
new Handle:Queriess
Queriess = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS Avatar (steamid varchar(32) PRIMARY KEY,\
Li INT(11),\
LiT INT(11),\
Al INT(11),\
AlT INT(11),\
Fig INT(11),\
FigT INT(11),\
Gop INT(11),\
GopT INT(11),\
Pun INT(11),\
PunT INT(11),\
Vee INT(11),\
VeeT INT(11),\
Assa INT(11),\
AssaT INT(11),\
Rea INT(11),\
ReaT INT(11),\
Fr INT(11),\
FrT INT(11),\
Hoo INT(11),\
HooT INT(11),\
Els INT(11))")
if(!SQL_Execute(Queries))
{
SQL_QueryError(Queries,g_Error,charsmax(g_Error))
set_fail_state(g_Error)
}
if(!SQL_Execute(Queriess))
{
SQL_QueryError(Queriess,g_Error,charsmax(g_Error))
set_fail_state(g_Error)
}
SQL_FreeHandle(Queries)
SQL_FreeHandle(Queriess)
SQL_FreeHandle(SqlConnection)
}
public plugin_end()
{
SQL_FreeHandle(g_SqlTuple)
}
public Load_MySql(id)
{
new szSteamId[32], szTemp[512]
get_user_authid(id, szSteamId, charsmax(szSteamId))
new Data[1]
Data[0] = id
//we will now select from the table `tutorial` where the steamid match
format(szTemp,charsmax(szTemp),"SELECT * FROM `Alapanyag` WHERE (`Alapanyag`.`steamid` = '%s')", szSteamId)
format(szTemp,charsmax(szTemp),"SELECT * FROM `Avatar` WHERE (`Avatar`.`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, charsmax(szSteamId))
if (equal(szSteamId,"ID_PENDING"))
return PLUGIN_HANDLED
new szTemp[512]
format(szTemp,charsmax(szTemp),"INSERT INTO `Alapanyag` ( `steamid` ,\
`PlayerLevel`,\
`PlayerXP`,\
`PlayerClass`,\
`Vas`,\
`Polimer`,\
`Aram`,\
`Otvozet`,\
`Karbon`,\
`Floxgem`,\
`Blessium`,\
`Kontrol`,\
`Energia`,\
`Szenzor`,\
`Bloxy`)VALUES ('%s','0');",szSteamId)
format(szTemp,charsmax(szTemp),"INSERT INTO `Avatar` ( `steamid` ,\
`Li`,\
`LiT`,\
`Al`,\
`AlT`,\
`Fig`,\
`FigT`,\
`Gop`,\
`GopT`,\
`Pun`,\
`PunT`,\
`Vee`,\
`VeeT`,\
`Assa`,\
`AssaT`,\
`Rea`,\
`ReaT`,\
`Fr`,\
`FrT`,\
`Hoo`,\
`HooT`,\
`Els`)VALUES ('%s','0');",szSteamId)
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
}
else
{
PlayerLevel[id] = SQL_ReadResult(Query, 1)
PlayerXP[id] = SQL_ReadResult(Query, 2)
PlayerClass[id] = SQL_ReadResult(Query, 3)
vaserc[id] = SQL_ReadResult(Query, 4)
polimer_szal[id] = SQL_ReadResult(Query, 5)
aramkorok[id] = SQL_ReadResult(Query, 6)
otvozet[id] = SQL_ReadResult(Query, 7)
karbon_szal[id] = SQL_ReadResult(Query, 8)
floxgem[id] = SQL_ReadResult(Query, 9)
blessium[id] = SQL_ReadResult(Query, 10)
kontrol_panel[id] = SQL_ReadResult(Query, 11)
energia_cella[id] = SQL_ReadResult(Query, 12)
szenzor[id] = SQL_ReadResult(Query, 13)
bloxy[id] = SQL_ReadResult(Query, 14)
lien[id] = SQL_ReadResult(Query, 1)
lienterv[id] = SQL_ReadResult(Query, 2)
alien[id] = SQL_ReadResult(Query, 3)
alienterv[id] = SQL_ReadResult(Query, 4)
fighter[id] = SQL_ReadResult(Query, 5)
fighterterv[id] = SQL_ReadResult(Query, 6)
gopnik[id] = SQL_ReadResult(Query, 7)
gopnikterv[id] = SQL_ReadResult(Query, 8)
punisher[id] = SQL_ReadResult(Query, 9)
punisherterv[id] = SQL_ReadResult(Query, 10)
vee[id] = SQL_ReadResult(Query, 11)
veeterv[id] = SQL_ReadResult(Query, 12)
assassin[id] = SQL_ReadResult(Query, 13)
assassinterv[id] = SQL_ReadResult(Query, 14)
reaper[id] = SQL_ReadResult(Query, 15)
reaperterv[id] = SQL_ReadResult(Query, 16)
frost[id] = SQL_ReadResult(Query, 17)
frostterv[id] = SQL_ReadResult(Query, 18)
hooz[id] = SQL_ReadResult(Query, 19)
hoozterv[id] = SQL_ReadResult(Query, 20)
elsocsati[id] = SQL_ReadResult(Query, 21)
}
return PLUGIN_HANDLED
}
public Save_MySql(id)
{
new szSteamId[32], szTemp[512]
get_user_authid(id, szSteamId, charsmax(szSteamId))
// Here we will update the user hes information in the database where the steamid matches.
format(szTemp,charsmax(szTemp),"UPDATE `Alapanyag` SET `PlayerLevel` = '%i',\
`PlayerXP` = '%i',\
`PlayerClass` = '%i',\
`Vas` = '%i',\
`Polimer` = '%i',\
`Aram` = '%i',\
`Otvozet` = '%i',\
`Karbon` = '%i',\
`Floxgem` = '%i',\
`Blessium` = '%i',\
`Kontrol` = '%i',\
`Energia` = '%i',\
`Szenzor` = '%i',\
`Bloxy` = '%i',\
WHERE `AvaFrame`.`steamid` = '%s';",PlayerLevel[id],
PlayerXP[id],
PlayerClass[id],
vaserc[id],
polimer_szal[id],
aramkorok[id],
otvozet[id],
karbon_szal[id],
floxgem[id],
blessium[id],
kontrol_panel[id],
energia_cella[id],
szenzor[id],
bloxy[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `Alapanyag` SET `Li` = '%i',\
`LiT` = '%i',\
`Al` = '%i',\
`AlT` = '%i',\
`Fig` = '%i',\
`FigT` = '%i',\
`Gop` = '%i',\
`GopT` = '%i',\
`Pun` = '%i',\
`PunT` = '%i',\
`Vee` = '%i',\
`VeeT` = '%i',\
`Assa` = '%i',\
`AssaT` = '%i',\
`Rea` = '%i',\
`ReaT` = '%i',\
`Fr` = '%i',\
`FrT` = '%i',\
`Hoo` = '%i',\
`HooT` = '%i',\
`Els` = '%i'\
WHERE `AvaFrame`.`steamid` = '%s';",lien[id],
lienterv[id],
alien[id],
alienterv[id],
fighter[id],
fighterterv[id],
gopnik[id],
gopnikterv[id],
punisher[id],
punisherterv[id],
vee[id],
veeterv[id],
assassin[id],
assassinterv[id],
reaper[id],
reaperterv[id],
frost[id],
frostterv[id],
hooz[id],
hoozterv[id],
elsocsati[id], szSteamId)
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
}