19.03.2015, 16:53
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:
SpawnChar Stock:
The spawn function called under DIALOG_LOGIN:
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
Thats the SaveUser function:
Its called OnPlayerDisconenct.
Please help me with this out
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;
}
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);
}
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);
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;
}
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);
}
Please help me with this out