-
Notifications
You must be signed in to change notification settings - Fork 396
/
Copy pathclient.lua
926 lines (837 loc) · 36 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
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
--[[
FiveM Scripts
Copyright C 2018 Sighmir
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]
maxErrors = 5 -- Change the amount of Errors allowed for the player to pass the driver test, any number above this will result in a failed test
local options = {
x = 0.1,
y = 0.2,
width = 0.2,
height = 0.04,
scale = 0.4,
font = 0,
menu_title = "NPC",
menu_subtitle = "Categories",
color_r = 0,
color_g = 128,
color_b = 255,
}
local dmvped = {
{type=4, hash=0xc99f21c4, x=239.471, y=-1380.96, z=32.74176, a=3374176},
}
local dmvpedpos = {
{ ['x'] = 239.471, ['y'] = -1380.96, ['z'] = 33.74176 },
}
--[[Locals]]--
local dmvschool_location = {232.054, -1389.98, 29.4812}
local kmh = 3.6
local VehSpeed = 0
local speed_limit_resi = 50.0
local speed_limit_town = 80.0
local speed_limit_freeway = 120
local speed = kmh
local DTutOpen = false
TestDone = false
RegisterNetEvent('dmv:CheckLicStatus')
AddEventHandler('dmv:CheckLicStatus', function()
--Check if player has completed theory test
TestDone = true
theorylock = false
testlock = false
end)
--[[Functions]]--
function drawNotification(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end
function DrawMissionText2(m_text, showtime)
ClearPrints()
SetTextEntry_2("STRING")
AddTextComponentString(m_text)
DrawSubtitleTimed(showtime, 1)
end
function LocalPed()
return GetPlayerPed(-1)
end
function GetCar()
return GetVehiclePedIsIn(GetPlayerPed(-1),false)
end
function Chat(debugg)
TriggerEvent("chatMessage", '', { 0, 0x99, 255 }, tostring(debugg))
end
function drawTxt(text,font,centre,x,y,scale,r,g,b,a)
SetTextFont(font)
SetTextProportional(0)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0,255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextCentre(centre)
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x , y)
end
--[[Arrays]]--
onTtest = false
onPtest = false
onTestEvent = 0
theorylock = true
testlock = true
DamageControl = 0
SpeedControl = 0
CruiseControl = 0
Error = 0
function startintro()
DIntro()
theorylock = false
end
function startttest()
if theorylock then
DrawMissionText2("~r~Locked", 5000)
else
TriggerServerEvent('dmv:ttcharge')
end
end
RegisterNetEvent('dmv:startttest')
AddEventHandler('dmv:startttest', function()
openGui()
Menu.hidden = not Menu.hidden
end)
function startptest()
if testlock then
DrawMissionText2("~r~Locked", 5000)
else
TriggerServerEvent('dmv:ptcharge')
end
end
RegisterNetEvent('dmv:startptest')
AddEventHandler('dmv:startptest', function()
onTestBlipp = AddBlipForCoord(255.13990783691,-1400.7319335938,30.5374584198)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
onTestEvent = 1
DamageControl = 1
SpeedControl = 1
onPtest = true
DTut()
end)
function EndDTest()
if Error > maxErrors then
drawNotification("You failed\nYou accumulated ".. Error.." ~r~Error Points")
onPtest = false
EndTestTasks()
else
--local licID = 1
--TriggerServerEvent('ply_prefecture:CheckForLicences', licID) --Uncomment this if youre using ply_prefecture, also make sure your drivers license has 1 as ID
TriggerServerEvent('dmv:success')
onPtest = false
TestDone = true
theorylock = false
testlock = false
drawNotification("You passed\nYou accumulated ".. Error.." ~r~Error Points")
EndTestTasks()
end
end
function EndTestTasks()
onTestBlipp = nil
onTestEvent = 0
DamageControl = 0
Error = 0
TaskLeaveVehicle(GetPlayerPed(-1), veh, 0)
Wait(1000)
CarTargetForLock = GetPlayersLastVehicle(GetPlayerPed(-1))
lockStatus = GetVehicleDoorLockStatus(CarTargetForLock)
SetVehicleDoorsLocked(CarTargetForLock, 2)
SetVehicleDoorsLockedForPlayer(CarTargetForLock, PlayerId(), false)
SetEntityAsMissionEntity(CarTargetForLock, true, true)
Wait(2000)
Citizen.InvokeNative( 0xEA386986E786A54F, Citizen.PointerValueIntInitialized( CarTargetForLock ) )
end
function SpawnTestCar()
Citizen.Wait(0)
local myPed = GetPlayerPed(-1)
local player = PlayerId()
local vehicle = GetHashKey('blista')
RequestModel(vehicle)
while not HasModelLoaded(vehicle) do
Wait(1)
end
colors = table.pack(GetVehicleColours(veh))
extra_colors = table.pack(GetVehicleExtraColours(veh))
plate = math.random(100, 900)
local spawned_car = CreateVehicle(vehicle, 249.40971374512,-1407.2303466797,30.409454345703, true, false)
SetVehicleColours(spawned_car,4,5)
SetVehicleExtraColours(spawned_car,extra_colors[1],extra_colors[2])
SetEntityHeading(spawned_car, 317.64)
SetVehicleOnGroundProperly(spawned_car)
SetPedIntoVehicle(myPed, spawned_car, - 1)
SetModelAsNoLongerNeeded(vehicle)
Citizen.InvokeNative(0xB736A491E64A32CF, Citizen.PointerValueIntInitialized(spawned_car))
CruiseControl = 0
DTutOpen = false
SetEntityVisible(myPed, true)
SetVehicleDoorsLocked(GetCar(), 4)
FreezeEntityPosition(myPed, false)
end
function DIntro()
Citizen.Wait(0)
local myPed = GetPlayerPed(-1)
DTutOpen = true
SetEntityCoords(myPed,173.01181030273, -1391.4141845703, 29.408880233765,true, false, false,true)
TriggerEvent("pNotify:SendNotification",{
text = "<b style='color:#1E90FF'>DMV Introduction</b> <br /><br />Theory and practice are both important elements of driving instruction.<br />This introduction will cover the basics and ensure you are prepared with enough information and knowledge for your test.<br /><br />The information from your theory lessons combined with the experience from your practical lesson are vital for negotiating the situations and dilemmas you will face on the road.<br /><br />Sit back and enjoy the ride as we start. It is highly recommended that you pay attention to every detail, most of these questions can be existent under your theory test.",
type = "alert",
timeout = (15000),
layout = "center",
queue = "global"
})
Citizen.Wait(16500)
SetEntityCoords(myPed,-428.49026489258, -993.306640625, 46.008815765381,true, false, false,true)
TriggerEvent("pNotify:SendNotification",{
text = "<b style='color:#1E90FF'>Accidents, incidents and environmental concerns</b><br /><br /><b style='color:#87CEFA'>Duty to yield</b><br />All drivers have a duty to obey the rules of the road in order to avoid foreseeable harm to others. Failure to yield the right of way when required by law can lead to liability for any resulting accidents.<br /><br /> When you hear a siren coming, you should yield to the emergency vehicle, simply pull over to your right.<br />You must always stop when a traffic officer tells you to.<br /><br /><b style='color:#87CEFA'>Aggressive Driving</b><br />A car that endangers or is likely to endanger people or property is considered to be aggressive driving.<br />However, aggressive driving, can lead to tragic accidents. It is far wiser to drive defensively and to always be on the lookout for the potential risk of crashes.<br />",
type = "alert",
timeout = (15000),
layout = "center",
queue = "global"
})
Citizen.Wait(16500)
SetEntityCoords(myPed,-282.55557250977, -282.55557250977, 31.633310317993,true, false, false,true)
TriggerEvent("pNotify:SendNotification",{
text = "<b style='color:#1E90FF'>Residential Area</b> <br /><br /> Maintain an appropriate speed - Never faster than the posted limit, slower if traffic is heavy.<br /><br />Stay centered in your lane. Never drive in the area reserved for parked cars.<br /><br />Maintain a safe following distance - an least 1 car length for every 10 mph.<br /><br />The speed limit in a Residential Area is 50 km/h.<br />",
type = "alert",
timeout = (15000),
layout = "center",
queue = "global"
})
Citizen.Wait(16500)
SetEntityCoords(myPed,246.35220336914, -1204.3403320313, 43.669715881348,true, false, false,true)
TriggerEvent("pNotify:SendNotification",{
text = "<b style='color:#1E90FF'>Built-Up Areas/Towns</b> <br /><br />The 80 km/h limit usually applies to all traffic on all roads with street lighting unless otherwise specified.<br />Driving at speeds too fast for the road and driving conditions can be dangerous.<br /><br />You should always reduce your speed when:<br /><br />• Sharing the road with pedestrians<br />• Driving at night, as it is more difficult to see other road users<br />• Weather conditions make it safer to do so<br /><br />Remember, large vehicles and motorcycles need a greater distance to stop<br />",
type = "alert",
timeout = (15000),
layout = "center",
queue = "global"
})
Citizen.Wait(16500)
SetEntityCoords(myPed,-138.413, -2498.53, 52.2765,true, false, false,true)
TriggerEvent("pNotify:SendNotification",{
text = "<b style='color:#1E90FF'>Freeways/Motorways</b> <br /><br />Traffic on motorways usually travels faster than on other roads, so you have less time to react.<br />It is especially important to use your sences earlier and look much further ahead than you would on other roads.<br /><br />Check the traffic on the motorway and match your speed to fit safely into the traffic flow in the left-hand lane.<br /><br />The speed limit in a Freeway/Motorway Area is 120 km/h.<br />",
type = "alert",
timeout = (15000),
layout = "center",
queue = "global"
})
Citizen.Wait(16500)
SetEntityCoords(myPed,187.465, -1428.82, 43.9302,true, false, false,true)
TriggerEvent("pNotify:SendNotification",{
text = "<b style='color:#1E90FF'>Alcohol</b> <br /><br />Drinking while driving is very dangerous, alcohol and/or drugs impair your judgment. Impaired judgment affects how you react to sounds and what you see. However, the DMV allows a certain amount of alcohol concentration for those driving with a valid drivers license.<br /><br />0.08% is the the legal limit for a driver's blood alcohol concentration (BAC)<br />",
type = "alert",
timeout = (15000),
layout = "center",
queue = "global"
})
Citizen.Wait(16500)
SetEntityCoords(myPed,238.756, -1381.65, 32.743,true, false, false,true)
SetEntityVisible(myPed, true)
FreezeEntityPosition(myPed, false)
DTutOpen = false
end
function DTut()
Citizen.Wait(0)
local myPed = GetPlayerPed(-1)
DTutOpen = true
SetEntityCoords(myPed,238.70791625977, -1394.7208251953, -1394.7208251953,true, false, false,true)
SetEntityHeading(myPed, 314.39)
TriggerEvent("pNotify:SendNotification",{
text = "<b style='color:#1E90FF'>DMV Instructor:</b> <br /><br /> We are currently preparing your vehicle for the test, meanwhile you should read a few important lines.<br /><br /><b style='color:#87CEFA'>Speed limit:</b><br />- Pay attention to the traffic, and stay under the <b style='color:#A52A2A'>speed</b> limit<br /><br />- By now, you should know the basics, however we will try to remind you whenever you <b style='color:#DAA520'>enter/exit</b> an area with a posted speed limit",
type = "alert",
timeout = (15000),
layout = "center",
queue = "global"
})
Citizen.Wait(16500)
TriggerEvent("pNotify:SendNotification",{
text = "<b style='color:#1E90FF'>DMV Instructor:</b> <br /><br /> Use the <b style='color:#DAA520'>Cruise Control</b> feature to avoid <b style='color:#87CEFA'>speeding</b>, activate this during the test by pressing the <b style='color:#20B2AA'>X</b> button on your keyboard.<br /><br /><b style='color:#87CEFA'>Evaluation:</b><br />- Try not to crash the vehicle or go over the posted speed limit. You will receive <b style='color:#A52A2A'>Error Points</b> whenever you fail to follow these rules<br /><br />- Too many <b style='color:#A52A2A'>Error Points</b> accumulated will result in a <b style='color:#A52A2A'>Failed</b> test",
type = "alert",
timeout = (15000),
layout = "center",
queue = "global"
})
Citizen.Wait(16500)
SpawnTestCar()
DTutOpen = false
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local veh = GetVehiclePedIsUsing(GetPlayerPed(-1))
local ped = GetPlayerPed(-1)
if HasEntityCollidedWithAnything(veh) and DamageControl == 1 then
TriggerEvent("pNotify:SendNotification",{
text = "The vehicle was <b style='color:#B22222'>damaged!</b><br /><br />Watch it!",
type = "alert",
timeout = (2000),
layout = "bottomCenter",
queue = "global"
})
Citizen.Wait(1000)
Error = Error + 1
elseif(IsControlJustReleased(1, 23)) and DamageControl == 1 then
drawNotification("You cannot leave the vehicle during the test")
end
if onTestEvent == 1 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), 255.13990783691,-1400.7319335938,29.5374584198, true) > 4.0001 then
DrawMarker(1,255.13990783691,-1400.7319335938,29.5374584198,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(271.8747253418,-1370.5744628906,31.932783126831)
N_0x80ead8e2e1d5d52e(onTestBlipp)
DrawMissionText2("Head to the next point !", 5000)
onTestEvent = 2
end
end
if onTestEvent == 2 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),271.8747253418,-1370.5744628906,30.932783126831, true) > 4.0001 then
DrawMarker(1,271.8747253418,-1370.5744628906,30.932783126831,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(234.90780639648,-1345.3854980469, 30.542045593262)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
DrawMissionText2("Head over to the next point!", 5000)
onTestEvent = 3
end
end
if onTestEvent == 3 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),234.90780639648,-1345.3854980469, 29.542045593262, true) > 4.0001 then
DrawMarker(1,234.90780639648,-1345.3854980469, 29.542045593262,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(217.82102966309,-1410.5201416016,29.292112350464)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
DrawMissionText2("Make a quick ~r~stop~s~ for pedastrian ~y~crossing", 5000)
PlaySound(-1, "RACE_PLACED", "HUD_AWARDS", 0, 0, 1)
FreezeEntityPosition(GetVehiclePedIsUsing(GetPlayerPed(-1)), true) -- Freeze Entity
Citizen.Wait(4000)
FreezeEntityPosition(GetVehiclePedIsUsing(GetPlayerPed(-1)), false) -- Freeze Entity
DrawMissionText2("~g~Great!~s~ lets keep moving!", 5000)
onTestEvent = 4
end
end
if onTestEvent == 4 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),217.82102966309,-1410.5201416016,28.292112350464, true) > 4.0001 then
DrawMarker(1,217.82102966309,-1410.5201416016,28.292112350464,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(178.55052185059,-1401.7551269531,28.725154876709)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
DrawMissionText2("Do a quick ~r~stop~s~ and watch your ~y~LEFT~s~ before entering traffic", 5000)
PlaySound(-1, "RACE_PLACED", "HUD_AWARDS", 0, 0, 1)
FreezeEntityPosition(GetVehiclePedIsUsing(GetPlayerPed(-1)), true) -- Freeze Entity
Citizen.Wait(6000)
FreezeEntityPosition(GetVehiclePedIsUsing(GetPlayerPed(-1)), false) -- Freeze Entity
DrawMissionText2("~g~Great!~s~ now take a ~y~RIGHT~s~ and pick your lane", 5000)
drawNotification("Area: ~y~Town\n~s~Speed limit: ~y~80 km/h\n~s~Error Points: ~y~".. Error.."/"..maxErrors)
SpeedControl = 2
onTestEvent = 5
Citizen.Wait(4000)
end
end
if onTestEvent == 5 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),178.55052185059,-1401.7551269531,27.725154876709, true) > 4.0001 then
DrawMarker(1,178.55052185059,-1401.7551269531,27.725154876709,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(113.16044616699,-1365.2762451172,28.725179672241)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
DrawMissionText2("Watch the traffic ~y~lights~s~ !", 5000)
onTestEvent = 6
end
end
if onTestEvent == 6 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),113.16044616699,-1365.2762451172,27.725179672241, true) > 4.0001 then
DrawMarker(1,113.16044616699,-1365.2762451172,27.725179672241,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(-73.542953491211,-1364.3355712891,27.789325714111)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
onTestEvent = 7
end
end
if onTestEvent == 7 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),-73.542953491211,-1364.3355712891,27.789325714111, true) > 4.0001 then
DrawMarker(1,-73.542953491211,-1364.3355712891,27.789325714111,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(-355.14373779297,-1420.2822265625,27.868143081665)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
DrawMissionText2("Make sure to stop for passing vehicles !", 5000)
onTestEvent = 8
end
end
if onTestEvent == 8 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),-355.14373779297,-1420.2822265625,27.868143081665, true) > 4.0001 then
DrawMarker(1,-355.14373779297,-1420.2822265625,27.868143081665,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(-439.14846801758,-1417.1004638672,27.704095840454)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
onTestEvent = 9
end
end
if onTestEvent == 9 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),-439.14846801758,-1417.1004638672,27.704095840454, true) > 4.0001 then
DrawMarker(1,-439.14846801758,-1417.1004638672,27.704095840454,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(-453.79092407227,-1444.7265625,27.665870666504)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
onTestEvent = 10
end
end
if onTestEvent == 10 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),-453.79092407227,-1444.7265625,27.665870666504, true) > 4.0001 then
DrawMarker(1,-453.79092407227,-1444.7265625,27.665870666504,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(-463.23712158203,-1592.1785888672,37.519771575928)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
DrawMissionText2("Time to hit the road, watch your speed and dont crash !", 5000)
PlaySound(-1, "RACE_PLACED", "HUD_AWARDS", 0, 0, 1)
drawNotification("Area: ~y~Freeway\n~s~Speed limit: ~y~120 km/h\n~s~Error Points: ~y~".. Error.."/"..maxErrors)
onTestEvent = 11
SpeedControl = 3
Citizen.Wait(4000)
end
end
if onTestEvent == 11 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),-463.23712158203,-1592.1785888672,37.519771575928, true) > 4.0001 then
DrawMarker(1,-463.23712158203,-1592.1785888672,37.519771575928,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(-900.64721679688,-1986.2814941406,26.109502792358)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
onTestEvent = 12
end
end
if onTestEvent == 12 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),-900.64721679688,-1986.2814941406,26.109502792358, true) > 4.0001 then
DrawMarker(1,-900.64721679688,-1986.2814941406,26.109502792358,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(1225.7598876953,-1948.7922363281,38.718940734863)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
onTestEvent = 13
end
end
if onTestEvent == 13 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),1225.7598876953,-1948.7922363281,38.718940734863, true) > 4.0001 then
DrawMarker(1,1225.7598876953,-1948.7922363281,38.718940734863,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(209.54621887207,-1412.8677978516,29.652387619019)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
onTestEvent = 14
end
end
if onTestEvent == 14 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),1225.7598876953,-1948.7922363281,38.718940734863, true) > 4.0001 then
DrawMarker(1,1225.7598876953,-1948.7922363281,38.718940734863,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(1163.6030273438,-1841.7713623047,35.679168701172)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
DrawMissionText2("Entering town, watch your speed!", 5000)
drawNotification("~r~Slow down!\n~s~Area: ~y~Town\n~s~Speed limit: ~y~80 km/h\n~s~Error Points: ~y~".. Error.."/"..maxErrors)
onTestEvent = 15
end
end
if onTestEvent == 15 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),1163.6030273438,-1841.7713623047,35.679168701172, true) > 4.0001 then
DrawMarker(1,1163.6030273438,-1841.7713623047,35.679168701172,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
onTestBlipp = AddBlipForCoord(235.28327941895,-1398.3292236328,28.921098709106)
N_0x80ead8e2e1d5d52e(onTestBlipp)
SetBlipRoute(onTestBlipp, 1)
PlaySound(-1, "RACE_PLACED", "HUD_AWARDS", 0, 0, 1)
DrawMissionText2("Good job, now lets head back!", 5000)
drawNotification("Area: ~y~Town\n~s~Speed limit: ~y~80 km/h\n~s~Error Points: ~y~".. Error.."/"..maxErrors)
SpeedControl = 2
onTestEvent = 16
end
end
if onTestEvent == 16 then
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),235.28327941895,-1398.3292236328,28.921098709106, true) > 4.0001 then
DrawMarker(1,235.28327941895,-1398.3292236328,28.921098709106,0, 0, 0, 0, 0, 0, 1.5, 1.5, 1.5, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
else
if onTestBlipp ~= nil and DoesBlipExist(onTestBlipp) then
Citizen.InvokeNative(0x86A652570E5F25DD,Citizen.PointerValueIntInitialized(onTestBlipp))
end
EndDTest()
end
end
end
end)
----Theory Test NUI Operator
-- ***************** Open Gui and Focus NUI
function openGui()
onTtest = true
SetNuiFocus(true)
SendNUIMessage({openQuestion = true})
end
-- ***************** Close Gui and disable NUI
function closeGui()
SetNuiFocus(false)
SendNUIMessage({openQuestion = false})
end
-- ***************** Disable controls while GUI open
Citizen.CreateThread(function()
while true do
if onTtest then
local ply = GetPlayerPed(-1)
local active = true
DisableControlAction(0, 1, active) -- LookLeftRight
DisableControlAction(0, 2, active) -- LookUpDown
DisablePlayerFiring(ply, true) -- Disable weapon firing
DisableControlAction(0, 142, active) -- MeleeAttackAlternate
DisableControlAction(0, 106, active) -- VehicleMouseControlOverride
if IsDisabledControlJustReleased(0, 142) then -- MeleeAttackAlternate
SendNUIMessage({type = "click"})
end
end
Citizen.Wait(0)
end
end)
-- ***************** NUI Callback Methods
-- Callbacks pages opening
RegisterNUICallback('question', function(data, cb)
SendNUIMessage({openSection = "question"})
cb('ok')
end)
-- Callback actions triggering server events
RegisterNUICallback('close', function(data, cb)
-- if question success
closeGui()
cb('ok')
DrawMissionText2("~b~Test passed, you can now proceed to the driving test", 2000)
theorylock = true
testlock = false
onTtest = false
end)
RegisterNUICallback('kick', function(data, cb)
closeGui()
cb('ok')
DrawMissionText2("~r~You failed the test, you might try again another day", 2000)
onTtest = false
theorylock = false
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
if(IsPedInAnyVehicle(GetPlayerPed(-1), false)) and not TestDone and not onPtest then
DrawMissionText2("~r~You are driving without a license", 2000)
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
CarSpeed = GetEntitySpeed(GetCar()) * speed
if(IsPedInAnyVehicle(GetPlayerPed(-1), false)) and SpeedControl == 1 and CarSpeed >= speed_limit_resi then
TriggerEvent("pNotify:SendNotification",{
text = "You are speeding! <b style='color:#B22222'>Slow down!</b><br /><br />You are driving in a <b style='color:#DAA520'>50 km/h</b> zone!",
type = "alert",
timeout = (2000),
layout = "bottomCenter",
queue = "global"
})
Error = Error + 1
Citizen.Wait(10000)
elseif(IsPedInAnyVehicle(GetPlayerPed(-1), false)) and SpeedControl == 2 and CarSpeed >= speed_limit_town then
TriggerEvent("pNotify:SendNotification",{
text = "You are speeding! <b style='color:#B22222'>Slow down!</b><br /><br />You are driving in a <b style='color:#DAA520'>80 km/h</b> zone!",
type = "alert",
timeout = (2000),
layout = "bottomCenter",
queue = "global"
})
Error = Error + 1
Citizen.Wait(10000)
elseif(IsPedInAnyVehicle(GetPlayerPed(-1), false)) and SpeedControl == 3 and CarSpeed >= speed_limit_freeway then
TriggerEvent("pNotify:SendNotification",{
text = "You are speeding! <b style='color:#B22222'>Slow down!</b><br /><br />You are driving in a <b style='color:#DAA520'>120 km/h</b> zone!",
type = "alert",
timeout = (2000),
layout = "bottomCenter",
queue = "global"
})
Error = Error + 1
Citizen.Wait(10000)
end
end
end)
local speedLimit = 0
Citizen.CreateThread( function()
while true do
Citizen.Wait( 0 )
local ped = GetPlayerPed(-1)
local vehicle = GetVehiclePedIsIn(ped, false)
local vehicleModel = GetEntityModel(vehicle)
local speed = GetEntitySpeed(vehicle)
local inVehicle = IsPedSittingInAnyVehicle(ped)
local float Max = GetVehicleMaxSpeed(vehicleModel)
if ( ped and inVehicle and DamageControl == 1 ) then
if IsControlJustPressed(1, 73) then
if (GetPedInVehicleSeat(vehicle, -1) == ped) then
if CruiseControl == 0 then
speedLimit = speed
SetEntityMaxSpeed(vehicle, speedLimit)
drawNotification("~y~Cruise Control: ~g~enabled\n~s~MAX speed ".. math.floor(speedLimit*3.6).."kmh")
Citizen.Wait(1000)
DisplayHelpText("Adjust your max speed with ~INPUT_CELLPHONE_UP~ ~INPUT_CELLPHONE_DOWN~ controls")
PlaySound(-1, "COLLECTED", "HUD_AWARDS", 0, 0, 1)
CruiseControl = 1
else
SetEntityMaxSpeed(vehicle, Max)
drawNotification("~y~Cruise Control: ~r~disabled")
CruiseControl = 0
end
else
drawNotification("You need to be driving to preform this action")
end
elseif IsControlJustPressed(1, 27) then
if CruiseControl == 1 then
speedLimit = speedLimit + 0.45
SetEntityMaxSpeed(vehicle, speedLimit)
PlaySound(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0, 0, 1)
DisplayHelpText("Max speed adjusted to ".. math.floor(speedLimit*3.6).. "kmh")
end
elseif IsControlJustPressed(1, 173) then
if CruiseControl == 1 then
speedLimit = speedLimit - 0.45
SetEntityMaxSpeed(vehicle, speedLimit)
PlaySound(-1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0, 0, 1)
DisplayHelpText("Max speed adjusted to ".. math.floor(speedLimit*3.6).. "kmh")
end
end
end
end
end)
----Theory Test NUI Operator
-- ***************** Open Gui and Focus NUI
function openGui()
onTtest = true
SetNuiFocus(true)
SendNUIMessage({openQuestion = true})
end
-- ***************** Close Gui and disable NUI
function closeGui()
SetNuiFocus(false)
SendNUIMessage({openQuestion = false})
end
-- ***************** Disable controls while GUI open
Citizen.CreateThread(function()
while true do
if onTtest then
local ply = GetPlayerPed(-1)
local active = true
DisableControlAction(0, 1, active) -- LookLeftRight
DisableControlAction(0, 2, active) -- LookUpDown
DisablePlayerFiring(ply, true) -- Disable weapon firing
DisableControlAction(0, 142, active) -- MeleeAttackAlternate
DisableControlAction(0, 106, active) -- VehicleMouseControlOverride
if IsDisabledControlJustReleased(0, 142) then -- MeleeAttackAlternate
SendNUIMessage({type = "click"})
end
end
Citizen.Wait(0)
end
end)
Citizen.CreateThread(function()
while true do
if DTutOpen then
local ply = GetPlayerPed(-1)
local active = true
SetEntityVisible(ply, false)
FreezeEntityPosition(ply, true)
DisableControlAction(0, 1, active) -- LookLeftRight
DisableControlAction(0, 2, active) -- LookUpDown
DisablePlayerFiring(ply, true) -- Disable weapon firing
DisableControlAction(0, 142, active) -- MeleeAttackAlternate
DisableControlAction(0, 106, active) -- VehicleMouseControlOverride
end
Citizen.Wait(0)
end
end)
-- ***************** NUI Callback Methods
-- Callbacks pages opening
RegisterNUICallback('question', function(data, cb)
SendNUIMessage({openSection = "question"})
cb('ok')
end)
-- Callback actions triggering server events
RegisterNUICallback('close', function(data, cb)
-- if question success
closeGui()
cb('ok')
DrawMissionText2("~b~Test passed, you can now proceed to the driving test", 2000)
theorylock = true
testlock = false
onTtest = false
end)
RegisterNUICallback('kick', function(data, cb)
closeGui()
cb('ok')
DrawMissionText2("~r~You failed the test, you might try again another day", 2000)
onTtest = false
end)
---------------------------------- DMV PED ----------------------------------
Citizen.CreateThread(function()
RequestModel(GetHashKey("a_m_y_business_01"))
while not HasModelLoaded(GetHashKey("a_m_y_business_01")) do
Wait(1)
end
RequestAnimDict("mini@strip_club@idles@bouncer@base")
while not HasAnimDictLoaded("mini@strip_club@idles@bouncer@base") do
Wait(1)
end
-- Spawn the DMV Ped
for _, item in pairs(dmvped) do
dmvmainped = CreatePed(item.type, item.hash, item.x, item.y, item.z, item.a, false, true)
SetEntityHeading(dmvmainped, 137.71)
FreezeEntityPosition(dmvmainped, true)
SetEntityInvincible(dmvmainped, true)
SetBlockingOfNonTemporaryEvents(dmvmainped, true)
TaskPlayAnim(dmvmainped,"mini@strip_club@idles@bouncer@base","base", 8.0, 0.0, -1, 1, 0, 0, 0, 0)
end
end)
local talktodmvped = true
--DMV Ped interaction
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local pos = GetEntityCoords(GetPlayerPed(-1), false)
for k,v in ipairs(dmvpedpos) do
if(Vdist(v.x, v.y, v.z, pos.x, pos.y, pos.z) < 1.0)then
DisplayHelpText("Press ~INPUT_CONTEXT~ to interact with ~y~NPC")
if(IsControlJustReleased(1, 38))then
if talktodmvped then
Notify("~b~Welcome to the ~h~DMV School!")
Citizen.Wait(500)
DMVMenu()
Menu.hidden = false
talktodmvped = false
else
talktodmvped = true
end
end
Menu.renderGUI(options)
end
end
end
end)
------------
------------ DRAW MENUS
------------
function DMVMenu()
ClearMenu()
options.menu_title = "DMV School"
Menu.addButton("Obtain a drivers license","VehLicenseMenu",nil)
Menu.addButton("Close","CloseMenu",nil)
end
function VehLicenseMenu()
ClearMenu()
options.menu_title = "Vehicle License"
Menu.addButton("Introduction FREE","startintro",nil)
Menu.addButton("Theory test 200$","startttest",nil)
Menu.addButton("Practical test 500$","startptest",nil)
Menu.addButton("Return","DMVMenu",nil)
end
function CloseMenu()
Menu.hidden = true
end
function Notify(text)
SetNotificationTextEntry('STRING')
AddTextComponentString(text)
DrawNotification(false, false)
end
function drawNotification(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(true, true)
end
function DisplayHelpText(str)
SetTextComponentFormat("STRING")
AddTextComponentString(str)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end
----------------
----------------blip
----------------
Citizen.CreateThread(function()
pos = dmvschool_location
local blip = AddBlipForCoord(pos[1],pos[2],pos[3])
SetBlipSprite(blip,408)
SetBlipColour(blip,11)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString('DMV School')
EndTextCommandSetBlipName(blip)
SetBlipAsShortRange(blip,true)
SetBlipAsMissionCreatorBlip(blip,true)
end)