House system loading
#1

Alright so I've recently been making a house system for my server, very basic and not finished as I've only made /acreatehouse and /adeletehouse.

Works fine, both commands, however the houses don't load when I restart my server. I mean the 3DText and Pickups won't appear. Here is the stock which loads the houses:
Код:
stock LoadHouses()
{
	for(new i = 0; i < MAX_HOUSES;i++)
	{
	    new labelstring[128];
	    switch(HouseInfo[i][hOwned])
	    {
	        case 0: // for sale
	        {
                HousePickup[i] = CreatePickup(1273,1,HouseInfo[i][hOutsideX],HouseInfo[i][hOutsideY],HouseInfo[i][hOutsideZ],0);
	    		format(labelstring,128,"%i %s is currently for sale! \nPurchase it for $%i",i,HouseInfo[i][hLocation],HouseInfo[i][hPrice]);
				HouseLabel[i] = Create3DTextLabel(labelstring,0x32CD32FF,HouseInfo[i][hOutsideX],HouseInfo[i][hOutsideY],HouseInfo[i][hOutsideZ] + 0.7,10,0,0);
			}
			case 1: // owned by player
			{
			    // later
			}
	    }
	}
	return 1;
}
I'm not using case 1 yet because I haven't made the /buyhouse command so players can't own houses yet. It all saves in HouseInfo[houseid].. etc. Here is the enum:

Код:
enum hInfo
{
	hOwner[24],
	hOwned,
	hPrice,
	Float:hOutsideX,
	Float:hOutsideY,
	Float:hOutsideZ,
	Float:hInsideX,
	Float:hInsideY,
	Float:hInsideZ,
	hInterior,
	hVirtualWorld,
	hLocation[24]
}
new HouseInfo[MAX_HOUSES][hInfo];
When I restart my server the house pickup/text just won't appear, it all saves in scriptfiles fine though, just wont load.

Here are both of the commands (createhouse & deletehouse):

Код:
CMD:acreatehouse(playerid,params[])
{
	if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid,-1,"{AA3333}ERROR:{FFFFFF} Only administrators may use this command.");
	{
	    new houseid, Float:outsidex, Float:outsidey, Float:outsidez, Float:insidex, Float:insidey, Float:insidez, price, interior, virtualworld, location[24], string[128], string2[128];
	    if(sscanf(params,"ifffiiis[24]",houseid,insidex,insidey,insidez,price,interior,virtualworld,location)) return SendClientMessage(playerid,-1,"{AA3333}USAGE:{FFFFFF} /acreatehouse (houseid) (insideX) (insideY) (insideZ) (price) (interior) (virtualworld) (location)");
		if(houseid > MAX_HOUSES) return SendClientMessage(playerid,-1,"{AA3333}ERROR:{FFFFFF} House ID is out of range.");
		GetPlayerPos(playerid,outsidex,outsidey,outsidez);
	    {
	        new INI:File = INI_Open(HousePath(houseid));
            INI_SetTag(File,"data");
            INI_WriteString(File,"Owner","None");
            INI_WriteInt(File,"Owned",0);
            INI_WriteInt(File,"Price",0);
            INI_WriteFloat(File,"OutsideX",0);
            INI_WriteFloat(File,"OutsideY",0);
            INI_WriteFloat(File,"OutsideZ",0);
            INI_WriteFloat(File,"InsideX",0);
            INI_WriteFloat(File,"InsideY",0);
            INI_WriteFloat(File,"InsideZ",0);
            INI_WriteInt(File,"Interior",0);
            INI_WriteInt(File,"VirtualWorld",0);
            INI_WriteString(File,"Location","None");
            INI_Close(File);
	    }
	    HousePickup[houseid] = CreatePickup(1273,1,outsidex,outsidey,outsidez,0);
	    format(string,128,"%i %s is currently for sale! \nPurchase it for $%i",houseid,location,price);
		HouseLabel[houseid] = Create3DTextLabel(string,0x32CD32FF,outsidex,outsidey,outsidez + 0.7,10,0,0);
		HouseInfo[houseid][hOutsideX] = outsidex;
		HouseInfo[houseid][hOutsideY] = outsidey;
		HouseInfo[houseid][hOutsideZ] = outsidez;
		HouseInfo[houseid][hInsideX] = insidex;
		HouseInfo[houseid][hInsideY] = insidey;
		HouseInfo[houseid][hInsideZ] = insidez;
		HouseInfo[houseid][hPrice] = price;
		HouseInfo[houseid][hOwned] = 0;
		HouseInfo[houseid][hInterior] = interior;
		HouseInfo[houseid][hVirtualWorld] = virtualworld;
		HouseInfo[houseid][hLocation] = location;
		HouseLocked[houseid] = 1;
		{
      		new INI:File = INI_Open(HousePath(houseid));
			INI_SetTag(File,"data");
    		INI_WriteString(File,"Owner",HouseInfo[houseid][hOwner]);
    		INI_WriteInt(File,"Owned",HouseInfo[houseid][hOwned]);
    		INI_WriteInt(File,"Price",HouseInfo[houseid][hPrice]);
    		INI_WriteFloat(File,"OutsideX",HouseInfo[houseid][hOutsideX]);
    		INI_WriteFloat(File,"OutsideY",HouseInfo[houseid][hOutsideY]);
    		INI_WriteFloat(File,"OutsideZ",HouseInfo[houseid][hOutsideZ]);
    		INI_WriteFloat(File,"InsideX",HouseInfo[houseid][hInsideX]);
    		INI_WriteFloat(File,"InsideY",HouseInfo[houseid][hInsideY]);
    		INI_WriteFloat(File,"InsideZ",HouseInfo[houseid][hInsideZ]);
    		INI_WriteInt(File,"Interior",HouseInfo[houseid][hInterior]);
    		INI_WriteInt(File,"VirtualWorld",HouseInfo[houseid][hVirtualWorld]);
    		INI_WriteString(File,"Location",HouseInfo[houseid][hLocation]);
    		INI_Close(File);
		}
		format(string2,128,"{AA3333}AdminCMD:{FFFFFF} You have created %i %s.",houseid,location);
		SendClientMessage(playerid,-1,string2);
	}
	return 1;
}
Код:
CMD:adeletehouse(playerid,params[])
{
	if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid,-1,"{AA3333}ERROR:{FFFFFF} Only administrators may use this command.");
	{
	    new houseid, string[128];
	    if(sscanf(params,"i",houseid)) return SendClientMessage(playerid,-1,"{AA3333}USAGE:{FFFFFF} /adeletehouse (houseid)");
	    Delete3DTextLabel(HouseLabel[houseid]);
	    DestroyPickup(HousePickup[houseid]);
	    format(string,sizeof(string),HPATH,houseid);
	    fremove(string);
	}
	return 1;
}
If anything else is necessary I'll put it, but please help, this is so annoying.
Reply
#2

Did you actually load houses at OnGameModeInit?
Reply
#3

Yes.
Reply
#4

pawn Код:
new str[64];
for(new i = 0; i < MAX_HOUSES;i++)
{
    format(str,sizeof(str), HousePath, i);
    INI_ParseFile(str, "LoadHouses_%s", .bExtra = true, .extra = i );
}
This is proper way to load it at yini.

And this is how you shoud define load data....

pawn Код:
forward LoadHouses_data(i, name[], value[]);
public LoadHouses_data(i, name[], value[])
{
    yourhousedata...
    return true;
}
Reply
#5

Fixed, thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)