18.02.2012, 18:57
Hello, I have a saving system using y_ini. I've implemented a saving position on logoff and setting it on spawn.
I was making my gamemode in LS, but due to frustration. I've moved it to a smaller scale location. Red County. Everything works fine, except when a player connects. It saves perfectly on disconnect, buy on connect y_ini is writing the position floats as zero, causing the logging in player to spawn at the noobie spawn. If anyone has any clue to what I'm doing wrong it would be greatly appreciated for you to share your advice.
================================================== ============================
OnPlayerConnect.
Loding User Data.
================================================== =================
EDIT
I found a new problem. Whenever a player registers, or is logging in. y_ini creates a file with a blank name.
This it what it looks like.
I was making my gamemode in LS, but due to frustration. I've moved it to a smaller scale location. Red County. Everything works fine, except when a player connects. It saves perfectly on disconnect, buy on connect y_ini is writing the position floats as zero, causing the logging in player to spawn at the noobie spawn. If anyone has any clue to what I'm doing wrong it would be greatly appreciated for you to share your advice.
================================================== ============================
OnPlayerConnect.
pawn Код:
public OnPlayerConnect(playerid)
{
OnPlayerLogin(playerid);
return 1;
}
forward OnPlayerLogin(playerid);
public OnPlayerLogin(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registering...","Type your password below to register a new account.","Register","Quit");
}
}
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Faction",pInfo[playerid][pFaction]);
INI_Int("Rank",pInfo[playerid][pRank]);
INI_Int("Leader",pInfo[playerid][pLeader]);
INI_Int("Job",pInfo[playerid][pJob]);
INI_Int("Mats",pInfo[playerid][pMats]);
INI_Int("Crack",pInfo[playerid][pCrack]);
INI_Int("Bank",pInfo[playerid][pBank]);
INI_Int("Cash",pInfo[playerid][pCash]);
INI_Int("HasInvite",pInfo[playerid][pHasInvite]);
INI_Int("Password",pInfo[playerid][pPass]);
INI_Int("IsDead",pInfo[playerid][pIsDead]);
INI_Int("CanKill",pInfo[playerid][pCanKill]);
INI_Int("Skin",pInfo[playerid][pSkin]);
INI_Float("LastX",pInfo[playerid][pPosX]);
INI_Float("LastY",pInfo[playerid][pPosY]);
INI_Float("LastZ",pInfo[playerid][pPosZ]);
INI_Float("Angle",pInfo[playerid][pAngle]);
INI_Float("Health",pInfo[playerid][pHealth]);
INI_Float("Armour",pInfo[playerid][pArmour]);
INI_Int("AdminLevel",pInfo[playerid][pAdmin]);
INI_Int("Accent",pInfo[playerid][pAccent]);
INI_Int("Jailed",pInfo[playerid][pJailed]);
INI_Int("JailTime",pInfo[playerid][pJailTime]);
return 1;
}
EDIT
I found a new problem. Whenever a player registers, or is logging in. y_ini creates a file with a blank name.
This it what it looks like.
Код:
[data] Bank = 20000 Cash = 0 Faction = 2 Rank = 5 Leader = 2 Job = 0 Mats = 0 Crack = 0 HasInvite = 2 CanKill = 1 Skin = 0 LastX = 0.000000 LastY = -52.531036 LastZ = 26.484375 Angle = 0.000000 Health = 0.000000 Armour = 0.000000 AdminLevel = 0 Accent = 0 Jailed = 0 JailTime = 0