Saving ,but not loading
#1

Hello guys.

Why this code doesn't work?

PHP код:
#define BusinessFile "/Bizniai%i.ini"
#define BusinessTimeFile "Bizniai/Laikai.ini"
BusinessTime_Load()
{
    new 
File:BFileLineFromFile[100], ParameterName[50], ParameterValue[50];
    if (
fexist(BusinessTimeFile))
    {
        
BFile fopen(BusinessTimeFileio_read); // Open the businesstime-file for reading
        
fread(BFileLineFromFile); // Read the first line of the file
        
while (strlen(LineFromFile) > 0)
        {
            
StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
            
sscanf(LineFromFile"s[50]s[50]"ParameterNameParameterValue); // Extract parametername and parametervalue
            
if (strcmp(ParameterName"BusinessTime"false) == 0// If the parametername is correct ("BusinessTime")
                
BusinessTransactionTime strval(ParameterValue); // Store the BusinessTime
            
fread(BFileLineFromFile);
        }
        
fclose(BFile);
        return 
1;
    }
    else return 
0// Return 0 if the file couldn't be read (doesn't exist)
}
BusinessTime_Save()
{
    new 
File:BFileLineForFile[100];
    
BFile fopen(BusinessTimeFileio_write); // Open the businesstime-file for writing
    
format(LineForFile100"BusinessTime %i\r\n"BusinessTransactionTime); // Construct the line: "BusinessTime <BusinessTransactionTime>"
    
fwrite(BFileLineForFile); // And save it to the file
    
fclose(BFile); // Close the file
    
return 1;
}
BusinessFile_Load(BusID)
{
    new 
file[100], File:BFileLineFromFile[100], ParameterName[50], ParameterValue[50];
    
format(filesizeof(file), BusinessFileBusID);
    if (
fexist(file))
    {
        
BFile fopen(fileio_read);
        
fread(BFileLineFromFile);
        while (
strlen(LineFromFile) > 0)
        {
            
StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
            
sscanf(LineFromFile"s[50]s[50]"ParameterNameParameterValue); // Extract parametername and parametervalue
            
if (strlen(LineFromFile) > 0)
            {
                if (
strcmp(ParameterName"BusinessName"false) == 0// If the parametername is correct ("BusinessName")
                    
format(ABusinessData[BusID][BusinessName], 24ParameterValue); // Store the BusinessName
                
if (strcmp(ParameterName"BusinessX"false) == 0// If the parametername is correct ("BusinessX")
                    
ABusinessData[BusID][BusinessX] = floatstr(ParameterValue); // Store the BusinessX
                
if (strcmp(ParameterName"BusinessY"false) == 0// If the parametername is correct ("BusinessY")
                    
ABusinessData[BusID][BusinessY] = floatstr(ParameterValue); // Store the BusinessY
                
if (strcmp(ParameterName"BusinessZ"false) == 0// If the parametername is correct ("BusinessZ")
                    
ABusinessData[BusID][BusinessZ] = floatstr(ParameterValue); // Store the BusinessZ
                
if (strcmp(ParameterName"BusinessType"false) == 0// If the parametername is correct ("BusinessType")
                    
ABusinessData[BusID][BusinessType] = strval(ParameterValue); // Store the BusinessType
                
if (strcmp(ParameterName"BusinessLevel"false) == 0// If the parametername is correct ("BusinessLevel")
                    
ABusinessData[BusID][BusinessLevel] = strval(ParameterValue); // Store the BusinessLevel
                
if (strcmp(ParameterName"LastTransaction"false) == 0// If the parametername is correct ("LastTransaction")
                    
ABusinessData[BusID][LastTransaction] = strval(ParameterValue); // Store the LastTransaction
                
if (strcmp(ParameterName"Owned"false) == 0// If the parametername is correct ("Owned")
                
{
                    if (
strcmp(ParameterValue"Yes"false) == 0// If the value "Yes" was read
                        
ABusinessData[BusID][Owned] = true// House is owned
                    
else
                        
ABusinessData[BusID][Owned] = false// House is not owned
                
}
                if (
strcmp(ParameterName"Owner"false) == 0// If the parametername is correct ("Owner")
                    
format(ABusinessData[BusID][Owner], 24ParameterValue);
            }
            
fread(BFileLineFromFile);
        }
        
fclose(BFile);
        
Business_CreateEntrance(BusID);
        
TotalBusiness++;
        return 
1;
    }
    else return 
0// Return 0 if the file couldn't be read (doesn't exist)

Reply
#2

Bump?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)