Skip to content

Commit

Permalink
chore: improves code performance
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Aug 25, 2024
1 parent c33f1c4 commit 2c77a9f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,11 @@ local Keys = {
["N9"] = 118,
}

ESX = exports["es_extended"]:getSharedObject()
local idVisable = true

Citizen.CreateThread(function()
ESX = exports["es_extended"]:getSharedObject()

Citizen.Wait(2000)
ESX.TriggerServerCallback("esx_scoreboard:getConnectedPlayers", function(connectedPlayers)
UpdatePlayerTable(connectedPlayers)
end)
ESX.TriggerServerCallback("esx_scoreboard:getConnectedPlayers", function(connectedPlayers)
UpdatePlayerTable(connectedPlayers)
end)

Citizen.CreateThread(function()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fx_version("cerulean")
games({ "gta5" })

version("1.0.2")
ui_page("html/scoreboard.html")

files({
Expand Down
17 changes: 0 additions & 17 deletions server-data/resources/[esx_addons]/esx_scoreboard/html/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,6 @@ p {
size: 100%;
}

.jobs {
font-family: 'Segoe UI';
padding-top: 3px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
/*background-image: url(https://cdn.discordapp.com/attachments/715640529626595439/719964336470229022/bg4.png);*/
background-size: cover;
background-repeat: no-repeat;
height: 4.2vw;
width: 100%;
box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.3), 0px 1px 1px 0px rgba(0, 0, 0, 0.3);
}

.jobs p {
font-family: 'Segoe UI';
}

table {
text-align: left;
color: white;
Expand Down
19 changes: 6 additions & 13 deletions server-data/resources/[esx_addons]/esx_scoreboard/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@ local connectedPlayers = {}

ESX = exports["es_extended"]:getSharedObject()

ESX.RegisterServerCallback("esx_scoreboard:getConnectedPlayers", function(source, cb)
ESX.RegisterServerCallback("esx_scoreboard:getConnectedPlayers", function(_, cb)
cb(connectedPlayers)
end)

AddEventHandler("esx:setJob", function(playerId, job, lastJob)
connectedPlayers[playerId].job = job.name

TriggerClientEvent("esx_scoreboard:updateConnectedPlayers", -1, connectedPlayers)
end)

AddEventHandler("esx:playerLoaded", function(playerId, xPlayer)
AddEventHandler("esx:playerLoaded", function(_, xPlayer)
AddPlayerToScoreboard(xPlayer, true)
end)

Expand Down Expand Up @@ -45,7 +39,6 @@ function AddPlayerToScoreboard(xPlayer, update)
connectedPlayers[playerId].ping = GetPlayerPing(playerId)
connectedPlayers[playerId].id = playerId
connectedPlayers[playerId].name = GetPlayerName(playerId)
connectedPlayers[playerId].job = xPlayer.job.name

if update then
TriggerClientEvent("esx_scoreboard:updateConnectedPlayers", -1, connectedPlayers)
Expand Down Expand Up @@ -78,20 +71,20 @@ function UpdatePing()
TriggerClientEvent("esx_scoreboard:updatePing", -1, connectedPlayers)
end

RegisterCommand("screfresh", function(source, args, user)
RegisterCommand("screfresh", function(source)
local xPlayer = ESX.GetPlayerFromId(source)

if xPlayer.getGroup() == "admin" or xPlayer.getGroup() == "superadmin" then
if xPlayer.getGroup() == "admin" or xPlayer.getGroup() == "admin" then
AddPlayersToScoreboard()
else
TriggerClientEvent("chatMessage", source, "[CONSOLE]", { 255, 0, 0 }, " ^0Shoma ^1Admin ^0nistid!")
end
end, false)

RegisterCommand("sctoggle", function(source, args, user)
RegisterCommand("sctoggle", function(source)
local xPlayer = ESX.GetPlayerFromId(source)

if xPlayer.getGroup() == "admin" or xPlayer.getGroup() == "superadmin" then
if xPlayer.getGroup() == "admin" or xPlayer.getGroup() == "admin" then
TriggerClientEvent("esx_scoreboard:toggleID", source)
else
TriggerClientEvent("chatMessage", source, "[CONSOLE]", { 255, 0, 0 }, " ^0Shoma ^1Admin ^0nistid!")
Expand Down

0 comments on commit 2c77a9f

Please sign in to comment.