-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLanceScript.pluto
6632 lines (5980 loc) · 285 KB
/
LanceScript.pluto
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
--$$\ $$$$$$\ $$\ $$\ $$$$$$\ $$$$$$$$\
--$$ | $$ __$$\ $$$\ $$ |$$ __$$\ $$ _____|
--$$ | $$ / $$ |$$$$\ $$ |$$ / \__|$$ |
--$$ | $$$$$$$$ |$$ $$\$$ |$$ | $$$$$\
--$$ | $$ __$$ |$$ \$$$$ |$$ | $$ __|
--$$ | $$ | $$ |$$ |\$$$ |$$ | $$\ $$ |
--$$$$$$$$\ $$ | $$ |$$ | \$$ |\$$$$$$ |$$$$$$$$\
--\________|\__| \__|\__| \__| \______/ \________|
-- coded by Lance/stonerchrist on Discord
util.require_natives("2944b", "g")
pluto_use "0.5.0"
-- LANCESCRIPT FOREVER
local all_used_cameras = {}
local is_loading = true
local all_vehicles = {}
local all_objects = {}
local all_players = {}
local all_peds = {}
local all_pickups = {}
local handle_ptr = memory.alloc(13*8)
local player_cur_car = 0
local good_guns = {0, 453432689, 171789620, 487013001, -1716189206, 1119849093}
local util_alloc = memory.alloc(8)
local store_dir = filesystem.store_dir() .. '\\lancescript_forever\\'
local lyrics_dir = store_dir .. '\\lyrics\\'
local translations_dir = store_dir .. '\\translations\\'
local relative_translations_dir = "./store/lancescript_forever/translations/"
if not filesystem.is_dir(store_dir) then
filesystem.mkdirs(store_dir)
end
if not filesystem.is_dir(translations_dir) then
filesystem.mkdirs(translations_dir)
end
if not filesystem.is_dir(lyrics_dir) then
filesystem.mkdirs(lyrics_dir)
end
local function table_size(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
-- credit http://lua-users.org/wiki/StringRecipes
local function ends_with(str, ending)
return ending == "" or str:sub(-#ending) == ending
end
local translations = {}
setmetatable(translations, {
__index = function (self, key)
return key
end
})
local translation_dir_files = {}
local just_translation_files = {}
for i, path in ipairs(filesystem.list_files(translations_dir)) do
local file_str = path:gsub(translations_dir, '')
translation_dir_files[#translation_dir_files + 1] = file_str
if ends_with(file_str, '.lua') then
just_translation_files[#just_translation_files + 1] = file_str
end
end
if not table.contains(translation_dir_files, 'english.lua') then
util.toast('[LanceScript] The default english.lua translation table is missing. The script cannot run.')
util.stop_script()
end
local selected_lang_path = translations_dir .. 'selected_language.txt'
if not table.contains(translation_dir_files, 'selected_language.txt') then
local file = io.open(selected_lang_path, 'w')
file:write('english.lua')
file:close()
end
-- read selected language
if not fallback then
local selected_lang_file = io.open(selected_lang_path, 'r')
local selected_language = selected_lang_file:read()
if not table.contains(translation_dir_files, selected_language) then
util.toast(selected_language .. ' was not found. Defaulting to English.')
translations = require(relative_translations_dir .. "english")
else
translations = require(relative_translations_dir .. '\\' .. selected_language:gsub('.lua', ''))
end
end
function notify(text)
util.toast('[' .. translations.script_name_pretty .. '] ' .. text)
end
function get_user_primary_color()
local color = {}
color.r = menu.get_value(menu.ref_by_command_name("primaryred")) / 100
color.g = menu.get_value(menu.ref_by_command_name("primarygreen")) / 100
color.b = menu.get_value(menu.ref_by_command_name("primaryblue")) / 100
color.a = menu.get_value(menu.ref_by_command_name("primaryopacity")) / 100
return color
end
current_toasts = {}
-- toast renderer
util.create_tick_handler(function()
local current_y_pos = 0.00
local text_scale = 0.6
for index, toast in pairs(current_toasts) do
-- if a notif has expired, delete it
if current_y_pos == 0.00 then
current_y_pos = 0.04
else
current_y_pos += 0.07
end
if ((os.clock() - toast.start_time) >= toast.display_time) then
table.remove(current_toasts, index)
return
end
local scale_x, scale_y = directx.get_text_size(toast.text, text_scale)
local min_scale_x, min_scale_y = directx.get_text_size(translations.script_name_pretty, 0.6)
scale_x += 0.05
scale_y += 0.02
directx.draw_rect(0.5 - (scale_x / 2), current_y_pos, scale_x, scale_y, {r=0, g=0, b=0, a=0.7})
directx.draw_rect(0.5 - (scale_x / 2), current_y_pos - (scale_y/2), scale_x, 0.025, {r = 0, g = 0, b = 0, a = 1})
directx.draw_text(0.5, current_y_pos + (scale_y / 2), toast.text, 5, text_scale, {r=1, g=1, b=1, a=1}, false)
directx.draw_text(0.5, current_y_pos - (scale_y / 2), translations.script_name_pretty, 1, 0.6, {r=1, g=1, b=1, a=1}, false)
end
current_y_pos = 0.00
end)
-- holiday
local today = os.date('%m/%d')
if not SCRIPT_SILENT_START then
if today == "10/31" then
notify(translations.happy_halloween)
elseif today == '11/24' then
notify(translations.happy_thanksgiving)
elseif today == '12/25' then
notify(translations.merry_christmas)
elseif today == '12/31' then
notify(translations.new_years_eve)
elseif today == '01/01' then
notify(translations.new_years_day)
end
end
-- start organizing the MAIN lists (ones just at root level/right under it)
-- BEGIN SELF SUBSECTIONS
local self_root = menu.list(menu.my_root(), translations.me, {translations.me_cmd}, translations.me_desc)
local chauffeur_root = menu.list(self_root, translations.chauffeur, {translations.chauffeur}, translations.chauffeur_desc)
local rideable_animals_root = menu.list(self_root, translations.rideable_animals, {"rideableanimals"}, "")
local my_vehicle_root = menu.list(self_root, translations.my_vehicle, {translations.my_vehicle_cmd}, translations.my_vehicle_desc)
local combat_root = menu.list(self_root, translations.combat, {translations.combat_cmd}, translations.combat_desc)
-- END SELF SUBSECTIONS
-- BEGIN ONLINE SUBSECTIONS
local online_root = menu.list(menu.my_root(), translations.online, {translations.online_cmd}, translations.online_desc)
local players_root = menu.list(menu.my_root(), translations.players, {"lanceplayers"}, "")
local friends_in_this_session = {}
local modders_in_this_session = {}
local friends_in_session_list = menu.list_action(players_root, translations.friends_in_session, {"friendsinsession"}, "", friends_in_this_session, function(pid, name) menu.trigger_commands("p" .. players.get_name(pid)) end)
local modders_in_session_list = menu.list_action(players_root, translations.modders_in_session, {"moddersinsession"}, "", modders_in_this_session, function(pid, name) menu.trigger_commands("p" .. players.get_name(pid)) end)
local detections_root = menu.list(online_root, translations.detections, {translations.detections_cmd}, "")
local protections_root = menu.list(online_root, translations.protections, {translations.protections_cmd}, translations.protections_desc)
local randomizer_root = menu.list(online_root, translations.randomizer, {translations.randomizer_cmd}, translations.randomizer_desc)
local speedrun_root = menu.list(online_root, translations.speedrun, {translations.speedrun_cmd}, translations.speedrun_desc)
local chat_presets_root = menu.list(online_root, translations.chatpresets, {translations.chatpresets_cmd}, translations.chatpresets_desc)
local players_shortcut_command = menu.ref_by_path('Players', 37)
menu.action(players_root, translations.stand_players_shortcut, {}, "", function(click_type)
menu.trigger_command(players_shortcut_command)
end)
local function get_stat_by_name(stat_name, character)
if character then
stat_name = "MP" .. tostring(util.get_char_slot()) .. "_" .. stat_name
end
local out = memory.alloc(8)
STAT_GET_INT(GET_HASH_KEY(stat_name), out, -1)
return memory.read_int(out)
end
local ap_root = menu.list(online_root, translations.all_players, {translations.all_players_cmd}, "")
local apfriendly_root = menu.list(ap_root, translations.all_players_friendly, {translations.all_players_friendly_cmd}, "")
local aphostile_root = menu.list(ap_root, translations.all_players_hostile, {translations.all_players_hostile_cmd}, "")
local apneutral_root = menu.list(ap_root, translations.all_players_neutral, {translations.all_players_neutral_cmd}, "")
-- END ONLINE SUBSECTIONS
-- BEGIN ENTITIES SUBSECTION
local entities_root = menu.list(menu.my_root(), translations.entities, {translations.entities_cmd}, translations.entities_desc)
local peds_root = menu.list(entities_root, translations.peds, {translations.peds_cmd}, translations.peds_desc)
local vehicles_root = menu.list(entities_root, translations.vehicles, {translations.vehicles_cmd}, translations.vehicles_desc)
local pickups_root = menu.list(entities_root, translations.pickups, {translations.pickups_cmd}, translations.pickups_desc)
-- END ENTITIES SUBSECTION
local world_root = menu.list(menu.my_root(), translations.world, {translations.world_cmd}, translations.world_desc)
local train_root = menu.list(world_root, translations.train_control, {"traincontrol"})
local tweaks_root = menu.list(menu.my_root(), translations.gametweaks, {translations.gametweaks_cmd}, translations.gametweaks_desc)
local god_graphics_root = menu.list(tweaks_root, translations.god_graphics, {""}, translations.god_graphics_desc)
local lancescript_root = menu.list(menu.my_root(), translations.misc, {translations.misc_cmd}, translations.misc_desc)
menu.my_root():hyperlink('Join Discord', 'https://discord.gg/zZ2eEjj88v', '')
-- entity-pool gathering handling
vehicle_uses = 0
ped_uses = 0
pickup_uses = 0
player_uses = 0
object_uses = 0
robustmode = false
local function mod_uses(type, incr)
-- this func is a patch. every time the script loads, all the toggles load and set their state. in some cases this makes the _uses optimization negative and breaks things. this prevents that.
if incr < 0 and is_loading then
return
end
if type == "vehicle" then
if vehicle_uses <= 0 and incr < 0 then
return
end
vehicle_uses = vehicle_uses + incr
elseif type == "pickup" then
if pickup_uses <= 0 and incr < 0 then
return
end
pickup_uses = pickup_uses + incr
elseif type == "ped" then
if ped_uses <= 0 and incr < 0 then
return
end
ped_uses = ped_uses + incr
elseif type == "player" then
if player_uses <= 0 and incr < 0 then
return
end
player_uses = player_uses + incr
elseif type == "object" then
if object_uses <= 0 and incr < 0 then
return
end
object_uses = object_uses + incr
end
end
-- UTILTITY FUNCTIONS
local alphabet = "abcdefghijklmnopqrstuvwxyzABCEDFGHIJKLMNOPQRSTUVWXYZ0123456789"
function is_user_a_stand_user(pid)
if pid == players.user() then
return true
end
if players.exists(pid) then
for _, cmd in ipairs(menu.player_root(pid):getChildren()) do
if cmd:getType() == COMMAND_LIST_CUSTOM_SPECIAL_MEANING and (cmd:refByRelPath("Stand User"):isValid() or cmd:refByRelPath("Stand User (Co-Loading"):isValid()) then
return true
end
end
end
return false
end
function random_string(length)
local res = {}
for i=1, length do
res[i] = alphabet[math.random(#alphabet)]
end
return table.concat(res)
end
function random_ip_address()
local ip = {}
for i=1, 4 do
ip[i] = tostring(math.random(1, 255))
end
return table.concat(ip, '.')
end
local function request_anim_dict(dict)
while not HAS_ANIM_DICT_LOADED(dict) do
REQUEST_ANIM_DICT(dict)
util.yield()
end
end
local function request_anim_set(set)
while not HAS_ANIM_SET_LOADED(set) do
REQUEST_ANIM_SET(set)
util.yield()
end
end
local function exportstring( s )
return string.format("%q", s)
end
function table.save( tbl,filename )
local charS,charE = " ","\n"
local file,err = io.open( filename, "wb" )
if err then return err end
-- initiate variables for save procedure
local tables,lookup = { tbl },{ [tbl] = 1 }
file:write( "return {"..charE )
for idx,t in ipairs( tables ) do
file:write( "-- Table: {"..idx.."}"..charE )
file:write( "{"..charE )
local thandled = {}
for i,v in ipairs( t ) do
thandled[i] = true
local stype = type( v )
-- only handle value
if stype == "table" then
if not lookup[v] then
table.insert( tables, v )
lookup[v] = #tables
end
file:write( charS.."{"..lookup[v].."},"..charE )
elseif stype == "string" then
file:write( charS..exportstring( v )..","..charE )
elseif stype == "number" then
file:write( charS..tostring( v )..","..charE )
end
end
for i,v in pairs( t ) do
-- escape handled values
if (not thandled[i]) then
local str = ""
local stype = type( i )
-- handle index
if stype == "table" then
if not lookup[i] then
table.insert( tables,i )
lookup[i] = #tables
end
str = charS.."[{"..lookup[i].."}]="
elseif stype == "string" then
str = charS.."["..exportstring( i ).."]="
elseif stype == "number" then
str = charS.."["..tostring( i ).."]="
end
if str ~= "" then
stype = type( v )
-- handle value
if stype == "table" then
if not lookup[v] then
table.insert( tables,v )
lookup[v] = #tables
end
file:write( str.."{"..lookup[v].."},"..charE )
elseif stype == "string" then
file:write( str..exportstring( v )..","..charE )
elseif stype == "number" then
file:write( str..tostring( v )..","..charE )
end
end
end
end
file:write( "},"..charE )
end
file:write( "}" )
file:close()
end
function table.load( sfile )
local ftables,err = loadfile( sfile )
if err then return _,err end
local tables = ftables()
for idx = 1,#tables do
local tolinki = {}
for i,v in pairs( tables[idx] ) do
if type( v ) == "table" then
tables[idx][i] = tables[v[1]]
end
if type( i ) == "table" and tables[i[1]] then
table.insert( tolinki,{ i,tables[i[1]] } )
end
end
-- link indices
for _,v in ipairs( tolinki ) do
tables[idx][v[2]],tables[idx][v[1]] = tables[idx][v[1]],nil
end
end
return tables[1]
end
function request_anim_dict(dict)
request_time = os.time()
if not DOES_ANIM_DICT_EXIST(dict) then
return
end
REQUEST_ANIM_DICT(dict)
while not HAS_ANIM_DICT_LOADED(dict) do
if os.time() - request_time >= 10 then
break
end
util.yield()
end
end
function request_ptfx_asset(asset)
local request_time = os.time()
REQUEST_NAMED_PTFX_ASSET(asset)
while not HAS_NAMED_PTFX_ASSET_LOADED(asset) do
if os.time() - request_time >= 10 then
break
end
util.yield()
end
end
-- credit to vsus
local function is_script_running(str)
return GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(util.joaat(str)) > 0
end
local function request_game_script(str)
if not DOES_SCRIPT_EXIST(str) or is_script_running(str) then
return false
end
if is_script_running(str) then
return true
end
REQUEST_SCRIPT(str)
while not HAS_SCRIPT_LOADED(str) do
util.yield()
end
end
-- CREDIT TO NOWIRY
local function get_entity_owner(entity)
local pEntity = entities.handle_to_pointer(entity)
local addr = memory.read_long(pEntity + 0xD0)
return (addr ~= 0) and memory.read_byte(addr + 0x49) or -1
end
local function world_to_screen_coords(x, y, z)
sc_x = memory.alloc(8)
sc_y = memory.alloc(8)
GET_SCREEN_COORD_FROM_WORLD_COORD(x, y, z, sc_x, sc_y)
local ret = {
x = memory.read_float(sc_x),
y = memory.read_float(sc_y)
}
return ret
end
local function is_entity_a_projectile(hash)
local all_projectile_hashes = {
util.joaat("w_ex_vehiclemissile_1"),
util.joaat("w_ex_vehiclemissile_2"),
util.joaat("w_ex_vehiclemissile_3"),
util.joaat("w_ex_vehiclemissile_4"),
util.joaat("w_ex_vehiclem,tar"),
util.joaat("w_ex_apmine"),
util.joaat("w_ex_arena_landmine_01b"),
util.joaat("w_ex_birdshat"),
util.joaat("w_ex_grenadefrag"),
util.joaat("w_ex_grenadesmoke"),
util.joaat("w_ex_molotov"),
util.joaat("w_ex_pe"),
util.joaat("w_ex_pipebomb"),
util.joaat("w_ex_snowball"),
util.joaat("w_lr_rpg_rocket"),
util.joaat("w_lr_homing_rocket"),
util.joaat("w_lr_firew,k_rocket"),
util.joaat("xm_prop_x17_silo_rocket_01")
}
return table.contains(all_projectile_hashes, hash)
end
timed_thread = util.create_thread(function (thr)
tlightstate = 0
while true do
if tlightstate < 3 then
tlightstate = tlightstate + 1
else
tlightstate = 0
end
util.yield(100)
end
end)
rgb_thread = util.create_thread(function (thr)
local r = 255
local g = 0
local b = 0
rgb = {255, 0, 0}
while true do
if not custom_rgb then
if r > 0 and g < 255 and b == 0 then
r = r - 1
g = g + 1
elseif r == 0 and g > 0 and b < 255 then
g = g - 1
b = b + 1
elseif r < 255 and b > 0 then
r = r + 1
b = b - 1
end
rgb[1] = r
rgb[2] = g
rgb[3] = b
else
rgb = {custom_r, custom_g, custom_b}
end
util.yield()
end
end)
--https://stackoverflow.com/questions/34618946/lua-base64-encode
local b='/+9876543210zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA'
local function b64_enc(data)
return ((data:gsub('.', function(x)
local r,b='',x:byte()
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
return r;
end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
if (#x < 6) then return '' end
local c=0
for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
return b:sub(c+1,c+1)
end)..({ '', '==', '=' })[#data%3+1])
end
--https://stackoverflow.com/questions/34618946/lua-base64-encode
-- decoding
local function b64_dec(data)
data = string.gsub(data, '[^'..b..'=]', '')
return (data:gsub('.', function(x)
if (x == '=') then return '' end
local r,f='',(b:find(x)-1)
for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
return r;
end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
if (#x ~= 8) then return '' end
local c=0
for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
return string.char(c)
end))
end
-- detections
detection_teleports = false
menu.toggle(detections_root, translations.teleport_detection, {translations.teleport_detection_cmd}, translations.teleport_detection_desc, function(on)
detection_teleports = on
end)
detection_follow = false
menu.toggle(detections_root, translations.follow_detection, {translations.follow_detection_cmd}, translations.follow_detection_desc, function(on)
detection_follow = on
end)
detection_bslevel = false
menu.toggle(detections_root, translations.bullshit_level_detection, {translations.bullshit_level_detection_cmd}, translations.bullshit_level_detection_desc, function(on)
detection_bslevel = on
end, false)
detection_money = false
menu.toggle(detections_root, translations.money_detection, {translations.money_detection_cmd}, translations.money_detection_desc, function(on)
detection_money = on
end, false)
local admin_bail = true
menu.toggle(protections_root, translations.admin_bail, {translations.admin_bail_cmd}, translations.admin_bail_desc, function(on)
admin_bail = on
while admin_bail do
if util.is_session_started() then
for _, pid in players.list(false, true, true) do
if players.is_marked_as_admin(pid) then
notify(translations.admin_detected)
menu.trigger_commands("quickbail")
end
end
end
util.yield()
end
end, true)
local function get_random_joke()
local joke = 'WIP'
local in_progress = true
async_http.init('icanhazdadjoke.com', '', function(data)
joke = data
end, function()
joke = 'FAIL'
end)
async_http.add_header('Accept', 'text/plain')
async_http.dispatch()
while joke == "WIP" do
util.yield()
end
return joke
end
menu.action(chat_presets_root, translations.dox, {}, translations.dox_desc, function(click_type)
chat.send_message("${name}: ${ip} | ${geoip.city}, ${geoip.region}, ${geoip.country}", false, true, true)
end)
local function shuffle_in_place(t)
for i = #t, 2, -1 do
local j = math.random(i)
t[i], t[j] = t[j], t[i]
end
end
function first_to_upper(str)
return (str:gsub("^%l", string.upper))
end
local function chat_bullshit_data(pid)
local first_names = {"JAMES", "JOHN", "ROBERT", "MICHAEL", "WILLIAM", "DAVID", "RICHARD", "CHARLES", "JOSEPH", "THOMAS", "CHRISTOPHER", "DANIEL", "PAUL", "MARK", "DONALD", "GEORGE", "KENNETH", "STEVEN", "EDWARD", "BRIAN", "RONALD", "ANTHONY", "KEVIN", "JASON", "MATTHEW", "GARY", "TIMOTHY", "JOSE", "LARRY", "JEFFREY", "FRANK", "SCOTT", "ERIC", "STEPHEN", "ANDREW", "RAYMOND", "GREGORY", "JOSHUA", "JERRY", "DENNIS", "WALTER", "PATRICK", "PETER", "HAROLD", "DOUGLAS", "HENRY", "CARL", "ARTHUR", "RYAN", "ROGER", "JOE", "JUAN", "JACK", "ALBERT", "JONATHAN", "JUSTIN", "TERRY", "GERALD", "KEITH", "SAMUEL", "WILLIE", "RALPH", "LAWRENCE", "NICHOLAS", "ROY", "BENJAMIN", "BRUCE", "BRANDON", "ADAM", "HARRY", "FRED", "WAYNE", "BILLY", "STEVE", "LOUIS", "JEREMY", "AARON", "RANDY", "HOWARD", "EUGENE", "CARLOS", "RUSSELL", "BOBBY", "VICTOR", "MARTIN", "ERNEST", "PHILLIP", "TODD", "JESSE", "CRAIG", "ALAN", "SHAWN", "CLARENCE", "SEAN", "PHILIP", "CHRIS", "JOHNNY", "EARL", "JIMMY", "ANTONIO"}
local last_names = {"smith" , "johnson" , "williams" , "brown" , "jones" , "miller" , "davis" , "garcia" , "rodriguez" , "wilson" , "martinez" , "anderson" , "taylor" , "thomas" , "hernandez" , "moore" , "martin" , "jackson" , "thompson" , "white" , "lopez" , "lee" , "gonzalez" , "harris" , "clark" , "lewis" , "robinson" , "walker" , "perez" , "hall" , "young" , "allen" , "sanchez" , "wright" , "king" , "scott" , "green" , "baker" , "adams" , "nelson" , "hill" , "ramirez" , "campbell" , "mitchell" , "roberts" , "carter" , "phillips" , "evans" , "turner" , "torres" , "parker" , "collins" , "edwards" , "stewart" , "flores" , "morris" , "nguyen" , "murphy" , "rivera" , "cook" , "rogers" , "morgan" , "peterson" , "cooper" , "reed" , "bailey" , "bell" , "gomez" , "kelly" , "howard" , "ward" , "cox" , "diaz" , "richardson" , "wood" , "watson" , "brooks" , "bennett" , "gray" , "james" , "reyes" , "cruz" , "hughes" , "price" , "myers" , "long" , "foster" , "sanders" , "ross" , "morales" , "powell" , "sullivan" , "russell" , "ortiz" , "jenkins" , "gutierrez" , "perry" , "butler" , "barnes" , "fisher"}
local addresses = {"777 Brockton Avenue, Abington MA 2351" , "30 Memorial Drive, Avon MA 2322" , "250 Hartford Avenue, Bellingham MA 2019" , "700 Oak Street, Brockton MA 2301" , "66-4 Parkhurst Rd, Chelmsford MA 1824" , "591 Memorial Dr, Chicopee MA 1020" , "55 Brooksby Village Way, Danvers MA 1923" , "137 Teaticket Hwy, East Falmouth MA 2536" , "42 Fairhaven Commons Way, Fairhaven MA 2719" , "374 William S Canning Blvd, Fall River MA 2721" , "121 Worcester Rd, Framingham MA 1701" , "677 Timpany Blvd, Gardner MA 1440" , "337 Russell St, Hadley MA 1035" , "295 Plymouth Street, Halifax MA 2338" , "1775 Washington St, Hanover MA 2339" , "280 Washington Street, Hudson MA 1749" , "20 Soojian Dr, Leicester MA 1524" , "11 Jungle Road, Leominster MA 1453" , "301 Massachusetts Ave, Lunenburg MA 1462" , "780 Lynnway, Lynn MA 1905" , "70 Pleasant Valley Street, Methuen MA 1844" , "830 Curran Memorial Hwy, North Adams MA 1247" , "1470 S Washington St, North Attleboro MA 2760" , "506 State Road, North Dartmouth MA 2747" , "742 Main Street, North Oxford MA 1537" , "72 Main St, North Reading MA 1864" , "200 Otis Street, Northborough MA 1532" , "180 North King Street, Northhampton MA 1060" , "555 East Main St, Orange MA 1364" , "555 Hubbard Ave-Suite 12, Pittsfield MA 1201" , "300 Colony Place, Plymouth MA 2360" , "301 Falls Blvd, Quincy MA 2169" , "36 Paramount Drive, Raynham MA 2767" , "450 Highland Ave, Salem MA 1970" , "1180 Fall River Avenue, Seekonk MA 2771" , "1105 Boston Road, Springfield MA 1119" , "100 Charlton Road, Sturbridge MA 1566" , "262 Swansea Mall Dr, Swansea MA 2777" , "333 Main Street, Tewksbury MA 1876" , "550 Providence Hwy, Walpole MA 2081" , "352 Palmer Road, Ware MA 1082" , "3005 Cranberry Hwy Rt 6 28, Wareham MA 2538" , "250 Rt 59, Airmont NY 10901" , "141 Washington Ave Extension, Albany NY 12205" , "13858 Rt 31 W, Albion NY 14411" , "2055 Niagara Falls Blvd, Amherst NY 14228" , "101 Sanford Farm Shpg Center, Amsterdam NY 12010" , "297 Grant Avenue, Auburn NY 13021" , "4133 Veterans Memorial Drive, Batavia NY 14020" , "6265 Brockport Spencerport Rd, Brockport NY 14420" , "5399 W Genesse St, Camillus NY 13031" , "3191 County rd 10, Canandaigua NY 14424" , "30 Catskill, Catskill NY 12414" , "161 Centereach Mall, Centereach NY 11720" , "3018 East Ave, Central Square NY 13036" , "100 Thruway Plaza, Cheektowaga NY 14225" , "8064 Brewerton Rd, Cicero NY 13039" , "5033 Transit Road, Clarence NY 14031" , "3949 Route 31, Clay NY 13041" , "139 Merchant Place, Cobleskill NY 12043" , "85 Crooked Hill Road, Commack NY 11725" , "872 Route 13, Cortlandville NY 13045" , "279 Troy Road, East Greenbush NY 12061" , "2465 Hempstead Turnpike, East Meadow NY 11554" , "6438 Basile Rowe, East Syracuse NY 13057" , "25737 US Rt 11, Evans Mills NY 13637" , "901 Route 110, Farmingdale NY 11735" , "2400 Route 9, Fishkill NY 12524" , "10401 Bennett Road, Fredonia NY 14063" , "1818 State Route 3, Fulton NY 13069" , "4300 Lakeville Road, Geneseo NY 14454" , "990 Route 5 20, Geneva NY 14456" , "311 RT 9W, Glenmont NY 12077" , "200 Dutch Meadows Ln, Glenville NY 12302" , "100 Elm Ridge Center Dr, Greece NY 14626" , "1549 Rt 9, Halfmoon NY 12065" , "5360 Southwestern Blvd, Hamburg NY 14075" , "103 North Caroline St, Herkimer NY 13350" , "1000 State Route 36, Hornell NY 14843" , "1400 County Rd 64, Horseheads NY 14845" , "135 Fairgrounds Memorial Pkwy, Ithaca NY 14850" , "2 Gannett Dr, Johnson City NY 13790" , "233 5th Ave Ext, Johnstown NY 12095" , "601 Frank Stottile Blvd, Kingston NY 12401" , "350 E Fairmount Ave, Lakewood NY 14750" , "4975 Transit Rd, Lancaster NY 14086" , "579 Troy-Schenectady Road, Latham NY 12110" , "5783 So Transit Road, Lockport NY 14094" , "7155 State Rt 12 S, Lowville NY 13367" , "425 Route 31, Macedon NY 14502" , "3222 State Rt 11, Malone NY 12953" , "200 Sunrise Mall, Massapequa NY 11758" , "43 Stephenville St, Massena NY 13662" , "750 Middle Country Road, Middle Island NY 11953" , "470 Route 211 East, Middletown NY 10940" , "3133 E Main St, Mohegan Lake NY 10547" , "288 Larkin, Monroe NY 10950" , "41 Anawana Lake Road, Monticello NY 12701" , "4765 Commercial Drive, New Hartford NY 13413" , "1201 Rt 300, Newburgh NY 12550" , "255 W Main St, Avon CT 6001" , "120 Commercial Parkway, Branford CT 6405" , "1400 Farmington Ave, Bristol CT 6010" , "161 Berlin Road, Cromwell CT 6416" , "67 Newton Rd, Danbury CT 6810" , "656 New Haven Ave, Derby CT 6418" , "69 Prospect Hill Road, East Windsor CT 6088" , "150 Gold Star Hwy, Groton CT 6340" , "900 Boston Post Road, Guilford CT 6437" , "2300 Dixwell Ave, Hamden CT 6514" , "495 Flatbush Ave, Hartford CT 6106" , "180 River Rd, Lisbon CT 6351" , "420 Buckland Hills Dr, Manchester CT 6040" , "1365 Boston Post Road, Milford CT 6460" , "1100 New Haven Road, Naugatuck CT 6770" , "315 Foxon Blvd, New Haven CT 6513" , "164 Danbury Rd, New Milford CT 6776" , "3164 Berlin Turnpike, Newington CT 6111" , "474 Boston Post Road, North Windham CT 6256" , "650 Main Ave, Norwalk CT 6851" , "680 Connecticut Avenue, Norwalk CT 6854" , "220 Salem Turnpike, Norwich CT 6360" , "655 Boston Post Rd, Old Saybrook CT 6475" , "625 School Street, Putnam CT 6260" , "80 Town Line Rd, Rocky Hill CT 6067" , "465 Bridgeport Avenue, Shelton CT 6484" , "235 Queen St, Southington CT 6489" , "150 Barnum Avenue Cutoff, Stratford CT 6614" , "970 Torringford Street, Torrington CT 6790" , "844 No Colony Road, Wallingford CT 6492" , "910 Wolcott St, Waterbury CT 6705" , "155 Waterford Parkway No, Waterford CT 6385" , "515 Sawmill Road, West Haven CT 6516" , "2473 Hackworth Road, Adamsville AL 35005" , "630 Coonial Promenade Pkwy, Alabaster AL 35007" , "2643 Hwy 280 West, Alexander City AL 35010" , "540 West Bypass, Andalusia AL 36420" , "5560 Mcclellan Blvd, Anniston AL 36206" , "1450 No Brindlee Mtn Pkwy, Arab AL 35016" , "1011 US Hwy 72 East, Athens AL 35611" , "973 Gilbert Ferry Road Se, Attalla AL 35954" , "1717 South College Street, Auburn AL 36830" , "701 Mcmeans Ave, Bay Minette AL 36507" , "750 Academy Drive, Bessemer AL 35022" , "312 Palisades Blvd, Birmingham AL 35209" , "1600 Montclair Rd, Birmingham AL 35210" , "5919 Trussville Crossings Pkwy, Birmingham AL 35235" , "9248 Parkway East, Birmingham AL 35206" , "1972 Hwy 431, Boaz AL 35957" , "10675 Hwy 5, Brent AL 35034" , "2041 Douglas Avenue, Brewton AL 36426" , "5100 Hwy 31, Calera AL 35040" , "1916 Center Point Rd, Center Point AL 35215" , "1950 W Main St, Centre AL 35960" , "16077 Highway 280, Chelsea AL 35043" , "1415 7Th Street South, Clanton AL 35045" , "626 Olive Street Sw, Cullman AL 35055" , "27520 Hwy 98, Daphne AL 36526" , "2800 Spring Avn SW, Decatur AL 35603" , "969 Us Hwy 80 West, Demopolis AL 36732" , "3300 South Oates Street, Dothan AL 36301" , "4310 Montgomery Hwy, Dothan AL 36303" , "600 Boll Weevil Circle, Enterprise AL 36330" , "3176 South Eufaula Avenue, Eufaula AL 36027" , "7100 Aaron Aronov Drive, Fairfield AL 35064" , "10040 County Road 48, Fairhope AL 36533" , "3186 Hwy 171 North, Fayette AL 35555" , "3100 Hough Rd, Florence AL 35630" , "2200 South Mckenzie St, Foley AL 36535" , "2001 Glenn Bldv Sw, Fort Payne AL 35968" , "340 East Meighan Blvd, Gadsden AL 35903" , "890 Odum Road, Gardendale AL 35071" , "1608 W Magnolia Ave, Geneva AL 36340" , "501 Willow Lane, Greenville AL 36037" , "170 Fort Morgan Road, Gulf Shores AL 36542" , "11697 US Hwy 431, Guntersville AL 35976" , "42417 Hwy 195, Haleyville AL 35565" , "1706 Military Street South, Hamilton AL 35570" , "1201 Hwy 31 NW, Hartselle AL 35640" , "209 Lakeshore Parkway, Homewood AL 35209" , "2780 John Hawkins Pkwy, Hoover AL 35244" , "5335 Hwy 280 South, Hoover AL 35242" , "1007 Red Farmer Drive, Hueytown AL 35023" , "2900 S Mem PkwyDrake Ave, Huntsville AL 35801" , "11610 Memorial Pkwy South, Huntsville AL 35803" , "2200 Sparkman Drive, Huntsville AL 35810" , "330 Sutton Rd, Huntsville AL 35763" , "6140A Univ Drive, Huntsville AL 35806" , "4206 N College Ave, Jackson AL 36545" , "1625 Pelham South, Jacksonville AL 36265" , "1801 Hwy 78 East, Jasper AL 35501" , "8551 Whitfield Ave, Leeds AL 35094" , "8650 Madison Blvd, Madison AL 35758" , "145 Kelley Blvd, Millbrook AL 36054" , "1970 S University Blvd, Mobile AL 36609" , "6350 Cottage Hill Road, Mobile AL 36609" , "101 South Beltline Highway, Mobile AL 36606" , "2500 Dawes Road, Mobile AL 36695" , "5245 Rangeline Service Rd, Mobile AL 36619" , "685 Schillinger Rd, Mobile AL 36695" , "3371 S Alabama Ave, Monroeville AL 36460" , "10710 Chantilly Pkwy, Montgomery AL 36117" , "3801 Eastern Blvd, Montgomery AL 36116" , "6495 Atlanta Hwy, Montgomery AL 36117" , "851 Ann St, Montgomery AL 36107" , "15445 Highway 24, Moulton AL 35650" , "517 West Avalon Ave, Muscle Shoals AL 35661" , "5710 Mcfarland Blvd, Northport AL 35476" , "2453 2Nd Avenue East, Oneonta AL 35121 205-625-647" , "2900 Pepperrell Pkwy, Opelika AL 36801" , "92 Plaza Lane, Oxford AL 36203" , "1537 Hwy 231 South, Ozark AL 36360" , "2181 Pelham Pkwy, Pelham AL 35124" , "165 Vaughan Ln, Pell City AL 35125" , "3700 Hwy 280-431 N, Phenix City AL 36867" , "1903 Cobbs Ford Rd, Prattville AL 36066" , "4180 Us Hwy 431, Roanoke AL 36274" , "13675 Hwy 43, Russellville AL 35653" , "1095 Industrial Pkwy, Saraland AL 36571" , "24833 Johnt Reidprkw, Scottsboro AL 35768" , "1501 Hwy 14 East, Selma AL 36703" , "7855 Moffett Rd, Semmes AL 36575" , "150 Springville Station Blvd, Springville AL 35146" , "690 Hwy 78, Sumiton AL 35148" , "41301 US Hwy 280, Sylacauga AL 35150" , "214 Haynes Street, Talladega AL 35160" , "1300 Gilmer Ave, Tallassee AL 36078" , "34301 Hwy 43, Thomasville AL 36784" , "1420 Us 231 South, Troy AL 36081" , "1501 Skyland Blvd E, Tuscaloosa AL 35405" , "3501 20th Av, Valley AL 36854" , "1300 Montgomery Highway, Vestavia Hills AL 35216" , "4538 Us Hwy 231, Wetumpka AL 36092" , "2575 Us Hwy 43, Winfield AL 35594"}
local rand_words = {"car", "cartoon", "fun", "boy", "girl", "spaghetti", "pizza", "guitar", "music", "ratio", "dog", "cat", "password"}
local password = rand_words[math.random(#rand_words)] .. math.random(10, 99)
local name = first_to_upper(string.lower(first_names[math.random(#first_names)])) .. ' ' .. first_to_upper(string.lower(last_names[math.random(#last_names)]))
local ssn = math.random(100, 999) .. '-' .. math.random(10, 99) .. '-' .. math.random(1000, 9999)
local phone_num = '+1 (' .. math.random(100, 999) .. ')' .. '-' .. math.random(100, 999) .. '-' .. math.random(1000, 9999)
local ip = math.random(255) .. '.' .. math.random(255) .. '.' .. math.random(255) .. '.' .. math.random(255)
local blood_types = {'A+', 'B+', 'AB+', 'A-', 'B-', 'AB-', 'O+', 'O-'}
chat.send_targeted_message(pid, players.user(), players.get_name(pid) .. ' DOX:', false, true, true)
chat.send_targeted_message(pid, players.user(), 'Real name: ' .. name .. ' • Address: ' .. addresses[math.random(#addresses)] .. ' • SSN: ' .. ssn .. ' • SC Password: ' .. password, false, true, true)
chat.send_targeted_message(pid, players.user(), 'Phone: ' .. phone_num .. ' • Mother\'s maiden name: ' .. first_to_upper(string.lower(last_names[math.random(#last_names)])) .. ' • IP: ' .. ip .. ' • Blood type: ' .. blood_types[math.random(#blood_types)], false, true, true)
end
menu.action(chat_presets_root, translations.ultra_dox, {}, translations.ultra_dox_desc, function(click_type)
-- now we have the request
for _, pid in pairs(players.list(true, true, true)) do
local data = chat_bullshit_data(pid)
end
end)
function fake_chat_with_percentage_and_target(action)
chat.send_message(action .. " ${name}. [|||| ] (25%)", false, true, true)
util.yield(math.random(500, 3000))
chat.send_message(action .. " ${name}. [|||||||| ] (50%)", false, true, true)
util.yield(math.random(500, 3000))
chat.send_message(action .. " ${name}. [|||||||||||| ] (75%)", false, true, true)
util.yield(math.random(500, 3000))
chat.send_message(action .. " ${name}. [||||||||||||||| ] (89%)", false, true, true)
util.yield(math.random(3000, 5000))
end
menu.action(chat_presets_root, translations.fake_crash, {}, translations.fake_crash_desc, function(click_type)
fake_chat_with_percentage_and_target(translations.crashing)
chat.send_message(translations.failed_to_crash .. " ${name}. " .. translations.reason_unknown, false, true, true)
end)
menu.action(chat_presets_root, translations.fake_hack, {}, translations.fake_hack_desc, function(click_type)
fake_chat_with_percentage_and_target(translations.hacking)
chat.send_message(translations.failed_to_hack .. " ${name}. " .. translations.reason_unknown, false, true, true)
end)
menu.action(chat_presets_root, translations.random_joke, {translations.random_joke_cmd}, translations.random_joke_desc, function(click_type)
local joke = get_random_joke()
if joke ~= "FAIL" then
chat.send_message(joke, false, true, true)
end
end)
menu.toggle_loop(chat_presets_root, translations.random_joke_loop, {translations.random_joke_loop_cmd}, translations.random_joke_loop_desc, function(click_type)
if util.is_session_started() then
local joke = get_random_joke()
if joke ~= "FAIL" then
chat.send_message(joke, false, true, true)
end
util.yield(5000)
end
end)
--https://icanhazdadjoke.com/
local chat_presets = {
[translations.chat_preset_1_name] = translations.chat_preset_1_content,
[translations.chat_preset_2_name] = translations.chat_preset_2_content,
[translations.chat_preset_3_name] = translations.chat_preset_3_content,
[translations.chat_preset_4_name] = translations.chat_preset_4_content,
[translations.chat_preset_5_name] = translations.chat_preset_5_content
}
for k,v in pairs(chat_presets) do
menu.action(chat_presets_root, k, {}, "\"" .. v .. "\"", function(click_type)
chat.send_message(v, false, true, true)
end)
end
local function pid_to_handle(pid)
NETWORK_HANDLE_FROM_PLAYER(pid, handle_ptr, 13)
return handle_ptr
end
local function get_model_size(hash)
local minptr = memory.alloc(24)
local maxptr = memory.alloc(24)
local min = {}
local max = {}
GET_MODEL_DIMENSIONS(hash, minptr, maxptr)
min.x, min.y, min.z = v3.get(minptr)
max.x, max.y, max.z = v3.get(maxptr)
local size = {}
size.x = max.x - min.x
size.y = max.y - min.y
size.z = max.z - min.z
size['max'] = math.max(size.x, size.y, size.z)
return size
end
-- creative rgb vector from params (unused func??)
local function to_rgb(r, g, b, a)
local color = {}
color.r = r
color.g = g
color.b = b
color.a = a
return color
end
-- credit to nowiry
local function set_entity_face_entity(entity, target, usePitch)
local pos1 = GET_ENTITY_COORDS(entity, false)
local pos2 = GET_ENTITY_COORDS(target, false)
local rel = v3.new(pos2)
rel:sub(pos1)
local rot = rel:toRot()
if not usePitch then
SET_ENTITY_HEADING(entity, rot.z)
else
SET_ENTITY_ROTATION(entity, rot.x, rot.y, rot.z, 2, 0)
end
end
-- pre-made rgb's
black = to_rgb(0.0,0.0,0.0,1.0)
white = to_rgb(1.0,1.0,1.0,1.0)
red = to_rgb(1,0,0,1)
green = to_rgb(0,1,0,1)
blue = to_rgb(0.0,0.0,1.0,1.0)
-- RAYCAST SHIT
local function interpolate(y0, y1, perc)
perc = perc > 1.0 and 1.0 or perc
return (1 - perc) * y0 + perc * y1
end
local function get_health_colour(perc)
local result = {a = 255}
local r, g, b
if perc <= 0.5 then
r = 1.0
g = interpolate(0.0, 1.0, perc/0.5)
b = 0.0
else
r = interpolate(1.0, 0, (perc - 0.5)/0.5)
g = 1.0
b = 0.0
end
result.r = math.ceil(r * 255)
result.g = math.ceil(g * 255)
result.b = math.ceil(b * 255)
return result
end
local function draw_marker(type, pos, dir, rot, scale, rotate, colour, txdDict, txdName)
txdDict = txdDict or 0
txdName = txdName or 0
colour = colour or {r = 255, g = 255, b = 255, a = 255}
DRAW_MARKER(type, pos.x, pos.y, pos.z, dir.x, dir.y, dir.z, rot.x, rot.y, rot.z, scale.x, scale.y, scale.z, colour.r, colour.g, colour.b, colour.a, false, true, 2, rotate, txdDict, txdName, false)
end
local function get_distance_between_entities(entity, target)
if not DOES_ENTITY_EXIST(entity) or not DOES_ENTITY_EXIST(target) then
return 0.0
end
local pos = GET_ENTITY_COORDS(entity, true)
return GET_ENTITY_COORDS(target, true):distance(pos)
end
local function get_offset_from_gameplay_camera(distance)
local cam_rot = GET_GAMEPLAY_CAM_ROT(0)
local cam_pos = GET_GAMEPLAY_CAM_COORD()
local direction = v3.toDir(cam_rot)
local destination =
{
x = cam_pos.x + direction.x * distance,
y = cam_pos.y + direction.y * distance,
z = cam_pos.z + direction.z * distance
}
return destination
end
-- credit to nowiry i think
local function get_offset_from_camera(distance, camera)
local cam_rot = GET_CAM_ROT(camera, 0)
local cam_pos = GET_CAM_COORD(camera)
local direction = v3.toDir(cam_rot)
local destination =
{
x = cam_pos.x + direction.x * distance,
y = cam_pos.y + direction.y * distance,
z = cam_pos.z + direction.z * distance
}
return destination
end
-- also credit to nowiry i believe
local function raycast_gameplay_cam(flag, distance)
local ptr1, ptr2, ptr3, ptr4 = memory.alloc(), memory.alloc(), memory.alloc(), memory.alloc()
local cam_rot = GET_GAMEPLAY_CAM_ROT(0)
local cam_pos = GET_GAMEPLAY_CAM_COORD()
local direction = v3.toDir(cam_rot)
local destination =
{
x = cam_pos.x + direction.x * distance,
y = cam_pos.y + direction.y * distance,
z = cam_pos.z + direction.z * distance
}
GET_SHAPE_TEST_RESULT(
START_EXPENSIVE_SYNCHRONOUS_SHAPE_TEST_LOS_PROBE(
cam_pos.x,
cam_pos.y,
cam_pos.z,
destination.x,
destination.y,
destination.z,
flag,
players.user_ped(),
1
), ptr1, ptr2, ptr3, ptr4)
local p1 = memory.read_int(ptr1)
local p2 = memory.read_vector3(ptr2)
local p3 = memory.read_vector3(ptr3)
local p4 = memory.read_int(ptr4)
return {p1, p2, p3, p4}
end
-- i think nowiry gets credit here
local function raycast_cam(flag, distance, cam)
local ptr1, ptr2, ptr3, ptr4 = memory.alloc(), memory.alloc(), memory.alloc(), memory.alloc()
local cam_rot = GET_CAM_ROT(cam, 0)
local cam_pos = GET_CAM_COORD(cam)
local direction = v3.toDir(cam_rot)
local destination =
{
x = cam_pos.x + direction.x * distance,
y = cam_pos.y + direction.y * distance,
z = cam_pos.z + direction.z * distance
}
GET_SHAPE_TEST_RESULT(
START_EXPENSIVE_SYNCHRONOUS_SHAPE_TEST_LOS_PROBE(
cam_pos.x,
cam_pos.y,
cam_pos.z,
destination.x,
destination.y,
destination.z,
flag,
-1,
1
), ptr1, ptr2, ptr3, ptr4)
local p1 = memory.read_int(ptr1)
local p2 = memory.read_vector3(ptr2)
local p3 = memory.read_vector3(ptr3)
local p4 = memory.read_int(ptr4)
return {p1, p2, p3, p4}
end
-- set a player into a free seat in a vehicle, if any exist
local function set_player_into_suitable_seat(ent)
local driver = GET_PED_IN_VEHICLE_SEAT(ent, -1)
if not IS_PED_A_PLAYER(driver) or driver == 0 then
if driver ~= 0 then
entities.delete_by_handle(driver)
end
SET_PED_INTO_VEHICLE(players.user_ped(), ent, -1)
else
for i=0, GET_VEHICLE_MAX_NUMBER_OF_PASSENGERS(ent) do
if IS_VEHICLE_SEAT_FREE(ent, i) then
SET_PED_INTO_VEHICLE(players.user_ped(), ent, -1)
end
end
end
end
-- aim info
local ent_types = {translations.ped_type_1, translations.ped_type_2, translations.ped_type_3, translations.ped_type_4}
local function get_aim_info()
local outptr = memory.alloc(4)
local success = GET_ENTITY_PLAYER_IS_FREE_AIMING_AT(players.user(), outptr)
local info = {}
if success then
local ent = memory.read_int(outptr)
if not DOES_ENTITY_EXIST(ent) then
info["ent"] = 0
else
info["ent"] = ent
end
if GET_ENTITY_TYPE(ent) == 1 then
local veh = GET_VEHICLE_PED_IS_IN(ent, false)
if veh ~= 0 then
if GET_PED_IN_VEHICLE_SEAT(veh, -1) then
ent = veh
info['ent'] = ent
end
end
end
info["hash"] = GET_ENTITY_MODEL(ent)
info["health"] = GET_ENTITY_HEALTH(ent)
info["type"] = ent_types[GET_ENTITY_TYPE(ent)+1]
info["speed"] = math.floor(GET_ENTITY_SPEED(ent))
else
info['ent'] = 0
end
return info
end
-- shorthand for running commands
local function kick_from_veh(pid)
menu.trigger_commands("vehkick" .. players.get_name(pid))
end
-- npc carjack algorithm 3.0
local function npc_jack(target, nearest)
npc_jackthr = util.create_thread(function(thr)
local player_ped = GET_PLAYER_PED_SCRIPT_INDEX(target)
local last_veh = GET_VEHICLE_PED_IS_IN(player_ped, true)
kick_from_veh(target)
local st = os.time()
while not IS_VEHICLE_SEAT_FREE(last_veh, -1) do
if os.time() - st >= 10 then
notify(translations.failed_to_free_seat)
util.stop_thread()
end
util.yield()
end
local hash = 0x9C9EFFD8
util.request_model(hash, 2000)
local coords = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(player_ped, -2.0, 0.0, 0.0)
local ped = entities.create_ped(28, hash, coords, 30.0)
SET_ENTITY_INVINCIBLE(ped, true)
SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(ped, true)
SET_PED_FLEE_ATTRIBUTES(ped, 0, false)
SET_PED_COMBAT_ATTRIBUTES(ped, 46, true)
SET_PED_INTO_VEHICLE(ped, last_veh, -1)
SET_VEHICLE_ENGINE_ON(last_veh, true, true, false)
TASK_VEHICLE_DRIVE_TO_COORD(ped, last_veh, math.random(1000), math.random(1000), math.random(100), 100, 1, GET_ENTITY_MODEL(last_veh), 786996, 5, 0)
util.stop_thread()
end)
end
-- gets a random pedestrian
local function get_random_ped()
peds = entities.get_all_peds_as_handles()
npcs = {}
valid = 0
for k,p in pairs(peds) do
if p ~= nil and not IS_PED_A_PLAYER(p) then
table.insert(npcs, p)
valid = valid + 1
end
end
return npcs[math.random(valid)]
end
local function spawn_object_in_front_of_ped(ped, hash, ang, room, zoff, setonground)
coords = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(ped, 0.0, room, zoff)
util.request_model(hash, 2000)
hdng = GET_ENTITY_HEADING(ped)
new = CREATE_OBJECT_NO_OFFSET(hash, coords['x'], coords['y'], coords['z'], true, false, false)
SET_ENTITY_HEADING(new, hdng+ang)
if setonground then
PLACE_OBJECT_ON_GROUND_PROPERLY(new)
end
return new
end
-- entity ownership forcing
local function request_control_of_entity(ent)