Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vorp_menuConversion #12

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions client/MenuSetup/adminManagementMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ RegisterCommand(Config.AdminManagementMenuCommand, function()
end)

RegisterNetEvent('bcc-housing:AdminManagementMenu', function(allHouses)
MenuData.CloseAll()
VORPMenu.CloseAll()
Inmenu = true
TriggerEvent('bcc-housing:MenuClose')
local elements = {}

for k, houseInfo in pairs(allHouses) do
Expand All @@ -20,7 +19,7 @@ RegisterNetEvent('bcc-housing:AdminManagementMenu', function(allHouses)
}
end

MenuData.Open('default', GetCurrentResourceName(), 'menuapi',
VORPMenu.Open('default', GetCurrentResourceName(), 'vorp_menu',
{
title = _U("adminManagmentMenu"),
subtext = "",
Expand All @@ -33,7 +32,7 @@ RegisterNetEvent('bcc-housing:AdminManagementMenu', function(allHouses)
_G[data.trigger]()
end
if data.current.value then
MenuData.CloseAll()
VORPMenu.CloseAll()
AdminManagementMenuHouseChose(data.current.info)
end
end)
Expand All @@ -46,13 +45,13 @@ function AdminManagementMenuHouseChose(houseTable)
{ label = _U("changeHouseInvLimit"), value = 'changeinvlimit', desc = _U("changeHouseInvLimit_desc") },
{ label = _U("changeHouseTaxes"), value = 'changetaxes', desc = _U("changeHouseTaxes_desc") }
}
MenuData.Open('default', GetCurrentResourceName(), 'menuapi',
VORPMenu.Open('default', GetCurrentResourceName(), 'vorp_menu',
{
title = _U("adminManagmentMenu"),
align = 'top-left',
elements = elements
},
function(data)
function(data, menu)
if data.current == 'backup' then
_G[data.trigger]()
end
Expand All @@ -74,7 +73,7 @@ function AdminManagementMenuHouseChose(houseTable)
['delhouse'] = function()
TriggerServerEvent('bcc-house:AdminManagementDelHouse', houseTable.houseid)
VORPcore.NotifyRightTip(_U("housesDeleted"), 4000)
MenuData.CloseAll()
menu.close()
end,
['changeradius'] = function()
TriggerEvent("vorpinputs:advancedInput", json.encode(myInput), function(result)
Expand Down Expand Up @@ -111,5 +110,8 @@ function AdminManagementMenuHouseChose(houseTable)
if selectedOption[data.current.value] then
selectedOption[data.current.value]()
end
end,
function(data, menu)
menu.close()
end)
end
67 changes: 34 additions & 33 deletions client/MenuSetup/createHouseMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,21 @@
local ownerId, houseRadius, doors, houseCoords, InvLimit, ownerSource, taxAmount, tpInt = nil, nil, {}, nil, nil, nil, nil, nil
Inmenu = false

AddEventHandler('bcc-housing:MenuClose', function()
while Inmenu do
Wait(5)
if IsControlJustReleased(0, 0x156F7119) then
Inmenu = false
MenuData.CloseAll() break
end
end
end)

------ Main House Creation ------
function TpOptMenu()
Inmenu = true
TriggerEvent('bcc-housing:MenuClose')
MenuData.CloseAll()
VORPMenu.CloseAll()
local elements = {
{ label = _U("nonTp"), value = 'nontp', desc = _U("nonTp_desc") },
{ label = _U("Tp"), value = 'tp', desc = _U("Tp_desc") },
}
MenuData.Open('default', GetCurrentResourceName(), 'menuapi',
VORPMenu.Open('default', GetCurrentResourceName(), 'vorp_menu',
{
title = _U("creationMenuName"),
align = 'top-left',
elements = elements,
},
function(data)
function(data, menu)
if data.current == 'backup' then
_G[data.trigger]()
end
Expand All @@ -36,14 +25,16 @@ function TpOptMenu()
elseif data.current.value == 'tp' then
IntChoice()
end
end,
function(data, menu)
menu.close()
end)
end


function CreateHouseMenu(tp)
Inmenu = true
TriggerEvent('bcc-housing:MenuClose')
MenuData.CloseAll()
VORPMenu.CloseAll()
local elements = {
{ label = _U("setOwner"), value = 'setowner', desc = _U("setOwner_desc") },
{ label = _U("setRadius"), value = 'setradius', desc = _U("setRadius_desc") },
Expand All @@ -57,13 +48,13 @@ function CreateHouseMenu(tp)
table.insert(elements, { label = _U("Confirm"), value = 'confirm', desc = "" }) --placed here to always keep option at the bottom


MenuData.Open('default', GetCurrentResourceName(), 'menuapi',
VORPMenu.Open('default', GetCurrentResourceName(), 'vorp_menu',
{
title = _U("creationMenuName"),
align = 'top-left',
elements = elements,
},
function(data)
function(data, menu)
if data.current == 'backup' then
_G[data.trigger]()
end
Expand Down Expand Up @@ -123,7 +114,7 @@ function CreateHouseMenu(tp)
end)
end,
['confirm'] = function()
MenuData.CloseAll()
VORPMenu.CloseAll()
local tpHouse = false
if tpInt ~= nil then
tpHouse = tpInt
Expand All @@ -137,15 +128,17 @@ function CreateHouseMenu(tp)
if selectedOption[data.current.value] then
selectedOption[data.current.value]()
end
end,
function(data, menu)
menu.close()
end)
end

--------- Show the player list credit to vorp admin for this
function doorCreationMenu()
Inmenu = false
local doorMenuElements = {}

MenuData.CloseAll()
VORPMenu.CloseAll()

if #doorMenuElements == 0 or nil then
table.insert(doorMenuElements, { label = _U("createDoor"), value = 'doorcreation', desc = "" })
Expand All @@ -159,7 +152,7 @@ function doorCreationMenu()
}
end

MenuData.Open('default', GetCurrentResourceName(), 'menuapi',
VORPMenu.Open('default', GetCurrentResourceName(), 'vorp_menu',
{
title = _U("creationMenuName"),
subtext = _U("createdDoorList"),
Expand All @@ -168,27 +161,30 @@ function doorCreationMenu()
lastmenu = 'CreateHouseMenu',
itemHeight = "4vh",
},
function(data)
function(data, menu)
if data.current == 'backup' then
_G[data.trigger]()
end
if data.current.value == 'doorcreation' then
MenuData.CloseAll()
VORPMenu.CloseAll()
local door = exports['bcc-doorlocks']:createDoor()
table.insert(doors, door)
while true do
Wait(10)
if #MenuData.GetOpenedMenus() <= 0 then
if #VORPMenu.GetOpenedMenus() <= 0 then
doorCreationMenu() break
end
end
end
end,
function(data, menu)
menu.close()
end)
end

--------- Show the player list credit to vorp admin for this
function PlayerList(lastmenu, tpHouse)
MenuData.CloseAll()
VORPMenu.CloseAll()
Inmenu = false
local elements = {}
local players = GetPlayers()
Expand All @@ -206,7 +202,7 @@ function PlayerList(lastmenu, tpHouse)
}
end

MenuData.Open('default', GetCurrentResourceName(), 'menuapi',
VORPMenu.Open('default', GetCurrentResourceName(), 'vorp_menu',
{
title = _U("creationMenuName"),
subtext = _U("StaticId_desc"),
Expand All @@ -215,7 +211,7 @@ function PlayerList(lastmenu, tpHouse)
lastmenu = lastmenu,
itemHeight = "4vh",
},
function(data)
function(data, menu)
if data.current == 'backup' then
_G[data.trigger]()
end
Expand All @@ -224,32 +220,34 @@ function PlayerList(lastmenu, tpHouse)
ownerId = data.current.info.staticid
ownerSource = data.current.info.serverId
VORPcore.NotifyRightTip(_U("OwnerSet"), 4000)
MenuData.CloseAll()
VORPMenu.CloseAll()
CreateHouseMenu(tpHouse)
elseif lastmenu == 'HousingManagementMenu' then
VORPcore.NotifyRightTip(_U("givenAccess"), 4000)
TriggerServerEvent('bcc-housing:NewPlayerGivenAccess', data.current.info.staticid, HouseId, data.current.info.serverId)
end
end
end,
function(data, menu)
menu.close()
end)
end

------ Main House Creation ------
function IntChoice()
Inmenu = true
TriggerEvent('bcc-housing:MenuClose')
MenuData.CloseAll()
VORPMenu.CloseAll()
local elements = {
{ label = _U("Int1"), value = 'int1', desc = "" },
{ label = _U("Int2"), value = 'int2', desc = "" },
}
MenuData.Open('default', GetCurrentResourceName(), 'menuapi',
VORPMenu.Open('default', GetCurrentResourceName(), 'vorp_menu',
{
title = _U("creationMenuName"),
align = 'top-left',
elements = elements,
},
function(data)
function(data, menu)
if data.current == 'backup' then
_G[data.trigger]()
end
Expand All @@ -260,6 +258,9 @@ function IntChoice()
tpInt = 2
CreateHouseMenu(true)
end
end,
function(data, menu)
menu.close()
end)
end

Expand Down
Loading