Scripts/resources/[standalone]/MenuAPI/client/client.lua

73 lines
2.1 KiB
Lua
Raw Normal View History

2024-12-29 20:02:43 +00:00
CachedMenu = {}
function RegisterKey(fc, uniqid, description, key)
RegisterCommand(uniqid .. GetCurrentResourceName(), fc, false)
RegisterKeyMapping(uniqid .. GetCurrentResourceName(), description, 'keyboard', key)
end
--------------
-- Sending info about changing item in menu
--------------
RegisterKey(function()
SendNUIMessage({ type = "up" })
end, "menuapiup", "Tast op", "UP")
RegisterKey(function()
SendNUIMessage({ type = "down" })
end, "menuapidown", "Tast ned", "DOWN")
--------------
-- Sending info about selecting item
--------------
RegisterKey(function()
SendNUIMessage({ type = "enter" })
end, "menuapie", "Tast E", "E")
RegisterKey(function()
SendNUIMessage({ type = "enter" })
end, "menuapienter", "Tast ENTER", "RETURN")
--------------
-- closing menu keys
--------------
RegisterKey(function()
CloseAll()
end, "menuapiesc", "Tast ESC", "escape")
RegisterKey(function()
CloseAll()
end, "menuapiescaper", "Tast slet", "back")
--------------
--CreateThread(function()
-- Wait(200)
-- local vehicles = {
-- [1] = { label = "police car", model = "police"},
-- [2] = { label = "A FOCKING TANK?!", model = "rhino"},
-- [3] = { label = "a nice car!", model = "cerberus3"}
-- }
--
-- local menu = CreateMenu("identifier")
--
-- menu.SetMenuTitle("Vehicle spawner")
--
-- menu.SetProperties({
-- float = "right",
-- position = "middle",
-- })
--
-- for k,v in ipairs(vehicles) do
-- menu.AddItem(k, v.label, nil, { model = v.model })
-- end
--
-- menu.OnSelectEvent(function(index, data)
-- RequestModel(data.model)
-- local coords = GetEntityCoords(PlayerPedId())
-- while not HasModelLoaded(data.model) do
-- Wait(33)
-- end
-- local vehicle = CreateVehicle(data.model, coords.x, coords.y, coords.z, GetEntityHeading(PlayerPedId()), true, true)
-- SetVehicleOnGroundProperly(vehicle)
-- SetModelAsNoLongerNeeded(data.model)
-- TaskWarpPedIntoVehicle(PlayerPedId(), vehicle, -1)
-- end)
--
-- menu.Open()
--end)