PDA

View Full Version : Positions don't seem to be loading.


Jernu
20/07/2013, 04:16 PM
They save correctly
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
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.

Alternative112
20/07/2013, 04:22 PM
Where are you putting that loading code? I think you need it to be in OnPlayerRequestClass. So that it automatically spawns them.

IceBilizard
20/07/2013, 04:23 PM
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);

}

Jernu
20/07/2013, 04:27 PM
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!

Jernu
20/07/2013, 05:46 PM
I've got a problem, when the server restarts it resets your coords to 0.0000
Loading:
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:
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;
}

Lordzy
20/07/2013, 05:49 PM
I've got a problem, when the server restarts it resets your coords to 0.0000
Loading:
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:
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.

Jernu
20/07/2013, 05:50 PM
Even if the coords are saved and the server restarts, it will still set them to 0.0000

Lordzy
20/07/2013, 05:54 PM
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.

Jernu
20/07/2013, 06:02 PM
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?

Lordzy
20/07/2013, 06:08 PM
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.

Jernu
20/07/2013, 06:09 PM
Can I add you on skype? Faster replies.

If I leave the server. My stats save. I then close the console and restart it. I connect to the server again and it resets it to 0.00000

Jernu
20/07/2013, 06:12 PM
Can I just add you on skype?-.-

Lordzy
20/07/2013, 06:12 PM
Can I add you on skype? Faster replies.

If I leave the server. My stats save. I then close the console and restart it. I connect to the server again and it resets it to 0.00000

Sure, you can add me on Skype. But unfortunately, I can't log on to Skype for the moment. :( Anyway, if you're closing down the server while you're connected, I guess the function won't perform very well as the server shut downs more faster and it won't allow the code to perform well. I suggest you to use a timer in saving coordinates.

Jernu
20/07/2013, 06:49 PM
You're completely missing the point.

Example:
I join the server and leave. My coords have been saved. I join back and they load my position.

Now if I leave again, it saves my coords. After I leave I'll reset the sever - using either gmx or closing and reopening the console. I join and it resets my coords to 0.00000 and I spawn in blueberry!

Can someone please help me ASAP!

Lordzy
21/07/2013, 03:21 AM
You're completely missing the point.

Example:
I join the server and leave. My coords have been saved. I join back and they load my position.

Now if I leave again, it saves my coords. After I leave I'll reset the sever - using either gmx or closing and reopening the console. I join and it resets my coords to 0.00000 and I spawn in blueberry!

Can someone please help me ASAP!
Well, you got any codes under "OnGameModeExit" or if it's a FS, any code under "OnFilterScriptExit"?

Jernu
21/07/2013, 10:16 AM
No, this is what I don't understand!