2019-05-10, 11:08 PM
(This post was last modified: 2019-05-11, 06:48 PM by JustMichael.)
PHP 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;
}
PHP Code:
Business_ProductMenu(playerid, bizid)
{
? ?if (bizid == -1 || !BusinessData[bizid][bizExists])
? ? ? ?return 0;
? ?static
? ? ? ?string[512];
? ?switch (BusinessData[bizid][bizType])
? ?{
? ? ? ?case 1, 6:
? ? ? ?{
? ? ? ? ? ?format(string, sizeof(string), "Mobile Phone - %s\nGPS System - %s\nSpray Paint - %s\nBackpack - %s\nWater Bottle - %s\nSoda Bottle - %s\nLottery Ticket - %s\nPortable Radio - %s\nCan of Fuel - %s\nCrowbar - %s\nBoombox - %s\nMask - %s\nFirst Aid Kit - %s\nRepair Kit - %s\nNOS Canister - %s\nBaseball Bat - %s\nFrozen Pizza - %s\nFrozen Burger - %s",
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][0]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][1]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][2]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][3]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][4]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][5]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][6]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][7]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][8]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][9]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][10]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][11]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][12]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][13]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][14]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][15]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][16]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][17])
? ? ? ? ? ?);
? ? ? ? ? ?Dialog_Show(playerid, EditProduct, DIALOG_STYLE_LIST, "Business: Modify Item", string, "Modify", "Cancel");
? ? ? ?}
? ? ? ?case 2:
? ? ? ?{
? ? ? ? ? ?format(string, sizeof(string), "Magazine - %s\nAmmo Cartridge - %s\nArmored Vest - %s\nDesert Eagle - %s\nRemington 870 - %s\nM14 Rifle - %s",
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][0]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][1]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][2]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][3]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][4]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][5])
? ? ? ? ? ?);
? ? ? ? ? ?Dialog_Show(playerid, EditProduct, DIALOG_STYLE_LIST, "Business: Modify Item", string, "Modify", "Cancel");
? ? ? ?}
? ? ? ?case 3:
? ? ? ?{
? ? ? ? ? ?format(string, sizeof(string), "Clothes - %s\nGlasses - %s\nHats - %s\nBandana - %s",
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][0]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][1]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][2]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][3])
? ? ? ? ? ?);
? ? ? ? ? ?Dialog_Show(playerid, EditProduct, DIALOG_STYLE_LIST, "Business: Modify Item", string, "Modify", "Cancel");
? ? ? ?}
? ? ? ?case 4:
? ? ? ?{
? ? ? ? ? ?format(string, sizeof(string), "Water - %s\nSoda - %s\nFrench Fries - %s\nCheeseburger - %s\nChicken Burger - %s\nChicken Nuggets - %s\nSalad - %s",
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][0]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][1]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][2]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][3]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][4]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][5]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][6])
? ? ? ? ? ?);
? ? ? ? ? ?Dialog_Show(playerid, EditProduct, DIALOG_STYLE_LIST, "Business: Modify Item", string, "Modify", "Cancel");
? ? ? ?}
? ? ? ?case 7:
? ? ? ?{
? ? ? ? ? ?string[0] = 0;
? ? ? ? ? ?for (new i = 0; i < sizeof(g_aFurnitureTypes); i ) {
? ? ? ? ? ? ? ?format(string, sizeof(string), "%s%s - %s\n", string, g_aFurnitureTypes[i], FormatNumber(BusinessData[bizid][bizPrices][i]));
? ? ? ? ? ?}
? ? ? ? ? ?Dialog_Show(playerid, EditProduct, DIALOG_STYLE_LIST, "Business: Modify Item", string, "Modify", "Cancel");
? ? ? ?}
? ?}
? ?return 1;
}
Business_PurchaseMenu(playerid, bizid)
{
? ?if (bizid == -1 || !BusinessData[bizid][bizExists])
? ? ? ?return 0;
? ?static
? ? ? ?string[512];
? ?switch (BusinessData[bizid][bizType])
? ?{
? ? ? ?case 1, 6:
? ? ? ?{
? ? ? ? ? ?format(string, sizeof(string), "Mobile Phone - %s\nGPS System - %s\nSpray Paint - %s\nBackpack - %s\nWater Bottle - %s\nSoda Bottle - %s\nLottery Ticket - %s\nPortable Radio - %s\nCan of Fuel - %s\nCrowbar - %s\nBoombox - %s\nMask - %s\nFirst Aid Kit - %s\nRepair Kit - %s\nNOS Canister - %s\nBaseball Bat - %s\nFrozen Pizza - %s\nFrozen Burger - %s",
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][0]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][1]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][2]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][3]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][4]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][5]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][6]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][7]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][8]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][9]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][10]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][11]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][12]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][13]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][14]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][15]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][16]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][17])
? ? ? ? ? ?);
? ? ? ? ? ?Dialog_Show(playerid, BusinessBuy, DIALOG_STYLE_LIST, BusinessData[bizid][bizName], string, "Purchase", "Cancel");
? ? ? ?}
? ? ? ?case 2:
? ? ? ?{
? ? ? ? ? ?format(string, sizeof(string), "Magazine - %s\nAmmo Cartridge - %s\nArmored Vest - %s\nDesert Eagle - %s\nRemington 870 - %s\nM14 Rifle - %s",
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][0]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][1]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][2]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][3]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][4]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][5])
? ? ? ? ? ?);
? ? ? ? ? ?Dialog_Show(playerid, BusinessBuy, DIALOG_STYLE_LIST, BusinessData[bizid][bizName], string, "Purchase", "Cancel");
? ? ? ?}
? ? ? ?case 3:
? ? ? ?{
? ? ? ? ? ?format(string, sizeof(string), "Clothes - %s\nGlasses - %s\nHats - %s\nBandana - %s",
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][0]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][1]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][2]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][3])
? ? ? ? ? ?);
? ? ? ? ? ?Dialog_Show(playerid, BusinessBuy, DIALOG_STYLE_LIST, BusinessData[bizid][bizName], string, "Purchase", "Cancel");
? ? ? ?}
? ? ? ?case 4:
? ? ? ?{
? ? ? ? ? ?format(string, sizeof(string), "Water - %s\nSoda - %s\nFrench Fries - %s\nCheeseburger - %s\nChicken Burger - %s\nChicken Nuggets - %s\nSalad - %s",
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][0]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][1]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][2]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][3]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][4]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][5]),
? ? ? ? ? ? ? ?FormatNumber(BusinessData[bizid][bizPrices][6])
? ? ? ? ? ?);
? ? ? ? ? ?Dialog_Show(playerid, BusinessBuy, DIALOG_STYLE_LIST, BusinessData[bizid][bizName], string, "Purchase", "Cancel");
? ? ? ?}
? ? ? ?case 7:
? ? ? ?{
? ? ? ? ? ?string[0] = 0;
? ? ? ? ? ?for (new i = 0; i < sizeof(g_aFurnitureTypes); i ) {
? ? ? ? ? ? ? ?format(string, sizeof(string), "%s%s - %s\n", string, g_aFurnitureTypes[i], FormatNumber(BusinessData[bizid][bizPrices][i]));
? ? ? ? ? ?}
? ? ? ? ? ?Dialog_Show(playerid, BusinessBuy, DIALOG_STYLE_LIST, BusinessData[bizid][bizName], string, "Purchase", "Cancel");
? ? ? ?}
? ?}
? ?return 1;
} ?