vRP StaticOnlineJobs

VRP ONLY Front-End Programming knowledge needed

First of all, I’d like to comment that I have no professional training related to programming, so fails may happen.

This script shows a list of jobs in the main interface to let the users know how many workers of each of those jobs are online. This way you can deactivate the user list to improve RolePlay.

captura

__resource.lua

client_scripts{
  "lib/Proxy.lua",
  "client.lua"
}

server_scripts{
  "@vrp/lib/utils.lua",
  "server.lua"
}


ui_page "HTML/ui.html"

files {
    "HTML/ui.html",
    "HTML/ui.css",
    "HTML/ui.js"
}

Create the environment needed for that __resource.lua file or edit that.


ui.html

<!DOCTYPE html>
<html lang="es">
<head>
    <script src="nui://game/ui/jquery.js" type="text/javascript"></script>
    <link href = "ui.css" type = "text/css" rel = "stylesheet">
    <script src = "ui.js" type = "text/javascript"></script>
</head>
<body>
    <div class = "filauno">
        <ul style="list-style: none;">
            <li style="margin-left:8%;">
                <h1 style="display: inline;">👮: <h1 style="display: inline;" id = "policias"></h1></h1>
            </li>
            <li>
                <h1 style="display: inline;margin-top:8%;">🚕: <h1 style="display: inline;" id = "taxistas"></h1></h1>
            </li>
            <li>
                <h1 style="display: inline;margin-top:8%;">🔧: <h1 style="display: inline;" id = "mecanicos"></h1></h1>
            </li>

        </ul>
    </div>
</body>
</html>

ui.css

.filauno {
    position: absolute;
    padding: 0;
    margin: 0;
    bottom: 5vw;
    right: 3vw;
    color: white;
    font-size: 0.5vw;
}

ui.js

$(document).ready(function(){
    window.addEventListener('message', function(event) {
        var data = event.data;
        $(".filauno").css("display",data.show? "none":"block");
        $("#policias").text(data.policias);
        $("#taxistas").text(data.taxistas);
        $("#mecanicos").text(data.mecanicos);

    });
});


server.lua

local Proxy = module("vrp", "lib/Proxy")

vRP = Proxy.getInterface("vRP")

Citizen.CreateThread(function()
    while true do

		local polis = vRP.getUsersByPermission({"police.service"})
		local taxis = vRP.getUsersByPermission({"taxi.service"})
		local mechs = vRP.getUsersByPermission({"repair.service"})

		TriggerClientEvent("trabajos:update", -1, #polis, #taxis, #mechs)

		Citizen.Wait(X)
    end
end)

The bigger the X integer is, the less server consumption, but the more time it will take for the list to get updated.

client.lua

Citizen.CreateThread(function ()
    while true do
        Citizen.Wait(100)
        SendNUIMessage({
            show = IsPauseMenuActive(),
            policias = polis,
            taxistas = taxis,
            mecanicos = mechs,
        })
    end
end)

RegisterNetEvent("trabajos:update")
AddEventHandler("trabajos:update", function(rpolis, rtaxis, rmechs)
    polis = rpolis
    taxis = rtaxis
    mechs = rmechs
end)

---------------

I will upload the entire script when I’ve enough time to upload it.
Any feedback and :heart: is very appreciated.

¿ESX version? PM me.

9 Likes

screenshots?

Edit: Nevermind im blind sorry

@Aethen_games hahah don’t mind, I’ll add the desing I’m using at the moment.

Thanks :smiley:

Can you make it for esx?

@BestLifeOwner try replacing the server part with the esx functions.

How to install

@Gamer_s_Laver I will upload the entire script in a few days. At the moment, you only have to create the html, css and js files.

up (i am waiting for update)

@n3x With the actual pieces of code you can run it. Thanks for the :heart:, I’ll upload it to github in a few days.

I’m waiting for this in github very good contribution friend …

1 Like

ESX version?

@Mart475 Soon :wink:

1 Like

:open_mouth: Thank you so much!

vRP looks like a good framework but i prefer ESX because it is much easier for me to use.

2 Likes

bro pls change taxi jobs replace with ems

@Gamer_s_Laver groups depend on your configuration.

Hi Guy, please create the entire script please.

when will you upload it?

Love it!! but need esx version T_____T

@BestLifeOwner @Mart475 @Kuro_Neko1

PM me if yo want me to make it ESX for you.

@Gamer_s_Laver

PM me if you want any help.

@TheGamer_TeamW @Gamer_s_Laver

I don’t think I will upload this to github for the moment. If you want it as a script, PM me.

you are finished?