Player Spawn Problem
#1

Hey,
Recently i was trying to make users system and when saving x,y,z before he disconnects then load it on connect and spawn him there (basic saving xyz and spawn).
Problem is that when player register to server he spawn in the desired place X,Y,Z when he reconnects he will spawn in the farm with 0 health. I'm loading everything and used any function right now I'm trying to do my best and still its going nowhere.

Here is some script that might let you figure out whats wrong:
OnPlayerSpawn:
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid)) return 1;
    if(GetPVarInt(playerid, "LoggedIn") == 1) SpawnChar(playerid);
    return 1;
}
SpawnChar Stock:
pawn Код:
stock SpawnChar(playerid)
{
    SetPlayerPos(playerid, PlayerInfo[playerid][posX], PlayerInfo[playerid][posY], PlayerInfo[playerid][posZ]);
    SetPlayerFacingAngle(playerid, PlayerInfo[playerid][posA]);
    SetPlayerInterior(playerid, PlayerInfo[playerid][pInterior]);
    SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVW]);
    SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
    SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
    SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
    GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
    SetPlayerColor(playerid, COLOR_WHITE);
    SetCameraBehindPlayer(playerid);
    TogglePlayerControllable(playerid, 1);
}
The spawn function called under DIALOG_LOGIN:
pawn Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);                   
SetPVarInt(playerid, "LoggedIn", 1);
SetSpawnInfo(playerid, 0, 255, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
So when player register to the server this exact function called but without the ParseFile, because in the register I'm not saving the variables I'm just using them instantly in the spawn. Here seems like the ParseFile brings X,Y,Z 0,0,0 & Skin 0 & HP 0 & basiaclly everything 0...

Here is
LoadUser_data
pawn Код:
public LoadUser_data(playerid,name[],value[])
{
    INI_String("Password", PlayerInfo[playerid][pPass], 129);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Money", PlayerInfo[playerid][pMoney]);
    INI_Int("Admin", PlayerInfo[playerid][pAdmin]);
    INI_Int("Ban", PlayerInfo[playerid][pBan]);
    INI_String("IP", PlayerInfo[playerid][pIP], 16);
    INI_Int("Interior", PlayerInfo[playerid][pInterior]);
    INI_Int("VirutalWorld", PlayerInfo[playerid][pVW]);
    INI_Int("Skin", PlayerInfo[playerid][pSkin]);
    INI_Int("Gender", PlayerInfo[playerid][pGender]);
    INI_Int("Age", PlayerInfo[playerid][pAge]);
    INI_Int("Hospital", PlayerInfo[playerid][pHospital]);
    INI_Float("Health", PlayerInfo[playerid][pHealth]);
    INI_Float("Armour", PlayerInfo[playerid][pArmour]);
    INI_Float("PositionX",PlayerInfo[playerid][posX]);
    INI_Float("PositionY",PlayerInfo[playerid][posY]);
    INI_Float("PositionZ",PlayerInfo[playerid][posZ]);
    INI_Float("PositionA",PlayerInfo[playerid][posA]);
    return 1;
}
Thats the SaveUser function:
pawn Код:
stock SaveUser(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
   
    GetPlayerPos(playerid, PlayerInfo[playerid][posX], PlayerInfo[playerid][posY], PlayerInfo[playerid][posZ]);
   
    GetPlayerFacingAngle(playerid, PlayerInfo[playerid][posA]);
   
    GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
    GetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
   
    INI_SetTag(File,"PlayerData");
    INI_WriteInt(File,"Skin", GetPlayerSkin(playerid));
    INI_WriteInt(File,"Ban", PlayerInfo[playerid][pBan]);
    if(PlayerInfo[playerid][pBan])
    {
        INI_WriteString(File, "BanReason", PlayerInfo[playerid][pBanReason]);
        INI_WriteString(File, "BannedBy", PlayerInfo[playerid][pBannedBy]);
    }
    INI_WriteInt(File,"Money", PlayerInfo[playerid][pMoney]);
    INI_WriteInt(File,"Admin", PlayerInfo[playerid][pAdmin]);
    INI_WriteString(File,"IP", PlayerInfo[playerid][pIP]);
    INI_WriteInt(File,"Interior", GetPlayerInterior(playerid));
    INI_WriteInt(File,"VirtualWorld", GetPlayerVirtualWorld(playerid));
    INI_WriteInt(File,"Hospital", PlayerInfo[playerid][pHospital]);
    INI_WriteFloat(File,"Health", PlayerInfo[playerid][pHealth]);
    INI_WriteFloat(File,"Armour", PlayerInfo[playerid][pArmour]);
    INI_WriteFloat(File,"PositionX", PlayerInfo[playerid][posX]);
    INI_WriteFloat(File,"PositionY", PlayerInfo[playerid][posY]);
    INI_WriteFloat(File,"PositionZ", PlayerInfo[playerid][posZ]);
    INI_WriteFloat(File,"PositionA", PlayerInfo[playerid][posA]);
   
    INI_Close(File);
}
Its called OnPlayerDisconenct.
Please help me with this out
Reply
#2

Change your LoadUser_data function name to LoadUser_PlayerData.

Why?
1.
pawn Код:
INI_SetTag(File,"PlayerData");
2.
https://sampforum.blast.hk/showthread.php?tid=175565 - read up on remoteFormat parameter.
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Change your LoadUser_data function name to LoadUser_PlayerData.

Why?
1.
pawn Код:
INI_SetTag(File,"PlayerData");
2.
https://sampforum.blast.hk/showthread.php?tid=175565 - read up on remoteFormat parameter.
Ohhhhh! I'm such a clumsy person I didnt check those because i was totally sure of myself they are right.

Thanks alot for the help, +Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)