[y_ini]Loading house files
#1

pawn Код:
forward LoadCreatedHouses(houseid, name[], value[]);
public LoadCreatedHouses(houseid, name[], value[])
{
        if(!strcmp(name, "HouseOwner"))         strset(HouseData[houseid][E_HOUSE_OWNER], value);
        if(!strcmp(name, "House_IntUID"))       HouseData[houseid][E_HOUSE_INT_UID] = strval(value);
        if(!strcmp(name, "HouseCost"))          HouseData[houseid][E_HOUSE_COST] = strval(value);
        if(!strcmp(name, "HouseLocked"))        HouseData[houseid][E_HOUSE_LOCKED] = strval(value);
        if(!strcmp(name, "HouseDescription"))   strset(HouseData[houseid][E_HOUSE_DESCRIPTION], value);
        if(!strcmp(name, "HouseInX"))                        HouseData[houseid][E_HOUSE_IN][0] = floatstr(value);
        if(!strcmp(name, "HouseInY"))                        HouseData[houseid][E_HOUSE_IN][1] = floatstr(value);
        if(!strcmp(name, "HouseInZ"))                        HouseData[houseid][E_HOUSE_IN][2] = floatstr(value);
        if(!strcmp(name, "HouseInA"))                        HouseData[houseid][E_HOUSE_IN][3] = floatstr(value);
        if(!strcmp(name, "HouseInInt"))               HouseData[houseid][E_HOUSE_IN_INT] = strval(value);
        if(!strcmp(name, "HouseInVW"))               HouseData[houseid][E_HOUSE_IN_VW] = strval(value);
        if(!strcmp(name, "HouseOutX"))                        HouseData[houseid][E_HOUSE_OUT][0] = floatstr(value);
        if(!strcmp(name, "HouseOutY"))                        HouseData[houseid][E_HOUSE_OUT][1] = floatstr(value);
        if(!strcmp(name, "HouseOutZ"))                        HouseData[houseid][E_HOUSE_OUT][2] = floatstr(value);
        if(!strcmp(name, "HouseOutA"))                        HouseData[houseid][E_HOUSE_OUT][3] = floatstr(value);
        if(!strcmp(name, "HouseOutInt"))               HouseData[houseid][E_HOUSE_OUT_INT] = strval(value);
        if(!strcmp(name, "HouseOutVW"))               HouseData[houseid][E_HOUSE_OUT_VW] = strval(value);

        PickupUID[houseid] = CreatePickup(19198, 1, HouseData[houseid][E_HOUSE_OUT][0], HouseData[houseid][E_HOUSE_OUT][1], HouseData[houseid][E_HOUSE_OUT][2]+0.5, HouseData[houseid][E_HOUSE_OUT_VW]);
       
        new string[128];
        format(string, sizeof(string), "Właściciel: \"%s\"\nKoszt: %d\nOpis: \"%s\"", HouseData[houseid][E_HOUSE_OWNER], HouseData[houseid][E_HOUSE_COST], HouseData[houseid][E_HOUSE_DESCRIPTION]);
        HouseData[houseid][E_HOUSE_LABEL] = Create3DTextLabel(string, 0xFFC973FF, HouseData[houseid][E_HOUSE_OUT][0], HouseData[houseid][E_HOUSE_OUT][1], HouseData[houseid][E_HOUSE_OUT][2], 3.0, HouseData[houseid][E_HOUSE_OUT_VW], 0);
        return true;
}

stock LoadHouses()
{
        for(new i = 0; i != MAX_HOUSES; i++)
        {
            INI_ParseFile(HouseFile(i), "LoadCreatedHouses", .bExtra = true, .extra = i);
        }
}
This should load all houses from files, and yes it's loading them but this one i need to make on [playerid] array.
pawn Код:
PickupUID[houseid]
It's sets unique id from CreatePickup. And it's all working when i creating in game, but when i save it and load - it won't.

P.S
Can't open/close houses as well, so that seems like script just doesn't get it that i loaded some houses. I tried debugging and it said it has loaded some files and the ids was right.
Reply
#2

Bump (3rd page).

Actually, i don't need that o load:
pawn Код:
PickupUID[houseid] = Create[...]
So i've just removed that. But still, there's a problem with y_ini, i guess. Because it seems like system doesn't know that i loaded some files. It loading checkpoints, labels and PROPER text to the labels, so it looks like:

"I didn't used anywhere (i.e.) lock muliti-dimensional array, so i don't know what to do next."

But it has been used in set some value from loading, i mean equals strval(value);

P.S
1,000 post.

Код:
Debug: Loading house number: 0
Debug: Door state of this house is: 1

Debug: Loading house number: 1
Debug: Door state of this house is: 0

Debug: Loading house number: 2
Debug: Door state of this house is: 0

Debug: Loading house number: 3
Debug: Door state of this house is: 0

Debug: Loading house number: 4
Debug: Door state of this house is: 0

Debug: Loading house number: 5
Debug: Door state of this house is: 0

Debug: Loading house number: 6
Debug: Door state of this house is: 0

Debug: Loading house number: 7
Debug: Door state of this house is: 0

Debug: Loading house number: 8
Debug: Door state of this house is: 0

Debug: Loading house number: 9
Debug: Door state of this house is: 0
Only house 0 and 1 id's are real files. The other one doesn't matter.

Line about locked doors in the house ID: 0.
pawn Код:
HouseLocked = 1
Line about locked doors in the house ID: 1.
pawn Код:
HouseLocked = 0
So it loads good. Any other idea?
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
As for the second post, I'm not sure what you mean by saying y_ini doesn't know it has loaded some files.
Because it's loading houses (as you seen debug) but when i'm trying to use my test command /lock to open/close house doors - I can't. The doors are closed to the houses, doesn't matter is script loaded state to 0 or 1. They're always closed.
Reply
#4

Wait a second, because i totally forgot to put in LoadCreatedHouses function this:
pawn Код:
HouseData[houseid][E_HOUSE_CREATED] = true;
I totally failed, but now i can only open/close doors of the first house.. cannot access to the other houses.
Reply
#5

I made some changes, it works different now but i still need help with loading:

pawn Код:
stock SaveHouses()
{
    new houseid = 0;
    while(houseid != SerwerData[E_SERWER_LAST_PICKUP])
    {
        if(HouseData[houseid][E_HOUSE_CREATED])
        {
            new INI:House = INI_Open(HouseFile(houseid));
            INI_WriteString (House,     "HouseOwner",       HouseData[houseid][E_HOUSE_OWNER]);
            INI_WriteInt    (House,     "House_IntUID",     HouseData[houseid][E_HOUSE_INT_UID]);
            INI_WriteInt    (House,     "HouseCost",        HouseData[houseid][E_HOUSE_COST]);
            INI_WriteInt    (House,     "HouseLocked",      HouseData[houseid][E_HOUSE_LOCKED]);
            INI_WriteString (House,     "HouseDescription", HouseData[houseid][E_HOUSE_DESCRIPTION]);
            INI_WriteFloat  (House,     "HouseInX",         HouseData[houseid][E_HOUSE_IN][0]);
            INI_WriteFloat  (House,     "HouseInY",         HouseData[houseid][E_HOUSE_IN][1]);
            INI_WriteFloat  (House,     "HouseInZ",         HouseData[houseid][E_HOUSE_IN][2]);
            INI_WriteFloat  (House,     "HouseInA",         HouseData[houseid][E_HOUSE_IN][3]);
            INI_WriteInt    (House,     "HouseInInt",       HouseData[houseid][E_HOUSE_IN_INT]);
            INI_WriteInt    (House,     "HouseInVW",        HouseData[houseid][E_HOUSE_IN_VW]);
            INI_WriteFloat  (House,     "HouseOutX",        HouseData[houseid][E_HOUSE_OUT][0]);
            INI_WriteFloat  (House,     "HouseOutY",        HouseData[houseid][E_HOUSE_OUT][1]);
            INI_WriteFloat  (House,     "HouseOutZ",        HouseData[houseid][E_HOUSE_OUT][2]);
            INI_WriteFloat  (House,     "HouseOutA",        HouseData[houseid][E_HOUSE_OUT][3]);
            INI_WriteInt    (House,     "HouseOutInt",      HouseData[houseid][E_HOUSE_OUT_INT]);
            INI_WriteInt    (House,     "HouseOutVW",       HouseData[houseid][E_HOUSE_OUT_VW]);
            INI_Close       (House);
        }
        houseid += 1;
    }
   
    new INI:Serwer = INI_Open("SerwerStats.ini");
    INI_WriteInt(Serwer,    "CREATED_HOUSES",       SerwerData[E_SERWER_LAST_PICKUP]);
    INI_Close(Serwer);
}

forward LoadCreatedHouses(houseid, name[], value[]);
public LoadCreatedHouses(houseid, name[], value[])
{
    if(!strcmp(name, "HouseOwner"))         strset(HouseData[houseid][E_HOUSE_OWNER], value);
    if(!strcmp(name, "House_IntUID"))       HouseData[houseid][E_HOUSE_INT_UID] = strval(value);
    if(!strcmp(name, "HouseCost"))          HouseData[houseid][E_HOUSE_COST] = strval(value);
    if(!strcmp(name, "HouseLocked"))        HouseData[houseid][E_HOUSE_LOCKED] = strval(value);
    if(!strcmp(name, "HouseDescription"))   strset(HouseData[houseid][E_HOUSE_DESCRIPTION], value);
    if(!strcmp(name, "HouseInX"))           HouseData[houseid][E_HOUSE_IN][0] = floatstr(value);
    if(!strcmp(name, "HouseInY"))           HouseData[houseid][E_HOUSE_IN][1] = floatstr(value);
    if(!strcmp(name, "HouseInZ"))           HouseData[houseid][E_HOUSE_IN][2] = floatstr(value);
    if(!strcmp(name, "HouseInA"))           HouseData[houseid][E_HOUSE_IN][3] = floatstr(value);
    if(!strcmp(name, "HouseInInt"))         HouseData[houseid][E_HOUSE_IN_INT] = strval(value);
    if(!strcmp(name, "HouseInVW"))          HouseData[houseid][E_HOUSE_IN_VW] = strval(value);
    if(!strcmp(name, "HouseOutX"))          HouseData[houseid][E_HOUSE_OUT][0] = floatstr(value);
    if(!strcmp(name, "HouseOutY"))          HouseData[houseid][E_HOUSE_OUT][1] = floatstr(value);
    if(!strcmp(name, "HouseOutZ"))          HouseData[houseid][E_HOUSE_OUT][2] = floatstr(value);
    if(!strcmp(name, "HouseOutA"))          HouseData[houseid][E_HOUSE_OUT][3] = floatstr(value);
    if(!strcmp(name, "HouseOutInt"))        HouseData[houseid][E_HOUSE_OUT_INT] = strval(value);
    if(!strcmp(name, "HouseOutVW"))         HouseData[houseid][E_HOUSE_OUT_VW] = strval(value);
   
    CreateHouse(HouseData[houseid][E_HOUSE_INT_UID],
    HouseData[houseid][E_HOUSE_OUT][0],
    HouseData[houseid][E_HOUSE_OUT][1],
    HouseData[houseid][E_HOUSE_OUT][2],
    HouseData[houseid][E_HOUSE_OUT][3],
    HouseData[houseid][E_HOUSE_OUT_INT],
    HouseData[houseid][E_HOUSE_OUT_VW],
    HouseData[houseid][E_HOUSE_COST],
    HouseData[houseid][E_HOUSE_DESCRIPTION]);
    return true;
}

INI:SerwerStats[](name[], value[])
{
    if(!strcmp(name, "CREATED_HOUSES"))     SerwerData[E_SERWER_LOAD_PICKUP] = strval(value);
    return true;
}
   
stock LoadHouses()
{
    INI_Load("SerwerStats.ini");
   
    new houseid = 0;
    while(houseid != SerwerData[E_SERWER_LOAD_PICKUP])
    {
        INI_ParseFile(HouseFile(houseid), "LoadCreatedHouses", .bExtra = true, .extra = houseid);
       
        if(fexist(HouseFile(houseid)))
        {
            printf("Found that record (%d)", houseid);
        }
        else printf("Didn't find house (%d)", houseid);
        houseid += 1;
    }
}
edit://
I swapped code again. This time saving is working, but loading fails. It loads only one house, any idea?
Also.. it creates me some files with House ids in folder, up to House_84.. weird?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)