Description: POPUP UI to Fireplace Occasions as a substitute of utilizing whereas loop controlpressed – FIVEM (0.00 ms idle or energetic)
A Easy instrument to make use of for any use instances.
a pattern use instances are to exchange the native means of isControlPressed with DrawText native that devour lots of resmon (cpu) utilization.
This can be utilized too for requesting a job , requesting a motion , and so on…(superior customers)

        native desk = {
                ['event'] = 'opengarage', -- occasion to fireside
                ['title'] = 'Storage A', -- title of window
                ['server_event'] = false, -- default false
                ['unpack_arg'] = false, -- default false
                ['invehicle_title'] = 'Retailer Car',
                ['confirm'] = '[ENTER]',
                ['reject'] = '[CLOSE]',
                ['fa'] = '<i class="fad fa-gas-pump"></i>', -- font awsome
                ['custom_arg'] = {}, -- instance: {1,2,3,4}
                ['use_cursor'] = false, -- USE MOUSE CURSOR INSTEAD OF INPUT (ENTER)
        }
        
        TriggerEvent('renzu_popui:showui',desk)`

            - Shut UI
    
        TriggerEvent('renzu_popui:closeui')
    
  • DEMO image
  • SAMPLE USAGE
        native desk = {
                ['key'] = 'E', -- key
                ['event'] = 'script:myevent',
                ['title'] = 'Press [E] to BUY COLA',
                ['invehicle_title'] = 'BUY COLA',
                ['server_event'] = false, -- server occasion or shopper
                ['unpack_arg'] = false, -- ship args as unpack 1,2,3,4 order
                ['fa'] = '<i class="fad fa-gas-pump"></i>',
                ['custom_arg'] = {}, -- instance: {1,2,3,4}
        }
        
        TriggerEvent('renzu_popui:drawtextuiwithinput',desk)
        
        - Shut UI
    
        TriggerEvent('renzu_popui:closeui')
    
Implementation Pattern utilizing a LOOP
  • code beneath is for pattern don’t copy and paste it
  • OLD CODE to transform (code pattern is utilizing drawtext loop 0) the excessive utilization for resmon
        Citizen.CreateThread(operate()
            whereas true do
                native sleep = 500
                native coords = GetEntityCoords(PlayerPedId())
                    for i, v in pairs(Config.Places) do
                        native pos = Config.Places[i]
                        native 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 Purchase Jerry Can")
                            if IsControlJustPressed(0, Keys["E"]) then
                                TriggerEvent('script:myevent')
                            finish
                            -- TO REPLACE CODE END
                        finish
                    finish
                Citizen.Wait(sleep)
            finish
        finish)
        Citizen.CreateThread(operate()
            whereas true do
                native sleep = 500
                native coords = GetEntityCoords(PlayerPedId())
                    for i, v in pairs(Config.Places) do
                        native pos = Config.Places[i]
                        native dist = GetDistanceBetweenCoords(pos["x"], pos["y"], pos["z"] + 0.98, coords, true)
                        if dist <= 3.5 then
                            -- NEW CODE START
                            native desk = {
                                ['key'] = 'E', -- key
                                ['event'] = 'script:myevent',
                                ['title'] = 'Press [E] to BUY Jerry Can',
                                ['fa'] = '<i class="fad fa-gas-pump"></i>',
                                ['custom_arg'] = {}, -- instance: {1,2,3,4}
                            }
                           TriggerEvent('renzu_popui:drawtextuiwithinput',desk) -- present the ui
                           whereas dist <= 3.5 do -- look ahead to dist change into > 3.5 and shut the ui as soon as its > 3.5
                                coords = GetEntityCoords(PlayerPedId() -- coords must be right here to be refreshed ea 500ms
                                dist = GetDistanceBetweenCoords(pos["x"], pos["y"], pos["z"] + 0.98, coords, true)
                                Wait(500)
                           finish
                           TriggerEvent('renzu_popui:closeui') -- shut the ui as soon as dist is > 3.5
                           Wait(1000) -- wait 1 second
                           -- NEW CODE END
                        finish
                    finish
                Citizen.Wait(sleep)
            finish
        finish)
        Citizen.CreateThread(operate()
            whereas true do
                native sleep = 500
                native coords = GetEntityCoords(PlayerPedId())
                    for i, v in pairs(Config.Places) do
                        native pos = Config.Places[i]
                        native dist = GetDistanceBetweenCoords(pos["x"], pos["y"], pos["z"] + 0.98, coords, true)
                        if dist <= 3.5 then
                            -- NEW CODE START
                            native desk = {
                                ['event'] = 'opengarage',
                                ['title'] = 'Storage 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',desk) -- present the ui
                           whereas dist <= 3.5 do -- look ahead to dist change into > 3.5 and shut the ui as soon as its > 3.5
                                coords = GetEntityCoords(PlayerPedId() -- coords must be right here to be refreshed ea 500ms
                                dist = GetDistanceBetweenCoords(pos["x"], pos["y"], pos["z"] + 0.98, coords, true)
                                Wait(500)
                           finish
                           TriggerEvent('renzu_popui:closeui') -- shut the ui as soon as dist is > 3.5
                           Wait(1000) -- wait 1 second
                           -- NEW CODE END
                        finish
                    finish
                Citizen.Wait(sleep)
            finish
        finish)

This was sleeping in my Github for some time
i truly dont wished to share this right here, as a result of it was too easy.
however i feel some individuals may discovered this convenient
No License you possibly can edit the code and even redistribute it.



Looking for paid scripts? Click here