PopUI
Description: POPUP UI to Fire Events instead of using while loop controlpressed - FIVEM (0.00 ms idle or active)
A Simple tool to use for any use cases.
a sample use cases are to replace the native way of isControlPressed with DrawText native that consume a lot of resmon (cpu) usage.
This can be used too for requesting a job , requesting a action , etc…(advanced users)
Download
Methods
POPUI
- DEMO
- SAMPLE USAGE
local table = {
['event'] = 'opengarage', -- event to fire
['title'] = 'Garage A', -- title of window
['server_event'] = false, -- default false
['unpack_arg'] = false, -- default false
['invehicle_title'] = 'Store Vehicle',
['confirm'] = '[ENTER]',
['reject'] = '[CLOSE]',
['fa'] = '<i class="fad fa-gas-pump"></i>', -- font awsome
['custom_arg'] = {}, -- example: {1,2,3,4}
['use_cursor'] = false, -- USE MOUSE CURSOR INSTEAD OF INPUT (ENTER)
}
TriggerEvent('renzu_popui:showui',table)`
- Close UI
TriggerEvent('renzu_popui:closeui')
DrawTEXTUI
local table = {
['key'] = 'E', -- key
['event'] = 'script:myevent',
['title'] = 'Press [E] to BUY COLA',
['invehicle_title'] = 'BUY COLA',
['server_event'] = false, -- server event or client
['unpack_arg'] = false, -- send args as unpack 1,2,3,4 order
['fa'] = '<i class="fad fa-gas-pump"></i>',
['custom_arg'] = {}, -- example: {1,2,3,4}
}
TriggerEvent('renzu_popui:drawtextuiwithinput',table)
- Close UI
TriggerEvent('renzu_popui:closeui')
Implementation Sample using a LOOP
Implementation Sample
- code below is for sample do not copy and paste it
- OLD CODE to convert (code sample is using drawtext loop 0) the high usage for resmon
Citizen.CreateThread(function()
while true do
local sleep = 500
local coords = GetEntityCoords(PlayerPedId())
for i, v in pairs(Config.Locations) do
local pos = Config.Locations[i]
local dist = GetDistanceBetweenCoords(pos["x"], pos["y"], pos["z"] + 0.98, coords, true)
if dist <= 1.5 then
-- TO REPLACE CODE START
sleep = 5
DrawText3D(pos["x"], pos["y"], pos["z"], "Press [E] to Buy Jerry Can")
if IsControlJustPressed(0, Keys["E"]) then
TriggerEvent('script:myevent')
end
-- TO REPLACE CODE END
end
end
Citizen.Wait(sleep)
end
end)
- New Code with DrawtextUI
Citizen.CreateThread(function()
while true do
local sleep = 500
local coords = GetEntityCoords(PlayerPedId())
for i, v in pairs(Config.Locations) do
local pos = Config.Locations[i]
local dist = GetDistanceBetweenCoords(pos["x"], pos["y"], pos["z"] + 0.98, coords, true)
if dist <= 3.5 then
-- NEW CODE START
local table = {
['key'] = 'E', -- key
['event'] = 'script:myevent',
['title'] = 'Press [E] to BUY Jerry Can',
['fa'] = '<i class="fad fa-gas-pump"></i>',
['custom_arg'] = {}, -- example: {1,2,3,4}
}
TriggerEvent('renzu_popui:drawtextuiwithinput',table) -- show the ui
while dist <= 3.5 do -- wait for dist become > 3.5 and close the ui once its > 3.5
coords = GetEntityCoords(PlayerPedId() -- coords need to be here to be refreshed ea 500ms
dist = GetDistanceBetweenCoords(pos["x"], pos["y"], pos["z"] + 0.98, coords, true)
Wait(500)
end
TriggerEvent('renzu_popui:closeui') -- close the ui once dist is > 3.5
Wait(1000) -- wait 1 second
-- NEW CODE END
end
end
Citizen.Wait(sleep)
end
end)
- New Code with POPUI
Citizen.CreateThread(function()
while true do
local sleep = 500
local coords = GetEntityCoords(PlayerPedId())
for i, v in pairs(Config.Locations) do
local pos = Config.Locations[i]
local dist = GetDistanceBetweenCoords(pos["x"], pos["y"], pos["z"] + 0.98, coords, true)
if dist <= 3.5 then
-- NEW CODE START
local table = {
['event'] = 'opengarage',
['title'] = 'Garage A',
['confirm'] = '[ENTER]',
['reject'] = '[CLOSE]',
['fa'] = '<i class="fad fa-gas-pump"></i>',
['use_cursor'] = false, -- USE MOUSE CURSOR INSTEAD OF INPUT (ENTER)
}
TriggerEvent('renzu_popui:showui',table) -- show the ui
while dist <= 3.5 do -- wait for dist become > 3.5 and close the ui once its > 3.5
coords = GetEntityCoords(PlayerPedId() -- coords need to be here to be refreshed ea 500ms
dist = GetDistanceBetweenCoords(pos["x"], pos["y"], pos["z"] + 0.98, coords, true)
Wait(500)
end
TriggerEvent('renzu_popui:closeui') -- close the ui once dist is > 3.5
Wait(1000) -- wait 1 second
-- NEW CODE END
end
end
Citizen.Wait(sleep)
end
end)
Disclaimer
This was sleeping in my Github for a while
i actually dont wanted to share this here, because it was too simple.
but i think some people might found this useful
No License you can edit the code or even redistribute it.