Load Houses
#3

Still doesn't load it. Here's my full house code:
pawn Код:
#define MAX_HOUSES 200
new HouseMapIcon[MAX_HOUSES],Text3D:HouseLabel[MAX_PLAYERS];
enum hInfo
{
    Float:hEnterX, //Entrance X. It's an float! example: 0.0000000. I'm gonna use the same with the other entrances/exits
    Float:hEnterY,
    Float:hEnterZ,
    hInsideInt, //The inside interior.. DUH!
    hInsideVir, //Already subscribed above
    hOutsideInt,
    hOutsideVir,
    bool:hOwned, //boolean! Is house owned? NO = False, YES = True
    hOwner[MAX_PLAYER_NAME], //The house owner! I'm gonna use MAX_PLAYER_NAME, because a player can't have a longer name :')
    hPrice, //Will store the price
    hLevel,
    hPickup, //The pickup. This is used to remove/move the pickup icon!
    hIcon, //The map icon. Also used to remove/move it! We are going to need an ID. Without an ID we can't do NOTHING!
    hVecModel, //The housecar's model
    Float:hVecX, //X location. En float too.
    Float:hVecY,
    Float:hVecZ,
    Float:hVecA
};
new HouseInfo[MAX_HOUSES][hInfo];
new House[MAX_HOUSES];
new HouseCar[MAX_HOUSES];

stock LoadHouses(houseid)
{
    new fstring[128],string[256]; //The string for the file [format]
    format(fstring, 128, "Houses/%d.ini", houseid); //Format the filename
    if(!fexist(fstring)) return 0; //"If Houses/{houseid} not exists then return False (0)"
    print("Stage 1: COMPLETE");
    INI_ParseFile(fstring, "LoadHouseData_%s", .bExtra = true, .extra = houseid);
    HouseMapIcon[houseid] = CreateDynamicMapIcon(HouseInfo[houseid][hEnterX],HouseInfo[houseid][hEnterY],HouseInfo[houseid][hEnterZ],31,-1,-1,-1,-1,100.0);
    House[houseid] = CreateDynamicPickup(1272, 1, HouseInfo[houseid][hEnterX],HouseInfo[houseid][hEnterY],HouseInfo[houseid][hEnterZ]-0.5, -1, -1, -1, 50.0); //line 1458
    if(HouseInfo[houseid][hOwned] == false){
    format(string,sizeof(string),"{00FF00}Buy this house using /buyhouse\nHouse Price = %i\nHouse Level = %i\nHouse ID: %d",HouseInfo[houseid][hPrice],HouseInfo[houseid][hLevel],houseid);
    HouseLabel[houseid] = CreateDynamic3DTextLabel(string, 0xFFFFFFFFFF, HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ]+0.3,50.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0,-1,-1,-1,100.0);
    print("Stage 2: COMPLETE");
    }
    else{
    format(string,sizeof(string),"{00FF00}House Owner = %d\nHouse Level = %i\nHouse ID: %d",HouseInfo[houseid][hOwner],HouseInfo[houseid][hLevel],houseid);
    HouseLabel[houseid] = CreateDynamic3DTextLabel(string, 0xFFFFFFFFFF, HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ]+0.3,50.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0,-1,-1,-1,100.0);
    print("Stage 2: COMPLETE");
    }
    return 1;
}
forward LoadHouseData_Main(houseid, name[], value[]);
public LoadHouseData_Main(houseid, name[], value[])
{
    INI_Float("EnterX", HouseInfo[houseid][hEnterX]);
    INI_Float("EnterY", HouseInfo[houseid][hEnterY]);
    INI_Float("EnterZ", HouseInfo[houseid][hEnterY]);
    INI_Int("InsideInt", HouseInfo[houseid][hInsideInt]);
    INI_Int("InsideVir", HouseInfo[houseid][hInsideVir]);
    INI_Int("OutsideInt", HouseInfo[houseid][hOutsideInt]);
    INI_Int("OutsideVir", HouseInfo[houseid][hOutsideVir]);
    INI_Int("Price", HouseInfo[houseid][hPrice]);
    INI_Int("HV_Model", HouseInfo[houseid][hVecModel]);
    INI_Float("HV_PosX", HouseInfo[houseid][hVecX]);
    INI_Float("HV_PosY", HouseInfo[houseid][hVecY]);
    INI_Float("HV_PosZ", HouseInfo[houseid][hVecZ]);
    INI_Float("HV_PosA", HouseInfo[houseid][hVecA]);
    INI_Bool("Owned", HouseInfo[houseid][hOwned]);
    INI_String("Owner",HouseInfo[houseid][hOwner],40);
    print("Stage 3: COMPLETE");
    return 1;
}

public OnGameModeInit()
{
    for(new i = 0; i < MAX_HOUSES; i++)
    {
    LoadHouses(i);
    }
        return 1;
}

stock GetNextHouseID()
{
    for(new i = 0; i < MAX_HOUSES; i++)
    {
        if(fexist(HousePath(i))) continue;
        return i;
    }
    return -1;
}

CMD:createhouse(playerid,params[])
{
    if(PlayerInfo[playerid][pLevel] < 3) return error
    new price,level;
    if(sscanf(params,"ii",price,level)) return SendClientMessage(playerid, COLOR_RED,"USAGE: /createhouse <price> <level>");
    if(level < 1 || level > 10) return SendClientMessage(playerid, COLOR_RED,"Minimum house level: 1\nMaximum house level: 10");
    if(price < 100000) return SendClientMessage(playerid, COLOR_RED,"Too cheap! Please choose a higher value!");
    new Float:x,Float:y,Float:z,string[128],nextid = GetNextHouseID();
    GetPlayerPos(playerid,x,y,z); //line 1447
    new file[64];
    format(file, sizeof(file), HousePath(nextid));
    new INI:File2 = INI_Open(file);
    INI_SetTag(File2, "Main");
    INI_WriteFloat(File2, "EnterX", x); //line 1981
    INI_WriteFloat(File2, "EnterY", y);
    INI_WriteFloat(File2, "EnterZ", z);
    INI_WriteInt(File2, "InsideInt", HouseInfo[nextid][hInsideInt]);
    INI_WriteInt(File2, "InsideVir", HouseInfo[nextid][hInsideVir]);
    INI_WriteInt(File2, "OutsideInt", HouseInfo[nextid][hOutsideInt]);
    INI_WriteInt(File2, "OutsideVir", HouseInfo[nextid][hOutsideVir]);
    INI_WriteInt(File2, "Price", price);
    INI_WriteInt(File2, "Level", level);
    INI_WriteInt(File2, "HV_Model", HouseInfo[nextid][hVecModel]);
    INI_WriteFloat(File2, "HV_PosX", HouseInfo[nextid][hVecX]);
    INI_WriteFloat(File2, "HV_PosY", HouseInfo[nextid][hVecY]);
    INI_WriteFloat(File2, "HV_PosZ", HouseInfo[nextid][hVecZ]);
    INI_WriteFloat(File2, "HV_PosA", HouseInfo[nextid][hVecA]);
    INI_WriteBool(File2, "Owned", false);
    INI_WriteString(File2, "Owner",HouseInfo[nextid][hOwner]);
    INI_Close(File2);
    HouseInfo[nextid][hEnterX] = x;
    HouseInfo[nextid][hEnterY] = y;
    HouseInfo[nextid][hEnterZ] = z;
    HouseInfo[nextid][hPrice] = price;
    HouseInfo[nextid][hLevel] = level;
    HouseMapIcon[nextid] = CreateDynamicMapIcon(HouseInfo[nextid][hEnterX],HouseInfo[nextid][hEnterY],HouseInfo[nextid][hEnterZ],31,-1,-1,-1,-1,100.0);
    House[nextid] = CreateDynamicPickup(1272, 1, x, y, z-0.5, -1, -1, -1, 50.0); //line 1458
    format(string,sizeof(string),"{00FF00}Buy this house using /buyhouse\nHouse Price = %i\nHouse Level = %i\nHouse ID: %d",HouseInfo[nextid][hPrice],HouseInfo[nextid][hLevel],nextid);
    HouseLabel[nextid] = CreateDynamic3DTextLabel(string, 0xFFFFFFFFFF, HouseInfo[nextid][hEnterX], HouseInfo[nextid][hEnterY], HouseInfo[nextid][hEnterZ]+0.3,50.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0,-1,-1,-1,100.0);
    SendClientMessage(playerid, COLOR_LIMEGREEN,"House successfully created!");
    return 1;
 }

stock HousePath(houseid)
{
    new string[64];
    format(string,sizeof(string),"/Houses/%d.ini", houseid);
    return string;
}
Reply


Messages In This Thread
Load Houses - by wumpyc - 01.08.2013, 00:36
Re: Load Houses - by ReVo_ - 01.08.2013, 00:39
Re: Load Houses - by wumpyc - 01.08.2013, 00:48
Re: Load Houses - by ReVo_ - 01.08.2013, 00:58
Re: Load Houses - by wumpyc - 01.08.2013, 01:49
Re: Load Houses - by Threshold - 01.08.2013, 06:49
Re: Load Houses - by wumpyc - 01.08.2013, 08:27
Re: Load Houses - by wumpyc - 02.08.2013, 03:37
Re: Load Houses - by wumpyc - 03.08.2013, 05:28
Re: Load Houses - by Ayumi - 03.08.2013, 12:39

Forum Jump:


Users browsing this thread: 3 Guest(s)