21.09.2012, 19:19
I have a dynamic business system
but whenever i create a business and do /savebusinesss it saves it etc and adds it into the biz.cfg file, I have ongamemodeinit LoadBusiness(); but it doesnt load them?
Code:
Im pretty sure its something to do with the %d and %f stuff but im not sure
+rep to anyone who can even help!
thanks alot guys
but whenever i create a business and do /savebusinesss it saves it etc and adds it into the biz.cfg file, I have ongamemodeinit LoadBusiness(); but it doesnt load them?
Code:
Код:
LoadBusiness() {
if(!fexist("Business/biz.cfg")) return 1;
new
szFileStr[1024],
File: iFileHandle = fopen("Business/biz.cfg", io_read),
iIndex;
while(iIndex < sizeof(BizInfo) && fread(iFileHandle, szFileStr)) {
sscanf(szFileStr, "p<|>iiis[128]s[24]ffffffffiiiiiff",
%d|%d|%d|%s|%s|%f|%f|%f|%f|%f|%f|%f|%f|%d|%d|%d|%d|%d|%f|%f\r\n
BizInfo[iIndex][bOwned],
BizInfo[iIndex][bBInteriorWorld],
BizInfo[iIndex][bDescription],
BizInfo[iIndex][bOwner],
BizInfo[iIndex][bExteriorX],
BizInfo[iIndex][bExteriorY],
BizInfo[iIndex][bExteriorZ],
BizInfo[iIndex][bExteriorR],
BizInfo[iIndex][bInteriorX],
BizInfo[iIndex][bInteriorY],
BizInfo[iIndex][bInteriorZ],
BizInfo[iIndex][bInteriorR],
BizInfo[iIndex][bLock],
BizInfo[iIndex][bValue],
BizInfo[iIndex][bSafeMoney],
BizInfo[iIndex][bPickupID],
BizInfo[iIndex][bExteriorA],
BizInfo[iIndex][bInteriorA]
);
new lockedinfo[20];
if(BizInfo[iIndex][bLock] == 0)
{ lockedinfo = "Open"; }
if(BizInfo[iIndex][bLock] == 1)
{ lockedinfo = "Closed"; }
else { lockedinfo = "Open"; }
new biztype[20];
if(BizInfo[iIndex][b247] == 1)
{ biztype = "24/7 Store"; }
if(BizInfo[iIndex][bGunshop] == 1)
{ biztype = "Gun Store"; }
if(BizInfo[iIndex][bClotheshop] == 1)
{ biztype = "Clothing Store"; }
else { biztype = "Open"; }
if(BizInfo[iIndex][bOwned]) {
if(BizInfo[iIndex][bRentable] == 0) format(szFileStr, sizeof(szFileStr), "Business: %s\n\nOwner: %s\nStatus: %s\n\n{FFFFFF}ID: %d",biztype, BizInfo[iIndex][bOwner],lockedinfo, iIndex);
}
else format(szFileStr, sizeof(szFileStr), "{E8A831}This Business is for sale!\n\n{FFFFFF}Cost: $%d\n{FFFFFF}ID: %d\n\nTo buy this business type /buybiz",BizInfo[iIndex][bValue], iIndex);
BizInfo[iIndex][bPickupID] = CreateDynamicPickup(1239, 23, BizInfo[iIndex][bExteriorX], BizInfo[iIndex][bExteriorY], BizInfo[iIndex][bExteriorZ]);
BizInfo[iIndex][bTextID] = CreateDynamic3DTextLabel(szFileStr, COLOR_GREEN, BizInfo[iIndex][bExteriorX], BizInfo[iIndex][bExteriorY], BizInfo[iIndex][bExteriorZ]+0.5,30.0, .testlos = 1, .streamdistance = 30.0);
++iIndex;
}
return fclose(iFileHandle);
}
Код:
SaveBusiness() {
new
szFileStr[1024],
File: fHandle = fopen("Business/biz.cfg", io_write);
for(new iIndex; iIndex < MAX_BUSINESS; iIndex++) {
format(szFileStr, sizeof(szFileStr), "%d|%d|%d|%s|%s|%f|%f|%f|%f|%f|%f|%f|%f|%d|%d|%d|%d|%d|%f|%f\r\n",
BizInfo[iIndex][bOwned],
BizInfo[iIndex][bBInteriorWorld],
BizInfo[iIndex][bDescription],
BizInfo[iIndex][bOwner],
BizInfo[iIndex][bExteriorX],
BizInfo[iIndex][bExteriorY],
BizInfo[iIndex][bExteriorZ],
BizInfo[iIndex][bExteriorR],
BizInfo[iIndex][bInteriorX],
BizInfo[iIndex][bInteriorY],
BizInfo[iIndex][bInteriorZ],
BizInfo[iIndex][bInteriorR],
BizInfo[iIndex][bLock],
BizInfo[iIndex][b247],
BizInfo[iIndex][bGunshop],
BizInfo[iIndex][bClotheshop],
BizInfo[iIndex][bValue],
BizInfo[iIndex][bSafeMoney],
BizInfo[iIndex][bPickupID],
BizInfo[iIndex][bExteriorA],
BizInfo[iIndex][bInteriorA]
);
fwrite(fHandle, szFileStr);
}
return fclose(fHandle);
}
+rep to anyone who can even help!
thanks alot guys

