-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.lua
More file actions
103 lines (85 loc) · 3.67 KB
/
client.lua
File metadata and controls
103 lines (85 loc) · 3.67 KB
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
--[[
───────────────────────────────────────────────────────────────
hsDevelopment 911 Script - Created by hsDevelopment Team!
Version: 1.0.2
Release Date: October 2025
Support: https://hammity.app/invite/t584eX9X
───────────────────────────────────────────────────────────────
]]
local activeBlips = {}
RegisterNetEvent('hsDevelopment-911:CreateCallBlip')
AddEventHandler('hsDevelopment-911:CreateCallBlip', function(callID, message, x, y, onDuty)
local ped = PlayerPedId()
local inEmergencyVehicle = false
-- Check if in emergency vehicle
if IsPedInAnyVehicle(ped, false) then
local veh = GetVehiclePedIsIn(ped, false)
if veh and GetVehicleClass(veh) == 18 then
inEmergencyVehicle = true
end
end
-- Only show call if on-duty or in emergency vehicle
if onDuty or inEmergencyVehicle then
-- Chat notification
TriggerEvent('chat:addMessage', {
args = { string.format("^5[^911^5] ^3INCOMING CALL: ^0%s | Use ^2/call %s", message, callID) }
})
-- Map blip (always visible to responders)
if Config.MapBlip.Enabled then
-- Remove old blip if exists
if activeBlips[callID] then
RemoveBlip(activeBlips[callID])
end
local blip = AddBlipForCoord(x, y, 0.0)
SetBlipSprite(blip, Config.MapBlip.Sprite)
SetBlipColour(blip, Config.MapBlip.Color)
SetBlipScale(blip, Config.MapBlip.Scale)
SetBlipAsShortRange(blip, false)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(Config.MapBlip.Text)
EndTextCommandSetBlipName(blip)
activeBlips[callID] = blip
-- Auto-remove after 5 minutes
Citizen.SetTimeout(5 * 60 * 1000, function()
if activeBlips[callID] then
RemoveBlip(activeBlips[callID])
activeBlips[callID] = nil
end
end)
end
end
end)
RegisterNetEvent("hsDevelopment-911:SetWaypoint")
AddEventHandler("hsDevelopment-911:SetWaypoint", function(x, y)
-- Set the waypoint
SetNewWaypoint(x, y)
-- Optional: create a short-lived blip to mark the exact location
if Config.MapBlip.Enabled then
local blip = AddBlipForCoord(x, y, 0.0)
SetBlipSprite(blip, Config.MapBlip.Sprite)
SetBlipColour(blip, Config.MapBlip.Color)
SetBlipScale(blip, Config.MapBlip.Scale)
SetBlipAsShortRange(blip, false)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Responding to 911")
EndTextCommandSetBlipName(blip)
Citizen.SetTimeout(60 * 1000, function() RemoveBlip(blip) end)
end
end)
RegisterNetEvent('hsDevelopment-911:CheckEmergencyVehicle')
AddEventHandler('hsDevelopment-911:CheckEmergencyVehicle', function(callID, message, onDuty)
local ped = PlayerPedId()
local inEmergencyVehicle = false
if IsPedInAnyVehicle(ped, false) then
local veh = GetVehiclePedIsIn(ped, false)
if veh and GetVehicleClass(veh) == 18 then -- emergency vehicle
inEmergencyVehicle = true
end
end
-- Display call if on foot and on-duty OR in an emergency vehicle
if onDuty or inEmergencyVehicle then
TriggerEvent('chat:addMessage', {
args = { string.format("^5[^911^5] ^3INCOMING CALL: ^0%s | Use ^2/call %s", message, callID) }
})
end
end)