-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcl_playerBlips.lua
106 lines (91 loc) · 2.54 KB
/
cl_playerBlips.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
local createdPlayerBlips = {}
local get_player_from_server_id = GetPlayerFromServerId
local get_player_ped = GetPlayerPed
local get_blip_from_entity = GetBlipFromEntity
local add_blip_for_entity = AddBlipForEntity
local network_is_player_active = NetworkIsPlayerActive
local does_blip_exist = DoesBlipExist
local remove_blip = RemoveBlip
local set_blip_sprite = SetBlipSprite
local set_blip_colour = SetBlipColour
local set_blip_scale = SetBlipScale
local set_blip_category = SetBlipCategory
local set_blip_as_short_range = SetBlipAsShortRange
local show_heading_indicator_on_blip = ShowHeadingIndicatorOnBlip
local function createBlip(player)
if player == Cache.ClientPlayerId or player == -1 then
return
end
local ped = get_player_ped(player)
local blip = get_blip_from_entity(ped)
if blip <= 0 then
blip = AddBlipForEntity(ped)
set_blip_scale(blip, 0.75)
show_heading_indicator_on_blip(blip, false)
set_blip_category(blip, 7)
set_blip_sprite(blip, 1)
set_blip_colour(blip, 6)
set_blip_as_short_range(blip, true)
createdPlayerBlips[player] = blip
end
end
AddEventHandler(
"gameEventTriggered",
function(name, args)
if name == "CEventNetworkEntityDamage" then
local isDead = args[4] == 1
if isDead then
local victim = args[1]
if victim == Cache.ClientPedId then
return
end
local blip = get_blip_from_entity(victim)
if blip > 0 then
set_blip_sprite(blip, 274)
set_blip_colour(blip, 40)
end
end
end
end
)
RegisterNetEvent("onPlayerRespawned")
AddEventHandler(
"onPlayerRespawned",
function(netId)
local player = get_player_from_server_id(netId)
if player == Cache.ClientPlayerId then
return
end
local ped = get_player_ped(player)
local blip = get_blip_from_entity(ped)
if blip > 0 then
set_blip_sprite(blip, 1)
set_blip_colour(blip, 6)
else
createBlip(player)
end
end
)
Citizen.CreateThread(
function()
while true do
Wait(1000)
for _, player in ipairs(Cache.ActivePlayers) do
if player ~= -1 then
if not createdPlayerBlips[player] then
createBlip(player)
end
end
end
for player, blip in pairs(createdPlayerBlips) do
-- check if player is still active
if not network_is_player_active(player) and player ~= -1 then
if does_blip_exist(blip) then
remove_blip(blip)
end
createdPlayerBlips[player] = nil
end
end
end
end
)