SA-MP Forums Archive
Y-Ini - how to load info O.o - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Y-Ini - how to load info O.o (/showthread.php?tid=253752)



[SOLVED] Y-Ini - how to load info O.o - Unknown123 - 07.05.2011

pawn Код:
#include <a_samp>
#include <zcmd>
#include <YSI/y_ini>

enum ServerSavings
{
    Banned,
    Kicked,
    Fucked
}
new ServerInfo[ServerSavings];

public OnFilterScriptInit()
{
    LoadCreateFile();
    return 1;
}

COMMAND:fuck(playerid, params[])
{
    ServerInfo[Fucked] ++, SaveInfo();
    return 1;
}

stock LoadCreateFile()
{
    new File[] = "ServerInfo.ini";
    new INI:iniFile = INI_Open(File);
    if(!fexist(File))
    {
        INI_WriteInt(iniFile, "Banned", 0);
        INI_WriteInt(iniFile, "Kicked", 0);
        INI_WriteInt(iniFile, "Fucked", 0);
        INI_Close(iniFile);
    }
    else
    {
        //LoadInfo
    }
}

stock SaveInfo()
{
    new File[] = "ServerInfo.ini";
    new INI:iniFile = INI_Open(File);
    INI_WriteInt(iniFile, "Banned", ServerInfo[Banned]);
    INI_WriteInt(iniFile, "Kicked", ServerInfo[Kicked]);
    INI_WriteInt(iniFile, "Fucked", ServerInfo[Fucked]);
    INI_Close(iniFile);
}
How to load from the file?


//LOL
ServerInfo[Banned] = INI_Read(iniFile, "Banned");


Re: Y-Ini - how to load info O.o - Zh3r0 - 07.05.2011

pawn Код:
//This goes inside the function where you want to load the data.
INI_ParseFile("ServerData", "ServerInfo.ini" );

//somwehere in the script.
forward ServerData(name[], value[])
public ServerData(name[], value[])
{
    if(!strcmp(name, "Banned"))
        ServerInfo[Banned] = strval(value);

    if(!strcmp(name, "Kicked"))
        ServerInfo[Kicked] = strval(value);

    if(!strcmp(name, "Fucked"))
        ServerInfo[Fucked] = strval(value);
}



Re: Y-Ini - how to load info O.o - Unknown123 - 07.05.2011

Thank You!


Re: Y-Ini - how to load info O.o - Unknown123 - 09.05.2011

I just have to bump this because i just noticed that the Server info is not loading.

pawn Код:
//Yes i remembered to add this :P
INI_ParseFile("LoadServerData", "ServerInfo.ini");
pawn Код:
forward LoadServerData(name[], value[])
public LoadServerData(name[], value[])
{
    print("Debug: Works!");
    if(!strcmp(name, "Banned")) ServerInfo[Banned] = strval(value);
    if(!strcmp(name, "Kicked")) ServerInfo[Kicked] = strval(value);
    if(!strcmp(name, "Fucked")) ServerInfo[Fucked] = strval(value);
}
The print debug get never printed O.o

Edit: SOLVED!