-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathclient.lua
105 lines (95 loc) · 3.5 KB
/
client.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Config.IllegalActions = GlobalState.IllegalActions or Config.IllegalActions
local scoreboardOpen = false
local PlayerOptin = {}
--------------------------------------------------------------------------------
---- FUNCTIONS
--------------------------------------------------------------------------------
local function GetPlayers()
local players = {}
for _, player in ipairs(GetActivePlayers()) do
if GetPlayerPed(player) then
table.insert(players, player)
end
end
return players
end
local function DrawText3D(x, y, z, text)
SetTextScale(0.35, 0.35)
SetTextFont(4)
SetTextProportional(true)
SetTextColour(255, 255, 255, 215)
SetTextEntry("STRING")
SetTextCentre(true)
AddTextComponentString(text)
SetDrawOrigin(x,y,z, 0)
DrawText(0.0, 0.0)
local factor = (string.len(text)) / 370
DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75)
ClearDrawOrigin()
end
local function GetPlayersFromCoords(coords, distance)
local players = GetPlayers()
local closePlayers = {}
if coords == nil then
coords = GetEntityCoords(PlayerPedId())
end
if distance == nil then
distance = 5.0
end
for _, player in pairs(players) do
local target = GetPlayerPed(player)
local targetCoords = GetEntityCoords(target)
local targetdistance = #(targetCoords - vector3(coords.x, coords.y, coords.z))
if targetdistance <= distance then
table.insert(closePlayers, player)
end
end
return closePlayers
end
--------------------------------------------------------------------------------
---- EVENTS & HANDLERS
--------------------------------------------------------------------------------
AddStateBagChangeHandler('IllegalActions', 'global', function(_, _, value)
Config.IllegalActions = value
end)
--------------------------------------------------------------------------------
---- THREADS
--------------------------------------------------------------------------------
CreateThread(function()
while true do
Wait(3)
if IsControlJustReleased(0, Config.OpenKey) then -- Config Keybind
if not scoreboardOpen then
exports['qbr-core']:TriggerCallback('qbr-scoreboard:server:GetPlayersArrays', function(playerList)
exports['qbr-core']:TriggerCallback('qbr-scoreboard:server:GetActivity', function(cops, ambulance)
PlayerOptin = playerList
Config.CurrentCops = cops
SendNUIMessage({
action = "open",
players = GlobalState['Count:Players'],
maxPlayers = Config.MaxPlayers,
requiredCops = Config.IllegalActions,
currentCops = Config.CurrentCops,
currentAmbulance = ambulance
})
scoreboardOpen = true
end)
end)
else
SendNUIMessage({action = "close"})
scoreboardOpen = false
end
if scoreboardOpen then
for _, player in pairs(GetPlayersFromCoords(GetEntityCoords(PlayerPedId()), 10.0)) do
local PlayerId = GetPlayerServerId(player)
local PlayerPed = GetPlayerPed(player)
local PlayerName = GetPlayerName(player)
local PlayerCoords = GetEntityCoords(PlayerPed)
if not PlayerOptin[PlayerId].permission then
DrawText3D(PlayerCoords.x, PlayerCoords.y, PlayerCoords.z + 1.0, '['..PlayerId..']')
end
end
end
end
end
end)