Problem with Y_Ini
#1

Hello.

I am using Y_Ini to save some of players' data.

The RulesRead variable is to show the rules dialog in OnPlayerRequestSpawn callback if they haven't accepted the rules yet and if its set to 1, it shouldn't show the dialog again but its showing even if the value is set to 1 in the player data file. Same script was working fine in my backup server which had Y_ini for all the player data. I moved to mysql and since these 4 variables aren't necessary to save in mysql db, i thought of making a separate file using Y_ini and found the problem with RulesRead variable. I have inventory file system with the same method and its working fine. I guess something is wrong on the dialog?

pawn Код:
#define DATA_DIRECTORY              "/Player Data/%s.ini"

forward LoadUser_data(playerid, name[], value[]);
public LoadUser_data(playerid, name[], value[])
{
    new HouseIndex, BusIndex;
    INI_Int("MoneyBoost",       pInfo[playerid][MoneyBoost]);
    INI_Int("BoostTime",        pInfo[playerid][BoostTime]);
    INI_Int("Jailed",           pInfo[playerid][Jailed]);
    INI_Int("RulesRead",        pInfo[playerid][RulesRead]);
    INI_Int("Houses",           pInfo[playerid][Houses][HouseIndex]);  HouseIndex++;
    INI_Int("Business",         pInfo[playerid][Business][BusIndex]);  BusIndex++;
    return 1;
}

stock pData_Create(playerid)
{
    new INI:File = INI_Open(DataPath(playerid));
    INI_SetTag(File,"DATA");
    INI_WriteInt(File, "MoneyBoost", 0);
    INI_WriteInt(File, "BoostTime", 0);
    INI_WriteInt(File, "Jailed", 0);
    INI_WriteInt(File, "RulesRead", 0);
    INI_Close(File);
}

stock pData_Save(playerid)
{
    new INI:File = INI_Open(DataPath(playerid));
    INI_SetTag(File,"DATA");
    INI_WriteInt(File, "MoneyBoost", pInfo[playerid][MoneyBoost]);
    INI_WriteInt(File, "BoostTime", pInfo[playerid][BoostTime]);
    INI_WriteInt(File, "Jailed", pInfo[playerid][Jailed]);
    INI_WriteInt(File, "RulesRead", pInfo[playerid][RulesRead]);
    for (new i; i < MAX_HOUSESPERPLAYER; i++)
        if (pInfo[playerid][Houses][i] != 0)
            INI_WriteInt(File, "Houses", pInfo[playerid][Houses][i]);
    for (new i; i < MAX_BUSINESSPERPLAYER; i++)
        if (pInfo[playerid][Business][i] != 0)
            INI_WriteInt(File, "Businesses", pInfo[playerid][Business][i]);
    INI_Close(File);
    for (new i; i < MAX_HOUSESPERPLAYER; i++)
        if (pInfo[playerid][Houses][i] != 0)
            HouseFile_Save(pInfo[playerid][Houses][i]);
    for (new i; i < MAX_BUSINESSPERPLAYER; i++)
        if (pInfo[playerid][Business][i] != 0)
            BusinessFile_Save(pInfo[playerid][Business][i]);
    return 1;
}

stock DataPath(playerid)
{
    new str[128], Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name,sizeof(Name));
    format(str,sizeof(str), DATA_DIRECTORY, Name);
    return str;
}

public OnPlayerDisconnect(playerid, reason)
{
    pData_Save(playerid);
    //some other codes are here
    return 1;
}

public OnPlayerConnect(playerid)
{
    //some other codes are here
    if(fexist(DataPath(playerid)))
        INI_ParseFile(DataPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
    return 1;
}

Dialog_Rules(playerid, response)
{
    if(!response)
    {
        Timer_Disconnect[playerid] = SetTimerEx("DisconnectPlayer", 100, false, "d", playerid);
        SendClientMessage(playerid, DARK_RED, "We do not allow any players who don't follow our server rules!");
    }
    if(response)
    {
        if (pInfo[playerid][RulesRead] == 0)
        {
            RewardPlayer(playerid, 10000, 5);
            pInfo[playerid][RulesRead] = 1;
            SendClientMessage(playerid, YELLOW, "You got $10000 and 5 score for accepting our server's rules.");
            pData_Save(playerid);
        }
    }
    return 1;
}

//In register dialog
pData_Create(playerid);

//In login dialog
INI_ParseFile(DataPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
Reply


Messages In This Thread
Problem with Y_Ini - by iOxide - 25.06.2014, 11:14
Re: Problem with Y_Ini - by Jack_Leslie - 25.06.2014, 11:16
Re: Problem with Y_Ini - by iOxide - 25.06.2014, 11:21
Re: Problem with Y_Ini - by Jack_Leslie - 25.06.2014, 11:22
Re: Problem with Y_Ini - by iOxide - 25.06.2014, 11:25
Re: Problem with Y_Ini - by Jack_Leslie - 25.06.2014, 11:30
Re: Problem with Y_Ini - by Threshold - 25.06.2014, 11:38
Re: Problem with Y_Ini - by Jack_Leslie - 25.06.2014, 12:30
Re: Problem with Y_Ini - by Threshold - 25.06.2014, 13:01
Re: Problem with Y_Ini - by Jack_Leslie - 25.06.2014, 13:03

Forum Jump:


Users browsing this thread: 1 Guest(s)