Position saving/loading
#1

Hey everyone.
I have made a login/register system using Dini.
I want it to save the players position when he disconnects,Ё
and spawns him at the same place when he logs in again next time.
I already did like this:
OnPlayerDisconnect:
pawn Код:
if(dini_Exists(file))
        {
            PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
            PlayerInfo[playerid][pActivity] = GetPlayerScore(playerid);
            dini_IntSet(file, "Money",PlayerInfo[playerid][pMoney]);
            new Float:Health;
            GetPlayerHealth(playerid, Health);
            dini_FloatSet(file, "Health", floatround(Health));
            dini_IntSet(file, "Activity",PlayerInfo[playerid][pActivity]);
            new Float:x, Float:y, Float:z;
            GetPlayerPos(playerid, x, y, z);
            dini_FloatSet(file, "PosX", floatround(x));
            dini_FloatSet(file, "PosY", floatround(y));
            dini_FloatSet(file, "PosZ", floatround(z));
            dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
            dini_IntSet(file, "Banned",PlayerInfo[playerid][pBanned]);
        }
and when the player logs in:
pawn Код:
SetPlayerPos(playerid, dini_Float(file, "PosX"), dini_Float(file, "PosY"), dini_Float(file, "PosZ"));
Hope you can help me. Thank you.
Reply
#2

Try This
pawn Код:
new Float[3];
GetPlayerPos(playerid, Float[0], Float[1], Float[2]);
dini_FloatSet(file, "PosX", Float[0]);
dini_FloatSet(file, "PosY", Float[1]);
dini_FloatSet(file, "PosZ", Float[2]);
Reply
#3

What do you mean?
Reply
#4

Quote:
Originally Posted by sim_sima
Посмотреть сообщение
What do you mean?
Check above post i edited it.
Reply
#5

Ok, ill try that
Reply
#6

Gives me warnings. Other ideas?
Reply
#7

Okay. I have it almost done.
When player disconnects, his position is being saved.
But how do i set the players position when he logs in?
I already entered this line
pawn Код:
SetPlayerPos(playerid, dini_Float(file, "PosX"),dini_Float(file, "PosY"),dini_Float(file, "PosZ"));
in "OnDialogResponse" for the login dialog. But when he logs in, selects a class and spawns, its not setting his pos from the file.
Reply
#8

Okay. Now i entered it in "OnPlayerSpawn" but now the player spawns there every time he respawns. I want it to be only the first time he spawns after joining the server. Anyone knows?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)