[Release] esx_scoreboard

thanks bro
AddEventHandler(‘esx:playerLoaded’, function(source)
local xPlayer = ESX.GetPlayerFromId(source)
AddPlayerToScoreboard(xPlayer, true)
end)
When I added the command line to client.lua and main.luaya, my problem was solved.

1 Like

hey,

So i installed my scoreboard but it doen’st refresh :frowning: Can somebody help :slight_smile:

I need help about adding new job to scoreboard how can I add

im confused i have read through this whole fourm. is there still issues with this scoreboard because it dosent show myself being online or any other players or update and im using it right out of the box named as esx_scoreboard unedited and its not working

Got it if it dosent work edit server lua and change this function to match

AddEventHandler('esx:playerLoaded', function(source)
	local xPlayer = ESX.GetPlayerFromId(source)
	AddPlayerToScoreboard(xPlayer, true)
end)

not everyone can update esx some people took esx and built it into there own system but still enjoy this menu so thank you for making it

1 Like

Hi.

I have the same error as some other people here and I did update ESX already earlier today.

Any idea what could be causing that ?

Thanks.

— NEVERMIND , I fixed this by simply putting my start command line after es_extended.

I think this can be useful, so I will let this here still.

What about my question ??

Haw can we Add new job to scoreboard

Actually if someone could try to guide me towards something that actually works …

I’m trying to get it to show the number of player in duty for each of the jobs instead of simply the number of player with that job.

So far I have not been very successful with what I’ve tried.

Since I’m using esx_service for getting players on duty, I’m trying to callback CountInService that isn’t set up as a callback and I can’t seem to get the count value from another script.

Here’s the server/main.lua from esx_service that I edited

function GetInServiceCount(name)
	local count = 0

	for k,v in pairs(InService[name]) do
		if v == true then
			count = count + 1
		end
	end

	return count
end

--- Callback function I added ---

ESX.RegisterServerCallback('esx_service:ServiceCount', function(cb, name)
	local inServiceCount = GetInServiceCount(name)
	
	cb(inServiceCount)
end)

Now in esx_scoreboard/client/main.lua I edited the following

	for k,v in pairs(connectedPlayers) do
		table.insert(formattedPlayerList, ('<tr><td>%s</td><td>%s</td><td>%s</td></tr>'):format(v.name, v.id, v.ping))
		players = players + 1

		ESX.TriggerServerCallback('esx_service:ServiceCount', function(inServiceCount)
		
			ems = inServiceCount
		end, 'ambulance')

      end

However all I’m getting is this console error

If someone could help me figure this out , this would be nice !

I was successful to add jobs to the scoreboard doing the following edits

First add it to /html/listener.js

		case 'updatePlayerJobs':
				var jobs = event.data.jobs;

				$('#player_count').html(jobs.player_count);

				$('#ems').html(jobs.ems);
				$('#newjob').html(jobs.newjob);

Then gotta add it the /html/scoreboard.html

		<div class="header">
			<div class="jobs">
				<p style="color:red;"> 🚑 <span id="ems">0</span> </p>
	        	<p style="color:purple;"> 🆕 <span id="newjob">0</span> </p>

Finally in /client/main.lua

function UpdatePlayerTable(connectedPlayers)
	local formattedPlayerList = {}
	local ems,newjob,players = 0,0,0
          
                   .................

	if v.job == 'ambulance' then
			ems = ems + 1
		elseif v.job == 'newjob' then
			newjob = newjob + 1

                  ...................


	SendNUIMessage({
		action = 'updatePlayerJobs',
		jobs   = {ems = ems, newjob = newjob, player_count = players}
	})

Hopefully this helps you out !

Let me know if it doesn’t work !

1 Like

We cant do last step

Are you serious ? lol.

Go open the main.lua file in the client folder in esx_scoreboard folder lol.

Actually we cant find like this command https://media.discordapp.net/attachments/480352969125134336/546076472637521921/Screenshot_5.png?width=750&height=422

We need add this manual ?

If you don’t have it already in your file then yes.

Ok I will try.Thank you for everthing and sorry for my stupid questions

It’s fine, no worry.

We did what you said but it isnt work :frowning:

Work great but sometime, there will be some player that appear 2 time in the scoreboard… one with the good ping and the other one will be at 0 ms

Hi, I have installed everything perfect, I have removed the uptime because I see it extremely stupid, but what I do not understand is because it gives an error when a person comes in and if I do a restart, it works perfectly. here the error and some photos

Sin%20t%C3%ADtulo

Error running system event handling function for resource esx_scoreboard: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: server/main.lua:44: attempt to index a nil value (local ‘xPlayer’)
stack traceback:
server/main.lua:44: in function ‘AddPlayerToScoreboard’
server/main.lua:18: in upvalue ‘handler’
citizen:/scripting/lua/scheduler.lua:219: in function <citizen:/scripting/lua/scheduler.lua:218>
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/scheduler.lua:41: in field ‘CreateThreadNow’
citizen:/scripting/lua/scheduler.lua:218: in function <citizen:/scripting/lua/scheduler.lua:182>

Restart resource:
Sin%20t%C3%ADtulo

EDIT:
FIXED, thanks you @Skrubby

In esx_scoreboard/server/main.lua Line: 17

AddEventHandler(‘esx:playerLoaded’, function(source)
local xPlayer = ESX.GetPlayerFromId(source)
AddPlayerToScoreboard(xPlayer, true)
end)

Thanks :slight_smile: