Sziasztok!
Van nekem egy biznisz rendszerem de nem menti el a boltokat amiket veszek
Itt van a mentés és a betöltés:
stock LoadBiz()
{
if(!fexist(\"businesses.cfg\")) fcreate(\"businesses.cfg\");
new binfo[12][32];
new string[256];
new File:file = fopen(\"businesses.cfg\", io_read);
if(file)
{
new idx = 1;
while(idx < MAX_BIZ)
{
fread(file, string);
split(string, binfo, \'|\');
BizInfo[idx][bType] = strval(binfo[0]);
BizInfo[idx][bStatus] = strval(binfo[1]);
format(BizInfo[idx][bOwner], 32, \"%s\", binfo[2]);
BizInfo[idx][blX] = floatstr(binfo[3]);
BizInfo[idx][blY] = floatstr(binfo[4]);
BizInfo[idx][blZ] = floatstr(binfo[5]);
BizInfo[idx][bMoney] = strval(binfo[6]);
BizInfo[idx][bProducts] = strval(binfo[7]);
BizInfo[idx][bSold] = strval(binfo[8]);
BizInfo[idx][bLevel] = strval(binfo[9]);
BizInfo[idx][bPrice] = strval(binfo[10]);
BizInfo[idx][bAP] = strval(binfo[11]);
if(BizInfo[idx][bType]) // If Business is owned
{
BizInfo[idx][bPickup] = CreateDynamicPickup(1272, 1, BizInfo[idx][blX], BizInfo[idx][blY], BizInfo[idx][blZ], 0);
if(!strcmp(\"The State\", BizInfo[idx][bOwner])) format(string, sizeof(string), \"[iD: %d]\\nTípus: %s\\nTulajdonos: %s\\nStátusz: Eladó\\nÁr: $%d\", idx, RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice]);
//else format(string, sizeof(string), \"ID: %d\\n%s\\nOwner: %s\\nStatus: %s\", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
else format(string, sizeof(string), \"[iD: %d]\\nTípus: %s\\nTulajdonos: %s\\nStátusz: %s\", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
BizInfo[idx][bText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, BizInfo[idx][blX], BizInfo[idx][blY], BizInfo[idx][blZ]+0.3, 15);
}
idx++;
}
}
print(\"Businesses loaded successfully.\");
return 1;
}
stock SaveBiz()
{
if(!fexist(\"bizniszek.cfg\")) fcreate(\"bizniszek.cfg\");
new idx = 1, File:file;
new string[256];
while(idx < MAX_BIZ)
{
format(string, sizeof(string), \"%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%d\\r\\n\", BizInfo[idx][bType], BizInfo[idx][bStatus], BizInfo[idx][bOwner], BizInfo[idx][blX], BizInfo[idx][blY], BizInfo[idx][blZ], BizInfo[idx][bMoney], BizInfo[idx][bProducts], BizInfo[idx][bSold], BizInfo[idx][bLevel], BizInfo[idx][bPrice], BizInfo[idx][bAP]);
if(idx == 1)
{
file = fopen(\"bizniszek.cfg\", io_write);
}
else
{
file = fopen(\"bizniszek.cfg\", io_append);
}
fwrite(file, string);
fclose(file);
idx++;
}
print(\"A bizniszek sikeresen elmentve!\");
}