#1

Why when i create server and restart the server bizs got removed

and i have this

PHP код:
stock CheckFiles()
{
    if(!
dini_Exists("businesses.cfg")) dini_Create("businesses.cfg");
    return 
1;
}
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(filestring);
            
split(stringbinfo'|');
            
BizInfo[idx][bType] = strval(binfo[0]);
            
BizInfo[idx][bStatus] = strval(binfo[1]);
            
format(BizInfo[idx][bOwner], 32"%s"binfo[2]);
            
BizInfo[idx][bX] = floatstr(binfo[3]);
            
BizInfo[idx][bY] = floatstr(binfo[4]);
            
BizInfo[idx][bZ] = 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(12721BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], 0);
                if(!
strcmp("The State"BizInfo[idx][bOwner])) format(stringsizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d"idxRBT(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(stringsizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: %s"idxRBT(idx), BizInfo[idx][bOwner], RBS(idx));
                
BizInfo[idx][bText] = CreateDynamic3DTextLabel(stringCOLOR_WHITEBizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]+0.315);
            }
            
idx++;
        }
    }
    print(
"Businesses loaded successfully.");
    return 
1;
}
stock SaveBiz()
{
    if(!
fexist("businesses.cfg")) fcreate("businesses.cfg");
    new 
idx 1File:file;
    new 
string[256];
    while(
idx MAX_BIZ)
    {
        
format(stringsizeof(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][bX], BizInfo[idx][bY], BizInfo[idx][bZ], BizInfo[idx][bMoney], BizInfo[idx][bProducts], BizInfo[idx][bSold], BizInfo[idx][bLevel], BizInfo[idx][bPrice], BizInfo[idx][bAP]);
        if(
idx == 1)
        {
            
file fopen("businesses.cfg"io_write);
        }
        else
        {
            
file fopen("businesses.cfg"io_append);
        }
        
fwrite(filestring);
        
fclose(file);
        
idx++;
    }
    print(
"Businesses saved successfully.");

+REP if you help me fix it
Reply
#2

Are they saving to the .cfg file?
When you restart, does the file stay the same and just not loading?
Possible Solution;
If your businesses are staying in the file, just not loading do add the following
pawn Код:
OnGameModeInit()
{
    LoadBiz() ;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)