Business Saving System
#1

Hey!!!I`m working on a business system non mysql and I`m trying to fix the save and load of business but with no succes.The businesses doesn`t load in game....and in businesses.cfg everything is set on 0.Please help me.
Code:
SaveBusiness() {

	new
	szFileStr[1024],
	File: fHandle = fopen("business.cfg", io_write);

	for(new iIndex; iIndex < MAX_BUSINESSES; iIndex++) {
		format(szFileStr, sizeof(szFileStr), "%s|%s|%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%f|%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|%i|%f|%i|%i|%i|%i|%i|%i|%i|%f|%f|%f|%f|%f|%f|%i|%f|%f|%i|%i|%i\r\n",
                BusinessInfo[iIndex][bName],//String
                BusinessInfo[iIndex][bOwnerName],//String
		BusinessInfo[iIndex][bOwner],//Int
		BusinessInfo[iIndex][bValue],//Int
		BusinessInfo[iIndex][bType],//Int
		BusinessInfo[iIndex][bLevel],//Int
		BusinessInfo[iIndex][bLevelProgress],//Int
		BusinessInfo[iIndex][bAutoSale],//Int
		BusinessInfo[iIndex][bSafeBalance],//Int
		BusinessInfo[iIndex][bInventory],//Int
		BusinessInfo[iIndex][bInventoryCapacity],//Int
		BusinessInfo[iIndex][bStatus],//Int
		BusinessInfo[iIndex][bRankPay],//Int
		BusinessInfo[iIndex][bExtPosX],//Float
		BusinessInfo[iIndex][bExtPosY],//Float
		BusinessInfo[iIndex][bExtPosZ],//Float
		BusinessInfo[iIndex][bExtPosR],//Float
		BusinessInfo[iIndex][bIntPosX],//Float
		BusinessInfo[iIndex][bIntPosY],//Float
		BusinessInfo[iIndex][bIntPosZ],//Float
		BusinessInfo[iIndex][bIntPosR],//Float
		BusinessInfo[iIndex][bSupplyPosX],//Float
		BusinessInfo[iIndex][bSupplyPosY],//Float
		BusinessInfo[iIndex][bSupplyPosZ],//Float
		BusinessInfo[iIndex][bInt],//Int
		BusinessInfo[iIndex][bVW],//Int
		BusinessInfo[iIndex][bMinInviteRank],//Int
		BusinessInfo[iIndex][bMinGiveRankRank],//Int
		BusinessInfo[iIndex][bMinSupplyRank],//Int
		BusinessInfo[iIndex][bMinSafeRank],//Int
		BusinessInfo[iIndex][bMinInventoryRank],//Int
		BusinessInfo[iIndex][bMinStatusRank],//Int
		BusinessInfo[iIndex][bMinDoorRank],//Int
		BusinessInfo[iIndex][bGunsOffered],//Int
		BusinessInfo[iIndex][bSkinsOffered],//Int
		BusinessInfo[iIndex][bToysOffered],//Int
		BusinessInfo[iIndex][bItemPrices],//Int
		BusinessInfo[iIndex][bTotalSales],//Int
		BusinessInfo[iIndex][bTotalProfits],//Int
		BusinessInfo[iIndex][bPickup],//Int
		BusinessInfo[iIndex][bAutoPay],//Int
		BusinessInfo[iIndex][bGasPrice], //Float
		BusinessInfo[iIndex][bStrictPrice],//Int
		BusinessInfo[iIndex][bOrderState],//Int
		BusinessInfo[iIndex][bOrderAmount],//Int
		BusinessInfo[iIndex][bOrderDate],//Int
		BusinessInfo[iIndex][bCustomExterior],//Int
		BusinessInfo[iIndex][bCustomInterior],//Int
		BusinessInfo[iIndex][bGrade],//Int
		BusinessInfo[iIndex][GasPumpPosX],//Float
		BusinessInfo[iIndex][GasPumpPosY],//Float
		BusinessInfo[iIndex][GasPumpPosZ],//Float
		BusinessInfo[iIndex][GasPumpAngle],//Float
		BusinessInfo[iIndex][GasPumpCapacity],//Float
		BusinessInfo[iIndex][GasPumpGallons],//Float
		BusinessInfo[iIndex][GasPumpObjectID],//Int
		BusinessInfo[iIndex][GasPumpSaleGallons],//Float
		BusinessInfo[iIndex][GasPumpSalePrice],//Float
		BusinessInfo[iIndex][GasPumpTimer],//Int
		BusinessInfo[iIndex][GasPumpVehicleID],//Int
		BusinessInfo[iIndex][bMonths]//Int
		);
		fwrite(fHandle, szFileStr);
	}
	return fclose(fHandle);
}
Code:
LoadBusiness() {

	if(!fexist("businesses.cfg")) return 1;

	new
	szFileStr[1024],
	File: iFileHandle = fopen("businesses.cfg", io_read),
	iIndex;

	while(iIndex < sizeof(BusinessInfo) && fread(iFileHandle, szFileStr)) {
		sscanf(szFileStr, "p<|>s[128]s[24]iiiiiiiiiiifffffffffffiiiiiiiiiiiiiiiiifiiiiiiiffffffiffiii",
                BusinessInfo[iIndex][bName],//String
                BusinessInfo[iIndex][bOwnerName],//String
		BusinessInfo[iIndex][bOwner],//Int
		BusinessInfo[iIndex][bValue],//Int
		BusinessInfo[iIndex][bType],//Int
		BusinessInfo[iIndex][bLevel],//Int
		BusinessInfo[iIndex][bLevelProgress],//Int
		BusinessInfo[iIndex][bAutoSale],//Int
		BusinessInfo[iIndex][bSafeBalance],//Int
		BusinessInfo[iIndex][bInventory],//Int
		BusinessInfo[iIndex][bInventoryCapacity],//Int
		BusinessInfo[iIndex][bStatus],//Int
		BusinessInfo[iIndex][bRankPay],//Int
		BusinessInfo[iIndex][bExtPosX],//Float
		BusinessInfo[iIndex][bExtPosY],//Float
		BusinessInfo[iIndex][bExtPosZ],//Float
		BusinessInfo[iIndex][bExtPosR],//Float
		BusinessInfo[iIndex][bIntPosX],//Float
		BusinessInfo[iIndex][bIntPosY],//Float
		BusinessInfo[iIndex][bIntPosZ],//Float
		BusinessInfo[iIndex][bIntPosR],//Float
		BusinessInfo[iIndex][bSupplyPosX],//Float
		BusinessInfo[iIndex][bSupplyPosY],//Float
		BusinessInfo[iIndex][bSupplyPosZ],//Float
		BusinessInfo[iIndex][bInt],//Int
		BusinessInfo[iIndex][bVW],//Int
		BusinessInfo[iIndex][bMinInviteRank],//Int
		BusinessInfo[iIndex][bMinGiveRankRank],//Int
		BusinessInfo[iIndex][bMinSupplyRank],//Int
		BusinessInfo[iIndex][bMinSafeRank],//Int
		BusinessInfo[iIndex][bMinInventoryRank],//Int
		BusinessInfo[iIndex][bMinStatusRank],//Int
		BusinessInfo[iIndex][bMinDoorRank],//Int
		BusinessInfo[iIndex][bGunsOffered],//Int
		BusinessInfo[iIndex][bSkinsOffered],//Int
		BusinessInfo[iIndex][bToysOffered],//Int
		BusinessInfo[iIndex][bItemPrices],//Int
		BusinessInfo[iIndex][bTotalSales],//Int
		BusinessInfo[iIndex][bTotalProfits],//Int
		BusinessInfo[iIndex][bPickup],//Int
		BusinessInfo[iIndex][bAutoPay],//Int
		BusinessInfo[iIndex][bGasPrice], //Float
		BusinessInfo[iIndex][bStrictPrice],//Int
		BusinessInfo[iIndex][bOrderState],//Int
		BusinessInfo[iIndex][bOrderAmount],//Int
		BusinessInfo[iIndex][bOrderDate],//Int
		BusinessInfo[iIndex][bCustomExterior],//Int
		BusinessInfo[iIndex][bCustomInterior],//Int
		BusinessInfo[iIndex][bGrade],//Int
		BusinessInfo[iIndex][GasPumpPosX],//Float
		BusinessInfo[iIndex][GasPumpPosY],//Float
		BusinessInfo[iIndex][GasPumpPosZ],//Float
		BusinessInfo[iIndex][GasPumpAngle],//Float
		BusinessInfo[iIndex][GasPumpCapacity],//Float
		BusinessInfo[iIndex][GasPumpGallons],//Float
		BusinessInfo[iIndex][GasPumpObjectID],//Int
		BusinessInfo[iIndex][GasPumpSaleGallons],//Float
		BusinessInfo[iIndex][GasPumpSalePrice],//Float
		BusinessInfo[iIndex][GasPumpTimer],//Int
		BusinessInfo[iIndex][GasPumpVehicleID],//Int
		BusinessInfo[iIndex][bMonths]//Int
		);
		
		if (!(BusinessInfo[iIndex][bExtPosX] == 0.0 && BusinessInfo[iIndex][bExtPosY] == 0.0 &&                                 BusinessInfo[iIndex][bExtPosZ] == 0.0)) { 
    	        new string[128];
		BusinessInfo[iIndex][bPickup] = CreateDynamicPickup(GetBusinessDefaultPickup(iIndex), 23, BusinessInfo[iIndex][bExtPosX], BusinessInfo[iIndex][bExtPosY], BusinessInfo[iIndex][bExtPosZ]);
                 if (BusinessInfo[iIndex][bOwner] < 1) {
			format(string,sizeof(string),"%s\n\nBusiness For Sale!\nCost: %s\nTo buy this business type /buybiz\nID: %d", GetBusinessTypeName(BusinessInfo[iIndex][bType]), number_format(BusinessInfo[iIndex][bValue]), iIndex);
		}
		else {
		    if(BusinessInfo[iIndex][bType] != BUSINESS_TYPE_GYM) {
				format(string,sizeof(string),"%s\n\n%s [Owner: %s]\nID: %d", GetBusinessTypeName(BusinessInfo[iIndex][bType]), BusinessInfo[iIndex][bName], StripUnderscore(BusinessInfo[iIndex][bOwnerName]), iIndex);
			}
			else {
			    format(string,sizeof(string),"%s\n\n%s [Owner: %s]\nID: %d\nGym Entrance: $%s", GetBusinessTypeName(BusinessInfo[iIndex][bType]), BusinessInfo[iIndex][bName], StripUnderscore(BusinessInfo[iIndex][bOwnerName]), iIndex, number_format(BusinessInfo[iIndex][bGymEntryFee]));
			}
		}
		BusinessInfo[iIndex][bDoorText] =	CreateDynamic3DTextLabel(string, BUSINESS_NAME_COLOR, BusinessInfo[iIndex][bExtPosX], BusinessInfo[iIndex][bExtPosY], BusinessInfo[iIndex][bExtPosZ] + 0.85, 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1);
		BusinessInfo[iIndex][bStateText] =	CreateDynamic3DTextLabel((BusinessInfo[iIndex][bStatus]) ? ("Open") : ("Closed"), (BusinessInfo[iIndex][bStatus]) ? BUSINESS_OPEN_COLOR : BUSINESS_CLOSED_COLOR, BusinessInfo[iIndex][bExtPosX], BusinessInfo[iIndex][bExtPosY], BusinessInfo[iIndex][bExtPosZ] + 1.05, 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1);
		format(string,sizeof(string),"%s\nSupply Delivery Point", BusinessInfo[iIndex][bName]);
		BusinessInfo[iIndex][bSupplyText] = CreateDynamic3DTextLabel(string, BUSINESS_NAME_COLOR, BusinessInfo[iIndex][bSupplyPosX], BusinessInfo[iIndex][bSupplyPosY], BusinessInfo[iIndex][bSupplyPosZ], 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1);
	    }
	}
	return fclose(iFileHandle);
}
Reply
#2

Its saving correctly but wont load correctly ?
Reply
#3

This is how businesses.cfg looks like when is created and even when I create a business it will stay like that...

Code:
||0|0|0|0|0|0|0|0|0|0|0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.000000|0|0|0|0|0|0|0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0.000000|0.000000|0|0|0
||0|0|0|0|0|0|0|0|0|0|0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.000000|0|0|0|0|0|0|0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0.000000|0.000000|0|0|0
||0|0|0|0|0|0|0|0|0|0|0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.000000|0|0|0|0|0|0|0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0.000000|0.000000|0|0|0
||0|0|0|0|0|0|0|0|0|0|0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.000000|0|0|0|0|0|0|0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0.000000|0.000000|0|0|0
Reply
#4

Problem is you need make Float variables to make them work with positions also try add Float:BussinessX to bussiness enum and what why its not working
Reply
#5

I have
Code:
enum eBiz {
	Float: bExtPosX,
	Float: bExtPosY,
	Float: bExtPosZ,
	Float: bExtPosR,
	Float: bIntPosX,
	Float: bIntPosY,
	Float: bIntPosZ,
	Float: bIntPosR,
	Float: bSupplyPosX,
	Float: bSupplyPosY,
	Float: bSupplyPosZ,
Reply
#6

sscanf(szFileStr, "p<|>s[128]s[24]iiiiiiiiiiifffffffffffiiiiiiiiiiiiiiiiifiiiiiiifff fffiffiii", but correct wayscanf(szFileStr, "p<|>s[128]s[24]iiiiiiiiiiidddddddddddiiiiiiiiiiiiiiiiiiiiiiiiffff ffiffiii", because floats not intreger.
Reply
#7

Still not working....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)