18.04.2014, 12:13
Hello guys.
Why this code doesn't work?
Why this code doesn't work?
PHP код:
#define BusinessFile "/Bizniai%i.ini"
#define BusinessTimeFile "Bizniai/Laikai.ini"
BusinessTime_Load()
{
new File:BFile, LineFromFile[100], ParameterName[50], ParameterValue[50];
if (fexist(BusinessTimeFile))
{
BFile = fopen(BusinessTimeFile, io_read); // Open the businesstime-file for reading
fread(BFile, LineFromFile); // 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]", ParameterName, ParameterValue); // Extract parametername and parametervalue
if (strcmp(ParameterName, "BusinessTime", false) == 0) // If the parametername is correct ("BusinessTime")
BusinessTransactionTime = strval(ParameterValue); // Store the BusinessTime
fread(BFile, LineFromFile);
}
fclose(BFile);
return 1;
}
else return 0; // Return 0 if the file couldn't be read (doesn't exist)
}
BusinessTime_Save()
{
new File:BFile, LineForFile[100];
BFile = fopen(BusinessTimeFile, io_write); // Open the businesstime-file for writing
format(LineForFile, 100, "BusinessTime %i\r\n", BusinessTransactionTime); // Construct the line: "BusinessTime <BusinessTransactionTime>"
fwrite(BFile, LineForFile); // And save it to the file
fclose(BFile); // Close the file
return 1;
}
BusinessFile_Load(BusID)
{
new file[100], File:BFile, LineFromFile[100], ParameterName[50], ParameterValue[50];
format(file, sizeof(file), BusinessFile, BusID);
if (fexist(file))
{
BFile = fopen(file, io_read);
fread(BFile, LineFromFile);
while (strlen(LineFromFile) > 0)
{
StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
sscanf(LineFromFile, "s[50]s[50]", ParameterName, ParameterValue); // Extract parametername and parametervalue
if (strlen(LineFromFile) > 0)
{
if (strcmp(ParameterName, "BusinessName", false) == 0) // If the parametername is correct ("BusinessName")
format(ABusinessData[BusID][BusinessName], 24, ParameterValue); // 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], 24, ParameterValue);
}
fread(BFile, LineFromFile);
}
fclose(BFile);
Business_CreateEntrance(BusID);
TotalBusiness++;
return 1;
}
else return 0; // Return 0 if the file couldn't be read (doesn't exist)
}