01.08.2013, 00:36
This is my code I use for loading houses. It should load the house because there is all needed information in the scriptfiles, but i don't why it wont :/
pawn Код:
stock LoadHouses(houseid)
{
new fstring[10],file[40],string[256]; //The string for the file [format]
format(fstring, 10, "Houses/%d.ini", houseid); //Format the filename
if(!fexist(fstring)) return 0; //"If Houses/{houseid} not exists then return False (0)"
INI_ParseFile(file, "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);
}
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);
}
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);
return 1;
}
public OnGameModeInit()
{
for(new i = 0; i < MAX_HOUSES; i++)
{
LoadHouses(i);
}
return 1;
}