02.10.2016, 15:19
When i buy something in the store on the SC script, it crashes the server.
Here is the cmd:buy code.
Here is the cmd:buy code.
Код:
CMD:buy(playerid, params[])
{
static
id = -1;
if ((id = House_Nearest(playerid)) != -1)
{
if (House_GetCount(playerid) >= MAX_OWNABLE_HOUSES)
return SendErrorMessage(playerid, "You can only own %d houses at a time.", MAX_OWNABLE_HOUSES);
if (HouseData[id][houseOwner] != 0)
return SendErrorMessage(playerid, "This house is already owned at the moment.");
if (HouseData[id][housePrice] > GetMoney(playerid))
return SendErrorMessage(playerid, "You have insufficient funds for the purchase.");
HouseData[id][houseOwner] = GetPlayerSQLID(playerid);
House_Refresh(id);
House_Save(id);
GiveMoney(playerid, -HouseData[id][housePrice]);
SendServerMessage(playerid, "You have purchased \"%s\" for %s!", HouseData[id][houseAddress], FormatNumber(HouseData[id][housePrice]));
ShowPlayerFooter(playerid, "You have ~g~purchased~w~ a house!");
Log_Write("logs/house_log.txt", "[%s] %s has purchased house ID: %d for %s.", ReturnDate(), ReturnName(playerid), id, FormatNumber(HouseData[id][housePrice]));
}
else if ((id = Business_Nearest(playerid)) != -1)
{
if (Business_GetCount(playerid) >= MAX_OWNABLE_BUSINESSES)
return SendErrorMessage(playerid, "You can only own %d businesses at a time.", MAX_OWNABLE_BUSINESSES);
if (BusinessData[id][bizOwner] != 0)
return SendErrorMessage(playerid, "This business is already owned at the moment.");
if (BusinessData[id][bizPrice] > GetMoney(playerid))
return SendErrorMessage(playerid, "You have insufficient funds for the purchase.");
BusinessData[id][bizOwner] = GetPlayerSQLID(playerid);
Business_Refresh(id);
Business_Save(id);
GiveMoney(playerid, -BusinessData[id][bizPrice]);
SendServerMessage(playerid, "You have purchased \"%s\" for %s!", BusinessData[id][bizName], FormatNumber(BusinessData[id][bizPrice]));
ShowPlayerFooter(playerid, "You have ~g~purchased~w~ a business!");
Log_Write("logs/biz_log.txt", "[%s] %s has purchased business ID: %d for %s.", ReturnDate(), ReturnName(playerid), id, FormatNumber(BusinessData[id][bizPrice]));
}
else if ((id = Business_Inside(playerid)) != -1)
{
if (BusinessData[id][bizLocked] != 0 || !BusinessData[id][bizOwner])
return SendErrorMessage(playerid, "This business is closed!");
if (BusinessData[id][bizType] == 5) {
Business_CarMenu(playerid, id);
} else {
Business_PurchaseMenu(playerid, id);
}
}
return 1;
}


