Skip to content

Commit e61cd1f

Browse files
alertTime editable per alert (#240)
* Update README.md * Update alerts.lua * Update main.lua * Update config.lua * Update main.lua * final fix XD final fix XD * updated readme, should be fine now updated readme, should be fine now * Update config.lua * Updated instructions --------- Co-authored-by: MonkeyWhisper <82112471+MonkeyWhisper@users.noreply.github.com>
1 parent faef67c commit e61cd1f

4 files changed

Lines changed: 50 additions & 4 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ Dispatch notifications are sent containing only the alert name, omitting additio
9696
- On shared/config.lua make set Config.Debug = true to test calls as police officer.(ONLY to be used as testing, make sure to disable on live production)
9797

9898
* How to change colors of the calls?
99-
- Priority 1 is red and priority 2 is normal on the config.
99+
- Priority 1 is red and priority 2 is normal on the config.
100+
101+
* To increase the time that calls are shown on the screen, do the following:
102+
- Find the "alerts.lua" file in the client folder.
103+
- Open this file with a text editor or a development tool like Visual Studio Code.
104+
- Look for the code "alertTime = nil".
105+
- Replace "nil" with the number of seconds you want the calls to display. For example, setting "alertTime = 25" means calls will be shown for 25 seconds.
100106

101107
# Credits
102108
* [OK1ez](https://github.com/OK1ez)

client/alerts.lua

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ local function VehicleTheft()
1616
color = vehicle.color,
1717
class = vehicle.class,
1818
doors = vehicle.doors,
19+
alertTime = nil,
1920
jobs = { 'leo' }
2021
}
2122

@@ -36,6 +37,7 @@ local function Shooting()
3637
street = GetStreetAndZone(coords),
3738
gender = GetPlayerGender(),
3839
weapon = GetWeaponName(),
40+
alertTime = nil,
3941
jobs = { 'leo' }
4042
}
4143

@@ -56,6 +58,7 @@ local function Hunting()
5658
coords = coords,
5759
gender = GetPlayerGender(),
5860
street = GetStreetAndZone(coords),
61+
alertTime = nil,
5962
jobs = { 'leo' }
6063
}
6164

@@ -82,6 +85,7 @@ local function VehicleShooting()
8285
color = vehicle.color,
8386
class = vehicle.class,
8487
doors = vehicle.doors,
88+
alertTime = nil,
8589
jobs = { 'leo' }
8690
}
8791

@@ -107,6 +111,7 @@ local function SpeedingVehicle()
107111
color = vehicle.color,
108112
class = vehicle.class,
109113
doors = vehicle.doors,
114+
alertTime = nil,
110115
jobs = { 'leo' }
111116
}
112117

@@ -126,6 +131,7 @@ local function Fight()
126131
coords = coords,
127132
gender = GetPlayerGender(),
128133
street = GetStreetAndZone(coords),
134+
alertTime = nil,
129135
jobs = { 'leo' }
130136
}
131137

@@ -145,6 +151,7 @@ local function PrisonBreak()
145151
coords = coords,
146152
gender = GetPlayerGender(),
147153
street = GetStreetAndZone(coords),
154+
alertTime = nil,
148155
jobs = { 'leo' }
149156
}
150157

@@ -165,6 +172,7 @@ local function StoreRobbery(camId)
165172
gender = GetPlayerGender(),
166173
street = GetStreetAndZone(coords),
167174
camId = camId,
175+
alertTime = nil,
168176
jobs = { 'leo' }
169177
}
170178

@@ -185,6 +193,7 @@ local function FleecaBankRobbery(camId)
185193
gender = GetPlayerGender(),
186194
street = GetStreetAndZone(coords),
187195
camId = camId,
196+
alertTime = nil,
188197
jobs = { 'leo' }
189198
}
190199

@@ -205,6 +214,7 @@ local function PaletoBankRobbery(camId)
205214
gender = GetPlayerGender(),
206215
street = GetStreetAndZone(coords),
207216
camId = camId,
217+
alertTime = nil,
208218
jobs = { 'leo' }
209219
}
210220

@@ -225,6 +235,7 @@ local function PacificBankRobbery(camId)
225235
gender = GetPlayerGender(),
226236
street = GetStreetAndZone(coords),
227237
camId = camId,
238+
alertTime = nil,
228239
jobs = { 'leo' }
229240
}
230241

@@ -245,6 +256,7 @@ local function VangelicoRobbery(camId)
245256
gender = GetPlayerGender(),
246257
street = GetStreetAndZone(coords),
247258
camId = camId,
259+
alertTime = nil,
248260
jobs = { 'leo' }
249261
}
250262

@@ -264,6 +276,7 @@ local function HouseRobbery()
264276
coords = coords,
265277
gender = GetPlayerGender(),
266278
street = GetStreetAndZone(coords),
279+
alertTime = nil,
267280
jobs = { 'leo' }
268281
}
269282

@@ -283,6 +296,7 @@ local function YachtHeist()
283296
coords = coords,
284297
gender = GetPlayerGender(),
285298
street = GetStreetAndZone(coords),
299+
alertTime = nil,
286300
jobs = { 'leo' }
287301
}
288302

@@ -302,6 +316,7 @@ local function DrugSale()
302316
coords = coords,
303317
gender = GetPlayerGender(),
304318
street = GetStreetAndZone(coords),
319+
alertTime = nil,
305320
jobs = { 'leo' }
306321
}
307322

@@ -321,6 +336,7 @@ local function SuspiciousActivity()
321336
coords = coords,
322337
gender = GetPlayerGender(),
323338
street = GetStreetAndZone(coords),
339+
alertTime = nil,
324340
jobs = { 'leo' }
325341
}
326342

@@ -346,6 +362,7 @@ local function CarJacking(vehicle)
346362
color = vehicle.color,
347363
class = vehicle.class,
348364
doors = vehicle.doors,
365+
alertTime = nil,
349366
jobs = { 'leo' }
350367
}
351368

@@ -365,6 +382,7 @@ local function InjuriedPerson()
365382
coords = coords,
366383
gender = GetPlayerGender(),
367384
street = GetStreetAndZone(coords),
385+
alertTime = 10,
368386
jobs = { 'ems' }
369387
}
370388

@@ -384,6 +402,7 @@ local function DeceasedPerson()
384402
coords = coords,
385403
gender = GetPlayerGender(),
386404
street = GetStreetAndZone(coords),
405+
alertTime = 10,
387406
jobs = { 'ems' }
388407
}
389408

@@ -405,6 +424,7 @@ local function OfficerDown()
405424
street = GetStreetAndZone(coords),
406425
name = PlayerData.charinfo.firstname .. " " .. PlayerData.charinfo.lastname,
407426
callsign = PlayerData.metadata["callsign"],
427+
alertTime = 10,
408428
jobs = { 'ems', 'leo' }
409429
}
410430

@@ -428,6 +448,7 @@ local function OfficerBackup()
428448
street = GetStreetAndZone(coords),
429449
name = PlayerData.charinfo.firstname .. " " .. PlayerData.charinfo.lastname,
430450
callsign = PlayerData.metadata["callsign"],
451+
alertTime = 10,
431452
jobs = { 'ems', 'leo' }
432453
}
433454

@@ -451,6 +472,7 @@ local function OfficerInDistress()
451472
street = GetStreetAndZone(coords),
452473
name = PlayerData.charinfo.firstname .. " " .. PlayerData.charinfo.lastname,
453474
callsign = PlayerData.metadata["callsign"],
475+
alertTime = 10,
454476
jobs = { 'ems', 'leo' }
455477
}
456478

@@ -472,6 +494,7 @@ local function EmsDown()
472494
street = GetStreetAndZone(coords),
473495
name = PlayerData.charinfo.firstname .. " " .. PlayerData.charinfo.lastname,
474496
callsign = PlayerData.metadata["callsign"],
497+
alertTime = 10,
475498
jobs = { 'ems', 'leo' }
476499
}
477500

@@ -493,6 +516,7 @@ local function Explosion()
493516
coords = coords,
494517
gender = GetPlayerGender(),
495518
street = GetStreetAndZone(coords),
519+
alertTime = nil,
496520
jobs = { 'leo' }
497521
}
498522

@@ -522,6 +546,7 @@ local function CustomAlert(data)
522546
name = data.name or nil,
523547
vehicle = data.model or nil,
524548
plate = data.plate or nil,
549+
alertTime = data.alertTime or nil,
525550
doorCount = data.doorCount or nil,
526551
automaticGunfire = data.automaticGunfire or false,
527552
alert = {
@@ -562,6 +587,7 @@ local function PhoneCall(message, anonymous, job, type)
562587
number = anonymous and locale('hidden_number') or PlayerData.charinfo.phone,
563588
information = message,
564589
street = GetStreetAndZone(coords),
590+
alertTime = nil,
565591
jobs = job
566592
}
567593

@@ -591,6 +617,7 @@ local function ArtGalleryRobbery()
591617
coords = coords,
592618
gender = GetPlayerGender(),
593619
street = GetStreetAndZone(coords),
620+
alertTime = nil,
594621
jobs = { 'leo' }
595622
}
596623
TriggerServerEvent('ps-dispatch:server:notify', dispatchData)
@@ -609,6 +636,7 @@ local function HumaneRobbery()
609636
coords = coords,
610637
gender = GetPlayerGender(),
611638
street = GetStreetAndZone(coords),
639+
alertTime = nil,
612640
jobs = { 'leo' }
613641
}
614642
TriggerServerEvent('ps-dispatch:server:notify', dispatchData)
@@ -628,6 +656,7 @@ local function TrainRobbery()
628656
coords = coords,
629657
gender = GetPlayerGender(),
630658
street = GetStreetAndZone(coords),
659+
alertTime = nil,
631660
jobs = { 'leo' }
632661
}
633662
TriggerServerEvent('ps-dispatch:server:notify', dispatchData)
@@ -647,6 +676,7 @@ local function VanRobbery()
647676
coords = coords,
648677
gender = GetPlayerGender(),
649678
street = GetStreetAndZone(coords),
679+
alertTime = nil,
650680
jobs = { 'leo' }
651681
}
652682
TriggerServerEvent('ps-dispatch:server:notify', dispatchData)
@@ -666,6 +696,7 @@ local function UndergroundRobbery()
666696
coords = coords,
667697
gender = GetPlayerGender(),
668698
street = GetStreetAndZone(coords),
699+
alertTime = nil,
669700
jobs = { 'leo' }
670701
}
671702
TriggerServerEvent('ps-dispatch:server:notify', dispatchData)
@@ -684,6 +715,7 @@ local function DrugBoatRobbery()
684715
coords = coords,
685716
gender = GetPlayerGender(),
686717
street = GetStreetAndZone(coords),
718+
alertTime = nil,
687719
jobs = { 'leo' }
688720
}
689721

@@ -703,6 +735,7 @@ local function UnionRobbery()
703735
coords = coords,
704736
gender = GetPlayerGender(),
705737
street = GetStreetAndZone(coords),
738+
alertTime = nil,
706739
jobs = { 'leo' }
707740
}
708741

@@ -728,6 +761,7 @@ local function CarBoosting(vehicle)
728761
color = vehicle.color,
729762
class = vehicle.class,
730763
doors = vehicle.doors,
764+
alertTime = nil,
731765
jobs = { 'leo' }
732766
}
733767

@@ -747,6 +781,7 @@ local function SignRobbery()
747781
coords = coords,
748782
gender = GetPlayerGender(),
749783
street = GetStreetAndZone(coords),
784+
alertTime = nil,
750785
jobs = { 'leo'}
751786
}
752787

client/main.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,15 @@ local function setWaypoint()
8484

8585
if not data then return end
8686

87+
if data.alertTime == nil then data.alertTime = Config.AlertTime end
88+
local timer = data.alertTime * 1000
89+
8790
if not waypointCooldown and lib.table.contains(data.jobs, PlayerData.job.type) then
8891
SetNewWaypoint(data.coords.x, data.coords.y)
8992
TriggerServerEvent('ps-dispatch:server:attach', data.id, PlayerData)
9093
lib.notify({ description = locale('waypoint_set'), position = 'top', type = 'success' })
9194
waypointCooldown = true
92-
SetTimeout(Config.AlertTime * 1000, function()
95+
SetTimeout(timer, function()
9396
waypointCooldown = false
9497
end)
9598
end
@@ -244,7 +247,9 @@ local OpenDispatchMenu = lib.addKeybind({
244247

245248
-- Events
246249
RegisterNetEvent('ps-dispatch:client:notify', function(data, source)
247-
local timer = Config.AlertTime * 1000
250+
if data.alertTime == nil then data.alertTime = Config.AlertTime end
251+
local timer = data.alertTime * 1000
252+
248253
if alertsDisabled then return end
249254
if not isJobValid(data.jobs) then return end
250255
if not IsOnDuty() then return end

shared/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Config.Debug = false -- Enables debug and send alerts when leo break the law.
55

66
Config.RespondKeybind = 'E'
77
Config.OpenDispatchMenu = 'O'
8-
Config.AlertTime = 5 -- How many seconds you want the alert to stay on screen
8+
Config.AlertTime = 5 -- Specify the duration for the alert to appear on the screen. The default time is 5 seconds for all alerts. To set a different duration for specific alerts, change the value in `alertTime = nil` found in the alerts.lua file.
99

1010
Config.MaxCallList = 25 -- maximum dispatch calls in dispatch list
1111
Config.OnDutyOnly = true -- Set true if only on duty players can see the alert

0 commit comments

Comments
 (0)