SA-MP Forums Archive
Y_Ini not loading properly - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Y_Ini not loading properly (/showthread.php?tid=472695)



Y_Ini not loading properly - ikbenremco - 30.10.2013

Hi guys,

When I login after a gmx in any way (Closing samp-server.exe or /rcon gmx) It won't load my items correctly, but when I login for the SECOND time after the GMX, I'll suddently get my weapons/ect

And it's always saving correctly

PHP код:
stock SavePlayer(playerid)
{
    new 
tmpIP[17];
    
GetPlayerIp(playerid, tmpIP, sizeof(tmpIP));
    
GetPlayerPos(playerid, pInfo[playerid][PosX], pInfo[playerid][PosY], pInfo[playerid][PosZ]);
    
GetPlayerFacingAngle(playerid, pInfo[playerid][pAngle]);
    
GetPlayerInterior(pInfo[playerid][pInterior]);
    
GetPlayerVirtualWorld(pInfo[playerid][pVirtualWorld]);
    
GetPlayerHealth(playerid,pInfo[playerid][pHealth]);
    
GetPlayerArmour(playerid,pInfo[playerid][pArmor]);
    
    
GetPlayerWeaponData(playerid, 0, pInfo[playerid][pWeapon0], pInfo[playerid][pWeapon0a]);
    
GetPlayerWeaponData(playerid, 1, pInfo[playerid][pWeapon1], pInfo[playerid][pWeapon1a]);
    
GetPlayerWeaponData(playerid, 2, pInfo[playerid][pWeapon2], pInfo[playerid][pWeapon2a]);
    
GetPlayerWeaponData(playerid, 3, pInfo[playerid][pWeapon3], pInfo[playerid][pWeapon3a]);
    
GetPlayerWeaponData(playerid, 4, pInfo[playerid][pWeapon4], pInfo[playerid][pWeapon4a]);
    
GetPlayerWeaponData(playerid, 5, pInfo[playerid][pWeapon5], pInfo[playerid][pWeapon5a]);
    
GetPlayerWeaponData(playerid, 6, pInfo[playerid][pWeapon6], pInfo[playerid][pWeapon6a]);
    
GetPlayerWeaponData(playerid, 7, pInfo[playerid][pWeapon7], pInfo[playerid][pWeapon7a]);
    
GetPlayerWeaponData(playerid, 8, pInfo[playerid][pWeapon8], pInfo[playerid][pWeapon8a]);
    
GetPlayerWeaponData(playerid, 9, pInfo[playerid][pWeapon9], pInfo[playerid][pWeapon9a]);
    
GetPlayerWeaponData(playerid, 10, pInfo[playerid][pWeapon10], pInfo[playerid][pWeapon10a]);
    
GetPlayerWeaponData(playerid, 11, pInfo[playerid][pWeapon11], pInfo[playerid][pWeapon11a]);
    
GetPlayerWeaponData(playerid, 12, pInfo[playerid][pWeapon12], pInfo[playerid][pWeapon12a]);
    
    
format(string2, sizeof(string2), "%s", tmpIP);
    
strmid(pInfo[playerid][pIP], string2, 0, strlen(string2), 255);
    
    new 
INI:File = INI_Open(UserPath(playerid));
    
INI_SetTag(File,"Position");
    
INI_WriteFloat(File, "PositionX", pInfo[playerid][PosX]);
    
INI_WriteFloat(File, "PositionY", pInfo[playerid][PosY]);
    
INI_WriteFloat(File, "PositionZ", pInfo[playerid][PosZ]);
    
INI_WriteFloat(File, "Angle", pInfo[playerid][pAngle]);
    
INI_WriteInt(File, "Interior", pInfo[playerid][pInterior]);
    
INI_WriteInt(File, "VirtualWorld", pInfo[playerid][pVirtualWorld]);
    
INI_SetTag(File,"User's statistics");
    
INI_WriteInt(File,"Respects",pInfo[playerid][pRespects]);
    
INI_WriteInt(File,"PayDay",pInfo[playerid][pPayDay]);
    
INI_WriteInt(File,"Helper",pInfo[playerid][pHelper]);
    
INI_WriteString(File,"IP",pInfo[playerid][pIP]);
    
INI_WriteFloat(File, "Health", pInfo[playerid][pHealth]);
    
INI_WriteFloat(File, "Armor", pInfo[playerid][pArmor]);
    
INI_WriteInt(File,"Kills",pInfo[playerid][pKills]);
    
INI_WriteInt(File,"Level",pInfo[playerid][pLevel]);
    
INI_WriteInt(File,"Registered",pInfo[playerid][pRegistered]);
    
INI_WriteInt(File,"Age",pInfo[playerid][pAge]);
    
INI_WriteInt(File,"Gender",pInfo[playerid][pGender]);
    
INI_WriteInt(File,"Deaths",pInfo[playerid][pDeaths]);
    
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    
INI_WriteInt(File,"Bank",pInfo[playerid][pAccount]);
    
INI_SetTag(File, "Ammo & Gunz");
    
INI_WriteInt(File,"Weapon0",pInfo[playerid][pWeapon0]);
    
INI_WriteInt(File,"Ammo0",pInfo[playerid][pWeapon0a]);
    
INI_WriteInt(File,"Weapon1",pInfo[playerid][pWeapon1]);
    
INI_WriteInt(File,"Ammo1",pInfo[playerid][pWeapon1a]);
    
INI_WriteInt(File,"Weapon2",pInfo[playerid][pWeapon2]);
    
INI_WriteInt(File,"Ammo2",pInfo[playerid][pWeapon2a]);
    
INI_WriteInt(File,"Weapon3",pInfo[playerid][pWeapon3]);
    
INI_WriteInt(File,"Ammo3",pInfo[playerid][pWeapon3a]);
    
INI_WriteInt(File,"Weapon4",pInfo[playerid][pWeapon4]);
    
INI_WriteInt(File,"Ammo4",pInfo[playerid][pWeapon4a]);
    
INI_WriteInt(File,"Weapon5",pInfo[playerid][pWeapon5]);
    
INI_WriteInt(File,"Ammo5",pInfo[playerid][pWeapon5a]);
    
INI_WriteInt(File,"Weapon6",pInfo[playerid][pWeapon6]);
    
INI_WriteInt(File,"Ammo6",pInfo[playerid][pWeapon6a]);
    
INI_WriteInt(File,"Weapon7",pInfo[playerid][pWeapon7]);
    
INI_WriteInt(File,"Ammo7",pInfo[playerid][pWeapon7a]);
    
INI_WriteInt(File,"Weapon8",pInfo[playerid][pWeapon8]);
    
INI_WriteInt(File,"Ammo8",pInfo[playerid][pWeapon8a]);
    
INI_WriteInt(File,"Weapon9",pInfo[playerid][pWeapon9]);
    
INI_WriteInt(File,"Ammo9",pInfo[playerid][pWeapon9a]);
    
INI_WriteInt(File,"Weapon10",pInfo[playerid][pWeapon10]);
    
INI_WriteInt(File,"Ammo10",pInfo[playerid][pWeapon10a]);
    
INI_WriteInt(File,"Weapon11",pInfo[playerid][pWeapon11]);
    
INI_WriteInt(File,"Ammo11",pInfo[playerid][pWeapon11a]);
    
INI_WriteInt(File,"Weapon12",pInfo[playerid][pWeapon12]);
    
INI_WriteInt(File,"Ammo12",pInfo[playerid][pWeapon12a]);
    
INI_SetTag(File,"Faction information");
    
INI_WriteInt(File,"Leader",pInfo[playerid][pLeader]);
    
INI_WriteInt(File,"Rank",pInfo[playerid][pRank]);
    
INI_WriteInt(File,"OnDuty",pInfo[playerid][pOnDuty]);
    
INI_WriteInt(File,"Member",pInfo[playerid][pMember]);
    
INI_WriteInt(File,"Faction",pInfo[playerid][pFaction]);
    
INI_SetTag(File,"Admin statistics");
    
INI_WriteInt(File,"Admin",pInfo[playerid][pAdmin]);
    
INI_WriteInt(File,"Stealthed",pInfo[playerid][pStealthed]);
    
INI_Close(File);
    return 
1;
} 
Loading public:
PHP код:
forward LoadUser_data(playerid,name[],value[]);
public 
LoadUser_data(playerid,name[],value[])
{
    
INI_Int("Password",pInfo[playerid][pPass]);
    
INI_Float("PositionX", pInfo[playerid][PosX]);
    
INI_Float("PositionY", pInfo[playerid][PosY]);
    
INI_Float("PositionZ", pInfo[playerid][PosZ]);
    
INI_Float("Angle", pInfo[playerid][pAngle]);
    
INI_Int("Interior", pInfo[playerid][pInterior]);
    
INI_Int("IP", pInfo[playerid][pIP]);
    
INI_Int("VirtualWorld", pInfo[playerid][pVirtualWorld]);
    
INI_Int("Registered", pInfo[playerid][pRegistered]);
    
INI_Int("Cash",pInfo[playerid][pCash]);
    
INI_Int("OnDuty",pInfo[playerid][pOnDuty]);
    
INI_Int("Stealthed",pInfo[playerid][pStealthed]);
    
INI_Int("Bank",pInfo[playerid][pAccount]);
    
INI_Float("Armor",pInfo[playerid][pArmor]);
    
INI_Float("Health",pInfo[playerid][pHealth]);
    
INI_Int("Gender",pInfo[playerid][pGender]);
    
INI_Int("Admin",pInfo[playerid][pAdmin]);
    
INI_Int("Helper",pInfo[playerid][pHelper]);
    
INI_Int("Rank",pInfo[playerid][pRank]);
    
INI_Int("Leader",pInfo[playerid][pLeader]);
    
INI_Int("Faction",pInfo[playerid][pFaction]);
    
INI_Int("Age",pInfo[playerid][pAge]);
    
INI_Int("Respects",pInfo[playerid][pRespects]);
    
INI_Int("PayDay",pInfo[playerid][pPayDay]);
    
INI_Int("Level",pInfo[playerid][pLevel]);
    
INI_Int("Member",pInfo[playerid][pMember]);
    
INI_Int("Kills",pInfo[playerid][pKills]);
    
INI_Int("Deaths",pInfo[playerid][pDeaths]);
    
INI_Int("Weapon0",pInfo[playerid][pWeapon0]);
    
INI_Int("Ammo0",pInfo[playerid][pWeapon0a]);
    
INI_Int("Weapon1",pInfo[playerid][pWeapon1]);
    
INI_Int("Ammo1",pInfo[playerid][pWeapon1a]);
    
INI_Int("Weapon2",pInfo[playerid][pWeapon2]);
    
INI_Int("Ammo2",pInfo[playerid][pWeapon2a]);
    
INI_Int("Weapon3",pInfo[playerid][pWeapon3]);
    
INI_Int("Ammo3",pInfo[playerid][pWeapon3a]);
    
INI_Int("Weapon4",pInfo[playerid][pWeapon4]);
    
INI_Int("Ammo4",pInfo[playerid][pWeapon4a]);
    
INI_Int("Weapon5",pInfo[playerid][pWeapon5]);
    
INI_Int("Ammo5",pInfo[playerid][pWeapon5a]);
    
INI_Int("Weapon6",pInfo[playerid][pWeapon6]);
    
INI_Int("Ammo6",pInfo[playerid][pWeapon6a]);
    
INI_Int("Weapon7",pInfo[playerid][pWeapon7]);
    
INI_Int("Ammo7",pInfo[playerid][pWeapon7a]);
    
INI_Int("Weapon8",pInfo[playerid][pWeapon8]);
    
INI_Int("Ammo8",pInfo[playerid][pWeapon8a]);
    
INI_Int("Weapon9",pInfo[playerid][pWeapon9]);
    
INI_Int("Ammo9",pInfo[playerid][pWeapon9a]);
    
INI_Int("Weapon10",pInfo[playerid][pWeapon10]);
    
INI_Int("Ammo10",pInfo[playerid][pWeapon10a]);
    
INI_Int("Weapon11",pInfo[playerid][pWeapon11]);
    
INI_Int("Ammo11",pInfo[playerid][pWeapon11a]);
    
INI_Int("Weapon12",pInfo[playerid][pWeapon12]);
    
INI_Int("Ammo12",pInfo[playerid][pWeapon12a]);
    return 
1;
} 
INI_PArsefile:


PHP код:
forward login_dialog(playerid);
public 
login_dialog(playerid)
{
    
ClearChat(playerid);
    if(
fexist(UserPath(playerid)))
    {
        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""EMBED_WHITE"Login",""EMBED_WHITE"Welcome back to "EMBED_YELLOW""SERVERNAME""EMBED_WHITE"\nType your password below to login.","Login","Quit");
        
format(string2,sizeof(string2), "Welcome back to "EMBED_YELLOW""SERVERNAME""EMBED_WHITE", %s!", GetPlayerForename(playerid));
        
SendClientMessage(playerid, COLOR_WHITE, string2);
    }
    else
    {
        
format(string2,sizeof(string2), "Welcome to "EMBED_YELLOW""SERVERNAME""EMBED_WHITE", %s!", GetPlayerForename(playerid));
        
SendClientMessage(playerid, COLOR_WHITE, string2);
        
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""EMBED_WHITE"Registering",""EMBED_WHITE"Welcome back to "EMBED_YELLOW""SERVERNAME""EMBED_WHITE"\nType your password below to register a new account.","Register","Quit");
    }
    return 
1;
} 
// timer for that, this is under OnPlayerRequestSpawn:

PHP код:
TogglePlayerSpectating(playerid, true);
SetTimerEx("login_dialog", 100, 0, "i", playerid); 
After that I got the INI_PArsefile after the DIALOG_LOGIN dialog.


Re: Y_Ini not loading properly - David (Sabljak) - 30.10.2013

It's not good idea to GMX server when players are online. Best way is to go Quit and Rejoin...

or maybe i dont know if will help, put under GMX command

foreach(Player,i)
{
SavePlayer(i)
}

and make gmx to SetTimer 5 seconds after saving accounts to restart


Re: Y_Ini not loading properly - ikbenremco - 30.10.2013

It is saving correctly but not loading correctly as I mentioned above.


Re: Y_Ini not loading properly - knackworst - 30.10.2013

I have the opposite problem, mine is loading, but not saving :/

anyways maybe put this:
pawn Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
When the dialog is called and not in the dialog?
This is how I do it and it works fine...


Re: Y_Ini not loading properly - ikbenremco - 30.10.2013

Quote:
Originally Posted by knackworst
Посмотреть сообщение
I have the opposite problem, mine is loading, but not saving :/

anyways maybe put this:
pawn Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
When the dialog is called and not in the dialog?
This is how I do it and it works fine...
It's not working, I tried adding debug's this is the result :

PHP код:
forward LoadUser_data(playerid,name[],value[]);
public 
LoadUser_data(playerid,name[],value[])
{
    
printf("Hoi");
    
INI_Int("Password",pInfo[playerid][pPass]);
    
INI_Float("PositionX", pInfo[playerid][PosX]);
    
INI_Float("PositionY", pInfo[playerid][PosY]);
    
INI_Float("PositionZ", pInfo[playerid][PosZ]);
    
INI_Float("Angle", pInfo[playerid][pAngle]);
    
INI_Int("Interior", pInfo[playerid][pInterior]);
    
INI_Int("IP", pInfo[playerid][pIP]);
    
INI_Int("VirtualWorld", pInfo[playerid][pVirtualWorld]);
    
INI_Int("Registered", pInfo[playerid][pRegistered]);
    
INI_Int("Cash",pInfo[playerid][pCash]);
    
INI_Int("OnDuty",pInfo[playerid][pOnDuty]);
    
INI_Int("Stealthed",pInfo[playerid][pStealthed]);
    
INI_Int("Bank",pInfo[playerid][pAccount]);
    
INI_Float("Armor",pInfo[playerid][pArmor]);
    
INI_Float("Health",pInfo[playerid][pHealth]);
    
INI_Int("Gender",pInfo[playerid][pGender]);
    
INI_Int("Admin",pInfo[playerid][pAdmin]);
    
INI_Int("Helper",pInfo[playerid][pHelper]);
    
INI_Int("Rank",pInfo[playerid][pRank]);
    
INI_Int("Leader",pInfo[playerid][pLeader]);
    
INI_Int("Faction",pInfo[playerid][pFaction]);
    
INI_Int("Age",pInfo[playerid][pAge]);
    
INI_Int("Respects",pInfo[playerid][pRespects]);
    
printf("Hoi :)");
    
INI_Int("PayDay",pInfo[playerid][pPayDay]);
    
INI_Int("Level",pInfo[playerid][pLevel]);
    
INI_Int("Member",pInfo[playerid][pMember]);
    
INI_Int("Kills",pInfo[playerid][pKills]);
    
INI_Int("Deaths",pInfo[playerid][pDeaths]);
    
INI_Int("Weapon0",pInfo[playerid][pWeapon0]);
    
INI_Int("Ammo0",pInfo[playerid][pWeapon0a]);
    
INI_Int("Weapon1",pInfo[playerid][pWeapon1]);
    
INI_Int("Ammo1",pInfo[playerid][pWeapon1a]);
    
INI_Int("Weapon2",pInfo[playerid][pWeapon2]);
    
INI_Int("Ammo2",pInfo[playerid][pWeapon2a]);
    
INI_Int("Weapon3",pInfo[playerid][pWeapon3]);
    
INI_Int("Ammo3",pInfo[playerid][pWeapon3a]);
    
INI_Int("Weapon4",pInfo[playerid][pWeapon4]);
    
INI_Int("Ammo4",pInfo[playerid][pWeapon4a]);
    
INI_Int("Weapon5",pInfo[playerid][pWeapon5]);
    
INI_Int("Ammo5",pInfo[playerid][pWeapon5a]);
    
INI_Int("Weapon6",pInfo[playerid][pWeapon6]);
    
INI_Int("Ammo6",pInfo[playerid][pWeapon6a]);
    
INI_Int("Weapon7",pInfo[playerid][pWeapon7]);
    
INI_Int("Ammo7",pInfo[playerid][pWeapon7a]);
    
INI_Int("Weapon8",pInfo[playerid][pWeapon8]);
    
INI_Int("Ammo8",pInfo[playerid][pWeapon8a]);
    
INI_Int("Weapon9",pInfo[playerid][pWeapon9]);
    
INI_Int("Ammo9",pInfo[playerid][pWeapon9a]);
    
INI_Int("Weapon10",pInfo[playerid][pWeapon10]);
    
INI_Int("Ammo10",pInfo[playerid][pWeapon10a]);
    
INI_Int("Weapon11",pInfo[playerid][pWeapon11]);
    
INI_Int("Ammo11",pInfo[playerid][pWeapon11a]);
    
INI_Int("Weapon12",pInfo[playerid][pWeapon12]);
    
INI_Int("Ammo12",pInfo[playerid][pWeapon12a]);
    
printf("Hoi2");
    return 
1;
} 



Re: Y_Ini not loading properly - ikbenremco - 31.10.2013

Bump, it only doesn't load the player's that after the first login it does after the second one.


Re: Y_Ini not loading properly - Pottus - 31.10.2013

I wouldn't touch GMX with a 10 foot pole, it causes client bugs and is a completely unacceptable thing to do. The best way is to always restart your server that means kill the process and restart it. You can still use OnGameModeExit() of course to do any saving etc but don't rely on ( /rcon GMX ) just consider that it doesn't even exist.


Re: Y_Ini not loading properly - ikbenremco - 31.10.2013

I already tried that /rcon gmx and closing the samp-server.exe both not working


Re: Y_Ini not loading properly - Pottus - 31.10.2013

Lets see this function then....

UserPath(playerid)


Re: Y_Ini not loading properly - ikbenremco - 31.10.2013

It does save so this shouldn't be the problem..

PHP код:
stock UserPath(playerid)
{
    new 
string[128],playername[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,playername,sizeof(playername));
    
format(string,sizeof(string),PATH,playername);
    return 
string;
} 
PHP код:
#define PATH "/Users/%s.ini"