SA-MP Forums Archive
creating a file with yini? - 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: creating a file with yini? (/showthread.php?tid=249379)



creating a file with yini? - Tommy_Mandaz - 18.04.2011

Hello,

I have this:

pawn Код:
if(dialogid == 1) //Register
    {
        if(response)
        {
            new name[MAX_PLAYER_NAME], files[256];
            GetPlayerName(playerid, name, sizeof(name));
            format(files, sizeof(files), "%s.ini", name);
            {
                new INI:file = INI_Open(files);
                gPlayerInfo[playerid][pPassword] = INI_WriteInt(file, "Password", udb_hash(inputtext));
                gPlayerInfo[playerid][pLevel] = INI_WriteInt(file, "Level", 1);
                SetPlayerScore(playerid,1);
                gPlayerInfo[playerid][pMoney] = INI_WriteInt(file, "Money", 5000);
                GivePlayerMoney(playerid,5000);
                gPlayerInfo[playerid][pHealth] = INI_WriteInt(file, "Health", 100);
                SetPlayerHealth(playerid,100);
                gPlayerInfo[playerid][pArmour] = INI_WriteInt(file, "Armour", 0);
                SetPlayerArmour(playerid,0);
                gPlayerInfo[playerid][pSkin] = INI_WriteInt(file, "Skin", 26);
                SetPlayerSkin(playerid,26);
                INI_Close(file);
                gPlayerLogged[playerid] = 1;
                return 1;
            }
        }
    }
But when I go to scriptfiles the file is not there, for example I join as John_Testy and it doesnt create a new .ini file called "John_Testy.ini"

Please help im using yini


Re: creating a file with yini? - Sascha - 18.04.2011

just add:
pawn Код:
new File:fi = fopen(files, io_write);
fclose(fi);
before the "new INI:file.........."


Re: creating a file with yini? - Tommy_Mandaz - 18.04.2011

Like this?

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new name[MAX_PLAYER_NAME], playerfile[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(playerfile, sizeof(playerfile), "%s.ini", name);
    {
        new INI:file = INI_Open(playerfile);
        new Float:health, Float:armour;
        gPlayerInfo[playerid][pLevel] = GetPlayerScore(playerid);
        INI_WriteInt(file, "Level", gPlayerInfo[playerid][pLevel]);
        gPlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
        INI_WriteInt(file, "Money", gPlayerInfo[playerid][pMoney]);
        gPlayerInfo[playerid][pHealth] = GetPlayerHealth(playerid, health);
        INI_WriteFloat(file, "Health", gPlayerInfo[playerid][pHealth]);
        gPlayerInfo[playerid][pArmour] = GetPlayerArmour(playerid, armour);
        INI_WriteFloat(file, "Armour", gPlayerInfo[playerid][pArmour]);
        gPlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
        INI_WriteInt(file, "Skin", gPlayerInfo[playerid][pSkin]);
        INI_Close(file);
    }
    return 1;
}



Re: creating a file with yini? - Tommy_Mandaz - 18.04.2011

So am I creating a .ini file using yini or am I still using dini? I am trying to use yini not dini is there INI_Create in yini or something similar


Re: creating a file with yini? - Sascha - 18.04.2011

this is not dini and not yini :P... it's the normal pwn way... and about the INI_Create: just try it out and see if it gives you any error :P (or check the Y_INI topic hehe)