Need help with these stuffs.
#1

Alright, i have been working whole day for this and i have finally converted this house system to Y_ini.

The house system loads/saves fine after gamemode restarts. Problem i got is that each player have 2 house slots available max, and whenever they buy 2 houses then relog, only 1 house is loading. Other house is still showing owned by the player but they aren't able to use it. In the player file where the houses are stored, its showing Houses = 2 but when player reconnects, its only loading 1. I have been trying to fix this since 7 hours but couldn't figure out whats wrong.

pawn Код:
//OnGamemodeInit()
Housing_LoadAll()
{
    for (new HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
    {
        if(fexist(House_File(HouseID)))
        {
            INI_ParseFile(House_File(HouseID), "LoadHouse_%s", .bExtra = true, .extra = HouseID);
            gHouseData[HouseID][HouseOpened] = false;
            House_CreateEntrance(HouseID);
            TotalHouses++;
        }
    }
    return 1;
}

//OnPlayerConnect(playerid)
if(fexist(UserPath(playerid)))
        INI_ParseFile(UserPath(playerid), "Load_%s", .bExtra = true, .extra = playerid);

public Load_playerdata(playerid, name[], value[])
{
    new
        BusIndex,
        HouseIndex
    ;

    INI_Int("MoneyBoost",       pInfo[playerid][MoneyBoost]);
    INI_Int("BoostTime",        pInfo[playerid][BoostTime]);
    INI_Int("Jailed",           pInfo[playerid][Jailed]);
    INI_Bool("Muted",           pInfo[playerid][Muted]);
    INI_Bool("RulesRead",       pInfo[playerid][RulesRead]);
    INI_Int("Houses",           pInfo[playerid][Houses][HouseIndex]); HouseIndex++;
    INI_Int("Business",         pInfo[playerid][Business][BusIndex]); BusIndex++;
    return 1;
}

//OnPlayerDisconnect(playerid, reason)
pData_Save(playerid)
{
    if(!pInfo[playerid][LoggedIn]) return 1;

    new
        INI:File = INI_Open(UserPath(playerid));

    INI_SetTag(File, "playerdata");
    INI_WriteInt(File, "MoneyBoost",    pInfo[playerid][MoneyBoost]);
    INI_WriteInt(File, "BoostTime",     pInfo[playerid][BoostTime]);
    INI_WriteInt(File, "Jailed",        pInfo[playerid][Jailed]);
    INI_WriteBool(File, "Muted",        pInfo[playerid][Muted]);
    INI_WriteBool(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)
        {
            Save_HouseData(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;
}

//These are working fine tho
forward LoadHouse_data(HouseID, name[], value[]);
public LoadHouse_data(HouseID, name[], value[])
{
    INI_String("HouseName", gHouseData[HouseID][HouseName], 24);
    INI_Float("HouseX", gHouseData[HouseID][HouseX]);
    INI_Float("HouseY", gHouseData[HouseID][HouseY]);
    INI_Float("HouseZ", gHouseData[HouseID][HouseZ]);
    INI_Int("HouseLevel", gHouseData[HouseID][HouseLevel]);
    INI_Int("HouseMaxLevel", gHouseData[HouseID][HouseMaxLevel]);
    INI_Int("HousePrice", gHouseData[HouseID][HousePrice]);
    INI_Bool("Owned", gHouseData[HouseID][Owned]);
    INI_String("Owner", gHouseData[HouseID][Owner], 24);
    INI_Int("Insurance", gHouseData[HouseID][Insurance]);
    return 1;
}

Save_HouseData(HouseID)
{
    new INI:hFile = INI_Open(House_File(HouseID));

    INI_SetTag(hFile, "data");
    INI_WriteString(hFile, "HouseName", gHouseData[HouseID][HouseName]);
    INI_WriteFloat(hFile, "HouseX", gHouseData[HouseID][HouseX]);
    INI_WriteFloat(hFile, "HouseY", gHouseData[HouseID][HouseY]);
    INI_WriteFloat(hFile, "HouseZ", gHouseData[HouseID][HouseZ]);
    INI_WriteInt(hFile, "HouseLevel", gHouseData[HouseID][HouseLevel]);
    INI_WriteInt(hFile, "HouseMaxLevel", gHouseData[HouseID][HouseMaxLevel]);
    INI_WriteInt(hFile, "HousePrice", gHouseData[HouseID][HousePrice]);
    INI_WriteBool(hFile, "Owned", gHouseData[HouseID][Owned]);
    INI_WriteString(hFile, "Owner", gHouseData[HouseID][Owner]);
    INI_WriteInt(hFile, "Insurance", gHouseData[HouseID][Insurance]);
    INI_Close(hFile);
    return 1;
}
Sorry for posting this huge code. Any help?
Reply


Messages In This Thread
Need help with these stuffs. - by iOxide - 13.09.2014, 19:23
Re: Need help with these stuffs. - by MikeB - 13.09.2014, 20:46
Re: Need help with these stuffs. - by iOxide - 13.09.2014, 20:55
Respuesta: Need help with these stuffs. - by MikeB - 13.09.2014, 21:55
Re: Need help with these stuffs. - by iOxide - 14.09.2014, 16:09
Re: Need help with these stuffs. - by iOxide - 16.09.2014, 14:03
Re: Need help with these stuffs. - by biker122 - 16.09.2014, 15:08
Re: Need help with these stuffs. - by iOxide - 16.09.2014, 16:00

Forum Jump:


Users browsing this thread: 1 Guest(s)