Not spawning me where my co-ords are. Please help me!
#1

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(JustLogged[playerid] == 1 && PlayerInfo[playerid][New] == 0)
    {
        //Won't read these co-ords SetPlayerPos(playerid, PlayerInfo[playerid][Pos][0], PlayerInfo[playerid][Pos][1], PlayerInfo[playerid][Pos][2]);
        SetPlayerFacingAngle(playerid, PlayerInfo[playerid][Pos][3]);
        JustLogged[playerid] = 0;
        {
            SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
        }
    }
    else
    {
        if(PlayerInfo[playerid][New] && gTeam[playerid] == TEAM_TRUCKER)
        {
            new RandPos = random(sizeof(TruckerSpawnPositions));
            SetPlayerPos(playerid, TruckerSpawnPositions[RandPos][0], TruckerSpawnPositions[RandPos][1], TruckerSpawnPositions[RandPos][2]);
            SetPlayerFacingAngle(playerid, TruckerSpawnPositions[RandPos][3]);
            PlayerInfo[playerid][New] = 0;
        }
    }
    return 1;
}
It's not spawning me at the saves position (Where the player logs out) but if i manually add co-ords it works...


Other parts that may help you, help me...

pawn Код:
public SaveUser(playerid)
{
    if(IsLogged[playerid] == 0) return 0;
   
    GetPlayerHealth(playerid, PlayerInfo[playerid][Health]);
    GetPlayerArmour(playerid, PlayerInfo[playerid][Armour]);
    GetPlayerPos(playerid, PlayerInfo[playerid][Pos][0], PlayerInfo[playerid][Pos][1], PlayerInfo[playerid][Pos][2]);
    GetPlayerFacingAngle(playerid, PlayerInfo[playerid][Pos][3]);
   
    PlayerInfo[playerid][Money] = GetPlayerMoney(playerid);
    PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
   
    dini_IntSet(Userfile, "Admin", PlayerInfo[playerid][Admin]);
    dini_IntSet(Userfile, "Money", PlayerInfo[playerid][Money]);
    dini_IntSet(Userfile, "Skin", PlayerInfo[playerid][Skin]);
   
    if(PlayerInfo[playerid][Health] != 0) dini_FloatSet(Userfile, "Health", PlayerInfo[playerid][Health]);
    if(PlayerInfo[playerid][Armour] != 0) dini_FloatSet(Userfile, "Armour", PlayerInfo[playerid][Armour]);
    if(PlayerInfo[playerid][Pos][0] != 0) dini_FloatSet(Userfile, "X", PlayerInfo[playerid][Pos][0]);
    if(PlayerInfo[playerid][Pos][1] != 0) dini_FloatSet(Userfile, "Y", PlayerInfo[playerid][Pos][1]);
    if(PlayerInfo[playerid][Pos][2] != 0) dini_FloatSet(Userfile, "Z", PlayerInfo[playerid][Pos][2]);
    if(PlayerInfo[playerid][Pos][3] != 0) dini_FloatSet(Userfile, "R", PlayerInfo[playerid][Pos][3]);
    return 1;
}
pawn Код:
stock LoginUser(playerid)
{
    format(Userfile, sizeof(Userfile), "users/%s.ini", GetName(playerid));
    IsLogged[playerid] = 1;
    JustLogged[playerid] = 1;
    PlayerInfo[playerid][Admin] = dini_Int(Userfile, "Admin");
    PlayerInfo[playerid][Money] = dini_Int(Userfile, "Money");
    PlayerInfo[playerid][Skin] = dini_Int(Userfile, "Skin");
    PlayerInfo[playerid][Health] = dini_Float(Userfile, "Health");
    PlayerInfo[playerid][Armour] = dini_Float(Userfile, "Armour");
    PlayerInfo[playerid][Pos][0] = dini_Float(Userfile, "X");
    PlayerInfo[playerid][Pos][1] = dini_Float(Userfile, "Y");
    PlayerInfo[playerid][Pos][2] = dini_Float(Userfile, "Z");
    PlayerInfo[playerid][Pos][3] = dini_Float(Userfile, "R");

    GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
    // Timers
    SaveTimer[playerid] = SetTimerEx("SaveUser", 60 * 1000 * 5, true, "i", playerid);
   
    return SendClientMessage(playerid, COLOR_INFO, "Logged in.");
}

Help please, it puts me in Blueberry!
Reply
#2

Where did you put the SaveUser(playerid); function?
I guess in onplayerdisconnect?
Reply
#3

Yeah
Reply
#4

Well the thing that I did to my server is:
I made an one second timer that every second use the GetPlayerPos(saves in variables);
And when he logs off it will saves the variables to the player data so it will be always the coords of the last second where he was standing.
I'm not sure but I think that the GetPlayerPos doesn't realy work bugless in onplayerdisconnect.
Reply
#5

Thanks for the advice I'll try it out
Reply
#6

Didn't work
Reply
#7

Well you can at least look in the player file if the coords get saved, yes or no, and when you load it, use a print() to see if they realy get loaded, if this all works then you know the mistake is at the onplayerspawn.
Reply
#8

It reads it but it doesn't work, so like a said it's a problem with that line..
Reply
#9

Quote:
Originally Posted by cloudysky
Посмотреть сообщение
It reads it but it doesn't work, so like a said it's a problem with that line..
Well wierd,
But not sure if this is the cause of your problem
but I don't see why you are using the
{

}

at this script:
Код:
JustLogged[playerid] = 0;
        {
            SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
        }
Reply
#10

Nah I really don't know what to do...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)