Positions don't seem to be loading. -
Jernu - 20.07.2013
They save correctly
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Float("Positon-PosX",PlayerInfo[playerid][PosX]);
INI_Float("Positon-PosY",PlayerInfo[playerid][PosY]);
INI_Float("Positon-PosZ",PlayerInfo[playerid][PosZ]);
INI_Int("Interior",PlayerInfo[playerid][pInterior]);
return 1;
}
But they don't load correctly
pawn Код:
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
TogglePlayerSpectating(playerid, false);
SendClientMessage(playerid, -1, "Loading last position...");
SetPlayerPos(playerid, PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ]);
SpawnPlayer(playerid);
}
And I get the "< > Spawn" box.
Re: Positions don't seem to be loading. -
Alternative112 - 20.07.2013
Where are you putting that loading code? I think you need it to be in OnPlayerRequestClass. So that it automatically spawns them.
Re: Positions don't seem to be loading. -
IceBilizard - 20.07.2013
pawn Код:
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
TogglePlayerSpectating(playerid, false);
SendClientMessage(playerid, -1, "Loading last position...");
SetSpawnInfo(playerid,0,0,PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ],0, 0, 0, 0, 0, 0, 0 );
SpawnPlayer(playerid);
}
Re: Positions don't seem to be loading. -
Jernu - 20.07.2013
Quote:
Originally Posted by IceBilizard
pawn Код:
if( response ) { if(udb_hash(inputtext) == PlayerInfo[playerid][pPass]) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]); TogglePlayerSpectating(playerid, false); SendClientMessage(playerid, -1, "Loading last position..."); SetSpawnInfo(playerid,0,0,PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ],0, 0, 0, 0, 0, 0, 0 ); SpawnPlayer(playerid); }
|
Thanks! Didn't think of using SetSpawnInfo!
Re: Positions don't seem to be loading. -
Jernu - 20.07.2013
I've got a problem, when the server restarts it resets your coords to 0.0000
Loading:
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Float("Positon-PosX",PlayerInfo[playerid][PosX]);
INI_Float("Positon-PosY",PlayerInfo[playerid][PosY]);
INI_Float("Positon-PosZ",PlayerInfo[playerid][PosZ]);
INI_Int("Interior",PlayerInfo[playerid][pInterior]);
INI_Int("Skin",PlayerInfo[playerid][pSkin]);
return 1;
}
Saving:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x,y,z);
INI_WriteFloat(File,"Position-PosX",PlayerInfo[playerid][PosX]=x);
INI_WriteFloat(File,"Position-PosY",PlayerInfo[playerid][PosY]=y);
INI_WriteFloat(File,"Position-PosZ",PlayerInfo[playerid][PosZ]=z);
new interior = GetPlayerInterior(playerid);
INI_WriteInt(File,"Interior", PlayerInfo[playerid][pInterior]=interior);
new skin = GetPlayerSkin(playerid);
INI_WriteInt(File,"Skin", PlayerInfo[playerid][pSkin]=skin);
INI_Close(File);
return 1;
}
Re: Positions don't seem to be loading. -
Lordzy - 20.07.2013
Quote:
Originally Posted by Jernu
I've got a problem, when the server restarts it resets your coords to 0.0000
Loading:
pawn Код:
forward LoadUser_data(playerid,name[],value[]); public LoadUser_data(playerid,name[],value[]) { INI_Int("Password",PlayerInfo[playerid][pPass]); INI_Int("Cash",PlayerInfo[playerid][pCash]); INI_Int("Admin",PlayerInfo[playerid][pAdmin]); INI_Float("Positon-PosX",PlayerInfo[playerid][PosX]); INI_Float("Positon-PosY",PlayerInfo[playerid][PosY]); INI_Float("Positon-PosZ",PlayerInfo[playerid][PosZ]); INI_Int("Interior",PlayerInfo[playerid][pInterior]); INI_Int("Skin",PlayerInfo[playerid][pSkin]); return 1; }
Saving:
pawn Код:
public OnPlayerDisconnect(playerid, reason) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"data"); INI_WriteInt(File,"Cash",GetPlayerMoney(playerid)); INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]); new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x,y,z); INI_WriteFloat(File,"Position-PosX",PlayerInfo[playerid][PosX]=x); INI_WriteFloat(File,"Position-PosY",PlayerInfo[playerid][PosY]=y); INI_WriteFloat(File,"Position-PosZ",PlayerInfo[playerid][PosZ]=z); new interior = GetPlayerInterior(playerid); INI_WriteInt(File,"Interior", PlayerInfo[playerid][pInterior]=interior); new skin = GetPlayerSkin(playerid); INI_WriteInt(File,"Skin", PlayerInfo[playerid][pSkin]=skin); INI_Close(File);
return 1; }
|
While the server restarts, player's position are being set to 0.00000, so basically, the script writes those coords. You could declare whether to save the position while the server is being restarted or if the coords are 0.0000, that might prevent it.
Re: Positions don't seem to be loading. -
Jernu - 20.07.2013
Even if the coords are saved and the server restarts, it will still set them to 0.0000
Re: Positions don't seem to be loading. -
Lordzy - 20.07.2013
Quote:
Originally Posted by Jernu
Even if the coords are saved and the server restarts, it will still set them to 0.0000
|
While the server is being restarted, it basically disconnects the players. As a fact, if I'm not wrong, 'OnPlayerDisconnect' is being called and the script performs the INI settings. While restart, every players's coords are being set to 0.0000. So it just sets the INI also as it's being done.
Re: Positions don't seem to be loading. -
Jernu - 20.07.2013
If I log out, it saves. If I reset the server then log back in, it resets it to 0.00000! So it's not when the player is still logged in.
Can you please help me via Skype?
Re: Positions don't seem to be loading. -
Lordzy - 20.07.2013
Quote:
Originally Posted by Jernu
If I log out, it saves. If I reset the server then log back in, it resets it to 0.00000!
|
TBH, I don't understand this. You mean you reset the data and then go back, it sets to 0.000000?
Edit:
It seems like on every players, the data is being written. So what if the file for the player isn't yet created? Like if a player isn't registered, normally they don't set files. If you're also doing the same thing, I suggest you to declare a variable and pass the function only if player is registered or has a player file under 'OnPlayerDisconnect' callback.