Skip to content

Commit

Permalink
Prompt Enhancements, uniqueName Validation, and Localization Updates (#…
Browse files Browse the repository at this point in the history
…35)

* Prompt Enhancements, uniqueName Validation, and Localization Updates

- Replaced hardcoded key values with BccUtils.Keys for easier prompt management.
- Fixed devPrint logging issue.
- Renamed firstPrompt to ManageHousePrompt for clarity.
- Added uniqueName for better identification in config and database.
- Verified that uniqueName matches between the database and config.
- Corrected MySQL table name in queries.
- Removed unused charIdentifier from config.
- Added localization keys to prompt names for multi-language support.
- Update fxmanifest

* version bump

Version bump

* small fixes

* Update prompts and menu

- Fix: Prevents prompts or menu from remaining active when the player is dead

* added doors to config

Adds associated doors to the doorlocks table and links the door IDs to the purchased house.

* Update buyHouse.lua

- This fix ensures that the correct set of doors is inserted into the database for each house purchased, based on the house's unique name

- Previously, doors from different houses could be incorrectly inserted
  • Loading branch information
iseeyoucopy authored Sep 13, 2024
1 parent 0300806 commit 1918179
Show file tree
Hide file tree
Showing 17 changed files with 474 additions and 222 deletions.
28 changes: 26 additions & 2 deletions client/MenuSetup/adminManagementMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ function AdminManagementMenu(allHouses)
if BCCHousingMenu then
BCCHousingMenu:Close() -- Ensure no other menus are open
end


if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

local adminMenuPage = BCCHousingMenu:RegisterPage('admin_management_menu_page')

adminMenuPage:RegisterElement('header', {
Expand Down Expand Up @@ -60,7 +64,11 @@ function AdminManagementMenuHouseChose(houseInfo)
if BCCHousingMenu then
BCCHousingMenu:Close()
end


if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

local houseOptionsPage = BCCHousingMenu:RegisterPage('house_options_page')

houseOptionsPage:RegisterElement('header', {
Expand Down Expand Up @@ -152,6 +160,10 @@ function deleteHouse(houseInfo)
return
end

if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

if BCCHousingMenu then
BCCHousingMenu:Close()
end
Expand Down Expand Up @@ -218,6 +230,10 @@ function changeHouseRadius(houseInfo)
BCCHousingMenu:Close()
end

if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

local changeRadiusPage = BCCHousingMenu:RegisterPage("set_radius_page")
changeRadiusPage:RegisterElement('header', {
value = _U("setRadius"),
Expand Down Expand Up @@ -294,6 +310,10 @@ function changeHouseTaxes(houseInfo)
BCCHousingMenu:Close()
end

if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

local changeHouseTaxesPage = BCCHousingMenu:RegisterPage("set_tax_amount_page")

changeHouseTaxesPage:RegisterElement('header', {
Expand Down Expand Up @@ -371,6 +391,10 @@ function changeHouseInventory(houseInfo)
BCCHousingMenu:Close() -- Ensure no other menus are open
end

if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

local changeHouseInventoryPage = BCCHousingMenu:RegisterPage('inventory_limit_page')
local inventoryLimit = nil

Expand Down
44 changes: 27 additions & 17 deletions client/MenuSetup/buyHouse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ local purchasedHouses = {}

Citizen.CreateThread(function()
local HouseDealerPrompt = BccUtils.Prompts:SetupPromptGroup()
local collectMoneyPrompt = HouseDealerPrompt:RegisterPrompt(_U("collectFromDealer"), Config.keys.collect, 1, 1, true,
'hold', { timedeventhash = 'MEDIUM_TIMED_EVENT' })
local collectMoneyPrompt = HouseDealerPrompt:RegisterPrompt(_U("collectFromDealer"), BccUtils.Keys[Config.keys.collect], 1, 1, true, 'hold', { timedeventhash = 'MEDIUM_TIMED_EVENT' })

for _, dealer in pairs(Config.houseDealer) do
if dealer.CreateNPC then
dealerPed = BccUtils.Ped:Create('A_M_O_SDUpperClass_01', dealer.NpcCoords.x, dealer.NpcCoords.y,
dealer.NpcCoords.z - 1, 0, 'world', false)
dealerPed = BccUtils.Ped:Create('A_M_O_SDUpperClass_01', dealer.NpcCoords.x, dealer.NpcCoords.y, dealer.NpcCoords.z - 1, 0, 'world', false)
dealerPed:Freeze()
dealerPed:SetHeading(dealer.NpcHeading)
dealerPed:Invincible()
Expand All @@ -21,6 +19,9 @@ Citizen.CreateThread(function()

while true do
Wait(1)
local playerPed = PlayerPedId()

if IsEntityDead(playerPed) then goto END end
for _, dealer in pairs(Config.houseDealer) do
local playerCoords = GetEntityCoords(PlayerPedId())
local dist = #(playerCoords - dealer.NpcCoords)
Expand All @@ -34,22 +35,24 @@ Citizen.CreateThread(function()
end
end
end
::END::
end
end)

CreateThread(function()
-- Request the purchased houses list from the server when the resource starts
TriggerServerEvent('bcc-housing:getPurchasedHouses')
local PromptGroup = BccUtils.Prompt:SetupPromptGroup() -- Setup Prompt Group
local BuyHousePrompt = PromptGroup:RegisterPrompt("More Info", Config.keys.buy, 1, 1, true, 'hold', {
timedeventhash = "MEDIUM_TIMED_EVENT"
}) -- Register your first prompt

local PromptGroup = BccUtils.Prompt:SetupPromptGroup()
local BuyHousePrompt = PromptGroup:RegisterPrompt("More Info", BccUtils.Keys[Config.keys.buy], 1, 1, true, 'hold', { timedeventhash = "MEDIUM_TIMED_EVENT" }) -- Register your first prompt

while true do
Wait(0) -- Run the loop continuously

local playerCoords = GetEntityCoords(PlayerPedId())
local playerPed = PlayerPedId()

if IsEntityDead(playerPed) then goto END end

for _, house in pairs(Config.HousesForSale) do
local isPurchased = false

Expand All @@ -67,19 +70,17 @@ CreateThread(function()
HouseBlips[house.name] = nil
elseif not isPurchased then
local distance = GetDistanceBetweenCoords(playerCoords, house.menuCoords, true)

-- Only create blips if forSaleBlips is true and blip hasn't been created yet
if house.forSaleBlips and not HouseBlips[house.name] then
local houseSaleBlip = BccUtils.Blips:SetBlip(house.name, house.saleBlipSprite, 0.2, house.menuCoords.x, house.menuCoords.y, house.menuCoords.z)

HouseBlips[house.name] = houseSaleBlip
-- Add a modifier to the blip
Citizen.InvokeNative(0x662D364ABF16DE2F, houseSaleBlip:Get(), joaat(house.saleBlipModifier)) -- WHITE
-- Potential additions for the next BCC-Utils update:
-- The following lines could be utilized to enhance blip management for house sales:
-- local blipModifier = BccUtils.Blips:AddBlipModifier(houseSaleBlip, house.saleBlipModifier)
-- blipModifier:ApplyModifier()

local blipModifier = BccUtils.Blips:AddBlipModifier(houseSaleBlip, house.saleBlipModifier)
blipModifier:ApplyModifier()
end

if distance < 2 then
PromptGroup:ShowGroup("Price : $" .. house.price)
if BuyHousePrompt:HasCompleted() then
Expand All @@ -91,6 +92,7 @@ CreateThread(function()
end
end
end
::END::
end
end)

Expand All @@ -113,6 +115,10 @@ end)
AddEventHandler('bcc-housing:openCollectMoneyMenu', function()
devPrint("Opening collect money menu")

if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

-- Request the list of sold houses from the server
TriggerServerEvent('bcc-housing:requestSoldHouses')

Expand Down Expand Up @@ -181,6 +187,10 @@ end)
AddEventHandler('bcc-housing:openBuyHouseMenu', function(house)
devPrint("Opening buy house menu for house with coordinates: " .. tostring(house.houseCoords))

if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

local buyHouseMenu = BCCHousingMenu:RegisterPage("bcc-housing:BuyHousePage")

buyHouseMenu:RegisterElement('header', {
Expand Down
44 changes: 39 additions & 5 deletions client/MenuSetup/createHouseMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ end

function PlayerListMenu(houseId, callback, context)
BCCHousingMenu:Close()

if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

local players = GetPlayers()
table.sort(players, function(a, b)
return a.serverId < b.serverId
Expand Down Expand Up @@ -84,6 +89,10 @@ function doorCreationMenu()
if BCCHousingMenu then
BCCHousingMenu:Close() -- Ensure no other menus are open
end

if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

local doorCreationMenuPage = BCCHousingMenu:RegisterPage('door_creation_page')

Expand Down Expand Up @@ -157,7 +166,11 @@ end

function IntChoice()
BCCHousingMenu:Close() -- Ensure no other menus are open


if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

-- Initialize the interior choice menu page
local interiorChoiceMenuPage = BCCHousingMenu:RegisterPage('interior_choice_page')

Expand Down Expand Up @@ -223,7 +236,11 @@ function HouseManagementMenu(allHouses)
if BCCHousingMenu then
BCCHousingMenu:Close() -- Ensure no other menus are open
end


if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

-- Initialize the teleport options menu page
local HouseManagementList = BCCHousingMenu:RegisterPage("tp_options_page")

Expand Down Expand Up @@ -283,11 +300,16 @@ function CreateHouseMenu(tp, refresh)
if refresh then
BCCHousingMenu:Close() -- Close the current menu before reopening
end

tp = tp or false -- Default to false if tp isn't provided
print("Adjusted tp in CreateHouseMenu:", tp)
devPrint("Adjusted tp in CreateHouseMenu:", tp)
-- Close any existing menus, assuming BCCHousingMenu is your FeatherMenu instance
BCCHousingMenu:Close()

if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

-- Register the main page for housing creation
local createHouseMenu = BCCHousingMenu:RegisterPage("bcc-housing-create-menu")

Expand Down Expand Up @@ -394,7 +416,11 @@ function setRadius()
if BCCHousingMenu then
BCCHousingMenu:Close() -- Ensure no other menus are open
end


if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

-- Initialize the teleport options menu page
local setRadiusPage = BCCHousingMenu:RegisterPage("set_radius_page")

Expand Down Expand Up @@ -479,6 +505,10 @@ function setTaxAmount()
BCCHousingMenu:Close() -- Ensure no other menus are open
end

if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

-- Initialize the tax amount settings menu page
local setTaxAmountPage = BCCHousingMenu:RegisterPage("set_tax_amount_page")

Expand Down Expand Up @@ -562,7 +592,11 @@ function setInvLimit(houseId)
if BCCHousingMenu then
BCCHousingMenu:Close() -- Ensure no other menus are open
end


if HandlePlayerDeathAndCloseMenu() then
return -- Skip opening the menu if the player is dead
end

local inventoryLimitPage = BCCHousingMenu:RegisterPage('inventory_limit_page')

-- Header for the inventory limit page
Expand Down
Loading

0 comments on commit 1918179

Please sign in to comment.