-
Notifications
You must be signed in to change notification settings - Fork 22
/
cl_main.lua
2884 lines (2509 loc) · 94.1 KB
/
cl_main.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local callID = 0
-- Hunting
local inHuntingZone = false
local huntingZone = PolyZone:Create({
vector2(-1416.86, 2730.74),
vector2(-2415.01, 3701.34),
vector2(-973.52, 6225.8),
vector2(356.86, 4802.33),
vector2(-292.75, 3766.8),
vector2(62.85, 3368.78)
}, {
name="huntingZone",
minZ=-50.0,
maxZ=750.0,
debugGrid=false,
gridDivisions=25
})
huntingZone:onPlayerInOut(function(isPointInside, point)
inHuntingZone = isPointInside
end)
CreateThread(function() -- Use this only if you think/plan on restarting the resource often.
while PlayerData['cid'] == nil do
PlayerData = exports['echorp']:GetPlayerData()
Wait(5000)
end
return
end)
local currentCallSign = ""
local playerPed, playerCoords = PlayerPedId(), vec3(0, 0, 0)
local currentVehicle, inVehicle, currentlyArmed, currentWeapon = nil, false, false, `WEAPON_UNARMED`
PlayerData = {}
RegisterNetEvent('echorp:playerSpawned') -- Use this to grab player info on spawn.
AddEventHandler('echorp:playerSpawned', function(sentData) PlayerData = sentData end)
RegisterNetEvent('echorp:updateinfo')
AddEventHandler('echorp:updateinfo', function(toChange, targetData)
PlayerData[toChange] = targetData
end)
RegisterNetEvent('echorp:doLogout') -- Use this to logout.
AddEventHandler('echorp:doLogout', function(sentData)
PlayerData = {}
currentCallSign = ""
currentVehicle, inVehicle, currentlyArmed, currentWeapon = nil, false, false, `WEAPON_UNARMED`
end)
local colors = {
--[0] = "Metallic Black",
[1] = "Metallic Graphite Black",
[2] = "Metallic Black Steel",
[3] = "Metallic Dark Silver",
[4] = "Metallic Silver",
[5] = "Metallic Blue Silver",
[6] = "Metallic Steel Gray",
[7] = "Metallic Shadow Silver",
[8] = "Metallic Stone Silver",
[9] = "Metallic Midnight Silver",
[10] = "Metallic Gun Metal",
[11] = "Metallic Anthracite Grey",
[12] = "Matte Black",
[13] = "Matte Gray",
[14] = "Matte Light Grey",
[15] = "Util Black",
[16] = "Util Black Poly",
[17] = "Util Dark Silver",
[18] = "Util Silver",
[19] = "Util Gun Metal",
[20] = "Util Shadow Silver",
[21] = "Worn Black",
[22] = "Worn Graphite",
[23] = "Worn Silver Grey",
[24] = "Worn Silver",
[25] = "Worn Blue Silver",
[26] = "Worn Shadow Silver",
[27] = "Metallic Red",
[28] = "Metallic Torino Red",
[29] = "Metallic Formula Red",
[30] = "Metallic Blaze Red",
[31] = "Metallic Graceful Red",
[32] = "Metallic Garnet Red",
[33] = "Metallic Desert Red",
[34] = "Metallic Cabernet Red",
[35] = "Metallic Candy Red",
[36] = "Metallic Sunrise Orange",
[37] = "Metallic Classic Gold",
[38] = "Metallic Orange",
[39] = "Matte Red",
[40] = "Matte Dark Red",
[41] = "Matte Orange",
[42] = "Matte Yellow",
[43] = "Util Red",
[44] = "Util Bright Red",
[45] = "Util Garnet Red",
[46] = "Worn Red",
[47] = "Worn Golden Red",
[48] = "Worn Dark Red",
[49] = "Metallic Dark Green",
[50] = "Metallic Racing Green",
[51] = "Metallic Sea Green",
[52] = "Metallic Olive Green",
[53] = "Metallic Green",
[54] = "Metallic Gasoline Blue Green",
[55] = "Matte Lime Green",
[56] = "Util Dark Green",
[57] = "Util Green",
[58] = "Worn Dark Green",
[59] = "Worn Green",
[60] = "Worn Sea Wash",
[61] = "Metallic Midnight Blue",
[62] = "Metallic Dark Blue",
[63] = "Metallic Saxony Blue",
[64] = "Metallic Blue",
[65] = "Metallic Mariner Blue",
[66] = "Metallic Harbor Blue",
[67] = "Metallic Diamond Blue",
[68] = "Metallic Surf Blue",
[69] = "Metallic Nautical Blue",
[70] = "Metallic Bright Blue",
[71] = "Metallic Purple Blue",
[72] = "Metallic Spinnaker Blue",
[73] = "Metallic Ultra Blue",
[74] = "Metallic Bright Blue",
[75] = "Util Dark Blue",
[76] = "Util Midnight Blue",
[77] = "Util Blue",
[78] = "Util Sea Foam Blue",
[79] = "Uil Lightning blue",
[80] = "Util Maui Blue Poly",
[81] = "Util Bright Blue",
[82] = "Matte Dark Blue",
[83] = "Matte Blue",
[84] = "Matte Midnight Blue",
[85] = "Worn Dark blue",
[86] = "Worn Blue",
[87] = "Worn Light blue",
[88] = "Metallic Taxi Yellow",
[89] = "Metallic Race Yellow",
[90] = "Metallic Bronze",
[91] = "Metallic Yellow Bird",
[92] = "Metallic Lime",
[93] = "Metallic Champagne",
[94] = "Metallic Pueblo Beige",
[95] = "Metallic Dark Ivory",
[96] = "Metallic Choco Brown",
[97] = "Metallic Golden Brown",
[98] = "Metallic Light Brown",
[99] = "Metallic Straw Beige",
[100] = "Metallic Moss Brown",
[101] = "Metallic Biston Brown",
[102] = "Metallic Beechwood",
[103] = "Metallic Dark Beechwood",
[104] = "Metallic Choco Orange",
[105] = "Metallic Beach Sand",
[106] = "Metallic Sun Bleeched Sand",
[107] = "Metallic Cream",
[108] = "Util Brown",
[109] = "Util Medium Brown",
[110] = "Util Light Brown",
[111] = "Metallic White",
[112] = "Metallic Frost White",
[113] = "Worn Honey Beige",
[114] = "Worn Brown",
[115] = "Worn Dark Brown",
[116] = "Worn straw beige",
[117] = "Brushed Steel",
[118] = "Brushed Black steel",
[119] = "Brushed Aluminium",
[120] = "Chrome",
[121] = "Worn Off White",
[122] = "Util Off White",
[123] = "Worn Orange",
[124] = "Worn Light Orange",
[125] = "Metallic Securicor Green",
[126] = "Worn Taxi Yellow",
[127] = "police car blue",
[128] = "Matte Green",
[129] = "Matte Brown",
[130] = "Worn Orange",
[131] = "Matte White",
[132] = "Worn White",
[133] = "Worn Olive Army Green",
[134] = "Pure White",
[135] = "Hot Pink",
[136] = "Salmon pink",
[137] = "Metallic Vermillion Pink",
[138] = "Orange",
[139] = "Green",
[140] = "Blue",
[141] = "Mettalic Black Blue",
[142] = "Metallic Black Purple",
[143] = "Metallic Black Red",
[144] = "Hunter Green",
[145] = "Metallic Purple",
[146] = "Metallic V Dark Blue",
[147] = "MODSHOP BLACK1",
[148] = "Matte Purple",
[149] = "Matte Dark Purple",
[150] = "Metallic Lava Red",
[151] = "Matte Forest Green",
[152] = "Matte Olive Drab",
[153] = "Matte Desert Brown",
[154] = "Matte Desert Tan",
[155] = "Matte Foilage Green",
[156] = "DEFAULT ALLOY COLOR",
[157] = "Epsilon Blue",
[158] = "Unknown",
}
local whitelisted = {
[`WEAPON_STUNGUN`] = true,
[`WEAPON_SNOWBALL`] = true
}
CreateThread(function()
while true do
playerPed = PlayerPedId()
playerCoords = GetEntityCoords(playerPed)
currentVehicle = GetVehiclePedIsIn(playerPed, false)
currentWeapon = GetSelectedPedWeapon(playerPed)
currentlyArmed = IsPedArmed(playerPed, 7) and not whitelisted[currentWeapon]
if currentVehicle ~= 0 then inVehicle = true elseif inVehicle then inVehicle = false end
Wait(1000)
end
end)
local function getCardinalDirectionFromHeading()
local heading = GetEntityHeading(playerPed)
if heading >= 315 or heading < 45 then return "North Bound"
elseif heading >= 45 and heading < 135 then return "West Bound"
elseif heading >=135 and heading < 225 then return "South Bound"
elseif heading >= 225 and heading < 315 then return "East Bound" end
end
function GetStreetAndZone()
local coords = GetEntityCoords(playerPed)
local currentStreetHash, intersectStreetHash = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
local currentStreetName = GetStreetNameFromHashKey(currentStreetHash)
local area = GetLabelText(tostring(GetNameOfZone(coords.x, coords.y, coords.z)))
local playerStreetsLocation = area
if not zone then zone = "UNKNOWN" end
if currentStreetName ~= nil and currentStreetName ~= "" then playerStreetsLocation = currentStreetName .. ", " ..area
else playerStreetsLocation = area end
return playerStreetsLocation
end
local function GetClosestNPC(sentPos, sentDistance, sentType, sentIgnoredPed)
if sentType == 'combat' then
local allPeds = GetGamePool('CPed')
for i=1, #allPeds do
local ped = allPeds[i]
if DoesEntityExist(ped) then
if ped ~= sentIgnoredPed then
local dist = #(GetEntityCoords(ped) - sentPos)
if dist < sentDistance then
return ped
end
end
end
end
elseif sentType == 'gunshot' then
local allPeds = GetGamePool('CPed')
for i=1, #allPeds do
local ped = allPeds[i]
if DoesEntityExist(ped) then
local dist = #(GetEntityCoords(ped) - sentPos)
if dist < sentDistance then
if (GetPedAlertness(ped) > 0) and not IsPedAimingFromCover(ped) and not IsPedBeingStunned(ped, 0) and not IsPedDeadOrDying(ped, 1) and IsPedHuman(ped) and not IsPedInAnyPlane(ped) and not IsPedInAnyHeli(ped) and not IsPedShooting(ped) and not IsPedAPlayer(ped) then
TaskUseMobilePhoneTimed(ped, 5000)
return ped
end
end
end
end
elseif sentType == 'armed' then
local allPeds = GetGamePool('CPed')
for i=1, #allPeds do
local ped = allPeds[i]
if DoesEntityExist(ped) and not IsPedAPlayer(ped) then
local dist = #(GetEntityCoords(ped) - sentPos)
if dist < 50.0 and math.random(10) > 4 then
if not IsPedAimingFromCover(ped) and not IsPedBeingStunned(ped, 0) and not IsPedDeadOrDying(ped, 1) and IsPedHuman(ped) and not IsPedInAnyPlane(ped) and not IsPedInAnyHeli(ped) and not IsPedShooting(ped) then
TaskUseMobilePhoneTimed(ped, 5000)
return ped
end
end
end
end
else
local allPeds = GetGamePool('CPed')
for i=1, #allPeds do
local ped = allPeds[i]
if DoesEntityExist(ped) and not IsPedAPlayer(ped) then
local dist = #(GetEntityCoords(ped) - sentPos)
if dist < sentDistance then
return ped
end
end
end
end
end
local function GetPedInFront()
local plyPed = playerPed
local plyPos = GetEntityCoords(plyPed, false)
local plyOffset = GetOffsetFromEntityInWorldCoords(plyPed, 0.0, 1.3, 0.0)
local rayHandle = StartShapeTestCapsule(plyPos.x, plyPos.y, plyPos.z, plyOffset.x, plyOffset.y, plyOffset.z, 1.0, 12, plyPed, 7)
local _, _, _, _, ped = GetShapeTestResult(rayHandle)
return ped
end
local function GetVehicleDescription(sentVehicle)
if not sentVehicle or sentVehicle == nil then
local currentVehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if not DoesEntityExist(currentVehicle) then
return
end
elseif sentVehicle then
currentVehicle = sentVehicle
end
plate = GetVehicleNumberPlateText(currentVehicle)
make = GetDisplayNameFromVehicleModel(GetEntityModel(currentVehicle))
color1, color2 = GetVehicleColours(currentVehicle)
if color1 == 0 then color1 = 1 end
if color2 == 0 then color2 = 2 end
if color1 == -1 then color1 = 158 end
if color2 == -1 then color2 = 158 end
if math.random(1, 2) == math.random(1, 2) then
plate = "Unknown"
end
local dir = getCardinalDirectionFromHeading()
local vehicleData = {
model = make,
plate = plate,
firstColor = colors[color1],
secondColor = colors[color2],
heading = dir
}
return vehicleData
end
local function canPedBeUsed(ped,isGunshot,isSpeeder)
if math.random(100) > 15 then
return false
end
if ped == nil then
return false
end
if isSpeeder == nil then
isSpeeder = false
end
if ped == PlayerPedId() then
return false
end
if GetEntityHealth(ped) == 0 then
return false
end
if isSpeeder then
if not IsPedInAnyVehicle(ped, false) then
return false
end
end
if `mp_f_deadhooker` == GetEntityModel(ped) then
return false
end
local curcoords = GetEntityCoords(PlayerPedId())
local startcoords = GetEntityCoords(ped)
if #(curcoords - startcoords) < 10.0 then
return false
end
-- here we add areas that peds can not alert the police
if #(curcoords - vector3( 1088.76, -3187.51, -38.99)) < 15.0 then
return false
end
if not HasEntityClearLosToEntity(PlayerPedId(), ped, 17) and not isGunshot then
return false
end
if not DoesEntityExist(ped) then
return false
end
if IsPedAPlayer(ped) then
return false
end
if IsPedFatallyInjured(ped) then
return false
end
if IsPedArmed(ped, 7) then
return false
end
if IsPedInMeleeCombat(ped) then
return false
end
if IsPedShooting(ped) then
return false
end
if IsPedDucking(ped) then
return false
end
if IsPedBeingJacked(ped) then
return false
end
if IsPedSwimming(ped) then
return false
end
if IsPedJumpingOutOfVehicle(ped) or IsPedBeingJacked(ped) then
return false
end
local pedType = GetPedType(ped)
if pedType == 6 or pedType == 27 or pedType == 29 or pedType == 28 then
return false
end
return true
end
-- GUNSHOTS
local NulledAreas = {
[1] = vector3(102.09, -1938.74, 20.79),
[2] = vector3(-221.78, -1667.06, 34.45),
[3] = vector3(-23.24, -1462.26, 30.8),
[4] = vector3(-9.77, -1842.7, 26.15),
[5] = vector3(16.54, -1548.8, 30.75),
[6] = vector3(-120.32, -1522.75, 34.89)
}
local KnownWeapons = {
--[[ Pistols ]]--
[`weapon_pistol`] = {['weaponName'] = 'Pistol', ['isAuto'] = false},
[`weapon_pistol_mk2`] = {['weaponName'] = 'Pistol Mk II', ['isAuto'] = false},
[`weapon_combatpistol`] = {['weaponName'] = 'Combat Pistol', ['isAuto'] = false},
[`weapon_appistol`] = {['weaponName'] = 'AP Pistol', ['isAuto'] = false},
[`weapon_stungun`] = {['weaponName'] = 'Stun Gun (?)', ['isAuto'] = false},
[`weapon_pistol50`] = {['weaponName'] = 'Pistol .50', ['isAuto'] = false},
[`weapon_snspistol`] = {['weaponName'] = 'SNS Pistol', ['isAuto'] = false},
[`weapon_snspistol_mk2`] = {['weaponName'] = 'SNS Pistol Mk II', ['isAuto'] = false},
[`weapon_heavypistol`] = {['weaponName'] = 'Heavy Pistol', ['isAuto'] = false},
[`weapon_vintagepistol`] = {['weaponName'] = 'Vintage Pistol', ['isAuto'] = false},
[`weapon_flaregun`] = {['weaponName'] = 'Flare Gun', ['isAuto'] = false},
[`weapon_marksmanpistol`] = {['weaponName'] = 'Marksman Pistol', ['isAuto'] = false},
[`weapon_revolver`] = {['weaponName'] = 'Heavy Revolver', ['isAuto'] = false},
[`weapon_revolver_mk2`] = {['weaponName'] = 'Heavy Revolver Mk II', ['isAuto'] = false},
[`weapon_doubleaction`] = {['weaponName'] = 'Double Action Revolver', ['isAuto'] = false},
[`weapon_raypistol`] = {['weaponName'] = 'Up-n-Atomizer', ['isAuto'] = false},
[`weapon_ceramicpistol`] = {['weaponName'] = 'Ceramic Pistol', ['isAuto'] = false},
[`weapon_navyrevolver`] = {['weaponName'] = 'Navy Revolver', ['isAuto'] = false},
--[[ Submachine Guns ]]--
[`weapon_microsmg`] = {['weaponName'] = 'Micro SMG', ['isAuto'] = true},
[`weapon_smg`] = {['weaponName'] = 'SMG', ['isAuto'] = true},
[`weapon_smg_mk2`] = {['weaponName'] = 'SMG Mk II', ['isAuto'] = true},
[`weapon_assaultsmg`] = {['weaponName'] = 'Assault SMG', ['isAuto'] = true},
[`weapon_combatpdw`] = {['weaponName'] = 'Combat PDW', ['isAuto'] = true},
[`weapon_machinepistol`] = {['weaponName'] = 'Machine Pistol', ['isAuto'] = true},
[`weapon_minismg`] = {['weaponName'] = 'Mini SMG', ['isAuto'] = true},
[`weapon_raycarbine`] = {['weaponName'] = 'Unholy Hellbringer', ['isAuto'] = true},
--[[ Shotguns ]]--
[`weapon_pumpshotgun`] = {['weaponName'] = 'Pump Shotgun', ['isAuto'] = false},
[`weapon_pumpshotgun_mk2`] = {['weaponName'] = 'Pump Shotgun Mk II', ['isAuto'] = false},
[`weapon_sawnoffshotgun`] = {['weaponName'] = 'Sawed-Off Shotgun', ['isAuto'] = false},
[`weapon_assaultshotgun`] = {['weaponName'] = 'Assault Shotgun', ['isAuto'] = true},
[`weapon_bullpupshotgun`] = {['weaponName'] = 'Bullpup Shotgun', ['isAuto'] = true},
[`weapon_musket`] = {['weaponName'] = 'Musket', ['isAuto'] = false},
[`weapon_heavyshotgun`] = {['weaponName'] = 'Heavy Shotgun', ['isAuto'] = true},
[`weapon_dbshotgun`] = {['weaponName'] = 'Double Barrel Shotgun', ['isAuto'] = false},
[`weapon_autoshotgun`] = {['weaponName'] = 'Sweeper Shotgun', ['isAuto'] = true},
--[[ Assault Rifle ]]--
[`weapon_assaultrifle`] = {['weaponName'] = 'Assault Rifle', ['isAuto'] = true},
[`weapon_assaultrifle_mk2`] = {['weaponName'] = 'Assault Rifle Mk II', ['isAuto'] = true},
[`weapon_carbinerifle`] = {['weaponName'] = 'Carbine Rifle', ['isAuto'] = true},
[`weapon_carbinerifle_mk2`] = {['weaponName'] = 'Carbine Rifle Mk II', ['isAuto'] =true},
[`weapon_advancedrifle`] = {['weaponName'] = 'Advanced Rifle', ['isAuto'] =true},
[`weapon_specialcarbine`] = {['weaponName'] = 'Special Carbine', ['isAuto'] =true},
[`weapon_specialcarbine_mk2`] = {['weaponName'] = 'Special Carbine Mk II', ['isAuto'] =true},
[`weapon_bullpuprifle`] = {['weaponName'] = 'Bullpup Rifle', ['isAuto'] =true},
[`weapon_bullpuprifle_mk2`] = {['weaponName'] = 'Bullpup Rifle Mk II', ['isAuto'] =true},
[`weapon_compactrifle`] = {['weaponName'] = 'Compact Rifle', ['isAuto'] =true},
--[[ LMG ]]--
[`weapon_mg`] = {['weaponName'] = 'MG', ['isAuto'] =true},
[`weapon_combatmg`] = {['weaponName'] = 'Combat MG', ['isAuto'] =true},
[`weapon_combatmg_mk2`] = {['weaponName'] = 'Combat MG Mk II', ['isAuto'] =true},
[`weapon_gusenberg`] = {['weaponName'] = 'Gusenberg Sweeper', ['isAuto'] =true},
--[[ Snooper Rifle ]]--
[`weapon_sniperrifle`] = {['weaponName'] = 'Sniper Rifle', ['isAuto'] =false},
[`weapon_heavysniper`] = {['weaponName'] = 'Heavy Rifle', ['isAuto'] =false},
[`weapon_heavysniper_mk2`] = {['weaponName'] = 'Heavy Sniper Mk II', ['isAuto'] =false},
[`weapon_marksmanrifle`] = {['weaponName'] = 'Marksman Rifle', ['isAuto'] =true},
[`weapon_marksmanrifle_mk2`] = {['weaponName'] = 'Marksman Rifle Mk II', ['isAuto'] =true},
}
CreateThread(function() -- Gun Shots
local isBusyGunShots, armed, cooldownGS, cooldownSMD = false, false, 0, 0
while true do
Wait(0)
if not isBusyGunShots then
armed = currentlyArmed
if armed and KnownWeapons[currentWeapon] then
if IsPedShooting(playerPed) and ((cooldownGS == 0) or cooldownGS - GetGameTimer() < 0) then
isBusyGunShots = true
if IsPedCurrentWeaponSilenced(playerPed) then
cooldownGS = GetGameTimer() + math.random(25000,30000) -- 20 => 25 Seconds.
TriggerEvent("civilian:alertPolice",15.0,"gunshot",0,true,inHuntingZone,currentWeapon)
elseif inVehicle then
cooldownGS = GetGameTimer() + math.random(20000,25000) -- 20 => 25 Seconds.
TriggerEvent("civilian:alertPolice",150.0,"gunshotvehicle",0,true,inHuntingZone,currentWeapon)
else
cooldownGS = GetGameTimer() + math.random(15000,20000) -- 15 => 20 Seconds.
TriggerEvent("civilian:alertPolice",550.0,"gunshot",0,true,inHuntingZone,currentWeapon)
end
isBusyGunShots = false
elseif (cooldownSMD == 0 and math.random(10) > 7) or ((cooldownSMD - GetGameTimer() < 0) and math.random(10) > 7) then
local shouldAlert = true
local myPos = GetEntityCoords(playerPed)
for i=1, #NulledAreas do
local dist = #(NulledAreas[i] - myPos)
if dist <= math.random(75, 100) then
shouldAlert = false
break
end
end
if not inVehicle and not shouldAlert then
if math.random(10) > 5 then
cooldownSMD = GetGameTimer() + math.random(45000,60000) -- 20 => 25 Seconds.
elseif not PlayerData.job.isPolice then
local closestNPC = GetClosestNPC(playerCoords, 25.0, 'armed')
if closestNPC and DoesEntityExist(closestNPC) then
cooldownSMD = GetGameTimer() + math.random(60000,90000) -- 20 => 25 Seconds.
ArmedPlayer()
end
end
end
end
else
Wait(1000)
end
else
Wait(250)
end
end
end)
function ArmedPlayer() -- When aiming weapon.
local locationInfo = GetStreetAndZone()
local gender = IsPedMale(playerPed)
local currentPos = GetEntityCoords(playerPed)
local isInVehicle = IsPedInAnyVehicle(PlayerPedId())
local vehicleData = GetVehicleDescription() or {}
local initialTenCode = "10-44"
Wait(math.random(3000, 5000))
TriggerServerEvent('erp-dispatch:armedperson', currentPos)
TriggerServerEvent('dispatch:svNotify', {
dispatchCode = initialTenCode,
firstStreet = locationInfo,
gender = gender,
model = vehicleData.model,
plate = vehicleData.plate,
priority = 3,
firstColor = vehicleData.firstColor,
secondColor = vehicleData.secondColor,
heading = vehicleData.heading,
origin = {
x = currentPos.x,
y = currentPos.y,
z = currentPos.z
},
dispatchMessage = "Brandishing",
job = {"lspd","bcso","pa","sast","sapr","sasp","doc"}
})
end
RegisterNetEvent('erp-dispatch:gunshotAlert')
AddEventHandler('erp-dispatch:gunshotAlert', function(sentCoords, isAuto, isCop)
if sentCoords then
if (PlayerData.job.isPolice) and PlayerData.job.duty == 1 then
local blipAlpha = 200
local gunshotBlip = AddBlipForRadius(sentCoords, 75.0)
SetBlipHighDetail(gunshotBlip, true)
if isCop then
SetBlipColour(gunshotBlip, 2) -- Green
elseif isAuto then
SetBlipColour(gunshotBlip, 3) -- Blue
else
SetBlipColour(gunshotBlip, 1) -- Red
end
SetBlipAlpha(gunshotBlip, blipAlpha)
SetBlipAsShortRange(gunshotBlip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString('10-60 Shots Fired')
EndTextCommandSetBlipName(gunshotBlip)
PlaySound(-1, "Lose_1st", "GTAO_FM_Events_Soundset", 0, 0, 1)
CreateThread(function()
while blipAlpha ~= 0 and DoesBlipExist(gunshotBlip) do
Citizen.Wait(math.random(20, 30) * 4)
blipAlpha = blipAlpha - 1
SetBlipAlpha(gunshotBlip, blipAlpha)
if blipAlpha == 0 then
RemoveBlip(gunshotBlip)
return
end
end
return
end)
end
end
end)
-- FIGHT IN PROGRESS
CreateThread(function() -- Fighting
local isBusy, cooldown = false, 0
while true do
Wait(0)
if not inVehicle and not isBusy and (cooldown - GetGameTimer() < 0) then
local pedinfront = GetPedInFront()
if pedinfront > 0 then
if IsPedInMeleeCombat(playerPed) and IsPedInCombat(pedinfront, playerPed) and GetClosestNPC(playerCoords, 25.0, 'combat', pedinfront) then
TriggerEvent("civilian:alertPolice",15.0,"fight",0)
cooldown = GetGameTimer() + math.random(20000,25000) -- 20 => 25 Seconds
else
Wait(1000)
end
else
Wait(1000)
end
else
Wait(1000)
end
end
end)
RegisterNetEvent('erp-dispatch:combatAlert')
AddEventHandler('erp-dispatch:combatAlert', function(sentCoords)
if sentCoords then
if (PlayerData.job.isPolice) and PlayerData.job.duty == 1 then
local alpha = 250
local combatBlip = AddBlipForCoord(sentCoords)
SetBlipScale(combatBlip, 1.3)
SetBlipSprite(combatBlip, 437)
SetBlipColour(combatBlip, 1)
SetBlipAlpha(combatBlip, alpha)
SetBlipAsShortRange(combatBlip, true)
BeginTextCommandSetBlipName("STRING") -- set the blip's legend caption
AddTextComponentString('10-11 Fight In Progress') -- to 'supermarket'
EndTextCommandSetBlipName(combatBlip)
SetBlipAsShortRange(combatBlip, 1)
PlaySound(-1, "Lose_1st", "GTAO_FM_Events_Soundset", 0, 0, 1)
CreateThread(function()
while alpha ~= 0 and DoesBlipExist(combatBlip) do
Citizen.Wait(90 * 4)
alpha = alpha - 1
SetBlipAlpha(combatBlip, alpha)
if alpha == 0 then
RemoveBlip(combatBlip)
return
end
end
return
end)
end
end
end)
RegisterNetEvent('erp-dispatch:armedperson')
AddEventHandler('erp-dispatch:armedperson', function(sentCoords)
if sentCoords then
if (PlayerData.job.isPolice) and PlayerData.job.duty == 1 then
local alpha = 250
local armedperson = AddBlipForCoord(sentCoords)
SetBlipScale(armedperson, 1.0)
SetBlipSprite(armedperson, 313)
SetBlipColour(armedperson, 1)
SetBlipAlpha(armedperson, alpha)
SetBlipAsShortRange(armedperson, true)
BeginTextCommandSetBlipName("STRING") -- set the blip's legend caption
AddTextComponentString('Armed Person') -- to 'supermarket'
EndTextCommandSetBlipName(armedperson)
SetBlipAsShortRange(armedperson, 1)
--PlaySound(-1, "Lose_1st", "GTAO_FM_Events_Soundset", 0, 0, 1)
CreateThread(function()
while alpha ~= 0 and DoesBlipExist(armedperson) do
Citizen.Wait(90 * 4)
alpha = alpha - 1
SetBlipAlpha(armedperson, alpha)
if alpha == 0 then
RemoveBlip(armedperson)
return
end
end
return
end)
end
end
end)
-- Dispatch Itself
local disableNotis, disableNotifSounds = false, false
RegisterNetEvent('erp-dispatch:manageNotifs')
AddEventHandler('erp-dispatch:manageNotifs', function(sentSetting)
local wantedSetting = tostring(sentSetting)
if wantedSetting == "on" then
disableNotis = false
disableNotifSounds = false
exports['erp_notifications']:SendAlert('inform', 'Dispatch enabled.')
elseif wantedSetting == "off" then
disableNotis = true
disableNotifSounds = true
exports['erp_notifications']:SendAlert('inform', 'Dispatch disabled.')
elseif wantedSetting == "mute" then
disableNotis = false
disableNotifSounds = true
exports['erp_notifications']:SendAlert('inform', 'Dispatch muted.')
else
exports['erp_notifications']:SendAlert('inform', 'Please choose to have dispatch as "on", "off" or "mute".', 5000)
end
end)
local function ResetMathRandom()
math.randomseed(GetCloudTimeAsInt())
end
local function randomizeBlipLocation(pOrigin)
local x = pOrigin.x
local y = pOrigin.y
local z = pOrigin.z
ResetMathRandom()
local luck = math.random(1, 2)
ResetMathRandom()
y = math.random(25) + y
ResetMathRandom()
if luck == math.random(1, 2) then
ResetMathRandom()
x = math.random(25) + x
end
return vec3(x, y, z)
end
RegisterNetEvent('alert:noPedCheck')
AddEventHandler('alert:noPedCheck', function(alertType)
if alertType == "banktruck" then
AlertBankTruck()
elseif alertType == "yacht" then
AlertYacht()
elseif alertType == "art" then
AlertArt()
end
end)
RegisterNetEvent('civilian:alertPolice')
AddEventHandler("civilian:alertPolice",function(basedistance,alertType,objPassed,isGunshot,isHunting,sentWeapon)
if PlayerData.job == nil then return end;
local isPolice = PlayerData.job.isPolice
local object = objPassed
if not daytime then
basedistance = basedistance * 8.2
else
basedistance = basedistance * 3.45
end
if alertType == "personRobbed" --[[and not isPolice]] then
AlertpersonRobbed()
end
if isGunshot == nil then
isGunshot = false
end
local plyCoords = GetEntityCoords(PlayerPedId())
if isGunshot then
shittypefuckyou = 'gunshot'
end
local nearNPC
if alertType == 'drugsale' then
nearNPC = GetClosestNPC(plyCoords, basedistance, 'combat', object)
else
nearNPC = GetClosestNPC(plyCoords, basedistance, shittypefuckyou)
end
local dst = 0
if nearNPC then
dst = #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(nearNPC))
end
if nearNPC and DoesEntityExist(nearNPC) then -- PED ANIMATION.
if not isSpeeder and alertType ~= "robberyhouse" then
Wait(500)
if GetEntityHealth(nearNPC) == 0 then
return
end
if not DoesEntityExist(nearNPC) then
return
end
if IsPedFatallyInjured(nearNPC) then
return
end
if IsPedInMeleeCombat(nearNPC) then
return
end
if IsPedShooting(nearNPC) then
return
end
local dontcall = {
[29] = true,
[28] = true,
[27] = true
}
if not dontcall[GetPedType(nearNPC)] then
ClearPedTasks(nearNPC)
TaskPlayAnim(nearNPC, "cellphone@", "cellphone_call_listen_base", 1.0, 1.0, -1, 49, 0, 0, 0, 0)
end
end
end
local isUnderground = false
if plyCoords.z <= -25 then isUnderground = true end
if alertType == "drugsale" and not underground --[[and not isPolice]] then
if dst > 50.5 and dst < 75.0 then
DrugSale()
end
elseif alertType == "druguse" and not underground and not pd then
if dst > 12.0 and dst < 18.0 then
DrugUse()
end
elseif alertType == "carcrash" then
CarCrash()
elseif alertType == "death" then
AlertDeath()
local roadtest2 = IsPointOnRoad(GetEntityCoords(PlayerPedId()), PlayerPedId())
if roadtest2 then return end
BringNpcs()
elseif alertType == "Suspicious" then
AlertSuspicious()
elseif alertType == "fight" and not underground then
AlertFight()
elseif (alertType == "gunshot" or alertType == "gunshotvehicle") then
AlertGunShot(isHunting, sentWeapon)
elseif alertType == "lockpick" then
if dst > 5.0 and dst < 85.0 then
if math.random(100) >= 25 then
AlertCheckLockpick(object)
end
end
elseif alertType == "robberyhouse" and not PlayerData.job.isPolice then
AlertCheckRobbery2()
end
end)
function BringNpcs()
for i = 1, #curWatchingPeds do
if DoesEntityExist(curWatchingPeds[i]) then
ClearPedTasks(curWatchingPeds[i])
SetEntityAsNoLongerNeeded(curWatchingPeds[i])
end
end
curWatchingPeds = {}
local basedistance = 35.0
local playerped = PlayerPedId()
local playerCoords = GetEntityCoords(playerped)
local handle, ped = FindFirstPed()
local success
local rped = nil
local distanceFrom
repeat
local pos = GetEntityCoords(ped)
local distance = #(playerCoords - pos)
if canPedBeUsed(ped,false) and distance < basedistance and distance > 3.0 then
if math.random(75) > 45 and #curWatchingPeds < 5 then
TriggerEvent("TriggerAIRunning",ped)
curWatchingPeds[#curWatchingPeds] = ped
end
end
success, ped = FindNextPed(handle)
until not success
EndFindPed(handle)
end
tasksIdle = {
[1] = "CODE_HUMAN_MEDIC_KNEEL",
[2] = "WORLD_HUMAN_STAND_MOBILE",
}
RegisterNetEvent('TriggerAIRunning')
AddEventHandler("TriggerAIRunning",function(p)
local usingped = p
local nm1 = math.random(6,9) / 100
local nm2 = math.random(6,9) / 100
nm1 = nm1 + 0.3
nm2 = nm2 + 0.3
if math.random(10) > 5 then
nm1 = 0.0 - nm1
end
if math.random(10) > 5 then
nm2 = 0.0 - nm2
end
local moveto = GetOffsetFromEntityInWorldCoords(PlayerPedId(), nm1, nm2, 0.0)
TaskGoStraightToCoord(usingped, moveto, 2.5, -1, 0.0, 0.0)
SetPedKeepTask(usingped, true)
local dist = #(moveto - GetEntityCoords(usingped))
while dist > 3.5 and (imdead == 1 or imcollapsed == 1) do
TaskGoStraightToCoord(usingped, moveto, 2.5, -1, 0.0, 0.0)
dist = #(moveto - GetEntityCoords(usingped))
Citizen.Wait(100)
end
ClearPedTasksImmediately(ped)
TaskLookAtEntity(usingped, PlayerPedId(), 5500.0, 2048, 3)
TaskTurnPedToFaceEntity(usingped, PlayerPedId(), 5500)
Citizen.Wait(3000)
if math.random(3) == 2 then
TaskStartScenarioInPlace(usingped, tasksIdle[2], 0, 1)
elseif math.random(1, 2) == 1 then
TaskStartScenarioInPlace(usingped, tasksIdle[1], 0, 1)
else
TaskStartScenarioInPlace(usingped, tasksIdle[2], 0, 1)
TaskStartScenarioInPlace(usingped, tasksIdle[1], 0, 1)
end
SetPedKeepTask(usingped, true)