Dialog Problem and loading last pos!
#1

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!
Reply
#2

After the first spawn, use a timer to change player position to the last known position that you take from .ini file.
Reply
#3

And how would I do that?
Reply
#4

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;
}
Reply
#5

Ok, and the YIni problem?
Reply
#6

I dont know yini well since i never used it, but you should show the code where you have the login dialog.
Reply
#7

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!
Reply
#8

You could try putting RestorePos(playerid); inside OnPlayerSpawn, dont know how that will work out though.
Reply
#9

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;
}
Reply
#10

Anyone?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)