Save and Load Positions[ MySQL]
#1

Hello so i wonder how i can load the last position of player when he relogs? It saves very well but i used the setplayerPosition(pinfo[playerid][posX],pinfo[playerid][posY],pinfo[playerid][posZ]) but when i relog it spawns me at x0 y0 z0 coords!! even if it saves correctly the coords when i disconnect!
Here is my function where it has to spawn player OnPlayerSpawnCallback

pawn Код:
if(pinfo[playerid][Registered] == 0)
            {
                SetPlayerSkin(playerid,pinfo[playerid][Skin]);
                SetClassFromSkin(playerid);
                WantedLevelColor(playerid);
                SetPlayerTeam(playerid,pinfo[playerid][Team]);
                SetPlayerToTeamColor(playerid);
                GivePlayerTeamWeapons(playerid);
                printf("%s stats have been given.Skin: %d Team: %d", GPN(playerid),pinfo[playerid][Skin],pinfo[playerid][Team]);

                if(pinfo[playerid][Team] == TEAM_COPS)
                {
                    SetPlayerPos(playerid, 1569.5902,-1694.6520,5.8906);
                    SetCameraBehindPlayer(playerid);
                }
                if(pinfo[playerid][Team] == NO_TEAM)
                {

                    if(pinfo[playerid][Cuffed] == 1)
                    {
                        SendClientMessage(playerid, COLOR_RED," [ AUTO CUFF]: You have been autojailed because you left server while cuffed!");
                        new rnd = random(sizeof(PrisonSpawn));
                        SetPlayerPos(playerid, PrisonSpawn[rnd][0], PrisonSpawn[rnd][1], PrisonSpawn[rnd][2]);
                        SendClientMessage(playerid, COLOR_GREY, "**LOS SANTOS PRISON**");
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, "[PRISON] You have been sent to prison. You will be released soon.");
                    }
                    if(pinfo[playerid][Jailed] == 1)
                    {
                        new rnd = random(sizeof(PrisonSpawn));
                        SetPlayerPos(playerid, PrisonSpawn[rnd][0], PrisonSpawn[rnd][1], PrisonSpawn[rnd][2]);
                        SendClientMessage(playerid, COLOR_GREY, "**LOS SANTOS PRISON**");
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, "[PRISON] You have been sent to prison. You will be released soon.");
                    }
                    else
                    {
                        new rnd = random(sizeof(SpawnPoints));
                        //SetPlayerPos(playerid, SpawnPoints[rnd][0], SpawnPoints[rnd][1], SpawnPoints[rnd][2]);
                    SetPlayerPos(playerid,pinfo[playerid][posX],pinfo[playerid][posY],pinfo[playerid][posZ]); <<<<<<<
                        SetPlayerFacingAngle(playerid, SpawnPoints[rnd][3]);
                        SetCameraBehindPlayer(playerid);
                    }
                }
            }
and here is my accountload callback
pawn Код:
public OnAccountLoad(playerid)
{
    pinfo[playerid][Admin] = cache_get_field_content_int(0, "Admin");
    pinfo[playerid][VIP] = cache_get_field_content_int(0, "VIP");
    pinfo[playerid][Money] = cache_get_field_content_int(0, "Money");
    pinfo[playerid][posX] = cache_get_field_content_float(0, "PosX");
    pinfo[playerid][posY] = cache_get_field_content_float(0, "PosY");
    pinfo[playerid][posZ] = cache_get_field_content_float(0, "PosZ");
    pinfo[playerid][Kills] = cache_get_field_content_int(0, "Kills");
    pinfo[playerid][Deaths] = cache_get_field_content_int(0, "Deaths");
    pinfo[playerid][Score] = cache_get_field_content_int(0, "Score");
    pinfo[playerid][Banned] = cache_get_field_content_int(0,"Banned");
    pinfo[playerid][Hours] = cache_get_field_content_int(0, "Hours");
    pinfo[playerid][Minutes] = cache_get_field_content_int(0, "Minutes");
    pinfo[playerid][Terskill] = cache_get_field_content_int(0, "Terskill");
    pinfo[playerid][Robskill] = cache_get_field_content_int(0, "Robskill");
    pinfo[playerid][Hitmanskill] = cache_get_field_content_int(0, "Hitmanskill");
    pinfo[playerid][WantedLevel] = cache_get_field_content_int(0, "WantedLevel");
    pinfo[playerid][TotalRobs] = cache_get_field_content_int(0, "TotalRobs");
    pinfo[playerid][Muted] = cache_get_field_content_int(0," Muted");
    pinfo[playerid][Cuffed] = cache_get_field_content_int(0,"Cuffed");
    pinfo[playerid][Jailed] = cache_get_field_content_int(0, "Jailed");
    pinfo[playerid][JailTime] = cache_get_field_content_int(0, "JailTime");
    pinfo[playerid][Skin] = cache_get_field_content_int(0, "Skin");
    pinfo[playerid][Team] = cache_get_field_content_int(0, "Team");
    pinfo[playerid][Drug] = cache_get_field_content_int(0, "Drugs");
    pinfo[playerid][DrugAmount] = cache_get_field_content_int(0, "DrugAmount");
   
    pinfo[playerid][Logged] = 1;
    pinfo[playerid][Registered] = 0;
    SpawnPlayer(playerid);

    GivePlayerMoney(playerid, pinfo[playerid][Money]);

    SendClientMessage(playerid, -1, "Successfully logged in");
    return 1;
}
Reply


Messages In This Thread
Save and Load Positions[ MySQL] - by vassilis - 07.11.2015, 12:34
Re: Save and Load Positions[ MySQL] - by MD5 - 07.11.2015, 12:40
Re: Save and Load Positions[ MySQL] - by vassilis - 07.11.2015, 12:41
Re: Save and Load Positions[ MySQL] - by Vince - 07.11.2015, 12:47
Re: Save and Load Positions[ MySQL] - by vassilis - 07.11.2015, 12:49
Re: Save and Load Positions[ MySQL] - by MD5 - 07.11.2015, 13:08
Re: Save and Load Positions[ MySQL] - by vassilis - 07.11.2015, 13:10

Forum Jump:


Users browsing this thread: 1 Guest(s)