Skip to content

Commit 9f22e55

Browse files
authored
Merge pull request #9 from Xogy/master
qbcore, esx, newest esx exports supports, optimalization.
2 parents 9d48eea + 8fe93e5 commit 9f22e55

File tree

12 files changed

+335
-115
lines changed

12 files changed

+335
-115
lines changed

README.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@ Eazy tag system with configuration
77

88
**Installation**
99
1) Put into relisoft_tag folder into your resource folder
10-
2) Start after es_extended in your server.cfg
10+
2) Start after es_extended/qbcore in your server.cfg
1111
3) Edit config.lua file to fit your needs
1212

1313
**Configurations**
1414

1515
`Config.SeeOwnLabel = true/false`
1616
- if true you will be see your own tag above yourself
1717

18-
`Config.SeeDistance = 100`
19-
- distance on which will other player will see your tag
20-
2118
`Config.TextSize = 1.5`
2219
- font size for tags more is bigger
2320

@@ -27,28 +24,37 @@ Eazy tag system with configuration
2724
`Config.NearCheckWait = 500`
2825
- miliseconds to check if player is near any admin
2926

30-
`Config.TagByPermission = true`
31-
- with this option tag system will use xPlayer.getPermission() function
32-
and labels for tags will be get by permission level not group, you have to have
33-
older ESX to have this function, its deprecated in newer versions.
27+
28+
- You can change your labels for admin groups in here
3429
```
3530
Config.GroupLabels = {
36-
helper = "HELPER",
37-
mod = "~g~MODERATOR",
38-
admin = "~b~ADMINISTRATOR",
39-
superadmin = "~r~GOD",
40-
}
41-
42-
Config.PermissionLabels = {
43-
[1] = "HELPER",
44-
[2] = "~g~MODERATOR",
45-
[3] = "~b~ADMINISTRATOR",
46-
[4] = "~r~GOD",
47-
[5] = "~r~GOD",
31+
ESX = {
32+
-- group system that used to work on numbers only
33+
[1] = {
34+
[1] = "HELPER",
35+
[2] = "~g~MODERATOR",
36+
[3] = "~b~ADMINISTRATOR",
37+
[4] = "~r~GOD",
38+
[5] = "~r~GOD",
39+
},
40+
-- group system that works on name
41+
[1] = {
42+
helper = "HELPER",
43+
mod = "~g~MODERATOR",
44+
admin = "~b~ADMINISTRATOR",
45+
superadmin = "~r~GOD",
46+
},
47+
},
48+
49+
QBCore = {
50+
-- group system that works on ACE
51+
[1] = {
52+
god = "~r~GOD",
53+
admin = "~b~ADMINISTRATOR",
54+
mod = "~g~MODERATOR",
55+
},
56+
}
4857
}
4958
```
5059
- Settings for tag labels, key in table is for group or permission level, you can change it
51-
to fit your needs.
52-
53-
**Dependency**
54-
- es_extended
60+
to fit your needs.

client/main.lua

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
-- relisoft.cz
2-
-- Some-RP.cz
3-
-- forum.some-rp.cz
1+
-- store.rcore.cz
42

5-
ESX = nil
63
local currentAdminPlayers = {}
74
local visibleAdmins = {}
8-
9-
Citizen.CreateThread(function()
10-
while ESX == nil do
11-
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
12-
Citizen.Wait(0)
13-
end
14-
end)
5+
local closeAdmins = {}
156

167
RegisterNetEvent('relisoft_tag:set_admins')
178
AddEventHandler('relisoft_tag:set_admins', function(admins)
@@ -23,9 +14,8 @@ AddEventHandler('relisoft_tag:set_admins', function(admins)
2314
end
2415
end)
2516

26-
RegisterNetEvent('esx:playerLoaded')
27-
AddEventHandler('esx:playerLoaded', function()
28-
ESX.TriggerServerCallback('relisoft_tag:getAdminsPlayers', function(admins)
17+
CreateThread(function()
18+
callCallback('getAdminsPlayers', function(admins)
2919
currentAdminPlayers = admins
3020
end)
3121
end)
@@ -36,7 +26,7 @@ function draw3DText(pos, text, options)
3626
local scaleOption = options.size or 0.8
3727

3828
local camCoords = GetGameplayCamCoords()
39-
local dist = #(vector3(camCoords.x, camCoords.y, camCoords.z) - vector3(pos.x, pos.y, pos.z))
29+
local dist = #(camCoords - pos)
4030
local scale = (scaleOption / dist) * 2
4131
local fov = (1 / GetGameplayCamFov()) * 100
4232
local scaleMultiplier = scale * fov
@@ -57,7 +47,7 @@ end
5747

5848
Citizen.CreateThread(function()
5949
while true do
60-
Citizen.Wait(Config.NearCheckWait)
50+
Wait(Config.NearCheckWait)
6151
local ped = PlayerPedId()
6252
local pedCoords = GetEntityCoords(ped)
6353
for k, v in pairs(currentAdminPlayers) do
@@ -67,7 +57,7 @@ Citizen.CreateThread(function()
6757
local adminCoords = GetEntityCoords(adminPed)
6858

6959
local distance = #(adminCoords - pedCoords)
70-
if distance < (Config.SeeDistance) then
60+
if distance < 40 then
7161
visibleAdmins[v.source] = v
7262
else
7363
visibleAdmins[v.source] = nil
@@ -78,47 +68,62 @@ Citizen.CreateThread(function()
7868
end)
7969

8070
CreateThread(function()
81-
local wtt = 500
8271
while true do
83-
Wait(wtt)
84-
if next(visibleAdmins) ~= nil then
85-
for k, v in pairs(visibleAdmins) do
86-
local playerServerID = GetPlayerFromServerId(v.source)
87-
if playerServerID ~= -1 then
88-
local adminPed = GetPlayerPed(playerServerID)
89-
local adminCoords = GetEntityCoords(adminPed)
90-
local x, y, z = table.unpack(adminCoords)
91-
z = z + Config.ZOffset
72+
Wait(500)
73+
closeAdmins = {}
74+
for k, v in pairs(visibleAdmins) do
75+
local playerServerID = GetPlayerFromServerId(v.source)
76+
if playerServerID ~= -1 then
77+
local adminPed = GetPlayerPed(playerServerID)
78+
local label
79+
80+
if v.permission then
81+
label = Config.GroupLabels.ESX[1][v.permission]
82+
end
83+
84+
if v.group then
85+
label = Config.GroupLabels.ESX[2][v.group]
86+
end
87+
88+
if v.qbcore then
89+
label = Config.GroupLabels.QBCore[1][v.qbcore]
90+
end
9291

93-
local label
94-
if GetPlayerName(PlayerPedId()) == 'Kouba' then
95-
label = "CoOnwer"
96-
end
97-
if Config.TagByPermission then
98-
label = Config.PermissionLabels[v.permission]
99-
else
100-
label = Config.GroupLabels[v.group]
101-
end
10292

103-
if label then
104-
if v.source == GetPlayerServerId(PlayerId()) then
105-
if Config.SeeOwnLabel == true then
106-
draw3DText(vector3(x, y, z), label, {
107-
size = Config.TextSize
108-
})
109-
wtt = 0
110-
end
111-
else
112-
draw3DText(vector3(x, y, z), label, {
93+
if label then
94+
closeAdmins[playerServerID] = {
95+
ped = adminPed,
96+
label = label,
97+
source = v.source,
98+
self = v.source == GetPlayerServerId(PlayerId()),
99+
}
100+
end
101+
end
102+
end
103+
end
104+
end)
105+
106+
CreateThread(function()
107+
while true do
108+
Wait(0)
109+
if next(closeAdmins) ~= nil then
110+
for k, v in pairs(closeAdmins) do
111+
if v.label then
112+
if v.self then
113+
if Config.SeeOwnLabel == true then
114+
draw3DText(GetEntityCoords(v.ped) + Config.Offset, v.label, {
113115
size = Config.TextSize
114116
})
115-
wtt = 0
116117
end
118+
else
119+
draw3DText(GetEntityCoords(v.ped) + Config.Offset, v.label, {
120+
size = Config.TextSize
121+
})
117122
end
118123
end
119124
end
120125
else
121-
wtt = 1000
126+
Wait(1000)
122127
end
123128
end
124129
end)

config.lua

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Config = {}
2+
3+
-- Framework.ESX
4+
-- Framework.QBCORE
5+
Config.Framework = Framework.ESX
6+
7+
Config.Locale = "en"
8+
9+
Config.SeeOwnLabel = true
10+
11+
Config.TextSize = 0.8
12+
Config.Offset = vector3(0, 0, 1.2)
13+
Config.NearCheckWait = 500
14+
15+
Config.GroupLabels = {
16+
ESX = {
17+
-- group system that used to work on numbers only
18+
[1] = {
19+
[1] = "HELPER",
20+
[2] = "~g~MODERATOR",
21+
[3] = "~b~ADMINISTRATOR",
22+
[4] = "~r~GOD",
23+
[5] = "~r~GOD",
24+
},
25+
-- group system that works on name
26+
[2] = {
27+
helper = "HELPER",
28+
mod = "~g~MODERATOR",
29+
admin = "~b~ADMINISTRATOR",
30+
superadmin = "~r~GOD",
31+
},
32+
},
33+
34+
QBCore = {
35+
-- group system that works on ACE
36+
[1] = {
37+
god = "~r~GOD",
38+
admin = "~b~ADMINISTRATOR",
39+
mod = "~g~MODERATOR",
40+
},
41+
}
42+
}

config/config.lua

Lines changed: 0 additions & 21 deletions
This file was deleted.

fxmanifest.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@ fx_version 'adamant'
22
games {'common'}
33

44
client_scripts {
5-
'config/config.lua',
6-
'client/main.lua'
5+
'utils/client/callback.lua',
6+
'client/main.lua',
77
}
88

99
server_scripts {
10-
'config/config.lua',
11-
'server/main.lua'
10+
'utils/server/callback.lua',
11+
'server/main.lua',
12+
}
13+
14+
shared_scripts {
15+
'utils/const.lua',
16+
'config.lua',
17+
'utils/shared.lua',
18+
'locales/*.lua',
1219
}

locales/cs.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Locales["cs"] = {
2+
["tag_on"] = "Právě jste si zapl tag",
3+
["tag_off"] = "Právě jste si vypnul tag",
4+
}

locales/en.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Locales["en"] = {
2+
["tag_on"] = "You just turned on your tag",
3+
["tag_off"] = "You just turned off your tag",
4+
}

0 commit comments

Comments
 (0)