21.10.2010, 23:40
Hopefully somebody could explain this problem to me...
When I log in to my server, I can register fine without any issues. My account is in the database, but only the username and password are saved, which is normal. When I leave the server, the "SavePlayerAccount" function is executed and in the 'mysql_log.txt' file, everything is showing as successful! Example:
In the database, however, nothing is showing up but the username and password - even though it's all been successful. This is the "SavePlayerAccount" function:
This is what happens when a player registers on the server...
When I join the server (for the 2nd time when my username is in the database) and then leave, my stats will save. Now somebody, tell me...what the hell is wrong?
When I log in to my server, I can register fine without any issues. My account is in the database, but only the username and password are saved, which is normal. When I leave the server, the "SavePlayerAccount" function is executed and in the 'mysql_log.txt' file, everything is showing as successful! Example:
Код:
[18:48:09] --------------------------- [18:48:09] MySQL Debugging activated (10/21/10) [18:48:09] --------------------------- [18:48:09] [18:48:09] >> mysql_connect( ) [18:48:09] CMySQLHandler::CMySQLHandler() - constructor called. [18:48:09] CMySQLHandler::CMySQLHandler() - Connecting to "blah" | DB: "blah" | Username: "blah" ... [18:48:09] CMySQLHandler::Connect() - Connection was successful. [18:48:09] CMySQLHandler::Connect() - Auto-Reconnect has been enabled. [18:48:09] >> mysql_query( Connection handle: 1 ) [18:48:09] CMySQLHandler::Query(SELECT * FROM `Vehicles`) - Successfully executed. [18:48:09] >> mysql_store_result( Connection handle: 1 ) [18:48:09] CMySQLHandler::StoreResult() - Result was stored. [18:48:09] >> mysql_num_rows( Connection handle: 1 ) [18:48:09] CMySQLHandler::NumRows() - Returned 0 row(s) [18:48:09] >> mysql_free_result( Connection handle: 1 ) [18:48:09] CMySQLHandler::FreeResult() - Result was successfully free'd. [18:48:37] >> mysql_real_escape_string( Connection handle: 1 ) [18:48:37] CMySQLHandler::EscapeString(RealCop228); - Escaped 10 characters to RealCop228. [18:48:37] >> mysql_query( Connection handle: 1 ) [18:48:38] CMySQLHandler::Query(SELECT `UserID` FROM `Accounts` WHERE `Username` = 'RealCop228') - Successfully executed. [18:48:38] >> mysql_store_result( Connection handle: 1 ) [18:48:38] CMySQLHandler::StoreResult() - Result was stored. [18:48:38] >> mysql_num_rows( Connection handle: 1 ) [18:48:38] CMySQLHandler::NumRows() - Returned 0 row(s) [18:48:38] >> mysql_free_result( Connection handle: 1 ) [18:48:38] CMySQLHandler::FreeResult() - Result was successfully free'd. [18:48:42] >> mysql_real_escape_string( Connection handle: 1 ) [18:48:42] CMySQLHandler::EscapeString(RealCop228); - Escaped 10 characters to RealCop228. [18:48:42] >> mysql_query( Connection handle: 1 ) [18:48:42] CMySQLHandler::Query(INSERT INTO `Accounts` (Username, Password) VALUES('RealCop228', 'blahblahblahblah')) - Successfully executed. [18:48:42] >> mysql_query( Connection handle: 1 ) [18:48:42] CMySQLHandler::Query(UPDATE `Accounts` SET `AdminLevel` = '0', `Money` = '10000', `BankMoney` = '0', `Score` = '0', `Skin` = '170' WHERE `UserID` = '0') - Successfully executed. [18:48:42] >> mysql_query( Connection handle: 1 ) [18:48:42] CMySQLHandler::Query(UPDATE `Accounts` SET `Health` = '0.000000', `Armour` = '0.000000', `PositionX` = '50.000000', `PositionY` = '50.000000', `PositionZ` = '50.000000' WHERE `UserID` = '0') - Successfully executed.
pawn Код:
stock SavePlayerAccount(playerid)
{
new String[255], Float: health, Float: armour;
if(PlayerStatistics[playerid][pAuth] == 1)
{
format(String, sizeof(String), "UPDATE `Accounts` SET `AdminLevel` = '%d', `Money` = '%d', `BankMoney` = '%d', `Score` = '%d', `Skin` = '%d' WHERE `UserID` = '%d'", PlayerStatistics[playerid][pAdminLevel], GetPlayerMoney(playerid), PlayerStatistics[playerid][pBankMoney], GetPlayerScore(playerid), GetPlayerSkin(playerid), PlayerStatistics[playerid][pDatabaseID]);
mysql_query(String);
GetPlayerPos(playerid, PlayerStatistics[playerid][pPositionX], PlayerStatistics[playerid][pPositionY], PlayerStatistics[playerid][pPositionZ]);
GetPlayerHealth(playerid, health);
GetPlayerArmour(playerid, armour);
format(String, sizeof(String), "UPDATE `Accounts` SET `Health` = '%f', `Armour` = '%f', `PositionX` = '%f', `PositionY` = '%f', `PositionZ` = '%f' WHERE `UserID` = '%d'", health, armour, PlayerStatistics[playerid][pPositionX], PlayerStatistics[playerid][pPositionY], PlayerStatistics[playerid][pPositionZ], PlayerStatistics[playerid][pDatabaseID]);
mysql_query(String);
}
return 1;
}
pawn Код:
new rand = random(sizeof(RandomSpawn));
new buf[130], EscapedName[MAX_PLAYER_NAME];
mysql_real_escape_string(GetName(playerid), EscapedName);
WP_Hash(buf, sizeof (buf), inputtext);
format(Query, sizeof(Query), "INSERT INTO `Accounts` (Username, Password) VALUES('%s', '%s')", EscapedName, buf);
mysql_query(Query);
PlayerStatistics[playerid][pAuth] = 1;
format(string, sizeof(string), "You have been automatically logged in, %s!", GetName(playerid));
SendClientMessage(playerid, COLOR_ORANGE, string);
TogglePlayerSpectating(playerid, false);
SetSpawnInfo(playerid, 0, 170, RandomSpawn[rand][0], RandomSpawn[rand][1], RandomSpawn[rand][2], 0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
SetPlayerHealth(playerid, 100);
GivePlayerMoneyEx(playerid, 10000);
SavePlayerAccount(playerid);
printf("%s has registered an account on the server.", GetName(playerid));