31.01.2017, 12:14
Saving function
The player coords are not saved right when the player leaves the server, when he comes back he will get spawned near the area where he left but not right in the place where he was when he left the server.
I the enum I have Float
Pos_x, Float
Pos_y, Float
Pos_z
And in mysql table I set them as Float and length to 16.
This is how I load them:
After few more logins I got spawned somewhere in San Fierro...
This is how they saved...
When I register a new account they save right for the first few logins and quits, but after that the problems starts coming, sometimes it doesn't save or it doesn't save the right location, now I got spawned in SF..
Код:
stock SavePlayerAccount(playerid) { new DB_Query[1024]; new Float:x, Float:y, Float:z ; if(PlayerInfo[playerid][LoggedIn] == 1) { GetPlayerPos(playerid,x,y,z); PlayerInfo[playerid][pPos_x] = x; PlayerInfo[playerid][pPos_y] = y; PlayerInfo[playerid][pPos_z] = z; mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `USERS` SET `PASSWORD` = '%s', `SCORE` = %d, `KILLS` = %d, `CASH` = %d, `DEATHS` = %d, `Admin` = %d WHERE `ID` = %d" , PlayerInfo[playerid][pPass], PlayerInfo[playerid][Score], PlayerInfo[playerid][Kills], PlayerInfo[playerid][pCash], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][ID]); mysql_tquery(Database, DB_Query); mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `USERS` SET `Sex` = %d, `Age` = %d, `Pos_x` = %f, `Pos_y` = %f, `Pos_z` = %f, `Skin` = %d, `Job` = %d, `AccLock` = %d WHERE `ID` = %d" , PlayerInfo[playerid][pSex], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pAccLock], PlayerInfo[playerid][ID]); mysql_tquery(Database, DB_Query); PlayerInfo[playerid][LoggedIn] = 0; } return 1; }
I the enum I have Float
![Tongue](images/smilies/razz.gif)
![Tongue](images/smilies/razz.gif)
![Tongue](images/smilies/razz.gif)
And in mysql table I set them as Float and length to 16.
This is how I load them:
Код:
cache_get_value_float(0, "Pos_x", PlayerInfo[playerid][pPos_x]); cache_get_value_float(0, "Pos_y", PlayerInfo[playerid][pPos_y]); cache_get_value_float(0, "Pos_z", PlayerInfo[playerid][pPos_z]);
This is how they saved...
Код:
-2382.02 Pos_x -582.044 Pos_y 132.617 Pos_z