Load Saved position
#1

Is this write or wrong No clue... Seems it ainting setting my position Or any other players Help please anyone

pawn Код:
new Float:X, Float:Y, Float:Z, Float:A;
        new I;
        SetPlayerPos(playerid, X,Y,Z);
        SetPlayerFacingAngle(playerid, A);
        SetPlayerInterior(playerid, I);
        dini_FloatSet(file, "LocX", X);
        dini_FloatSet(file, "LocY", Y);
        dini_FloatSet(file, "LocZ", Z);
        dini_FloatSet(file, "LocA", A);
        dini_IntSet(file, "LocI", I);
Reply
#2

It is setting the position and also setting the dini file to the position, what is this complyant with, a registration system?
Reply
#3

oops put that wrong and messed up LOL that was my floatSet so it put numbers in my user account file now i need it to retrieve them numbers and set player at the Position they last was when they logged out or server restart

So far it tries to get the numbers but fails and spawns the player in Red County at the farm so the code ain't right
Reply
#4

That happens to me sometimes in some of my scripts, try setting the z position a little bit higher than it is already. This will prevent the player from falling under the bounds and i believe that the exit point is around blueberry
Reply
#5

btw, 'new I;' will be set to 0!

pawn Код:
new I; I = GetPlayerInterior(playerid); // Get the player's interior, and 'hold it' into the 'I' var
Reply
#6

You're going at this the wrong way, you need to set the players position according to the retrieved data - You are setting the player at default float values (0.00), so they will spawn at the farm and fall through the ground. Use of the following code should fix your problems:
pawn Код:
SetPlayerPos( playerid, dini_Float( file, "LocX" ), dini_Float( file, "LocY" ), dini_Float( file, "LocZ" ) );
SetPlayerFacingAngle( playerid, dini_Float( file, "LocA" ) );
I'm a bit confused with your code, because you are setting the players coordinates, and setting the values to the file. The code I just wrote will set the players position by the values read from the file. Is that what you were trying to achieve?

I would also suggest you look into another file system like y-ini, SII or djSon. They are much more up-to-date and are far more efficient.
Reply
#7

Quote:
Originally Posted by [L3th4l]
Посмотреть сообщение
btw, 'new I;' will be set to 0!

pawn Код:
new I; I = GetPlayerInterior(playerid); // Get the player's interior, and 'hold it' into the 'I' var
Thanks i noticed it earlier I was wondering why kept putting 0 lol i changed the save to this

pawn Код:
public SavePlayerPos(playerid)
{
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), ARS_SERVERFILES, name);
    new Float:X, Float:Y, Float:Z, Float:A;
    GetPlayerPos(playerid, X,Y,Z);
    GetPlayerFacingAngle(playerid, A);
    dini_FloatSet(file, "LocX", X);
    dini_FloatSet(file, "LocY", Y);
    dini_FloatSet(file, "LocZ", Z);
    dini_FloatSet(file, "LocA", A);
    dini_IntSet(file, "LocI", GetPlayerInterior(playerid));
    return 1;
}
I looked off a tutorial to see how too. But still the same so i was like what the hell i put a format message to show me where its spawning me well the response was

Spawning you at your lasted saved position 0.0000 0.0000 0.0000 0.0000 and interior 0.0000 Okay so my code is reading wrong right? cause i coppied my user saved position from userfile to see if they are wrong and that was my results

Here the spawn command

pawn Код:
public SpawnLastSavedPosition(playerid)
{
    new string[128], Float:LocX, Float:LocY, Float:LocZ, Float:LocA, INT;
    LocX = GetPVarFloat(playerid, "pLocX");
    LocY = GetPVarFloat(playerid, "pLocY");
    LocZ = GetPVarFloat(playerid, "pLocZ");
    LocA = GetPVarFloat(playerid, "pLocA");
    INT = GetPVarInt(playerid, "pLocI");
    SetPlayerPos(playerid, LocX,LocY,LocZ);
    SetPlayerFacingAngle(playerid, LocA);
    SetPlayerInterior(playerid, INT);
    format(string, sizeof(string), "Spawning you back to your last saved position at %f, %f, %f, %f With Inteior %d.", LocX, LocY, LocZ, LocA, INT);
    SendClientMessage(playerid, WHITE, string);
    return 1;
}
Reply
#8

I don't know why you are using PVars and variables to get and set the data, the only code that is actually needed would be:
pawn Код:
// Reading and applying the information from the file
SetPlayerPos( playerid, dini_Float( file, "LocX" ), dini_Float( file, "LocY" ), dini_Float( file, "LocZ" ) );
SetPlayerFacingAngle( playerid, dini_Float( file, "LocA" ) );
SetPlayerInterior( playerid, dini_Int( file, "LocI" ) );
// Saving the information to the file
new Float:X, Float:Y, Float:Z, Float: A;
GetPlayerPos( playerid, X, Y, Z );
GetPlayerFacingAngle( playerid, A );
dini_FloatSet( file, "LocX", X );
dini_FloatSet( file, "LocY", Y );
dini_FloatSet( file, "LocZ", Z );
dini_FloatSet( file, "LocA", A );
dini_IntSet( file, "LocI", GetPlayerInterior( playerid ) );
Reply
#9

Quote:
Originally Posted by Grim_
Посмотреть сообщение
You're going at this the wrong way, you need to set the players position according to the retrieved data - You are setting the player at default float values (0.00), so they will spawn at the farm and fall through the ground. Use of the following code should fix your problems:
pawn Код:
SetPlayerPos( playerid, dini_Float( file, "LocX" ), dini_Float( file, "LocY" ), dini_Float( file, "LocZ" ) );
SetPlayerFacingAngle( playerid, dini_Float( file, "LocA" ) );
I'm a bit confused with your code, because you are setting the players coordinates, and setting the values to the file. The code I just wrote will set the players position by the values read from the file. Is that what you were trying to achieve?

I would also suggest you look into another file system like y-ini, SII or djSon. They are much more up-to-date and are far more efficient.
I just noticed your message grim thanks .. ill try that and yeah i was looking into djson I was thinking about it I still might i converted to sscanf the other night i might change file systems probably soon
Reply
#10

Grim Anychance you can help me with this It didnt work as planned i done it the way you mention still didnt work i even put into a command to see if it work still spawned in Blueberry farm or is it red county well the falling dont kill you the sudden stop does
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)