MySQL problem -
spedico - 01.01.2012
I am fairly new with MySQL, I need some help.
pawn Код:
enum bStats
{
Username[24],
Password[35],
Kills,
Deaths,
Money,
Admin,
Float:LastX,
Float:LastY,
Float:LastZ,
Interior,
Score,
Respect,
ArmorUpgrade
}
new bInfo[MAX_PLAYERS][bStats];
pawn Код:
stock SaveStats(playerid) // And this.
{
if(GetPVarInt(playerid, "IsLogged") == 1)
{
new Query[600];
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `kills` = %d, `deaths` = %d, `money` = %d, `Level` = %d, `Last Pos X` = %f, `Last Pos Y` = %f, `Last Pos Z` = %f, `Interior` = %d, `Score` = %d, `Respect` = %d, `ArmorUpgrade` = %d WHERE `user` = '%s'",
bInfo[playerid][Kills],
bInfo[playerid][Deaths],
GetPlayerMoney(playerid),
bInfo[playerid][Admin],
bInfo[playerid][LastX],
bInfo[playerid][LastY],
bInfo[playerid][LastZ],
GetPlayerInterior(playerid),
GetPlayerScore(playerid),
bInfo[playerid][Respect],
bInfo[playerid][ArmorUpgrade],
GetName(playerid));
mysql_query(Query);
mysql_free_result();
return 1;
}
else return 0;
}
pawn Код:
stock LoadPlayerInfo(playerid)
{
new Query[700];
if(mysql_fetch_row(Query))
{
sscanf(Query, "e<p<|>s[24]s[35]ddddfffdddd>", bInfo[playerid]);
mysql_free_result();
}
return 1;
}
Problem is, it won't save or load the info.
Re: MySQL problem -
[HiC]TheKiller - 01.01.2012
under OnGameModeInit, then post your mysql log file that is located in your server directory.
Re: MySQL problem -
spedico - 01.01.2012
Okay, what the hell.
I had debugging on, now I cleared the debug file (to see the problem, the whole file had like 1000 lines) and now it saves well?
edit: never mind, it doesn't :F
Код:
10:08:40] >> mysql_num_rows( Connection handle: 1 )
[10:08:40] CMySQLHandler::NumRows() - Returned 1 row(s)
[10:08:40] >> mysql_fetch_row_format( Connection handle: 1 )
[10:08:40] CMySQLHandler::FetchRow() - Return: bulftrik|<pass>|1|3|13337|5|212.808|-102.671|8.75324|0|84|3|0
[10:08:40] >> mysql_free_result( Connection handle: 1 )
[10:08:40] CMySQLHandler::FreeResult() - Result was successfully free'd.
Actually it seems that it doesn't save anything after I added those new variables.
Re: MySQL problem -
spedico - 01.01.2012
Hmm, if I do something like earn $1000 and rejoin, it saves. If I restart the server, it won't save? I have this in my OnGameModeExit:
pawn Код:
foreach(Player, i)
{
SaveStats(i);
}
and this under OnPlayerDisconnect:
mysql debug doesn't seem to work, it doesn't even create the log file