Businesses gets created automatically crashes in BB
#1

So basically when i create a business then lots of them gets created in the .cfg with the coords of 0,0,0,0,0

This is the screen shot of the .cfg
http://gyazo.com/847bffb43f627c9f739fecfbae592997


How can i stop that? because when people go in the middle of BB they crash and i noticed that coords is for BB farm
Reply
#2

Show code for creating business
Reply
#3

PHP код:
CMD:bedit(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < && PlayerInfo[playerid][pShopTech] < 1)
    {
        
SendClientMessageEx(playeridCOLOR_GRAD2"You are not authorized to use that command!");
        return 
1;
    }
    new 
string[128], choice[32], houseidamount;
    if(
sscanf(params"s[32]dD"choicehouseidamount))
    {
        
SendClientMessageEx(playeridCOLOR_WHITE"USAGE: /bedit [name] [business id] [(Optional)amount]");
        
SendClientMessageEx(playeridCOLOR_GREY"Available names: Exterior, Interior, CustomInterior, Type (1-3) (Leisure, Consumer, Retail), Level, Price, Delete");
        return 
1;
    }
    
    if(
strcmp(choice"delete"true) == 0)
    {
        
ClearBusiness(houseid);
        
format(stringsizeof(string), "%s has removed Business ID %d"GetPlayerNameEx(playerid), houseid);
        
Log("logs/bedit.log"string);
        
SaveBusinesses();
    }
    else if(
strcmp(choice"interior"true) == 0)
    {
        
GetPlayerPos(playeridBizInfo[houseid][bInteriorX], BizInfo[houseid][bInteriorY], BizInfo[houseid][bInteriorZ]);
        
GetPlayerFacingAngle(playeridBizInfo[houseid][bInteriorA]);
        
BizInfo[houseid][bHInteriorWorld] = GetPlayerInteriorplayerid );
        
SendClientMessageExplayeridCOLOR_WHITE"You have changed the interior!" );
        
SaveBusinesses();
        
format(stringsizeof(string), "%s has edited Business ID %d's Interior."GetPlayerNameEx(playerid), houseid);
        
Log("logs/bedit.log"string);
        return 
1;
    }
    else if(
strcmp(choice"custominterior"true) == 0)
    {
        if(
BizInfo[houseid][bCustomInterior] == 0)
        {
            
BizInfo[houseid][bCustomInterior] = 1;
            
SendClientMessageExplayeridCOLOR_WHITE"House set to custom interior!" );
        }
        else
        {
            
BizInfo[houseid][bCustomInterior] = 0;
            
SendClientMessageExplayeridCOLOR_WHITE"House set to normal (not custom) interior!" );
        }
        
SaveBusinesses();
        
format(stringsizeof(string), "%s has edited Business ID %d's Custom Interior."GetPlayerNameEx(playerid), houseid);
        
Log("logs/bedit.log"string);
        return 
1;
    }
    else if(
strcmp(choice"customexterior"true) == 0)
    {
        if(
BizInfo[houseid][bCustomExterior] == 0)
        {
            
BizInfo[houseid][bCustomExterior] = 1;
            
SendClientMessageExplayeridCOLOR_WHITE"House set to custom exterior!" );
        }
        else
        {
            
BizInfo[houseid][bCustomExterior] = 0;
            
SendClientMessageExplayeridCOLOR_WHITE"House set to normal (not custom) exterior!" );
        }
        
SaveBusinesses();
        
format(stringsizeof(string), "%s has edited Business ID %d's Custom Exterior."GetPlayerNameEx(playerid), houseid);
        
Log("logs/bedit.log"string);
        return 
1;
    }
    else if(
strcmp(choice"exterior"true) == 0)
    {
        
GetPlayerPos(playeridBizInfo[houseid][bExteriorX], BizInfo[houseid][bExteriorY], BizInfo[houseid][bExteriorZ]);
        
GetPlayerFacingAngle(playeridBizInfo[houseid][bExteriorA]);
        
SendClientMessageExplayeridCOLOR_WHITE"You have changed the exterior!" );
        
DestroyDynamicPickup(BizInfo[houseid][bPickupID]);
        
SaveBusinesses();
        
format(stringsizeof(string), "%s has edited Business ID %d's Exterior."GetPlayerNameEx(playerid), houseid);
        
Log("logs/bedit.log"string);
        if(
BizInfo[houseid][bOwned] ==0)
        {
            
DestroyDynamicPickup(BizInfo[houseid][bPickupID]);
            
DestroyDynamic3DTextLabel(BizInfo[houseid][bTextID]);
            
format(stringsizeof(string), "This business is\n for sale!\nDescription: %s\nCost: $%d\n Level: %d\nType: %d\nID: %d\nTo buy this business type /buybusiness",BizInfo[houseid][bDescription],BizInfo[houseid][bValue],BizInfo[houseid][bLevel],BizInfo[houseid][bType],houseid);
            
BizInfo[houseid][bTextID] = CreateDynamic3DTextLabelstringCOLOR_LIGHTBLUEBizInfo[houseid][bExteriorX], BizInfo[houseid][bExteriorY], BizInfo[houseid][bExteriorZ]+0.5,30.0, .testlos 1, .streamdistance 30.0);
            
BizInfo[houseid][bPickupID] = CreateDynamicPickup(127423BizInfo[houseid][bExteriorX], BizInfo[houseid][bExteriorY], BizInfo[houseid][bExteriorZ]);
        }
        else
        {
            
DestroyDynamicPickup(BizInfo[houseid][bPickupID]);
            
DestroyDynamic3DTextLabel(BizInfo[houseid][bTextID]);
            
format(stringsizeof(string), "This business is owned by\n%s\nDescription: %s\nLevel: %d\nType: %d\nID: %d",BizInfo[houseid][bOwner],BizInfo[houseid][bDescription],BizInfo[houseid][bLevel],BizInfo[houseid][bType],houseid);
            
BizInfo[houseid][bTextID] = CreateDynamic3DTextLabel(string,COLOR_LIGHTBLUE,BizInfo[houseid][bExteriorX], BizInfo[houseid][bExteriorY], BizInfo[houseid][bExteriorZ]+0.5,30.0, .testlos 1, .streamdistance 30.0);
            
BizInfo[houseid][bPickupID] = CreateDynamicPickup(127423BizInfo[houseid][bExteriorX], BizInfo[houseid][bExteriorY], BizInfo[houseid][bExteriorZ]);
        }
        
SaveBusinesses();
    }
    else if(
strcmp(choice"level"true) == 0)
    {
        
BizInfo[houseid][bLevel] = amount;
        
format(stringsizeof(string), "You have set the business level to %d."amount);
        
SendClientMessageEx(playeridCOLOR_WHITEstring);
        if(
BizInfo[houseid][bOwned] ==0)
        {
            
format(stringsizeof(string), "This business is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\nType: %d\nID: %d\nTo buy this business type /buybusiness",BizInfo[houseid][bDescription],BizInfo[houseid][bValue],BizInfo[houseid][bLevel],BizInfo[houseid][bType],houseid);
            
UpdateDynamic3DTextLabelText(BizInfo[houseid][bTextID], COLOR_LIGHTBLUEstring);
        }
        else
        {
            
format(stringsizeof(string), "This business is owned by\n%s\nDescription: %s\nLevel: %d\nType: %d\nID: %d",BizInfo[houseid][bOwner],BizInfo[houseid][bDescription],BizInfo[houseid][bLevel],BizInfo[houseid][bType],houseid);
            
UpdateDynamic3DTextLabelText(BizInfo[houseid][bTextID], COLOR_LIGHTBLUEstring);
        }
        
format(stringsizeof(string), "%s has edited Business ID %d's Level to %d."GetPlayerNameEx(playerid), houseidamount);
        
Log("logs/bedit.log"string);
        
SaveBusinesses();
    }
    else if(
strcmp(choice"price"true) == 0)
    {
        
BizInfo[houseid][bValue] = amount;
        
format(stringsizeof(string), "You have set the businesses price to $%d."amount );
        
SendClientMessageEx(playeridCOLOR_WHITEstring);
        if(
BizInfo[houseid][bOwned] ==0)
        {
            
format(stringsizeof(string), "This business is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\nType: %d\nID: %d\nTo buy this business type /buybusiness",BizInfo[houseid][bDescription],BizInfo[houseid][bValue],BizInfo[houseid][bLevel],BizInfo[houseid][bType],houseid);
            
UpdateDynamic3DTextLabelText(BizInfo[houseid][bTextID], COLOR_LIGHTBLUEstring);
        }
        
format(stringsizeof(string), "%s has edited Business ID %d's Price to $%d."GetPlayerNameEx(playerid), amount);
        
Log("logs/bedit.log"string);
        
SaveBusinesses();
    }
    else if(
strcmp(choice"type"true) == 0)
    {
        switch(
amount)
        {
        case 
1:
            {
                
BizInfo[houseid][bType] = 1;
                
SendClientMessageEx(playeridCOLOR_WHITE"You have set the businesses type to 1 (Leisure)" );
            }
        case 
2:
            {
                
BizInfo[houseid][bType] = 2;
                
SendClientMessageEx(playeridCOLOR_WHITE"You have set the businesses type to 2 (Consumer)" );
            }
        case 
3:
            {
                
BizInfo[houseid][bType] = 3;
                
SendClientMessageEx(playeridCOLOR_WHITE"You have set the businesses type to 3 (Retail)" );
            }
        }
        if(
BizInfo[houseid][bOwned] ==0)
        {
            
format(stringsizeof(string), "This business is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\nType: %d\nID: %d\nTo buy this business type /buybusiness",BizInfo[houseid][bDescription],BizInfo[houseid][bValue],BizInfo[houseid][bLevel],BizInfo[houseid][bType],houseid);
            
UpdateDynamic3DTextLabelText(BizInfo[houseid][bTextID], COLOR_LIGHTBLUEstring);
        }
        
format(stringsizeof(string), "%s has edited Business ID %d's Type to %d."GetPlayerNameEx(playerid), houseidamount);
        
Log("logs/bedit.log"string);
        
SaveBusinesses();
    }
    
SaveBusinesses();
    return 
1;

Reply
#4

PHP код:
SaveBusinesses() {
    new
        
szFileStr[1024],
        
FilefHandle fopen("businesses.cfg"io_write);
    for(new 
iIndexiIndex MAX_BUSINESSiIndex++) {
        
format(szFileStrsizeof(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][bLevel],
            
BizInfo[iIndex][bHInteriorWorld],
            
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][bValue],
            
BizInfo[iIndex][bType],
            
BizInfo[iIndex][bPickupID],
            
BizInfo[iIndex][bCustomInterior],
            
BizInfo[iIndex][bCustomExterior],
            
BizInfo[iIndex][bExteriorA],
            
BizInfo[iIndex][bInteriorA]
        );
        
fwrite(fHandleszFileStr);
    }
    return 
fclose(fHandle);

Reply
#5

PHP код:
LoadBusinesses() {
    if(!
fexist("businesses.cfg")) return 1;
    new
        
szFileStr[1024],
        
FileiFileHandle fopen("businesses.cfg"io_read),
        
iIndex;
    while(
iIndex sizeof(BizInfo) && fread(iFileHandleszFileStr)) {
        
sscanf(szFileStr"p<|>iiis[128]s[24]ffffffffiiiiiff",
            
BizInfo[iIndex][bOwned],
            
BizInfo[iIndex][bLevel],
            
BizInfo[iIndex][bHInteriorWorld],
            
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][bValue],
            
BizInfo[iIndex][bType],
            
BizInfo[iIndex][bPickupID],
            
BizInfo[iIndex][bCustomInterior],
            
BizInfo[iIndex][bCustomExterior],
            
BizInfo[iIndex][bExteriorA],
            
BizInfo[iIndex][bInteriorA]
        );
        if(
BizInfo[iIndex][bOwned]) {
            
format(szFileStrsizeof(szFileStr), "This business is owned by\n%s\nDescription: %s\nLevel: %d\nType: %d\nID: %d",BizInfo[iIndex][bOwner],BizInfo[iIndex][bDescription],BizInfo[iIndex][bLevel],BizInfo[iIndex][bType],iIndex);
            
DestroyDynamicPickup(BizInfo[iIndex][bPickupID]);
            
BizInfo[iIndex][bPickupID] = CreateDynamicPickup(1913223BizInfo[iIndex][bExteriorX], BizInfo[iIndex][bExteriorY], BizInfo[iIndex][bExteriorZ]);
        }
        else 
format(szFileStrsizeof(szFileStr), "This business is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\nType: %d\nID: %d\nTo buy this business type /buybusiness",BizInfo[iIndex][bDescription],BizInfo[iIndex][bValue],BizInfo[iIndex][bLevel],BizInfo[iIndex][bType],iIndex);
        
DestroyDynamicPickup(BizInfo[iIndex][bPickupID]);
        
BizInfo[iIndex][bPickupID] = CreateDynamicPickup(1913223BizInfo[iIndex][bExteriorX], BizInfo[iIndex][bExteriorY], BizInfo[iIndex][bExteriorZ]);
        
BizInfo[iIndex][bTextID] = CreateDynamic3DTextLabel(szFileStrCOLOR_LIGHTBLUEBizInfo[iIndex][bExteriorX], BizInfo[iIndex][bExteriorY], BizInfo[iIndex][bExteriorZ]+0.5,30.0, .testlos 1, .streamdistance 30.0);
        ++
iIndex;
    }
    return 
fclose(iFileHandle);

Reply
#6

The bug is in SaveBusinesses, In SaveBusinesses you are saving all business id from 0 to MAX_BUSINESS, you are not checking whether the business at the index exists or not..
So to correct we need to see if at a specific index business exists or not, to see this we will take a variable from business enum that would not be 0 if business exists. So we will take variable "value" business value can not be 0.
So use the following code for SaveBusinesses -
pawn Код:
SaveBusinesses() {

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

    for(new iIndex; iIndex < MAX_BUSINESS; iIndex++) {
        if(BizInfo[iIndex][bValue] < 1)continue;//just add this line and you are done
        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][bLevel],
            BizInfo[iIndex][bHInteriorWorld],
            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][bValue],
            BizInfo[iIndex][bType],
            BizInfo[iIndex][bPickupID],
            BizInfo[iIndex][bCustomInterior],
            BizInfo[iIndex][bCustomExterior],
            BizInfo[iIndex][bExteriorA],
            BizInfo[iIndex][bInteriorA]
        );
        fwrite(fHandle, szFileStr);
    }
    return fclose(fHandle);
}
Don't forget to delete that cfg file before running the script as it contains faulty entries already.
Reply
#7

after putting that code now they do not save
Reply
#8

reply asap please thanks
Reply
#9

Any can tell me why aint it saving anymore? after putting the code??
Reply
#10

Just change to
pawn Код:
if(!BizInfo[iIndex][bExteriorX]) continue;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)