create a new file + id - 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: create a new file + id (
/showthread.php?tid=287201)
create a new file + id -
Stefans94 - 02.10.2011
Hello all,
Can anyone help me with this?
So, when i got a file named 1.ini the next file needs to be called 2.ini and so on..
is there a good way to do this because this doesn't work
Код:
new i = 1;
while(fexist(HouseFile(i))) {
i++;
} else {
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
new INI:File = INI_Open(HouseFile(i));
INI_SetTag(File, "data");
INI_WriteFloat(File, "PosX", x);
INI_WriteFloat(File, "PosY", y);
INI_WriteFloat(File, "PosZ", z);
INI_WriteBool(File, "Owned", false);
INI_WriteString(File, "Owner", "");
INI_WriteInt(File, "BuyPrice", 10);
INI_WriteInt(File, "SellPrice", 9);
INI_WriteInt(File, "Slots", 2);
INI_Close(File);
}
I get this error:
Код:
error 029: invalid expression, assumed zero
on the } else { line
Thanks,
Stefan
Re: create a new file + id -
FireCat - 02.10.2011
Even tho I'm not understanding what you are trying to do, try this:
pawn Код:
new i = 1;
while(fexist(HouseFile(i))) {
i++;
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
new INI:File = INI_Open(HouseFile(i));
INI_SetTag(File, "data");
INI_WriteFloat(File, "PosX", x);
INI_WriteFloat(File, "PosY", y);
INI_WriteFloat(File, "PosZ", z);
INI_WriteBool(File, "Owned", false);
INI_WriteString(File, "Owner", "");
INI_WriteInt(File, "BuyPrice", 10);
INI_WriteInt(File, "SellPrice", 9);
INI_WriteInt(File, "Slots", 2);
INI_Close(File);
}
Re: create a new file + id -
Pharrel - 02.10.2011
r u using SII?
Re: create a new file + id -
Stefans94 - 02.10.2011
Quote:
Originally Posted by FireCat
Even tho I'm not understanding what you are trying to do, try this:
pawn Код:
new i = 1; while(fexist(HouseFile(i))) { i++; new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); new INI:File = INI_Open(HouseFile(i)); INI_SetTag(File, "data"); INI_WriteFloat(File, "PosX", x); INI_WriteFloat(File, "PosY", y); INI_WriteFloat(File, "PosZ", z); INI_WriteBool(File, "Owned", false); INI_WriteString(File, "Owner", ""); INI_WriteInt(File, "BuyPrice", 10); INI_WriteInt(File, "SellPrice", 9); INI_WriteInt(File, "Slots", 2); INI_Close(File); }
|
I'm trying to save houses,
by their id.ini
So when i create a new house, i will need a new id, so it doesn't replace another file
The script needs to check if that id is already in use, if it isn't, it has to create the file