Skip to content

Commit

Permalink
updates, fixes and improvements (#36)
Browse files Browse the repository at this point in the history
- Updated version check method to use a file instead of release.
- Implemented house ownership limit per character when purchasing a house.
- Removed associated doors from the doorlocks table based on houseId or uniqueName during house sale.
- Replaced bottomline with line in the house creation menu for inventory.
- Expanded localization keys to support multiple languages.
- Added an HTML element to the bottom menu to display an image. You can set the image link via config.
- Added an option to enable/disable the image display in the config.
- Removed the custom logo implementation.
- Replaced key hashes from config with actual keys; bcc-utils.keys will now resolve the hashes.
- Added bccutils keys support for hotel prompts.
  • Loading branch information
iseeyoucopy authored Sep 13, 2024
1 parent 1918179 commit de3896b
Show file tree
Hide file tree
Showing 20 changed files with 402 additions and 169 deletions.
8 changes: 4 additions & 4 deletions client/MainHousing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,22 @@ end)
RegisterNetEvent('bcc-housing:MainHotelHandler', function()
devPrint("Initializing main hotel handler")
local PromptGroup = BccUtils.Prompts:SetupPromptGroup()
local firstprompt = PromptGroup:RegisterPrompt(_U("promptBuy"), 0x760A9C6F, 1, 1, true, 'hold', {
local firstprompt = PromptGroup:RegisterPrompt(_U("promptBuy"), BccUtils.Keys[Config.keys.buy], 1, 1, true, 'hold', {
timedeventhash = "MEDIUM_TIMED_EVENT"
})

local PromptGroup2 = BccUtils.Prompts:SetupPromptGroup()
local firstprompt2 = PromptGroup2:RegisterPrompt(_U("promptEnterHotel"), 0x760A9C6F, 1, 1, true, 'hold', {
local firstprompt2 = PromptGroup2:RegisterPrompt(_U("promptEnterHotel"), BccUtils.Keys[Config.keys.manage], 1, 1, true, 'hold', {
timedeventhash = "MEDIUM_TIMED_EVENT"
})

local PromptGroup3 = BccUtils.Prompts:SetupPromptGroup()
local firstprompt3 = PromptGroup3:RegisterPrompt(_U("hotelInvName"), 0x760A9C6F, 1, 1, true, 'hold', {
local firstprompt3 = PromptGroup3:RegisterPrompt(_U("hotelInvName"), BccUtils.Keys[Config.keys.manage], 1, 1, true, 'hold', {
timedeventhash = "MEDIUM_TIMED_EVENT"
})

local PromptGroup4 = BccUtils.Prompts:SetupPromptGroup()
local firstprompt4 = PromptGroup4:RegisterPrompt(_U("promptLeaveHotel"), 0x760A9C6F, 1, 1, true, 'hold', {
local firstprompt4 = PromptGroup4:RegisterPrompt(_U("promptLeaveHotel"), BccUtils.Keys[Config.keys.manage], 1, 1, true, 'hold', {
timedeventhash = "MEDIUM_TIMED_EVENT"
})

Expand Down
13 changes: 6 additions & 7 deletions client/MenuSetup/adminManagementMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ function AdminManagementMenuHouseChose(houseInfo)
})

local houseDetails = string.format(
"House ID: %s\nOwner ID: %s\nRadius: %s\nInventory Limit: %s\nTaxes: %s",
tostring(houseInfo.houseid) or "N/A",
tostring(houseInfo.charidentifier) or "N/A",
tostring(houseInfo.house_radius_limit) or "N/A",
tostring(houseInfo.invlimit) or "N/A",
tostring(houseInfo.tax_amount) or "N/A"
)
_U("houseDetailsHouseID", houseInfo.houseid and tostring(houseInfo.houseid) or "N/A") .. "\n" ..
_U("houseDetailsOwnerID", houseInfo.charidentifier and tostring(houseInfo.charidentifier) or "N/A") .. "\n" ..
_U("houseDetailsRadius", houseInfo.house_radius_limit and tostring(houseInfo.house_radius_limit) or "N/A") .. "\n" ..
_U("houseDetailsInvLimit", houseInfo.invlimit and tostring(houseInfo.invlimit) or "N/A") .. "\n" ..
_U("houseDetailsTaxes", houseInfo.tax_amount and tostring(houseInfo.tax_amount) or "N/A")
)

houseOptionsPage:RegisterElement('textdisplay', {
value = houseDetails,
Expand Down
29 changes: 15 additions & 14 deletions client/MenuSetup/buyHouse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ CreateThread(function()
end

if distance < 2 then
PromptGroup:ShowGroup("Price : $" .. house.price)
PromptGroup:ShowGroup(_U("buyPricePrompt") .. house.price)
if BuyHousePrompt:HasCompleted() then
TriggerEvent('bcc-housing:openBuyHouseMenu', house)
end
Expand Down Expand Up @@ -194,7 +194,7 @@ AddEventHandler('bcc-housing:openBuyHouseMenu', function(house)
local buyHouseMenu = BCCHousingMenu:RegisterPage("bcc-housing:BuyHousePage")

buyHouseMenu:RegisterElement('header', {
value = "Confirm House Purchase",
value = _U("confirmHousePurchase"),
slot = 'header',
style = {}
})
Expand All @@ -212,18 +212,19 @@ AddEventHandler('bcc-housing:openBuyHouseMenu', function(house)

local htmlContent = string.format([[
<div style="text-align:center; margin: 20px;">
<p style="font-size:18px; margin-bottom: 10px;">Price: <strong style="color:#28A745;">$%d</strong></p>
<p style="font-size:18px; margin-bottom: 10px;">Sell Price: <strong style="color:#17A2B8;">$%d</strong></p>
<p style="font-size:18px; margin-bottom: 10px;">Can Sell: <strong style="color:#FFC107;">%s</strong></p>
<p style="font-size:18px; margin-bottom: 10px;">Inventory Limit: <strong>%d</strong></p>
<p style="font-size:18px; margin-bottom: 10px;">Tax Amount: <strong style="color:#DC3545;">$%d</strong></p>
<p style="font-size:18px; margin-bottom: 10px;">%s <strong style="color:#28A745;">$%d</strong></p>
<p style="font-size:18px; margin-bottom: 10px;">%s <strong style="color:#17A2B8;">$%d</strong></p>
<p style="font-size:18px; margin-bottom: 10px;">%s <strong style="color:#FFC107;">%s</strong></p>
<p style="font-size:18px; margin-bottom: 10px;">%s <strong>%d</strong></p>
<p style="font-size:18px; margin-bottom: 10px;">%s <strong style="color:#DC3545;">$%d</strong></p>
</div>
]],
tonumber(house.price or 0),
tonumber(house.sellPrice or 0),
tostring(house.canSell and "Yes" or "No"),
tonumber(house.invLimit or 0),
tonumber(house.taxAmount or 0))
_U('listBuyPrice'), tonumber(house.price or 0),
_U('listSellPrice'), tonumber(house.sellPrice or 0),
_U('listCanSell'), tostring(house.canSell and _U('Yes') or _U('No')),
_U('listInvLimit'), tonumber(house.invLimit or 0),
_U('listTaxAmount'), tonumber(house.taxAmount or 0)
)

buyHouseMenu:RegisterElement("html", {
value = { htmlContent },
Expand All @@ -241,7 +242,7 @@ AddEventHandler('bcc-housing:openBuyHouseMenu', function(house)
})

buyHouseMenu:RegisterElement('button', {
label = "Buy House for $" .. house.price,
label = _U('buyHouseFor') .. house.price,
style = {},
slot = "footer"
}, function()
Expand All @@ -250,7 +251,7 @@ AddEventHandler('bcc-housing:openBuyHouseMenu', function(house)
end)

buyHouseMenu:RegisterElement('button', {
label = "Cancel",
label = _U('cancel'),
style = {},
slot = "footer"
}, function()
Expand Down
30 changes: 15 additions & 15 deletions client/MenuSetup/createHouseMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function PlayerListMenu(houseId, callback, context)
})

TextDisplay = playerListMenupage:RegisterElement('textdisplay', {
value = "Select player from this list to own this house or to have access",
value = _U('selectPlayerFromList'),
style = {}
})

Expand Down Expand Up @@ -129,7 +129,7 @@ function doorCreationMenu()
label = _U("doorId") .. door.id, -- Assuming each door has a unique 'id'
style = {}
}, function()
print("Selected door with ID:", door.id)
devPrint("Selected door with ID:", door.id)
end)
end

Expand Down Expand Up @@ -273,7 +273,7 @@ function HouseManagementMenu(allHouses)
end)

HouseManagementList:RegisterElement('button', {
label = "Manage All Houses",
label = _U('manageAllHouses'),
style = {}
}, function()
TriggerServerEvent('bcc-housing:AdminGetAllHouses')
Expand Down Expand Up @@ -344,7 +344,7 @@ function CreateHouseMenu(tp, refresh)
style = {}
}, function()
globalHouseData.houseCoords = GetEntityCoords(PlayerPedId())
--print("house coords set to:", globalHouseData.houseCoords)
devPrint("house coords set to:", globalHouseData.houseCoords)
VORPcore.NotifyRightTip(_U("houseCoordsSet"), 4000)
end)

Expand Down Expand Up @@ -447,10 +447,10 @@ function setRadius()
-- Check the input value for validity
if data.value and tonumber(data.value) and tonumber(data.value) > 0 then
globalHouseData.radius = tonumber(data.value) -- Correctly assign to globalHouseData
--print("Radius set to:", globalHouseData.radius)
devPrint("Radius set to:", globalHouseData.radius)
else
globalHouseData.radius = nil -- Ensure radius is nil if input is invalid
--print("Invalid input for amount.")
devPrint("Invalid input for amount.")
end
end)

Expand Down Expand Up @@ -535,10 +535,10 @@ function setTaxAmount()
-- Validate the input from the user
if data.value and tonumber(data.value) and tonumber(data.value) > 0 then
globalHouseData.taxAmount = tonumber(data.value) -- Correctly update globalHouseData for tax amount
--print("Tax amount set to:", globalHouseData.taxAmount)
devPrint("Tax amount set to:", globalHouseData.taxAmount)
else
globalHouseData.taxAmount = nil -- Reset if invalid input
--print("Invalid input for tax amount.")
devPrint("Invalid input for tax amount.")
end
end)

Expand Down Expand Up @@ -622,14 +622,14 @@ function setInvLimit(houseId)
-- Validate the input from the user
if data.value and tonumber(data.value) and tonumber(data.value) > 0 then
globalHouseData.invLimit = tonumber(data.value)
--print("Inventory limit set to:", globalHouseData.invLimit)
devPrint("Inventory limit set to:", globalHouseData.invLimit)
else
globalHouseData.invLimit = nil
--print("Invalid input for inventory limit.")
devPrint("Invalid input for inventory limit.")
end
end)

inventoryLimitPage:RegisterElement('bottomline', {
inventoryLimitPage:RegisterElement('line', {
slot = "footer",
style = {}
})
Expand All @@ -645,7 +645,7 @@ function setInvLimit(houseId)
CreateHouseMenu(tpHouse) -- Optionally navigate back to the house creation menu
VORPcore.NotifyRightTip(_U("invLimitSet"), 4000)
else
--print("Error: Inventory limit not set or invalid.")
devPrint("Error: Inventory limit not set or invalid.")
VORPcore.NotifyRightTip(_U("InvalidInput"), 4000)
end
end)
Expand Down Expand Up @@ -679,11 +679,11 @@ end
-- Confirm House Creation function
function confirmCreation(globalHouseData)
if not globalHouseData then
print("Error: Data object is nil")
devPrint("Error: Data object is nil")
return
end
if not globalHouseData.owner or not globalHouseData.radius or not globalHouseData.doors or not globalHouseData.houseCoords or not globalHouseData.invLimit or not globalHouseData.ownerSource or not globalHouseData.taxAmount then
print("Error: One or more required fields are missing in the data object")
devPrint("Error: One or more required fields are missing in the data object")
return
end
local tpHouse = false
Expand All @@ -695,7 +695,7 @@ function confirmCreation(globalHouseData)
globalHouseData.doors, globalHouseData.houseCoords, globalHouseData.invLimit, globalHouseData.ownerSource,
globalHouseData.taxAmount)
-- Debug to confirm data contents
--print("Sending data to server:", tpHouse, globalHouseData.owner, globalHouseData.radius, globalHouseData.doors, globalHouseData.houseCoords, globalHouseData.invLimit, globalHouseData.ownerSource, globalHouseData.taxAmount)
devPrint("Sending data to server:", tpHouse, globalHouseData.owner, globalHouseData.radius, globalHouseData.doors, globalHouseData.houseCoords, globalHouseData.invLimit, globalHouseData.ownerSource, globalHouseData.taxAmount)
end

--Used to load houses after given one or given access so you dont have to relog to gain access
Expand Down
23 changes: 11 additions & 12 deletions client/MenuSetup/furnitureMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ function IndFurnitureTypeMenu(type, houseId)

local furnConfigTable = Config.Furniture[type]
if not furnConfigTable then
print("Error: Invalid furniture type '" .. type .. "'. Available types are:")
devPrint("Error: Invalid furniture type '" .. type .. "'. Available types are:")
for key in pairs(Config.Furniture) do
print(" - " .. key)
devPrint(" - " .. key)
end
return -- Exit the function if the type is invalid
end
Expand Down Expand Up @@ -236,20 +236,20 @@ end
function StartFurniturePlacementPrompts()
-- Debug: Check if BccUtils is loaded
if BccUtils then
print("BccUtils initialized successfully")
devPrint("BccUtils initialized successfully")
else
print("Error: BccUtils not initialized")
devPrint("Error: BccUtils not initialized")
end
if BccUtils and BccUtils.Keys then
print("Keys table exists")
devPrint("Keys table exists")
else
print("Error: Keys table not found in BccUtils")
devPrint("Error: Keys table not found in BccUtils")
end

if BccUtils and BccUtils.Keys and BccUtils.Keys['R'] then
PromptSetControlAction(MoveForwardPrompt, BccUtils.Keys['R'])
else
print("Error: Key 'R' not found in Keys table")
devPrint("Error: Key 'R' not found in Keys table")
end
-- Register movement prompts
MoveForwardPrompt = PromptRegisterBegin()
Expand Down Expand Up @@ -378,7 +378,7 @@ function PlaceFurnitureIntoWorldPrompt(model, cost, displayName, sellPrice)
local amountToMove = 0.1 -- default movement precision

-- Notify player of controls
VORPcore.NotifyRightTip("Furniture controls", 5000)
VORPcore.NotifyRightTip(_U('furnitureControls'), 5000)

-- Main loop for handling prompt inputs
Citizen.CreateThread(function()
Expand Down Expand Up @@ -587,13 +587,13 @@ end)

-- Function to trigger server event
function GetOwnedFurniture(houseId)
print("Requesting furniture for house ID:", houseId) -- Debug print
devPrint("Requesting furniture for house ID:", houseId) -- Debug print
TriggerServerEvent('bcc-housing:GetOwnerFurniture', houseId)
end

-- Helper function to handle the sale of furniture (implement as needed)
function SellFurniture(furniture)
print("Selling furniture:", furniture.model)
devPrint("Selling furniture:", furniture.model)
-- You can add server event here to handle the backend sale process
TriggerServerEvent('bcc-housing:SellFurniture', furniture)
end
Expand Down Expand Up @@ -633,7 +633,6 @@ function SellOwnedFurnitureMenu(houseId, furnTable)
DeleteEntity(entity)
table.remove(CreatedFurniture, idx)
TriggerServerEvent('bcc-housing:FurnSoldRemoveFromTable', v, houseId, furnTable, k)
--VORPcore.NotifyRightTip(_U("furnSold"), 4000)
sold = true
break
end
Expand All @@ -645,7 +644,7 @@ function SellOwnedFurnitureMenu(houseId, furnTable)
end
else
sellFurnMenu:RegisterElement('textdisplay', {
value = "No furniture Available",
value = _U('noFurnAvailable'),
slot = 'content',
style = {}
})
Expand Down
Loading

0 comments on commit de3896b

Please sign in to comment.