This repository was archived by the owner on Jan 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathclient.lua
944 lines (664 loc) · 24.2 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
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
essence = 0.142
local stade = 0
local lastModel = 0
local vehiclesUsed = {}
local currentCans = 0
Citizen.CreateThread(function()
TriggerServerEvent("essence:addPlayer")
while true do
Citizen.Wait(0)
CheckVeh()
renderBoxes()
if(currentCans > 0) then
local x,y,z = table.unpack(GetEntityCoords(GetPlayerPed(-1)))
local veh = GetClosestVehicle(x, y, z, 4.001, 0, 70)
if(veh ~= nil and GetVehicleNumberPlateText(veh) ~= nil) then
local nul, number = GetCurrentPedWeapon(GetPlayerPed(-1))
if(number == 883325847) then
Info(settings[lang].refeel)
if(IsControlJustPressed(1, 38)) then
RequestAnimDict("weapon@w_sp_jerrycan")
while not HasAnimDictLoaded("weapon@w_sp_jerrycan") do
Citizen.Wait(100)
end
local toPercent = essence/0.142
print(5000/toPercent)
TaskPlayAnim(GetPlayerPed(-1),"weapon@w_sp_jerrycan","fire", 8.0, -8, -1, 49, 0, 0, 0, 0)
local done = false
local amountToEssence = 0.142-essence
while done == false do
Wait(0)
local _essence = essence
if(amountToEssence-0.0005 > 0) then
amountToEssence = amountToEssence-0.0005
essence = _essence + 0.0005
_essence = essence
if(_essence > 0.142) then
essence = 0.142
TriggerEvent("advancedFuel:setEssence", 100, GetVehicleNumberPlateText(veh), GetDisplayNameFromVehicleModel(GetEntityModel(veh)))
done = true
end
SetVehicleUndriveable(veh, true)
SetVehicleEngineOn(veh, false, false, false)
local essenceToPercent = (essence/0.142)*65
SetVehicleFuelLevel(veh,round(essenceToPercent))
Wait(100)
else
essence = essence + amountToEssence
local essenceToPercent = (essence/0.142)*65
SetVehicleFuelLevel(veh,round(essenceToPercent))
TriggerEvent("advancedFuel:setEssence", 100, GetVehicleNumberPlateText(veh), GetDisplayNameFromVehicleModel(GetEntityModel(veh)))
done = true
end
end
TaskPlayAnim(GetPlayerPed(-1),"weapon@w_sp_jerrycan","fire_outro", 8.0, -8, -1, 49, 0, 0, 0, 0)
Wait(500)
ClearPedTasks(GetPlayerPed(-1))
currentCans = currentCans-1
if(currentCans == 0) then
RemoveWeaponFromPed(GetPlayerPed(-1), 0x34A67B97)
end
SetVehicleEngineOn(veh, true, false, false)
SetVehicleUndriveable(veh, false)
end
end
end
end
end
end)
Citizen.CreateThread(function()
local menu = false
local bool = false
local int = 0
local position = 1
local array = {"TEST", "TEST2", "TEST3", "TEST4"}
while true do
Citizen.Wait(0)
local isNearFuelStation, stationNumber = isNearStation()
local isNearFuelPStation, stationPlaneNumber = isNearPlaneStation()
local isNearFuelHStation, stationHeliNumber = isNearHeliStation()
local isNearFuelBStation, stationBoatNumber = isNearBoatStation()
--Police
local isNearFuelOStation, stationPoliceNumber = isNearPoliceStation()
--End
------------------------------- VEHICLE FUEL PART -------------------------------
if(isNearFuelStation and IsPedInAnyVehicle(GetPlayerPed(-1), -1) and not IsPedInAnyHeli(GetPlayerPed(-1)) and not isBlackListedModel() and not isElectricModel() and GetPedVehicleSeat(GetPlayerPed(-1)) == -1) then
Info(settings[lang].openMenu)
if(IsControlJustPressed(1, 38)) then
menu = not menu
int = 0
--[[Menu.hidden = not Menu.hidden
Menu.Title = "Station essence"
ClearMenu()
Menu.addButton("Eteindre le moteur", "stopMotor")]]--
end
if(menu) then
TriggerEvent("GUI:Title", settings[lang].buyFuel)
local maxEscense = 60-(essence/0.142)*60
TriggerEvent("GUI:Int", settings[lang].liters.." : ", int, 0, maxEscense, function(cb)
int = cb
end)
TriggerEvent("GUI:Option", settings[lang].confirm, function(cb)
if(cb) then
menu = not menu
TriggerServerEvent("essence:buy", int, stationNumber,false)
else
end
end)
TriggerEvent("GUI:Update")
end
else
if(isNearFuelStation and IsPedInAnyVehicle(GetPlayerPed(-1), -1) and not IsPedInAnyHeli(GetPlayerPed(-1)) and not isBlackListedModel() and isElectricModel()) then
Info(settings[lang].electricError)
end
end
------------------------------- POLICE PART -------------------------------
if(isNearFuelOStation and IsPedInAnyPoliceVehicle(GetPlayerPed(-1), -1) and not IsPedInAnyHeli(GetPlayerPed(-1)) and not isBlackListedModel() and not isElectricModel() and GetPedVehicleSeat(GetPlayerPed(-1)) == -1) then
Info(settings[lang].openMenu)
if(IsControlJustPressed(1, 38)) then
menu = not menu
int = 0
--[[Menu.hidden = not Menu.hidden
Menu.Title = "Station essence"
ClearMenu()
Menu.addButton("Eteindre le moteur", "stopMotor")]]--
end
if(menu) then
TriggerEvent("GUI:Title", settings[lang].buyFuel)
local maxEscense = 60-(essence/0.142)*60
TriggerEvent("GUI:Int", settings[lang].liters.." : ", int, 0, maxEscense, function(cb)
int = cb
end)
TriggerEvent("GUI:Option", settings[lang].confirm, function(cb)
if(cb) then
menu = not menu
TriggerServerEvent("essence:buy", int, stationPoliceNumber,false)
else
end
end)
TriggerEvent("GUI:Update")
end
else
if(isNearFuelOStation and IsPedInAnyPoliceVehicle(GetPlayerPed(-1), -1) and not IsPedInAnyHeli(GetPlayerPed(-1)) and not isBlackListedModel() and isElectricModel()) then
Info(settings[lang].electricError)
end
end
------------------------------- ELECTRIC VEHICLE PART -------------------------------
if(isNearElectricStation() and IsPedInAnyVehicle(GetPlayerPed(-1), -1) and not IsPedInAnyHeli(GetPlayerPed(-1)) and not isBlackListedModel() and isElectricModel() and GetPedVehicleSeat(GetPlayerPed(-1)) == -1) then
Info(settings[lang].openMenu)
if(IsControlJustPressed(1, 38)) then
menu = not menu
int = 0
--[[Menu.hidden = not Menu.hidden
Menu.Title = "Station essence"
ClearMenu()
Menu.addButton("Eteindre le moteur", "stopMotor")]]--
end
if(menu) then
TriggerEvent("GUI:Title", settings[lang].buyFuel)
local maxEssence = 60-(essence/0.142)*60
TriggerEvent("GUI:Int", settings[lang].percent.." : ", int, 0, maxEssence, function(cb)
int = cb
end)
TriggerEvent("GUI:Option", settings[lang].confirm, function(cb)
if(cb) then
menu = not menu
TriggerServerEvent("essence:buy", int, electricityPrice,true)
else
end
end)
TriggerEvent("GUI:Update")
end
else
if(isNearElectricStation() and IsPedInAnyVehicle(GetPlayerPed(-1), -1) and not IsPedInAnyHeli(GetPlayerPed(-1)) and not isBlackListedModel() and not isElectricModel()) then
Info(settings[lang].fuelError)
end
end
------------------------------- BOAT PART -------------------------------
if(isNearFuelBStation and IsPedInAnyVehicle(GetPlayerPed(-1), -1) and not IsPedInAnyHeli(GetPlayerPed(-1)) and not isBlackListedModel() and GetPedVehicleSeat(GetPlayerPed(-1)) == -1) then
Info(settings[lang].openMenu)
if(IsControlJustPressed(1, 38)) then
menu = not menu
int = 0
--[[Menu.hidden = not Menu.hidden
Menu.Title = "Station essence"
ClearMenu()
Menu.addButton("Eteindre le moteur", "stopMotor")]]--
end
if(menu) then
TriggerEvent("GUI:Title", settings[lang].buyFuel)
local maxEssence = 60-(essence/0.142)*60
TriggerEvent("GUI:Int", settings[lang].percent.." : ", int, 0, maxEssence, function(cb)
int = cb
end)
TriggerEvent("GUI:Option", settings[lang].confirm, function(cb)
if(cb) then
menu = not menu
TriggerServerEvent("essence:buy", int, stationBoatNumber,false)
else
end
end)
TriggerEvent("GUI:Update")
end
else
if(isNearFuelBStation and IsPedInAnyVehicle(GetPlayerPed(-1), -1) and not IsPedInAnyHeli(GetPlayerPed(-1)) and not isBlackListedModel() and isElectricModel()) then
Info(settings[lang].fuelError)
end
end
------------------------------- PLANE PART -------------------------------
if(isNearFuelPStation and IsPedInAnyVehicle(GetPlayerPed(-1), -1) and not isBlackListedModel() and isPlaneModel() and GetPedVehicleSeat(GetPlayerPed(-1)) == -1) then
Info(settings[lang].openMenu)
if(IsControlJustPressed(1, 38)) then
menu = not menu
int = 0
--[[Menu.hidden = not Menu.hidden
Menu.Title = "Station essence"
ClearMenu()
Menu.addButton("Eteindre le moteur", "stopMotor")]]--
end
if(menu) then
TriggerEvent("GUI:Title", settings[lang].buyFuel)
local maxEssence = 60-(essence/0.142)*60
TriggerEvent("GUI:Int", settings[lang].percent.." : ", int, 0, maxEssence, function(cb)
int = cb
end)
TriggerEvent("GUI:Option", settings[lang].confirm, function(cb)
if(cb) then
menu = not menu
TriggerServerEvent("essence:buy", int, stationPlaneNumber,false)
else
end
end)
TriggerEvent("GUI:Update")
end
else
if(isNearFuelPStation and IsPedInAnyVehicle(GetPlayerPed(-1), -1) and not isBlackListedModel() and not isPlaneModel()) then
Info(settings[lang].fuelError)
end
end
------------------------------- HELI PART -------------------------------
if(isNearFuelHStation and IsPedInAnyVehicle(GetPlayerPed(-1), -1) and not isBlackListedModel() and isHeliModel() and GetPedVehicleSeat(GetPlayerPed(-1)) == -1) then
Info(settings[lang].openMenu)
if(IsControlJustPressed(1, 38)) then
menu = not menu
int = 0
--[[Menu.hidden = not Menu.hidden
Menu.Title = "Station essence"
ClearMenu()
Menu.addButton("Eteindre le moteur", "stopMotor")]]--
end
if(menu) then
TriggerEvent("GUI:Title", settings[lang].buyFuel)
local maxEssence = 60-(essence/0.142)*60
TriggerEvent("GUI:Int", settings[lang].percent.." : ", int, 0, maxEssence, function(cb)
int = cb
end)
TriggerEvent("GUI:Option", settings[lang].confirm, function(cb)
if(cb) then
menu = not menu
TriggerServerEvent("essence:buy", int, stationHeliNumber,false)
else
end
end)
TriggerEvent("GUI:Update")
end
else
if(isNearFuelHStation and IsPedInAnyVehicle(GetPlayerPed(-1), -1) and not isBlackListedModel() and not isHeliModel()) then
Info(settings[lang].fuelError)
end
end
if((isNearFuelStation or isNearFuelPStation or isNearFuelHStation or isNearFuelBStation) and not IsPedInAnyVehicle(GetPlayerPed(-1))) then
Info(settings[lang].getJerryCan)
if(IsControlJustPressed(1, 38)) then
TriggerServerEvent("essence:buyCan")
end
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(1000)
local isEngineOn = Citizen.InvokeNative(0xAE31E7DF9B5B132E, GetVehiclePedIsIn(GetPlayerPed(-1))) -- Thanks to Asser
if(IsPedInAnyVehicle(GetPlayerPed(-1), -1) and isEngineOn and GetPedVehicleSeat(GetPlayerPed(-1)) == -1 and not isBlackListedModel()) then
local kmh = GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false)) * 3.6
local vitesse = math.ceil(kmh)
if(vitesse > 0 and vitesse <20) then
stade = 0.00001
elseif(vitesse >= 20 and vitesse <50) then
stade = 0.00002
elseif(vitesse >= 50 and vitesse < 70) then
stade = 0.00003
elseif(vitesse >= 70 and vitesse <90) then
stade = 0.00004
elseif(vitesse >=90 and vitesse <130) then
stade = 0.00005
elseif(vitesse >= 130) then
stade = 0.00006
elseif(vitesse == 0 and IsVehicleEngineOn(veh)) then
stade = 0.0000001
end
if(essence - stade > 0) then
essence = essence - stade
local essenceToPercent = (essence/0.142)*65
SetVehicleFuelLevel(GetVehiclePedIsIn(GetPlayerPed(-1)),round(essenceToPercent))
else
essence = 0
SetVehicleFuelLevel(GetVehiclePedIsIn(GetPlayerPed(-1)),0)
SetVehicleUndriveable(GetVehiclePedIsUsing(GetPlayerPed(-1)), true)
end
end
end
end)
--[[
FUNC PART
]]--
-- 0.0001 pour 0 à 20, 0.142 = 100%
-- Donc 0.0001 km en moins toutes les 10 secondes
local lastPlate = 0
local refresh = true
function CheckVeh()
if(IsPedInAnyVehicle(GetPlayerPed(-1)) and not isBlackListedModel()) then
--if((lastPlate == GetVehicleNumberPlateText(GetVehiclePedIsUsing(GetPlayerPed(-1))) and lastModel ~= GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(GetPlayerPed(-1))))) or (lastPlate ~= GetVehicleNumberPlateText(GetVehiclePedIsUsing(GetPlayerPed(-1))) and lastModel == GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(GetPlayerPed(-1))))) or (lastPlate ~= GetVehicleNumberPlateText(GetVehiclePedIsUsing(GetPlayerPed(-1))) and lastModel ~= GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(GetPlayerPed(-1))))) then
if(refresh) then
TriggerServerEvent("vehicule:getFuel", GetVehicleNumberPlateText(GetVehiclePedIsUsing(GetPlayerPed(-1))), GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(GetPlayerPed(-1)))))
lastModel = GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(GetPlayerPed(-1))))
lastPlate = GetVehicleNumberPlateText(GetVehiclePedIsUsing(GetPlayerPed(-1)))
refresh = false
end
else
if(not refresh) then
TriggerServerEvent("essence:setToAllPlayerEscense", essence, lastPlate, lastModel)
refresh = true
end
end
if(essence == 0 and GetVehiclePedIsUsing(GetPlayerPed(-1)) ~= nil) then
SetVehicleEngineOn(GetVehiclePedIsUsing(GetPlayerPed(-1)), false, false, false)
end
end
function renderBoxes()
if(IsPedInAnyVehicle(GetPlayerPed(-1), -1) and GetPedVehicleSeat(GetPlayerPed(-1)) == -1 and not isBlackListedModel()) then
if(hud_form == 1) then
if(showBar) then
DrawRect(hud_x, hud_y, 0.0149999999999998, 0.15, 255, 255, 255, 200)
DrawRect(hud_x, hud_y, 0.0119999999999998, 0.142, 80, 80, 80, 255)
DrawRect(hud_x, hud_y, 0.0119999999999998, essence, 225, 146, 45, 255)
end
if(showText) then
local percent = (essence/0.142)*100
DrawAdvancedText(text_x, text_y, 0.005, 0.0028, 0.4,round(percent,1).."%", 255, 255, 255, 255, 0, 1)
end
else
if(showBar) then
DrawRect(hud_x, hud_y, 0.15, 0.0149999999999998, 255, 255, 255, 200)
DrawRect(hud_x, hud_y, 0.142, 0.0119999999999998, 80, 80, 80, 255)
DrawRect(hud_x, hud_y, essence, 0.0119999999999998, 225, 146, 45, 255)
end
if(showText) then
local percent = (essence/0.142)*100
DrawAdvancedText(text_x, text_y, 0.005, 0.0028, 0.4,round(percent,1).."%", 255, 255, 255, 255, 0, 1)
end
end
end
end
function isNearStation()
local ped = GetPlayerPed(-1)
local plyCoords = GetEntityCoords(GetPlayerPed(-1), 0)
for _,items in pairs(station) do
if(GetDistanceBetweenCoords(items.x, items.y, items.z, plyCoords["x"], plyCoords["y"], plyCoords["z"], true) < 2) then
return true, items.s
end
end
return false
end
function isNearPlaneStation()
local ped = GetPlayerPed(-1)
local plyCoords = GetEntityCoords(GetPlayerPed(-1), 0)
for _,items in pairs(avion_stations) do
if(GetDistanceBetweenCoords(items.x, items.y, items.z, plyCoords["x"], plyCoords["y"], plyCoords["z"], true) < 10) then
return true, items.s
end
end
return false
end
function isNearHeliStation()
local ped = GetPlayerPed(-1)
local plyCoords = GetEntityCoords(GetPlayerPed(-1), 0)
for _,items in pairs(heli_stations) do
if(GetDistanceBetweenCoords(items.x, items.y, items.z, plyCoords["x"], plyCoords["y"], plyCoords["z"], true) < 10) then
return true, items.s
end
end
return false
end
function isNearBoatStation()
local ped = GetPlayerPed(-1)
local plyCoords = GetEntityCoords(GetPlayerPed(-1), 0)
for _,items in pairs(boat_stations) do
if(GetDistanceBetweenCoords(items.x, items.y, items.z, plyCoords["x"], plyCoords["y"], plyCoords["z"], true) < 10) then
return true, items.s
end
end
return false
end
function isNearElectricStation()
local ped = GetPlayerPed(-1)
local plyCoords = GetEntityCoords(GetPlayerPed(-1), 0)
for _,items in pairs(electric_stations) do
if(GetDistanceBetweenCoords(items.x, items.y, items.z, plyCoords["x"], plyCoords["y"], plyCoords["z"], true) < 2) then
return true
end
end
return false
end
--Police
--function isNearPoliceStation()
-- local ped = GetPlayerPed(-1)
-- local plyCoords = GetEntityCoords(GetPlayerPed(-1), 0)
--
-- for _,items in pairs(police_stations) do
-- if(GetDistanceBetweenCoords(items.x, items.y, items.z, plyCoords["x"], plyCoords["y"], plyCoords["z"], true) < 2) then
-- return true, items.s
-- end
-- end
--
-- return false
--end
function isNearPoliceStation()
local ped = GetPlayerPed(-1)
local plyCoords = GetEntityCoords(GetPlayerPed(-1), 0)
for _,items in pairs(police_stations) do
if(GetDistanceBetweenCoords(items.x, items.y, items.z, plyCoords["x"], plyCoords["y"], plyCoords["z"], true) < 2) then
return true, items.s
end
end
return false
end
--End
--100% = 100L = 100$
-- 1% = 1L = 1
function Info(text, loop)
SetTextComponentFormat("STRING")
AddTextComponentString(text)
DisplayHelpTextFromStringLabel(0, loop, 1, 0)
end
function round(num, dec)
local mult = 10^(dec or 0)
return math.floor(num * mult + 0.5) / mult
end
function isBlackListedModel()
local model = GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsIn(GetPlayerPed(-1))))
local isBL = false
for _,k in pairs(blacklistedModels) do
if(k==model) then
isBL = true
break;
end
end
return isBL
end
function isElectricModel()
local model = GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsIn(GetPlayerPed(-1))))
local isEL = false
for _,k in pairs(electric_model) do
if(k==model) then
isEL = true
break;
end
end
return isEL
end
--Police
function isPoliceModel()
local model = GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsIn(GetPlayerPed(-1))))
local isPo = false
for _,k in pairs(police_model) do
if(k==model) then
isPo = true
break;
end
end
return isPo
end
--End
function isHeliModel()
local model = GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsIn(GetPlayerPed(-1))))
local isHe = false
for _,k in pairs(heli_model) do
if(k==model) then
isHe = true
break;
end
end
return isHe
end
function isPlaneModel()
local model = GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsIn(GetPlayerPed(-1))))
local isPl = false
for _,k in pairs(plane_model) do
if(k==model) then
isPl = true
break;
end
end
return isPl
end
function DrawAdvancedText(x,y ,w,h,sc, text, r,g,b,a,font,jus)
SetTextFont(font)
SetTextProportional(0)
SetTextScale(sc, sc)
N_0x4e096588b13ffeca(jus)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0,255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x - 0.1+w, y - 0.02+h)
end
function drawTxt(x,y ,width,height,scale, text, r,g,b,a)
SetTextFont(4)
SetTextProportional(0)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0,255)
SetTextEdge(2, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x - width/2, y - height/2 + 0.005)
end
function drawRct(x,y,width,height,r,g,b,a)
DrawRect(x + width/2, y + height/2, width, height, r, g, b, a)
end
function GetPedVehicleSeat(ped)
local vehicle = GetVehiclePedIsIn(ped, false)
for i=-2,GetVehicleMaxNumberOfPassengers(vehicle) do
if(GetPedInVehicleSeat(vehicle, i) == ped) then return i end
end
return -2
end
function IsVehInArray()
for i,k in pairs(vehiclesUsed) do
if(k.plate == GetVehicleNumberPlateText(GetVehiclePedIsUsing(GetPlayerPed(-1))) and k.model == GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(GetPlayerPed(-1))))) then
return true
end
end
return false
end
function searchByModelAndPlate(plate, model)
for i,k in pairs(vehiclesUsed) do
if(k.plate == plate and k.model == model) then
return true, i
end
end
return false, nil
end
function getVehIndex()
local index = -1
for i,k in pairs(vehiclesUsed) do
if(k.plate == GetVehicleNumberPlateText(GetVehiclePedIsUsing(GetPlayerPed(-1))) and k.model == GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(GetPlayerPed(-1))))) then
index = i
end
end
return index
end
--[[
EVENTS PART
]]--
AddEventHandler("playerSpawned", function()
TriggerServerEvent("essence:playerSpawned")
TriggerServerEvent("essence:addPlayer")
end)
RegisterNetEvent("showNotif")
AddEventHandler("showNotif", function(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end)
RegisterNetEvent("advancedFuel:setEssence")
AddEventHandler("advancedFuel:setEssence", function(percent, plate, model)
local toEssence = (percent/100)*0.142
if(GetVehicleNumberPlateText(GetVehiclePedIsUsing(GetPlayerPed(-1))) == plate and model == GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(GetPlayerPed(-1))))) then
essence = toEssence
local essenceToPercent = (essence/0.142)*65
SetVehicleFuelLevel(GetVehiclePedIsIn(GetPlayerPed(-1)),round(essenceToPercent))
end
TriggerServerEvent("advancedFuel:setEssence_s",percent,plate,model)
end)
RegisterNetEvent('essence:sendEssence')
AddEventHandler('essence:sendEssence', function(array)
for i,k in pairs(array) do
vehiclesUsed[i] = {plate=k.plate,model=k.model,es=k.es}
end
end)
RegisterNetEvent('essence:syncWithAllPlayers')
AddEventHandler('essence:syncWithAllPlayers', function(fuel, vplate, vmodel)
if(IsPedInAnyVehicle(GetPlayerPed(-1))) then
currentPedVModel = GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(GetPlayerPed(-1))))
currentPedVPlate = GetVehicleNumberPlateText(GetVehiclePedIsUsing(GetPlayerPed(-1)))
if(currentPedVModel == vmodel and currentPedVPlate == vmodel) then
essence = fuel
end
end
end)
RegisterNetEvent("essence:setEssence")
AddEventHandler("essence:setEssence", function(ess,vplate,vmodel)
if(ess ~= nil and vplate ~= nil and vmodel ~=nil) then
local bool,index = searchByModelAndPlate(vplate,vmodel)
if(bool and index ~=nil) then
vehiclesUsed[index].es = ess
else
table.insert(vehiclesUsed, {plate = vplate, model = vmodel, es = ess})
end
end
end)
RegisterNetEvent("essence:hasBuying")
AddEventHandler("essence:hasBuying", function(amount)
showDoneNotif(settings[lang].YouHaveBought..amount..settings[lang].fuel)
local amountToEssence = (amount/60)*0.142
local done = false
while done == false do
Wait(0)
local _essence = essence
if(amountToEssence-0.0005 > 0) then
amountToEssence = amountToEssence-0.0005
essence = _essence + 0.0005
_essence = essence
if(_essence > 0.142) then
essence = 0.142
done = true
end
SetVehicleUndriveable(GetVehiclePedIsUsing(GetPlayerPed(-1)), true)
SetVehicleEngineOn(GetVehiclePedIsUsing(GetPlayerPed(-1)), false, false, false)
local essenceToPercent = (essence/0.142)*65
SetVehicleFuelLevel(GetVehiclePedIsIn(GetPlayerPed(-1)),round(essenceToPercent))
Wait(100)
else
essence = essence + amountToEssence
local essenceToPercent = (essence/0.142)*65
SetVehicleFuelLevel(GetVehiclePedIsIn(GetPlayerPed(-1)),round(essenceToPercent))
done = true
end
end
TriggerServerEvent("essence:setToAllPlayerEscense", essence, GetVehicleNumberPlateText(GetVehiclePedIsUsing(GetPlayerPed(-1))), GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(GetPlayerPed(-1)))))
SetVehicleUndriveable(GetVehiclePedIsUsing(GetPlayerPed(-1)), false)
SetVehicleEngineOn(GetVehiclePedIsUsing(GetPlayerPed(-1)), true, false, false)
end)
RegisterNetEvent("essence:buyCan")
AddEventHandler("essence:buyCan", function()
GiveWeaponToPed(GetPlayerPed(-1), 0x34A67B97, currentCans+1, 0, true)
currentCans = currentCans +1
end)
RegisterNetEvent("vehicule:sendFuel")
AddEventHandler("vehicule:sendFuel", function(bool, ess)
if(bool == 1) then
essence = ess
else
essence = (math.random(20,100)/100)*0.142
--table.insert(vehiclesUsed, {plate = GetVehicleNumberPlateText(GetVehiclePedIsUsing(GetPlayerPed(-1))), model = GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(GetPlayerPed(-1)))), es = essence})
vehicle = GetVehiclePedIsUsing(GetPlayerPed(-1))
TriggerServerEvent("essence:setToAllPlayerEscense", essence, GetVehicleNumberPlateText(GetVehiclePedIsUsing(GetPlayerPed(-1))), GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(GetPlayerPed(-1)))))
end
end)