Businesses gets created automatically crashes in BB -
Samieastwood - 01.02.2015
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
Re: Businesses gets created automatically crashes in BB -
BroZeus - 01.02.2015
Show code for creating business
Re: Businesses gets created automatically crashes in BB -
Samieastwood - 01.02.2015
PHP код:
CMD:bedit(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pShopTech] < 1)
{
SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command!");
return 1;
}
new string[128], choice[32], houseid, amount;
if(sscanf(params, "s[32]dD", choice, houseid, amount))
{
SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /bedit [name] [business id] [(Optional)amount]");
SendClientMessageEx(playerid, COLOR_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(string, sizeof(string), "%s has removed Business ID %d", GetPlayerNameEx(playerid), houseid);
Log("logs/bedit.log", string);
SaveBusinesses();
}
else if(strcmp(choice, "interior", true) == 0)
{
GetPlayerPos(playerid, BizInfo[houseid][bInteriorX], BizInfo[houseid][bInteriorY], BizInfo[houseid][bInteriorZ]);
GetPlayerFacingAngle(playerid, BizInfo[houseid][bInteriorA]);
BizInfo[houseid][bHInteriorWorld] = GetPlayerInterior( playerid );
SendClientMessageEx( playerid, COLOR_WHITE, "You have changed the interior!" );
SaveBusinesses();
format(string, sizeof(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;
SendClientMessageEx( playerid, COLOR_WHITE, "House set to custom interior!" );
}
else
{
BizInfo[houseid][bCustomInterior] = 0;
SendClientMessageEx( playerid, COLOR_WHITE, "House set to normal (not custom) interior!" );
}
SaveBusinesses();
format(string, sizeof(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;
SendClientMessageEx( playerid, COLOR_WHITE, "House set to custom exterior!" );
}
else
{
BizInfo[houseid][bCustomExterior] = 0;
SendClientMessageEx( playerid, COLOR_WHITE, "House set to normal (not custom) exterior!" );
}
SaveBusinesses();
format(string, sizeof(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(playerid, BizInfo[houseid][bExteriorX], BizInfo[houseid][bExteriorY], BizInfo[houseid][bExteriorZ]);
GetPlayerFacingAngle(playerid, BizInfo[houseid][bExteriorA]);
SendClientMessageEx( playerid, COLOR_WHITE, "You have changed the exterior!" );
DestroyDynamicPickup(BizInfo[houseid][bPickupID]);
SaveBusinesses();
format(string, sizeof(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(string, sizeof(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] = 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(1274, 23, BizInfo[houseid][bExteriorX], BizInfo[houseid][bExteriorY], BizInfo[houseid][bExteriorZ]);
}
else
{
DestroyDynamicPickup(BizInfo[houseid][bPickupID]);
DestroyDynamic3DTextLabel(BizInfo[houseid][bTextID]);
format(string, sizeof(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(1274, 23, BizInfo[houseid][bExteriorX], BizInfo[houseid][bExteriorY], BizInfo[houseid][bExteriorZ]);
}
SaveBusinesses();
}
else if(strcmp(choice, "level", true) == 0)
{
BizInfo[houseid][bLevel] = amount;
format(string, sizeof(string), "You have set the business level to %d.", amount);
SendClientMessageEx(playerid, COLOR_WHITE, string);
if(BizInfo[houseid][bOwned] ==0)
{
format(string, sizeof(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_LIGHTBLUE, string);
}
else
{
format(string, sizeof(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_LIGHTBLUE, string);
}
format(string, sizeof(string), "%s has edited Business ID %d's Level to %d.", GetPlayerNameEx(playerid), houseid, amount);
Log("logs/bedit.log", string);
SaveBusinesses();
}
else if(strcmp(choice, "price", true) == 0)
{
BizInfo[houseid][bValue] = amount;
format(string, sizeof(string), "You have set the businesses price to $%d.", amount );
SendClientMessageEx(playerid, COLOR_WHITE, string);
if(BizInfo[houseid][bOwned] ==0)
{
format(string, sizeof(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_LIGHTBLUE, string);
}
format(string, sizeof(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(playerid, COLOR_WHITE, "You have set the businesses type to 1 (Leisure)" );
}
case 2:
{
BizInfo[houseid][bType] = 2;
SendClientMessageEx(playerid, COLOR_WHITE, "You have set the businesses type to 2 (Consumer)" );
}
case 3:
{
BizInfo[houseid][bType] = 3;
SendClientMessageEx(playerid, COLOR_WHITE, "You have set the businesses type to 3 (Retail)" );
}
}
if(BizInfo[houseid][bOwned] ==0)
{
format(string, sizeof(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_LIGHTBLUE, string);
}
format(string, sizeof(string), "%s has edited Business ID %d's Type to %d.", GetPlayerNameEx(playerid), houseid, amount);
Log("logs/bedit.log", string);
SaveBusinesses();
}
SaveBusinesses();
return 1;
}
Re: Businesses gets created automatically crashes in BB -
Samieastwood - 01.02.2015
PHP код:
SaveBusinesses() {
new
szFileStr[1024],
File: fHandle = fopen("businesses.cfg", io_write);
for(new iIndex; iIndex < MAX_BUSINESS; iIndex++) {
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);
}
Re: Businesses gets created automatically crashes in BB -
Samieastwood - 01.02.2015
PHP код:
LoadBusinesses() {
if(!fexist("businesses.cfg")) return 1;
new
szFileStr[1024],
File: iFileHandle = fopen("businesses.cfg", io_read),
iIndex;
while(iIndex < sizeof(BizInfo) && fread(iFileHandle, szFileStr)) {
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(szFileStr, sizeof(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(19132, 23, BizInfo[iIndex][bExteriorX], BizInfo[iIndex][bExteriorY], BizInfo[iIndex][bExteriorZ]);
}
else format(szFileStr, sizeof(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(19132, 23, BizInfo[iIndex][bExteriorX], BizInfo[iIndex][bExteriorY], BizInfo[iIndex][bExteriorZ]);
BizInfo[iIndex][bTextID] = CreateDynamic3DTextLabel(szFileStr, COLOR_LIGHTBLUE, BizInfo[iIndex][bExteriorX], BizInfo[iIndex][bExteriorY], BizInfo[iIndex][bExteriorZ]+0.5,30.0, .testlos = 1, .streamdistance = 30.0);
++iIndex;
}
return fclose(iFileHandle);
}
Re: Businesses gets created automatically crashes in BB -
BroZeus - 01.02.2015
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.
Re: Businesses gets created automatically crashes in BB -
Samieastwood - 01.02.2015
after putting that code now they do not save
Re: Businesses gets created automatically crashes in BB -
Samieastwood - 01.02.2015
reply asap please thanks
Re: Businesses gets created automatically crashes in BB -
Samieastwood - 01.02.2015
Any can tell me why aint it saving anymore? after putting the code??
Re: Businesses gets created automatically crashes in BB -
Jefff - 02.02.2015
Just change to
pawn Код:
if(!BizInfo[iIndex][bExteriorX]) continue;