09.08.2018, 12:02
Hi
The player positions get saved correctly in the Mysql server, but for some odd reason it does not like loading them back to where they were, instead just loads them to a default position. I have even checked with the "/save" command. OnPlayerRequestClass also has the setspawninfo to see if that would change anything, but it did not.
Here is my saving script(for position):
Here is the loading script:
The player positions get saved correctly in the Mysql server, but for some odd reason it does not like loading them back to where they were, instead just loads them to a default position. I have even checked with the "/save" command. OnPlayerRequestClass also has the setspawninfo to see if that would change anything, but it did not.
Here is my saving script(for position):
PHP код:
stock SavePlayerPos(playerid)
{
new query[500], Float:posX, Float:posY, Float:posZ;
GetPlayerPos(playerid, posX, posY, posZ);
format(query, sizeof(query), "UPDATE `accounts` SET `playerX` = '%f', `playerY` = '%f', `playerZ` = '%f' WHERE `playerName` = '%s'", posX, posY, posZ, playerInfo[playerid][playerName]);
mysql_tquery(Database, query);
}
PHP код:
stock LoadPlayerStats(playerid)
{
new query[200], name[24];
GetPlayerName(playerid, name, 24);
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `playerName` = '%e' LIMIT 1", name);
mysql_tquery(Database, query);
cache_get_value_int(0, "playerAdmin", playerInfo[playerid][playerAdmin]);
cache_get_value_int(0, "playerMod", playerInfo[playerid][playerMod]);
cache_get_value_int(0, "playerHelper", playerInfo[playerid][playerHelper]);
cache_get_value_int(0, "playerLevel", playerInfo[playerid][playerLevel]);
cache_get_value_int(0, "playerCash", playerInfo[playerid][playerCash]);
cache_get_value_name_float(0, "playerX", playerInfo[playerid][playerX]);
cache_get_value_name_float(0, "playerY", playerInfo[playerid][playerY]);
cache_get_value_name_float(0, "playerZ", playerInfo[playerid][playerZ]);
SetPlayerScore(playerid, playerInfo[playerid][playerLevel]);
GivePlayerMoney(playerid, playerInfo[playerid][playerCash]);
SetSpawnInfo(playerid, 0,0,playerInfo[playerid][playerX],playerInfo[playerid][playerY], playerInfo[playerid][playerZ], 0, 0, 0, 0, 0,0,0);
printf("player loaded.");
}