-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
113 lines (103 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
106
107
108
109
110
111
112
113
QBCore = exports['qb-core']:GetCoreObject()
PlayerJob = {}
local DutyBlips = {}
local ShowAll = false
-- Functions
local function CreateDutyBlips(playerId, playerLabel, playerLocation)
local ped = GetPlayerPed(playerId)
if playerId ~= PlayerId() then
local blip = GetBlipFromEntity(ped)
if not DoesBlipExist(blip) then
if NetworkIsPlayerActive(playerId) then
blip = AddBlipForEntity(ped)
else
blip = AddBlipForCoord(playerLocation.x, playerLocation.y, playerLocation.z)
end
SetBlipSprite(blip, 1)
ShowHeadingIndicatorOnBlip(blip, true)
SetBlipRotation(blip, math.ceil(playerLocation.w))
SetBlipScale(blip, 1.0)
SetBlipColour(blip, 5)
SetBlipCategory(blip, 7)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName('STRING')
AddTextComponentSubstringPlayerName(playerLabel)
EndTextCommandSetBlipName(blip)
DutyBlips[#DutyBlips + 1] = blip
end
end
end
RegisterNetEvent('jobblips:client:toggleShowAll', function()
ShowAll = not ShowAll
end)
RegisterNetEvent('jobblips:client:UpdateBlips', function(players)
if ShowAll or (PlayerJob and PlayerJob.onduty) then
if DutyBlips then
for _, v in pairs(DutyBlips) do
RemoveBlip(v)
end
end
DutyBlips = {}
if ShowAll or (PlayerJob.name ~= 'unemployed' and PlayerJob.name ~= 'tow' and PlayerJob.name ~= 'hotdog' and PlayerJob.name ~= 'crazytaxi') then
if players then
for _, data in pairs(players) do
if ShowAll or PlayerJob.name == data.job.name or (PlayerJob.type == "leo" and PlayerJob.type == data.job.type) then
local id = GetPlayerFromServerId(data.source)
CreateDutyBlips(id, data.label, data.location)
end
end
end
end
end
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
AddTextEntry('BLIP_OTHPLYR', PlayerJob.label)
if DutyBlips then
for _, v in pairs(DutyBlips) do
RemoveBlip(v)
end
end
DutyBlips = {}
PlayerJob = JobInfo
end)
AddEventHandler('onResourceStart', function(resourceName)
if GetCurrentResourceName() == resourceName then
local player = QBCore.Functions.GetPlayerData()
PlayerJob = player.job
end
end)
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
local player = QBCore.Functions.GetPlayerData()
PlayerJob = player.job
TriggerServerEvent('jobblips:server:UpdateBlips')
AddTextEntry('BLIP_OTHPLYR', PlayerJob.label)
if DutyBlips then
for _, v in pairs(DutyBlips) do
RemoveBlip(v)
end
end
DutyBlips = {}
end)
RegisterNetEvent('QBCore:Client:SetDuty', function(newDuty)
PlayerJob.onduty = newDuty
end)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
PlayerJob = {}
if DutyBlips then
for _, v in pairs(DutyBlips) do
RemoveBlip(v)
end
DutyBlips = {}
end
end)
CreateThread(function()
Caffe = AddBlipForCoord(288.27, -920.12, 29.47)
SetBlipSprite (Caffe, 214)
SetBlipDisplay(Caffe, 4)
SetBlipScale (Caffe, 0.5)
SetBlipAsShortRange(Caffe, true)
SetBlipColour(Caffe, 75)
BeginTextCommandSetBlipName("STRING")
AddTextComponentSubstringPlayerName("Cafe")
EndTextCommandSetBlipName(Caffe)
end)