Savebiz help - 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: Savebiz help (
/showthread.php?tid=527047)
Savebiz help -
jeffery30162 - 20.07.2014
I am creating a biz system and when the businesses save, the last biz on the list copies itsself and it gets saved multiple times.
this is what the saved business look like:
its always the last on on the list that gets copied.
Код:
6|3|The State|810.887084|-1616.286499|13.546875|0|0|1|200000|0|Store41|205|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
5|3|The State|1631.909057|-1172.373046|24.084280|0|0|1|200000|0|Tax|150|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
20|3|The State|2442.482666|-2126.444580|14.164052|0|0|1|200000|0|TruckingBoss|113|50|50|50|50|50|50|1|2478.854492|-2111.114013|13.546895|91.180900
2|3|The State|1457.316284|-1137.367553|23.962814|0|0|1|200000|0|Clothes4|211|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
20|3|The State|2281.120117|-2365.066894|13.546875|0|0|1|200000|0|TowingBoss|120|50|50|50|50|50|50|2|2283.864501|-2352.406982|13.417593|226.547897
20|3|The State|1555.311889|-1675.596435|16.195312|0|0|1|200000|0|PoliceBoss|281|50|50|50|50|50|50|3|1537.270263|-1658.388916|5.612500|181.568099
4|3|The State|1022.479064|-1121.656005|23.871921|0|0|1|200000|0|Club|64|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
0|3|The State|1022.479064|-1121.656005|23.871921|0|0|1|200000|0|Club|64|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
0|3|The State|1022.479064|-1121.656005|23.871921|0|0|1|200000|0|Club|64|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
0|3|The State|1022.479064|-1121.656005|23.871921|0|0|1|200000|0|Club|64|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
0|3|The State|1022.479064|-1121.656005|23.871921|0|0|1|200000|0|Club|64|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
0|3|The State|1022.479064|-1121.656005|23.871921|0|0|1|200000|0|Club|64|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
0|3|The State|1022.479064|-1121.656005|23.871921|0|0|1|200000|0|Club|64|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
0|3|The State|1022.479064|-1121.656005|23.871921|0|0|1|200000|0|Club|64|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
0|3|The State|1022.479064|-1121.656005|23.871921|0|0|1|200000|0|Club|64|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
0|3|The State|1022.479064|-1121.656005|23.871921|0|0|1|200000|0|Club|64|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
0|3|The State|1022.479064|-1121.656005|23.871921|0|0|1|200000|0|Club|64|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
0|3|The State|1022.479064|-1121.656005|23.871921|0|0|1|200000|0|Club|64|50|50|50|50|50|50|0|0.000000|0.000000|0.000000|0.000000
Savebiz function:
Код:
stock SaveBiz()
{
if(!fexist("biz.cfg")) fcreate("biz.cfg");
new idx = 1, File:file;
new string[500];
new string1[500];
new string2[500];
while(idx < MAX_BIZ)
{
format(string, sizeof(string), "%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%s|%d|%d|%d|%d|%d|%d|%d", BizInfo[idx][bType], BizInfo[idx][bStatus], BizInfo[idx][bOwner], BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], BizInfo[idx][bMoney], BizInfo[idx][bSold], BizInfo[idx][bLevel], BizInfo[idx][bPrice], BizInfo[idx][bAP], BizInfo[idx][bNpc], BizInfo[idx][bNpcS], BizInfo[idx][b1Am], BizInfo[idx][b2Am], BizInfo[idx][b3Am], BizInfo[idx][b4Am], BizInfo[idx][b5Am]);
format(string1, sizeof(string1), "%d|%d|%f|%f|%f|%f\r\n", BizInfo[idx][b6Am], BizInfo[idx][bOfficeType], BizInfo[idx][bActionX], BizInfo[idx][bActionY], BizInfo[idx][bActionZ], BizInfo[idx][bActionAngle]);
format(string2, sizeof(string2), "%s%s", string, string1);
if(idx == 1)
{
file = fopen("biz.cfg", io_write);
}
else
{
file = fopen("biz.cfg", io_append);
}
fwrite(file, string2);
fclose(file);
idx++;
}
print("Businesses saved successfully.");
}
please help me
Re: Savebiz help -
Metharon - 20.07.2014
pawn Код:
stock SaveBiz()
{
if(!fexist("biz.cfg")) fcreate("biz.cfg");
new idx = 1, File:file;
new string[500];
new string1[500];
new string2[500];
while(idx < MAX_BIZ)
{
format(string, sizeof(string), "%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%s|%d|%d|%d|%d|%d|%d|%d", BizInfo[idx][bType], BizInfo[idx][bStatus], BizInfo[idx][bOwner], BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], BizInfo[idx][bMoney], BizInfo[idx][bSold], BizInfo[idx][bLevel], BizInfo[idx][bPrice], BizInfo[idx][bAP], BizInfo[idx][bNpc], BizInfo[idx][bNpcS], BizInfo[idx][b1Am], BizInfo[idx][b2Am], BizInfo[idx][b3Am], BizInfo[idx][b4Am], BizInfo[idx][b5Am]);
format(string1, sizeof(string1), "%d|%d|%f|%f|%f|%f\r\n", BizInfo[idx][b6Am], BizInfo[idx][bOfficeType], BizInfo[idx][bActionX], BizInfo[idx][bActionY], BizInfo[idx][bActionZ], BizInfo[idx][bActionAngle]);
format(string2, sizeof(string2), "%s%s\n", string, string1);
if(idx == 1)
{
file = fopen("biz.cfg", io_write);
}
else
{
file = fopen("biz.cfg", io_append);
}
fwrite(file, string2);
fclose(file);
idx++;
}
print("Businesses saved successfully.");
}
Re: Savebiz help -
jeffery30162 - 20.07.2014
It still does the same thing
Re: Savebiz help -
jeffery30162 - 20.07.2014
I still need help
Re: Savebiz help -
Scottas - 20.07.2014
You have to check is bussiness is created
Re: Savebiz help -
jeffery30162 - 20.07.2014
i dont understand, i have other systems that use the same function and they do not have this problem
Re: Savebiz help -
Scottas - 21.07.2014
Can you show full code? Post it at pastebin