SA-MP Forums Archive
Need help with createhouse.. - 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)
+--- Thread: Need help with createhouse.. (/showthread.php?tid=470844)



Need help with createhouse.. - Scrillex - 19.10.2013

Hello ear samp members.

I need help from You, maybe you could help me out..


So i have made my public etc...


And I have my question how can I save it as %d and it counts next number which are unused.


Second question is how can I save a VW for a player..


GetVirtualWorld(but next idk..)


here is my public:

pawn Code:
//
forward CreateHouse(playerid, costs, sells, interior , virtualworld);
public CreateHouse(playerid, costs, sells, interior , virtualworld)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    new INI:HouseFile = INI_Open(HousePath());
    HouseCount++;
    hInfo[playerid][hEnterX] = X;
    hInfo[playerid][hEnterY] = Y;
    hInfo[playerid][hEnterZ] = Z;
    hInfo[playerid][hInterior] = interior;
    hInfo[playerid][hCost] = costs;
    hInfo[playerid][hSell] = sells;
    hInfo[playerid][hVW] = virtualworld;
   
    INI_WriteFloat(HouseFile, "EnterenceX", hInfo[playerid][hEnterX]);
    INI_WriteFloat(HouseFile, "EnterenceY", hInfo[playerid][hEnterY]);
    INI_WriteFloat(HouseFile, "EnterenceZ", hInfo[playerid][hEnterZ]);
    INI_WriteFloat(HouseFile, "ExitX", 0);
    INI_WriteFloat(HouseFile, "ExitY", 0);
    INI_WriteFloat(HouseFile, "ExitZ", 0);
    INI_WriteInt(HouseFile, "Interior", hInfo[playerid][hInterior]);
    INI_WriteInt(HouseFile, "VW", hInfo[playerid][hVW]);
    INI_WriteInt(HouseFile, "Cost", hInfo[playerid][hCost]);
    INI_WriteInt(HouseFile, "Sell", hInfo[playerid][hSell]);
    INI_WriteString(HouseFile, "Phone", hInfo[playerid][hPhone]);
    INI_WriteInt(HouseFile, "Garderobe", hInfo[playerid][hGarderobe]);
    INI_WriteInt(HouseFile, "Garderobe1", hInfo[playerid][hGarderobe1]);
    INI_WriteInt(HouseFile, "Storage", hInfo[playerid][hStorage]);
    INI_WriteInt(HouseFile, "Storage1", hInfo[playerid][hStorage1]);
    INI_WriteInt(HouseFile, "Storage2", hInfo[playerid][hStorage2]);
    INI_WriteInt(HouseFile, "Storage3", hInfo[playerid][hStorage3]);
    INI_WriteInt(HouseFile, "Storage4", hInfo[playerid][hStorage4]);
    INI_WriteInt(HouseFile, "Storage5", hInfo[playerid][hStorage5]);
    INI_WriteInt(HouseFile, "Storage6", hInfo[playerid][hStorage6]);
    INI_WriteInt(HouseFile, "Storage7", hInfo[playerid][hStorage7]);
    INI_WriteInt(HouseFile, "Storage8", hInfo[playerid][hStorage8]);
    INI_WriteInt(HouseFile, "Storage9", hInfo[playerid][hStorage9]);
    INI_WriteInt(HouseFile, "Storage10", hInfo[playerid][hStorage10]);
    INI_WriteInt(HouseFile, "Money", hInfo[playerid][hMoney]);
    INI_WriteInt(HouseFile, "Drugs", hInfo[playerid][hDrugs]);
    INI_WriteInt(HouseFile, "Drugs1", hInfo[playerid][hDrugs1]);
    INI_WriteInt(HouseFile, "Drugs2", hInfo[playerid][hDrugs2]);
    INI_WriteInt(HouseFile, "Drugs3", hInfo[playerid][hDrugs3]);
    INI_WriteInt(HouseFile, "Drugs4", hInfo[playerid][hDrugs4]);
    INI_WriteInt(HouseFile, "Drugs5", hInfo[playerid][hDrugs5]);
    INI_WriteInt(HouseFile, "Drugs6", hInfo[playerid][hDrugs6]);
    INI_WriteInt(HouseFile, "Drugs7", hInfo[playerid][hDrugs7]);
    INI_WriteInt(HouseFile, "Drugs8", hInfo[playerid][hDrugs8]);
    INI_WriteInt(HouseFile, "Drugs9", hInfo[playerid][hDrugs9]);
    INI_WriteInt(HouseFile, "Drugs10", hInfo[playerid][hDrugs10]);
    INI_WriteInt(HouseFile, "Drugs11", hInfo[playerid][hDrugs11]);
    INI_WriteInt(HouseFile, "Products", hInfo[playerid][hProducts]);
    INI_WriteInt(HouseFile, "Products1", hInfo[playerid][hProducts1]);
    INI_WriteInt(HouseFile, "Products2", hInfo[playerid][hProducts2]);
    INI_WriteInt(HouseFile, "Products3", hInfo[playerid][hProducts3]);
    INI_WriteInt(HouseFile, "Products4", hInfo[playerid][hProducts4]);
    INI_WriteInt(HouseFile, "Products5", hInfo[playerid][hProducts5]);
    INI_WriteInt(HouseFile, "Products6", hInfo[playerid][hProducts6]);
    INI_WriteInt(HouseFile, "Products7", hInfo[playerid][hProducts7]);
    INI_WriteInt(HouseFile, "Products8", hInfo[playerid][hProducts8]);
    INI_WriteInt(HouseFile, "Products9", hInfo[playerid][hProducts9]);
    INI_WriteInt(HouseFile, "Products10", hInfo[playerid][hProducts10]);
    INI_WriteInt(HouseFile, "Products11", hInfo[playerid][hProducts11]);
}
forward LoadHouse_data(playerid, name[], value[]);
public LoadHouse_data(playerid, name[], value[])
{
    new Name[24];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    INI_String("Owner", Name, 48);
    INI_Float("EnterenceX", hInfo[playerid][hEnterX]);
    INI_Float("EnterenceY", hInfo[playerid][hEnterY]);
    INI_Float("EnterenceZ", hInfo[playerid][hEnterZ]);
    INI_Float("ExitX", hInfo[playerid][hExitX]);
    INI_Float("ExitY", hInfo[playerid][hExitY]);
    INI_Float("ExitZ", hInfo[playerid][hExitZ]);
    INI_Int("Interior", hInfo[playerid][hInterior]);
    INI_Int("VW", hInfo[playerid][hVW]);
    INI_Int("Cost", hInfo[playerid][hCost]);
    INI_Int("Sell", hInfo[playerid][hSell]);
    INI_String("Phone", hInfo[playerid][hPhone], 16);
    INI_Int("Garderobe", hInfo[playerid][hGarderobe]);
    INI_Int("Garderobe1", hInfo[playerid][hGarderobe1]);
    INI_Int("Storage", hInfo[playerid][hStorage]);
    INI_Int("Storage1", hInfo[playerid][hStorage1]);
    INI_Int("Storage2", hInfo[playerid][hStorage2]);
    INI_Int("Storage3", hInfo[playerid][hStorage3]);
    INI_Int("Storage4", hInfo[playerid][hStorage4]);
    INI_Int("Storage5", hInfo[playerid][hStorage5]);
    INI_Int("Storage6", hInfo[playerid][hStorage6]);
    INI_Int("Storage7", hInfo[playerid][hStorage7]);
    INI_Int("Storage8", hInfo[playerid][hStorage8]);
    INI_Int("Storage9", hInfo[playerid][hStorage9]);
    INI_Int("Storage10", hInfo[playerid][hStorage10]);
    INI_Int("Money", hInfo[playerid][hMoney]);
    INI_Int("Drugs", hInfo[playerid][hDrugs]);
    INI_Int("Drugs1", hInfo[playerid][hDrugs1]);
    INI_Int("Drugs2", hInfo[playerid][hDrugs2]);
    INI_Int("Drugs3", hInfo[playerid][hDrugs3]);
    INI_Int("Drugs4", hInfo[playerid][hDrugs4]);
    INI_Int("Drugs5", hInfo[playerid][hDrugs5]);
    INI_Int("Drugs6", hInfo[playerid][hDrugs6]);
    INI_Int("Drugs7", hInfo[playerid][hDrugs7]);
    INI_Int("Drugs8", hInfo[playerid][hDrugs8]);
    INI_Int("Drugs9", hInfo[playerid][hDrugs9]);
    INI_Int("Drugs10", hInfo[playerid][hDrugs10]);
    INI_Int("Drugs11", hInfo[playerid][hDrugs11]);
    INI_Int("Products", hInfo[playerid][hProducts]);
    INI_Int("Products1", hInfo[playerid][hProducts1]);
    INI_Int("Products2", hInfo[playerid][hProducts2]);
    INI_Int("Products3", hInfo[playerid][hProducts3]);
    INI_Int("Products4", hInfo[playerid][hProducts4]);
    INI_Int("Products5", hInfo[playerid][hProducts5]);
    INI_Int("Products6", hInfo[playerid][hProducts6]);
    INI_Int("Products7", hInfo[playerid][hProducts7]);
    INI_Int("Products8", hInfo[playerid][hProducts8]);
    INI_Int("Products9", hInfo[playerid][hProducts9]);
    INI_Int("Products10", hInfo[playerid][hProducts10]);
    INI_Int("Products11", hInfo[playerid][hProducts11]);
    return 1;
}
With best regards Scrillex.


Re: Need help with createhouse.. - Zex Tan - 19.10.2013

1) Probably use the loop method and Define
pawn Code:
#define MAX_HOUSE 1000
In MySQL it will be easier to create house IDs. Just saying

2)Its GetPlayerVirtualWorld. https://sampwiki.blast.hk/wiki/GetPlayerVirtualWorld


Re: Need help with createhouse.. - EiresJason - 19.10.2013

pawn Code:
forward NextAvailableHouse();
public NextAvailableHouse()
{
    for(new i=1;i<MAX_HOUSES;i++)
    {
        if(!fexist(HousePath(i))) return i;
    }
    return 1;
}

new houseid = NextAvailableHouse();
new INI:HouseFile = INI_Open(HousePath(houseid ));



Re: Need help with createhouse.. - Scrillex - 19.10.2013

Yeah I know in mysql it's easier but.. mysql ain't my thing to less acknowledges in it.. Umm yeah i think it will do it...
with loop..but how to make it some thing like this?

pawn Code:
forward CreateHouse(playerid, costs, sells, interior , virtualworld);
public CreateHouse(playerid, costs, sells, interior , virtualworld)
{
    for(new h = 0; h < MAX_HOUSE; h++)
    {
        new Float:X, Float:Y, Float:Z;
        new Float:X1, Float:Y1, Float:Z1;
        GetPlayerPos(playerid, X, Y, Z);
        GetPlayerPos(playerid, X1, Y1, Z1);
        GetPlayerVirtualWorld(virtualworld);
        new INI:HouseFile = INI_Open(HousePath());
        HouseCount++;
        hInfo[playerid][hEnterX] = X;
        hInfo[playerid][hEnterY] = Y;
        hInfo[playerid][hEnterZ] = Z;
        hInfo[playerid][hExitX] = X1;
        hInfo[playerid][hExitY] = Y1;
        hInfo[playerid][hExitZ] = Z1;
        hInfo[playerid][hInterior] = interior;
        hInfo[playerid][hCost] = costs;
        hInfo[playerid][hSell] = sells;
        hInfo[playerid][hVW] = virtualworld;

        INI_WriteFloat(HouseFile, "EnterenceX", hInfo[playerid][hEnterX]);
        INI_WriteFloat(HouseFile, "EnterenceY", hInfo[playerid][hEnterY]);
        INI_WriteFloat(HouseFile, "EnterenceZ", hInfo[playerid][hEnterZ]);
        INI_WriteFloat(HouseFile, "ExitX", hInfo[playerid][hExitX]);
        INI_WriteFloat(HouseFile, "ExitY", hInfo[playerid][hExitY]);
        INI_WriteFloat(HouseFile, "ExitZ", hInfo[playerid][hExitZ]);
        INI_WriteInt(HouseFile, "Interior", hInfo[playerid][hInterior]);
        INI_WriteInt(HouseFile, "VW", hInfo[playerid][hVW]);
        INI_WriteInt(HouseFile, "Cost", hInfo[playerid][hCost]);
        INI_WriteInt(HouseFile, "Sell", hInfo[playerid][hSell]);
        INI_WriteString(HouseFile, "Phone", hInfo[playerid][hPhone]);
        INI_WriteInt(HouseFile, "Garderobe", hInfo[playerid][hGarderobe]);
        INI_WriteInt(HouseFile, "Garderobe1", hInfo[playerid][hGarderobe1]);
        INI_WriteInt(HouseFile, "Storage", hInfo[playerid][hStorage]);
        INI_WriteInt(HouseFile, "Storage1", hInfo[playerid][hStorage1]);
        INI_WriteInt(HouseFile, "Storage2", hInfo[playerid][hStorage2]);
        INI_WriteInt(HouseFile, "Storage3", hInfo[playerid][hStorage3]);
        INI_WriteInt(HouseFile, "Storage4", hInfo[playerid][hStorage4]);
        INI_WriteInt(HouseFile, "Storage5", hInfo[playerid][hStorage5]);
        INI_WriteInt(HouseFile, "Storage6", hInfo[playerid][hStorage6]);
        INI_WriteInt(HouseFile, "Storage7", hInfo[playerid][hStorage7]);
        INI_WriteInt(HouseFile, "Storage8", hInfo[playerid][hStorage8]);
        INI_WriteInt(HouseFile, "Storage9", hInfo[playerid][hStorage9]);
        INI_WriteInt(HouseFile, "Storage10", hInfo[playerid][hStorage10]);
        INI_WriteInt(HouseFile, "Money", hInfo[playerid][hMoney]);
        INI_WriteInt(HouseFile, "Drugs", hInfo[playerid][hDrugs]);
        INI_WriteInt(HouseFile, "Drugs1", hInfo[playerid][hDrugs1]);
        INI_WriteInt(HouseFile, "Drugs2", hInfo[playerid][hDrugs2]);
        INI_WriteInt(HouseFile, "Drugs3", hInfo[playerid][hDrugs3]);
        INI_WriteInt(HouseFile, "Drugs4", hInfo[playerid][hDrugs4]);
        INI_WriteInt(HouseFile, "Drugs5", hInfo[playerid][hDrugs5]);
        INI_WriteInt(HouseFile, "Drugs6", hInfo[playerid][hDrugs6]);
        INI_WriteInt(HouseFile, "Drugs7", hInfo[playerid][hDrugs7]);
        INI_WriteInt(HouseFile, "Drugs8", hInfo[playerid][hDrugs8]);
        INI_WriteInt(HouseFile, "Drugs9", hInfo[playerid][hDrugs9]);
        INI_WriteInt(HouseFile, "Drugs10", hInfo[playerid][hDrugs10]);
        INI_WriteInt(HouseFile, "Drugs11", hInfo[playerid][hDrugs11]);
        INI_WriteInt(HouseFile, "Products", hInfo[playerid][hProducts]);
        INI_WriteInt(HouseFile, "Products1", hInfo[playerid][hProducts1]);
        INI_WriteInt(HouseFile, "Products2", hInfo[playerid][hProducts2]);
        INI_WriteInt(HouseFile, "Products3", hInfo[playerid][hProducts3]);
        INI_WriteInt(HouseFile, "Products4", hInfo[playerid][hProducts4]);
        INI_WriteInt(HouseFile, "Products5", hInfo[playerid][hProducts5]);
        INI_WriteInt(HouseFile, "Products6", hInfo[playerid][hProducts6]);
        INI_WriteInt(HouseFile, "Products7", hInfo[playerid][hProducts7]);
        INI_WriteInt(HouseFile, "Products8", hInfo[playerid][hProducts8]);
        INI_WriteInt(HouseFile, "Products9", hInfo[playerid][hProducts9]);
        INI_WriteInt(HouseFile, "Products10", hInfo[playerid][hProducts10]);
        INI_WriteInt(HouseFile, "Products11", hInfo[playerid][hProducts11]);
    }
    return 1;
}



Re: Need help with createhouse.. - EiresJason - 20.10.2013

What exactly do you want to do Scrillex?

Do you want to create a file that is numbered or do you want to create a file that is named after the player in the houses folder?

pawn Code:
//Houses Folder.
0 //House ID: 0.
1 //House ID: 1.
2 //House ID: 2.
3 //House ID: 3.
4 //House ID: 4.

//or

Scrillex //Scrillex's house.
EiresJason //EiresJason' house.
DifferentUserName //This users house.
..etc



Re: Need help with createhouse.. - Zex Tan - 20.10.2013

He want it with HouseIDs. Anyways, the 'h' variable in your loop will be your HouseID

pawn Code:
format(str, sizeof(str), "%d", h);



Re: Need help with createhouse.. - Scrillex - 20.10.2013

Um this will be good?
+ about loading house it will load right?
pawn Code:
forward CreateHouse(playerid, costs, sells, interior , virtualworld);
public CreateHouse(playerid, costs, sells, interior , virtualworld)
{
    for(new h = 0; h < MAX_HOUSE; h++)
    {
        new str[256];
        format(str, sizeof(str), "%d", h);
        new Float:X, Float:Y, Float:Z;
        new Float:X1, Float:Y1, Float:Z1;
        GetPlayerPos(playerid, X, Y, Z);
        GetPlayerPos(playerid, X1, Y1, Z1);
        GetPlayerVirtualWorld(virtualworld);
        new INI:HouseFile = INI_Open(HousePath());
        HouseCount++;
        hInfo[playerid][hEnterX] = X;
        hInfo[playerid][hEnterY] = Y;
        hInfo[playerid][hEnterZ] = Z;
        hInfo[playerid][hExitX] = X1;
        hInfo[playerid][hExitY] = Y1;
        hInfo[playerid][hExitZ] = Z1;
        hInfo[playerid][hInterior] = interior;
        hInfo[playerid][hCost] = costs;
        hInfo[playerid][hSell] = sells;
        hInfo[playerid][hVW] = virtualworld;

        INI_WriteFloat(HouseFile, "EnterenceX", hInfo[playerid][hEnterX]);
        INI_WriteFloat(HouseFile, "EnterenceY", hInfo[playerid][hEnterY]);
        INI_WriteFloat(HouseFile, "EnterenceZ", hInfo[playerid][hEnterZ]);
        INI_WriteFloat(HouseFile, "ExitX", hInfo[playerid][hExitX]);
        INI_WriteFloat(HouseFile, "ExitY", hInfo[playerid][hExitY]);
        INI_WriteFloat(HouseFile, "ExitZ", hInfo[playerid][hExitZ]);
        INI_WriteInt(HouseFile, "Interior", hInfo[playerid][hInterior]);
        INI_WriteInt(HouseFile, "VW", hInfo[playerid][hVW]);
        INI_WriteInt(HouseFile, "Cost", hInfo[playerid][hCost]);
        INI_WriteInt(HouseFile, "Sell", hInfo[playerid][hSell]);
        INI_WriteString(HouseFile, "Phone", hInfo[playerid][hPhone]);
        INI_WriteInt(HouseFile, "Garderobe", hInfo[playerid][hGarderobe]);
        INI_WriteInt(HouseFile, "Garderobe1", hInfo[playerid][hGarderobe1]);
        INI_WriteInt(HouseFile, "Storage", hInfo[playerid][hStorage]);
        INI_WriteInt(HouseFile, "Storage1", hInfo[playerid][hStorage1]);
        INI_WriteInt(HouseFile, "Storage2", hInfo[playerid][hStorage2]);
        INI_WriteInt(HouseFile, "Storage3", hInfo[playerid][hStorage3]);
        INI_WriteInt(HouseFile, "Storage4", hInfo[playerid][hStorage4]);
        INI_WriteInt(HouseFile, "Storage5", hInfo[playerid][hStorage5]);
        INI_WriteInt(HouseFile, "Storage6", hInfo[playerid][hStorage6]);
        INI_WriteInt(HouseFile, "Storage7", hInfo[playerid][hStorage7]);
        INI_WriteInt(HouseFile, "Storage8", hInfo[playerid][hStorage8]);
        INI_WriteInt(HouseFile, "Storage9", hInfo[playerid][hStorage9]);
        INI_WriteInt(HouseFile, "Storage10", hInfo[playerid][hStorage10]);
        INI_WriteInt(HouseFile, "Money", hInfo[playerid][hMoney]);
        INI_WriteInt(HouseFile, "Drugs", hInfo[playerid][hDrugs]);
        INI_WriteInt(HouseFile, "Drugs1", hInfo[playerid][hDrugs1]);
        INI_WriteInt(HouseFile, "Drugs2", hInfo[playerid][hDrugs2]);
        INI_WriteInt(HouseFile, "Drugs3", hInfo[playerid][hDrugs3]);
        INI_WriteInt(HouseFile, "Drugs4", hInfo[playerid][hDrugs4]);
        INI_WriteInt(HouseFile, "Drugs5", hInfo[playerid][hDrugs5]);
        INI_WriteInt(HouseFile, "Drugs6", hInfo[playerid][hDrugs6]);
        INI_WriteInt(HouseFile, "Drugs7", hInfo[playerid][hDrugs7]);
        INI_WriteInt(HouseFile, "Drugs8", hInfo[playerid][hDrugs8]);
        INI_WriteInt(HouseFile, "Drugs9", hInfo[playerid][hDrugs9]);
        INI_WriteInt(HouseFile, "Drugs10", hInfo[playerid][hDrugs10]);
        INI_WriteInt(HouseFile, "Drugs11", hInfo[playerid][hDrugs11]);
        INI_WriteInt(HouseFile, "Products", hInfo[playerid][hProducts]);
        INI_WriteInt(HouseFile, "Products1", hInfo[playerid][hProducts1]);
        INI_WriteInt(HouseFile, "Products2", hInfo[playerid][hProducts2]);
        INI_WriteInt(HouseFile, "Products3", hInfo[playerid][hProducts3]);
        INI_WriteInt(HouseFile, "Products4", hInfo[playerid][hProducts4]);
        INI_WriteInt(HouseFile, "Products5", hInfo[playerid][hProducts5]);
        INI_WriteInt(HouseFile, "Products6", hInfo[playerid][hProducts6]);
        INI_WriteInt(HouseFile, "Products7", hInfo[playerid][hProducts7]);
        INI_WriteInt(HouseFile, "Products8", hInfo[playerid][hProducts8]);
        INI_WriteInt(HouseFile, "Products9", hInfo[playerid][hProducts9]);
        INI_WriteInt(HouseFile, "Products10", hInfo[playerid][hProducts10]);
        INI_WriteInt(HouseFile, "Products11", hInfo[playerid][hProducts11]);
    }
    return 1;
}



Re: Need help with createhouse.. - EiresJason - 20.10.2013

Something like this is needed.

pawn Code:
forward CreateHouse(playerid, costs, sells, interior , virtualworld);
public CreateHouse(playerid, costs, sells, interior , virtualworld)
{
    for(new h = 0; h < MAX_HOUSE; h++)
    {
        if(!fexist(HousePath(h)))
        {
            //new str[256];
            //format(str, sizeof(str), "%d", h);
            new Float:X, Float:Y, Float:Z;
            new Float:X1, Float:Y1, Float:Z1;
            GetPlayerPos(playerid, X, Y, Z);
            GetPlayerPos(playerid, X1, Y1, Z1);
            GetPlayerVirtualWorld(virtualworld);
            new INI:HouseFile = INI_Open(HousePath(h)); //make sure HousePath points to something like this: "/houses/%i.ini".
            HouseCount++;
            hInfo[playerid][hEnterX] = X;
            hInfo[playerid][hEnterY] = Y;
            hInfo[playerid][hEnterZ] = Z;
            hInfo[playerid][hExitX] = X1;
            hInfo[playerid][hExitY] = Y1;
            hInfo[playerid][hExitZ] = Z1;
            hInfo[playerid][hInterior] = interior;
            hInfo[playerid][hCost] = costs;
            hInfo[playerid][hSell] = sells;
            hInfo[playerid][hVW] = virtualworld;

            INI_WriteFloat(HouseFile, "EnterenceX", hInfo[playerid][hEnterX]);
            INI_WriteFloat(HouseFile, "EnterenceY", hInfo[playerid][hEnterY]);
            INI_WriteFloat(HouseFile, "EnterenceZ", hInfo[playerid][hEnterZ]);
            INI_WriteFloat(HouseFile, "ExitX", hInfo[playerid][hExitX]);
            INI_WriteFloat(HouseFile, "ExitY", hInfo[playerid][hExitY]);
            INI_WriteFloat(HouseFile, "ExitZ", hInfo[playerid][hExitZ]);
            INI_WriteInt(HouseFile, "Interior", hInfo[playerid][hInterior]);
            INI_WriteInt(HouseFile, "VW", hInfo[playerid][hVW]);
            INI_WriteInt(HouseFile, "Cost", hInfo[playerid][hCost]);
            INI_WriteInt(HouseFile, "Sell", hInfo[playerid][hSell]);
            INI_WriteString(HouseFile, "Phone", hInfo[playerid][hPhone]);
            INI_WriteInt(HouseFile, "Garderobe", hInfo[playerid][hGarderobe]);
            INI_WriteInt(HouseFile, "Garderobe1", hInfo[playerid][hGarderobe1]);
            INI_WriteInt(HouseFile, "Storage", hInfo[playerid][hStorage]);
            INI_WriteInt(HouseFile, "Storage1", hInfo[playerid][hStorage1]);
            INI_WriteInt(HouseFile, "Storage2", hInfo[playerid][hStorage2]);
            INI_WriteInt(HouseFile, "Storage3", hInfo[playerid][hStorage3]);
            INI_WriteInt(HouseFile, "Storage4", hInfo[playerid][hStorage4]);
            INI_WriteInt(HouseFile, "Storage5", hInfo[playerid][hStorage5]);
            INI_WriteInt(HouseFile, "Storage6", hInfo[playerid][hStorage6]);
            INI_WriteInt(HouseFile, "Storage7", hInfo[playerid][hStorage7]);
            INI_WriteInt(HouseFile, "Storage8", hInfo[playerid][hStorage8]);
            INI_WriteInt(HouseFile, "Storage9", hInfo[playerid][hStorage9]);
            INI_WriteInt(HouseFile, "Storage10", hInfo[playerid][hStorage10]);
            INI_WriteInt(HouseFile, "Money", hInfo[playerid][hMoney]);
            INI_WriteInt(HouseFile, "Drugs", hInfo[playerid][hDrugs]);
            INI_WriteInt(HouseFile, "Drugs1", hInfo[playerid][hDrugs1]);
            INI_WriteInt(HouseFile, "Drugs2", hInfo[playerid][hDrugs2]);
            INI_WriteInt(HouseFile, "Drugs3", hInfo[playerid][hDrugs3]);
            INI_WriteInt(HouseFile, "Drugs4", hInfo[playerid][hDrugs4]);
            INI_WriteInt(HouseFile, "Drugs5", hInfo[playerid][hDrugs5]);
            INI_WriteInt(HouseFile, "Drugs6", hInfo[playerid][hDrugs6]);
            INI_WriteInt(HouseFile, "Drugs7", hInfo[playerid][hDrugs7]);
            INI_WriteInt(HouseFile, "Drugs8", hInfo[playerid][hDrugs8]);
            INI_WriteInt(HouseFile, "Drugs9", hInfo[playerid][hDrugs9]);
            INI_WriteInt(HouseFile, "Drugs10", hInfo[playerid][hDrugs10]);
            INI_WriteInt(HouseFile, "Drugs11", hInfo[playerid][hDrugs11]);
            INI_WriteInt(HouseFile, "Products", hInfo[playerid][hProducts]);
            INI_WriteInt(HouseFile, "Products1", hInfo[playerid][hProducts1]);
            INI_WriteInt(HouseFile, "Products2", hInfo[playerid][hProducts2]);
            INI_WriteInt(HouseFile, "Products3", hInfo[playerid][hProducts3]);
            INI_WriteInt(HouseFile, "Products4", hInfo[playerid][hProducts4]);
            INI_WriteInt(HouseFile, "Products5", hInfo[playerid][hProducts5]);
            INI_WriteInt(HouseFile, "Products6", hInfo[playerid][hProducts6]);
            INI_WriteInt(HouseFile, "Products7", hInfo[playerid][hProducts7]);
            INI_WriteInt(HouseFile, "Products8", hInfo[playerid][hProducts8]);
            INI_WriteInt(HouseFile, "Products9", hInfo[playerid][hProducts9]);
            INI_WriteInt(HouseFile, "Products10", hInfo[playerid][hProducts10]);
            INI_WriteInt(HouseFile, "Products11", hInfo[playerid][hProducts11]);
        }  
    }
    return 1;
}



Re: Need help with createhouse.. - Scrillex - 20.10.2013

BTW big thanks mate

Ok thanks thats one.. but still question about loading...
pawn Code:
forward LoadHouse_data(playerid, name[], value[]);
public LoadHouse_data(playerid, name[], value[])
{
    new Name[24];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    INI_String("Owner", Name, 48);
    INI_ParseFile(HousePath(playerid), "LoadHouse_data", .bExtra = true, .extra =%d);
    INI_Float("EnterenceX", hInfo[playerid][hEnterX]);
    INI_Float("EnterenceY", hInfo[playerid][hEnterY]);
    INI_Float("EnterenceZ", hInfo[playerid][hEnterZ]);
    INI_Float("ExitX", hInfo[playerid][hExitX]);
    INI_Float("ExitY", hInfo[playerid][hExitY]);
    INI_Float("ExitZ", hInfo[playerid][hExitZ]);
    INI_Int("Interior", hInfo[playerid][hInterior]);
    INI_Int("VW", hInfo[playerid][hVW]);
    INI_Int("Cost", hInfo[playerid][hCost]);
    INI_Int("Sell", hInfo[playerid][hSell]);
    INI_String("Phone", hInfo[playerid][hPhone], 16);
    INI_Int("Garderobe", hInfo[playerid][hGarderobe]);
    INI_Int("Garderobe1", hInfo[playerid][hGarderobe1]);
    INI_Int("Storage", hInfo[playerid][hStorage]);
    INI_Int("Storage1", hInfo[playerid][hStorage1]);
    INI_Int("Storage2", hInfo[playerid][hStorage2]);
    INI_Int("Storage3", hInfo[playerid][hStorage3]);
    INI_Int("Storage4", hInfo[playerid][hStorage4]);
    INI_Int("Storage5", hInfo[playerid][hStorage5]);
    INI_Int("Storage6", hInfo[playerid][hStorage6]);
    INI_Int("Storage7", hInfo[playerid][hStorage7]);
    INI_Int("Storage8", hInfo[playerid][hStorage8]);
    INI_Int("Storage9", hInfo[playerid][hStorage9]);
    INI_Int("Storage10", hInfo[playerid][hStorage10]);
    INI_Int("Money", hInfo[playerid][hMoney]);
    INI_Int("Drugs", hInfo[playerid][hDrugs]);
    INI_Int("Drugs1", hInfo[playerid][hDrugs1]);
    INI_Int("Drugs2", hInfo[playerid][hDrugs2]);
    INI_Int("Drugs3", hInfo[playerid][hDrugs3]);
    INI_Int("Drugs4", hInfo[playerid][hDrugs4]);
    INI_Int("Drugs5", hInfo[playerid][hDrugs5]);
    INI_Int("Drugs6", hInfo[playerid][hDrugs6]);
    INI_Int("Drugs7", hInfo[playerid][hDrugs7]);
    INI_Int("Drugs8", hInfo[playerid][hDrugs8]);
    INI_Int("Drugs9", hInfo[playerid][hDrugs9]);
    INI_Int("Drugs10", hInfo[playerid][hDrugs10]);
    INI_Int("Drugs11", hInfo[playerid][hDrugs11]);
    INI_Int("Products", hInfo[playerid][hProducts]);
    INI_Int("Products1", hInfo[playerid][hProducts1]);
    INI_Int("Products2", hInfo[playerid][hProducts2]);
    INI_Int("Products3", hInfo[playerid][hProducts3]);
    INI_Int("Products4", hInfo[playerid][hProducts4]);
    INI_Int("Products5", hInfo[playerid][hProducts5]);
    INI_Int("Products6", hInfo[playerid][hProducts6]);
    INI_Int("Products7", hInfo[playerid][hProducts7]);
    INI_Int("Products8", hInfo[playerid][hProducts8]);
    INI_Int("Products9", hInfo[playerid][hProducts9]);
    INI_Int("Products10", hInfo[playerid][hProducts10]);
    INI_Int("Products11", hInfo[playerid][hProducts11]);
    return 1;
}



Re: Need help with createhouse.. - EiresJason - 20.10.2013

This is the way you need to do it. The current way you want to save and load the houses won't work if you want the houses to be numbered on the files.

I added in some comments. I completely removed 'playerid' from the enum as you wouldnt want to store them like that.

It's best to store each house as it's own enum and then just give the player a variable storing his house number.

Also, make sure you keep backups of the code
pawn Code:
forward CreateHouse(playerid, costs, sells, interior , virtualworld);
public CreateHouse(playerid, costs, sells, interior , virtualworld)
{
    for(new h = 0; h < MAX_HOUSE; h++)
    {
        if(!fexist(HousePath(h))) //loops through all houses in the file, and when the file does not exist; that's the new house id.
        {
            //new str[256];
            //format(str, sizeof(str), "%d", h);
           
            PlayerInfo[playerid][pHouseID] = h; //store the players house id to their variable. This can be used later, when locking houses, etc. For example: See if they're infront of their house.
           
            new Float:X, Float:Y, Float:Z;
            new Float:X1, Float:Y1, Float:Z1;
            GetPlayerPos(playerid, X, Y, Z);
            GetPlayerPos(playerid, X1, Y1, Z1);
            GetPlayerVirtualWorld(virtualworld);
            new INI:HouseFile = INI_Open(HousePath(h)); //make sure HousePath points to something like this: "/houses/%i.ini".
            HouseCount++;
            hInfo[h][hEnterX] = X;
            hInfo[h][hEnterY] = Y;
            hInfo[h][hEnterZ] = Z;
            hInfo[h][hExitX] = X1;
            hInfo[h][hExitY] = Y1;
            hInfo[h][hExitZ] = Z1;
            hInfo[h][hInterior] = interior;
            hInfo[h][hCost] = costs;
            hInfo[h][hSell] = sells;
            hInfo[h][hVW] = virtualworld;

            INI_WriteFloat(HouseFile, "EnterenceX", hInfo[h][hEnterX]);
            INI_WriteFloat(HouseFile, "EnterenceY", hInfo[h][hEnterY]);
            INI_WriteFloat(HouseFile, "EnterenceZ", hInfo[h][hEnterZ]);
            INI_WriteFloat(HouseFile, "ExitX", hInfo[h][hExitX]);
            INI_WriteFloat(HouseFile, "ExitY", hInfo[h][hExitY]);
            INI_WriteFloat(HouseFile, "ExitZ", hInfo[h][hExitZ]);
            INI_WriteInt(HouseFile, "Interior", hInfo[h][hInterior]);
            INI_WriteInt(HouseFile, "VW", hInfo[h][hVW]);
            INI_WriteInt(HouseFile, "Cost", hInfo[h][hCost]);
            INI_WriteInt(HouseFile, "Sell", hInfo[h][hSell]);
            INI_WriteString(HouseFile, "Phone", hInfo[h][hPhone]);
            INI_WriteInt(HouseFile, "Garderobe", hInfo[h][hGarderobe]);
            INI_WriteInt(HouseFile, "Garderobe1", hInfo[h][hGarderobe1]);
            INI_WriteInt(HouseFile, "Storage", hInfo[h][hStorage]);
            INI_WriteInt(HouseFile, "Storage1", hInfo[h][hStorage1]);
            INI_WriteInt(HouseFile, "Storage2", hInfo[h][hStorage2]);
            INI_WriteInt(HouseFile, "Storage3", hInfo[h][hStorage3]);
            INI_WriteInt(HouseFile, "Storage4", hInfo[h][hStorage4]);
            INI_WriteInt(HouseFile, "Storage5", hInfo[h][hStorage5]);
            INI_WriteInt(HouseFile, "Storage6", hInfo[h][hStorage6]);
            INI_WriteInt(HouseFile, "Storage7", hInfo[h][hStorage7]);
            INI_WriteInt(HouseFile, "Storage8", hInfo[h][hStorage8]);
            INI_WriteInt(HouseFile, "Storage9", hInfo[h][hStorage9]);
            INI_WriteInt(HouseFile, "Storage10", hInfo[h][hStorage10]);
            INI_WriteInt(HouseFile, "Money", hInfo[h][hMoney]);
            INI_WriteInt(HouseFile, "Drugs", hInfo[h][hDrugs]);
            INI_WriteInt(HouseFile, "Drugs1", hInfo[h][hDrugs1]);
            INI_WriteInt(HouseFile, "Drugs2", hInfo[h][hDrugs2]);
            INI_WriteInt(HouseFile, "Drugs3", hInfo[h][hDrugs3]);
            INI_WriteInt(HouseFile, "Drugs4", hInfo[h][hDrugs4]);
            INI_WriteInt(HouseFile, "Drugs5", hInfo[h][hDrugs5]);
            INI_WriteInt(HouseFile, "Drugs6", hInfo[h][hDrugs6]);
            INI_WriteInt(HouseFile, "Drugs7", hInfo[h][hDrugs7]);
            INI_WriteInt(HouseFile, "Drugs8", hInfo[h][hDrugs8]);
            INI_WriteInt(HouseFile, "Drugs9", hInfo[h][hDrugs9]);
            INI_WriteInt(HouseFile, "Drugs10", hInfo[h][hDrugs10]);
            INI_WriteInt(HouseFile, "Drugs11", hInfo[h][hDrugs11]);
            INI_WriteInt(HouseFile, "Products", hInfo[h][hProducts]);
            INI_WriteInt(HouseFile, "Products1", hInfo[h][hProducts1]);
            INI_WriteInt(HouseFile, "Products2", hInfo[h][hProducts2]);
            INI_WriteInt(HouseFile, "Products3", hInfo[h][hProducts3]);
            INI_WriteInt(HouseFile, "Products4", hInfo[h][hProducts4]);
            INI_WriteInt(HouseFile, "Products5", hInfo[h][hProducts5]);
            INI_WriteInt(HouseFile, "Products6", hInfo[h][hProducts6]);
            INI_WriteInt(HouseFile, "Products7", hInfo[h][hProducts7]);
            INI_WriteInt(HouseFile, "Products8", hInfo[h][hProducts8]);
            INI_WriteInt(HouseFile, "Products9", hInfo[h][hProducts9]);
            INI_WriteInt(HouseFile, "Products10", hInfo[h][hProducts10]);
            INI_WriteInt(HouseFile, "Products11", hInfo[h][hProducts11]);
        }  
    }
    return 1;
}

//looks through all the houses that exist in the folder and loads their data.
forward LoadHouses();
public LoadHouses()
{
    for(new h=0;h<MAX_HOUSES;h++)
    {
        if(fexist(HousePath(h)))
        {  
            INI_ParseFile(HousePath(h), "LoadHouseData", .bExtra = true, .extra = h);
        }  
    }
    return 1;
}

forward LoadHouseData(houseid, name[], value[]);
public LoadHouseData(houseid, name[], value[])
{
    INI_String("Owner", hInfo[houseid][hOwner], MAX_PLAYER_NAME);
    INI_Float("EnterenceX", hInfo[houseid][hEnterX]);
    INI_Float("EnterenceY", hInfo[houseid][hEnterY]);
    INI_Float("EnterenceZ", hInfo[houseid][hEnterZ]);
    INI_Float("ExitX", hInfo[houseid][hExitX]);
    INI_Float("ExitY", hInfo[houseid][hExitY]);
    INI_Float("ExitZ", hInfo[houseid][hExitZ]);
    INI_Int("Interior", hInfo[houseid][hInterior]);
    INI_Int("VW", hInfo[houseid][hVW]);
    INI_Int("Cost", hInfo[houseid][hCost]);
    INI_Int("Sell", hInfo[houseid][hSell]);
    INI_String("Phone", hInfo[houseid][hPhone], 16);
    INI_Int("Garderobe", hInfo[houseid][hGarderobe]);
    INI_Int("Garderobe1", hInfo[houseid][hGarderobe1]);
    INI_Int("Storage", hInfo[houseid][hStorage]);
    INI_Int("Storage1", hInfo[houseid][hStorage1]);
    INI_Int("Storage2", hInfo[houseid][hStorage2]);
    INI_Int("Storage3", hInfo[houseid][hStorage3]);
    INI_Int("Storage4", hInfo[houseid][hStorage4]);
    INI_Int("Storage5", hInfo[houseid][hStorage5]);
    INI_Int("Storage6", hInfo[houseid][hStorage6]);
    INI_Int("Storage7", hInfo[houseid][hStorage7]);
    INI_Int("Storage8", hInfo[houseid][hStorage8]);
    INI_Int("Storage9", hInfo[houseid][hStorage9]);
    INI_Int("Storage10", hInfo[houseid][hStorage10]);
    INI_Int("Money", hInfo[houseid][hMoney]);
    INI_Int("Drugs", hInfo[houseid][hDrugs]);
    INI_Int("Drugs1", hInfo[houseid][hDrugs1]);
    INI_Int("Drugs2", hInfo[houseid][hDrugs2]);
    INI_Int("Drugs3", hInfo[houseid][hDrugs3]);
    INI_Int("Drugs4", hInfo[houseid][hDrugs4]);
    INI_Int("Drugs5", hInfo[houseid][hDrugs5]);
    INI_Int("Drugs6", hInfo[houseid][hDrugs6]);
    INI_Int("Drugs7", hInfo[houseid][hDrugs7]);
    INI_Int("Drugs8", hInfo[houseid][hDrugs8]);
    INI_Int("Drugs9", hInfo[houseid][hDrugs9]);
    INI_Int("Drugs10", hInfo[houseid][hDrugs10]);
    INI_Int("Drugs11", hInfo[houseid][hDrugs11]);
    INI_Int("Products", hInfo[houseid][hProducts]);
    INI_Int("Products1", hInfo[houseid][hProducts1]);
    INI_Int("Products2", hInfo[houseid][hProducts2]);
    INI_Int("Products3", hInfo[houseid][hProducts3]);
    INI_Int("Products4", hInfo[houseid][hProducts4]);
    INI_Int("Products5", hInfo[houseid][hProducts5]);
    INI_Int("Products6", hInfo[houseid][hProducts6]);
    INI_Int("Products7", hInfo[houseid][hProducts7]);
    INI_Int("Products8", hInfo[houseid][hProducts8]);
    INI_Int("Products9", hInfo[houseid][hProducts9]);
    INI_Int("Products10", hInfo[houseid][hProducts10]);
    INI_Int("Products11", hInfo[houseid][hProducts11]);
    return 1;
}