Dialog Problem and loading last pos! -
HazardGaming - 21.04.2012
Hello,
I'm using YIni for my saving/loading system and for some reason it doesn't show the dialog to log in!
Also,
How would I make it load a players last positions?
I already got everything saved in the .ini file, just making them load is the problem!
Re: Dialog Problem and loading last pos! -
Richie© - 21.04.2012
After the first spawn, use a timer to change player position to the last known position that you take from .ini file.
Re: Dialog Problem and loading last pos! -
HazardGaming - 21.04.2012
And how would I do that?
Re: Dialog Problem and loading last pos! -
Richie© - 21.04.2012
Make a variable like FirstSpawn[playerid], on connect its set to 0. When player spawn for the first time, do timer like this:
pawn Код:
if(FirstSpawn[playerid] == 0) SetTimerEx("RestorePos", 500, false, "i", playerid);
It will call for a public function called RestorePos:
pawn Код:
forward RestorePos(playerid);
public RestorePos(playerid)
{
SetPlayerPos(playerid, LAST X, LAST Y,LAST Z);
FirstSpawn[playerid] = 1; // setting this to 1 so it wont send player back on every spawn
GameTextForPlayer(playerid,"~y~Restored to last known pos",3000,1);
return 1;
}
Re: Dialog Problem and loading last pos! -
HazardGaming - 21.04.2012
Ok, and the YIni problem?
Re: Dialog Problem and loading last pos! -
Richie© - 21.04.2012
I dont know yini well since i never used it, but you should show the code where you have the login dialog.
Re: Dialog Problem and loading last pos! -
HazardGaming - 21.04.2012
Ok, I sorted the dialog out which works fine, but I want to force spawn a player once they entered there password and load there last position, without using a timer!(if there is another way)
EDIT: I was wrong, if pRegged is set to 1 then it doesn't show the dialog for the player when they connect again!
Re: Dialog Problem and loading last pos! -
Richie© - 21.04.2012
You could try putting RestorePos(playerid); inside OnPlayerSpawn, dont know how that will work out though.
Re: Dialog Problem and loading last pos! -
HazardGaming - 21.04.2012
Sorry can I sort this out aswell?
if pRegged is set to 1 then it doesn't show the dialog for the player when they connect again! here is my OnPlayerConnect!
Код:
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Register","Type your password below to register a new account.","Register","Quit");
SpawnPlayer(playerid);
}
SetPlayerColor(playerid, COLOR_WHITE);
return 1;
}
Re: Dialog Problem and loading last pos! -
HazardGaming - 21.04.2012
Anyone?