YINI Loading
#1

Hey I am trying to save a faction's stats into a file then load it when the server restarts The saving works fine but when I restart the server two times the values will be set to 0 again and I think that happens because the server is not loading.
This is what I am using to save

Код:
stock SaveLSPDData()
{
  	new INI:LSPD = INI_Open("Factions/LSPD.ini");
	INI_SetTag(LSPD, "Los Santos Police Department");
  	INI_WriteString(LSPD, "Chief", LSPDVar[FactionLeader]);
   	INI_WriteInt(LSPD, "Money", LSPDVar[FactionMoney]);
    INI_WriteInt(LSPD, "Drugs", LSPDVar[FactionDrugs]);
    INI_WriteInt(LSPD, "Weapons", LSPDVar[Factionguns]);
    INI_WriteInt(LSPD, "MembersCount", LSPDVar[FactionMembers]);
    INI_WriteInt(LSPD, "ArrestsCount", LSPDVar[FactionArrests]);
    INI_WriteInt(LSPD, "KillsCount", LSPDVar[FactionKills]);
    INI_WriteInt(LSPD, "DeathsCount", LSPDVar[FactionDeaths]);
    INI_Close(LSPD);
    return 1;
}
And ofc I call that function OnGameModeExit so can anyone help me to load the file OnGameModeInit?Thank you in advance
Reply
#2

Well, you need to use INI_Int for reading integers and INI_String for strings.. Best way is to create public, with all of these variables and then for example use INI_ParseFile with extra parameter playerid and load this public.
Reply
#3

This is what I have
Код:
public LoadLSPD_Data(name[], value[])
{
    INI_String("Chief", LSPDVar[FactionLeader],24);
   	INI_Int("Money", LSPDVar[FactionMoney]);
    INI_Int("Drugs", LSPDVar[FactionDrugs]);
    INI_Int("Weapons", LSPDVar[Factionguns]);
    INI_Int("MembersCount", LSPDVar[FactionMembers]);
    INI_Int("ArrestsCount", LSPDVar[FactionArrests]);
    INI_Int("KillsCount", LSPDVar[FactionKills]);
    INI_Int("DeathsCount", LSPDVar[FactionDeaths]);
    return 1;
}
I call that function OnGameModeInit But it's not working.It's not showing any errors but it's not Loading either.And by the way I have to use for playerid so I think I should use INI_LOAD instead of INI_ParseFile but I'm not sure how
Edit:
Nvm,I already got it.I will post my code maybe it will be useful for someone out there
Код:
INI:LSPD[](name[], value[])
{
    INI_String("Chief", LSPDVar[FactionLeader],24);
   	INI_Int("Money", LSPDVar[FactionMoney]);
    INI_Int("Drugs", LSPDVar[FactionDrugs]);
    INI_Int("Weapons", LSPDVar[Factionguns]);
    INI_Int("MembersCount", LSPDVar[FactionMembers]);
    INI_Int("ArrestsCount", LSPDVar[FactionArrests]);
    INI_Int("KillsCount", LSPDVar[FactionKills]);
    INI_Int("DeathsCount", LSPDVar[FactionDeaths]);
    return 1;
}
Under OnGameModeInit
Код:
INI_Load("Factions/LSPD.INI");
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)