I am so stumped with this function!
#1

I am trying to make a function, which is self explanatory when viewed, it's supposed to add a house.
Код:
forward AddHouse(playerid, houseid, interiorid, cost, Float:xx, Float:yy, Float:zz);
Код:
enum hInfo
{
	hHouseId,
	hHouseInterior,
	Float:hHousex,
	Float:hHousey,
	Float:hHousez,
	hHouseCost,
	hHouseOwnerId,
	hHouseOwnerName[16],
	hHouseLocked,
};
Код:
new HouseInfo[MAX_HOUSES][hInfo];
new HousePickup[MAX_HOUSES];
new houses;
Код:
public AddHouse(playerid, houseid, interiorid, cost, Float:xx, Float:yy, Float:zz)
{

		new string[128];
		format(string, sizeof(string), "%s.cer", houses + 1);
		new File:hFile;
		hFile = fopen(string, io_append);
		HouseInfo[houseid][hHouseCost] = cost;
		HouseInfo[houseid][hHouseInterior] = interiorid;
	 	HouseInfo[houseid][hHouseId] = houseid;
		HouseInfo[houseid][hHouseLocked] = 1;
		GetPlayerPos(playerid, xx, yy, zz);
		HouseInfo[houseid][hHousex] = xx;
		HouseInfo[houseid][hHousey] = yy;
		HouseInfo[houseid][hHousez] = zz;
		new stringowner[16];
		format(stringowner, sizeof(stringowner), "None");
		HouseInfo[houseid][hHouseOwnerName] = stringowner;
		HouseInfo[houseid][hHouseOwnerId] = 255;
		HousePickup[houseid] = CreatePickup(1273,1,xx,yy,zz);
		new var[32];//
		format(var, 32, "%s\n", HouseInfo[playerid][hHouseOwnerName]);fwrite(hFile, var);
    format(var, 32, "HouseOwnerId=%d\n", HouseInfo[playerid][hHouseOwnerId]);fwrite(hFile, var);
		format(var, 32, "HouseInterior=%d\n", HouseInfo[playerid][hHouseInterior]);fwrite(hFile, var);
    format(var, 32, "HouseId=%d\n", HouseInfo[playerid][hHouseId]);fwrite(hFile, var);
    format(var, 32, "Cost=%d\n", HouseInfo[playerid][hHouseCost]);fwrite(hFile, var);
    format(var, 32, "Locked=%d\n", HouseInfo[playerid][hHouseLocked]);fwrite(hFile, var);
    format(var, 32, "HouseX=%d\n", HouseInfo[playerid][hHousex]);fwrite(hFile, var);
    format(var, 32, "HouseY=%d\n", HouseInfo[playerid][hHousey]);fwrite(hFile, var);
    format(var, 32, "HouseZ=%d\n", HouseInfo[playerid][hHousez]);fwrite(hFile, var);
    format(var, 32, "HouseX=%d\n", HouseInfo[playerid][hHousex]);fwrite(hFile, var);
		fclose(hFile);

}
It does not write the file at all, can you help me please? I must be screwing up somewhere
Reply
#2

Does this file exist?
Reply
#3

Quote:
Originally Posted by MadeMan
Does this file exist?
nope.
Reply
#4

Maybe try this then, but not sure.

pawn Код:
hFile = fopen(string, io_write);
Reply
#5

EDITING
Reply
#6

You have

pawn Код:
hFile = fopen(string, io_append);
but I mean

pawn Код:
hFile = fopen(string, io_write);
They are not the same things.
Reply
#7

Quote:
Originally Posted by MadeMan
You have

pawn Код:
hFile = fopen(string, io_append);
but I mean

pawn Код:
hFile = fopen(string, io_write);
They are not the same things.
Sorry my bad.
Nope it didn't change anything.
Reply
#8

pawn Код:
format(string, sizeof(string), "%d.cer", houses + 1);
Made a little change here
Reply
#9

Quote:
Originally Posted by MadeMan
pawn Код:
format(string, sizeof(string), "%d.cer", houses + 1);
Made a little change here
Marry Me :O

It worked, thank you so much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)