-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAndyScript.lua
More file actions
1915 lines (1777 loc) · 80 KB
/
Copy pathAndyScript.lua
File metadata and controls
1915 lines (1777 loc) · 80 KB
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
--! DON'T CHANGE THESE
local script_version = "0.1.8"
local script_url = "https://raw.githubusercontent.com/Lancito01/AndyScript/main/AndyScript.lua"
--! DON'T CHANGE THESE
--#region auto-updater
-- Auto-Updater by Hexarobi, modified by Ren, tysm to the both of u <3
local wait_for_restart = false
local please_wait_while_updating_menu = menu.divider(menu.my_root(), "Please wait...")
local function convert_backslashes_to_forwardslashes(str)
return str:gsub("\\", "/")
end
local function parse_url_host_and_path(url)
return url:match("://(.-)/"), "/" .. url:match("://.-/(.*)")
end
local toast = util.toast
local format = string.format
local SCRIPTS_DIR = convert_backslashes_to_forwardslashes(filesystem.scripts_dir())
local SCRIPT_RELPATH = convert_backslashes_to_forwardslashes(SCRIPT_RELPATH)
local STORE_DIR = convert_backslashes_to_forwardslashes(filesystem.store_dir())
local SCRIPT_PATH = SCRIPTS_DIR .. SCRIPT_RELPATH
local VERSION_DIR = STORE_DIR .. SCRIPT_NAME .. "/"
local VERSION_PATH = VERSION_DIR .. "version.txt"
local WAITING_FOR_HTTP_RESULT = true
if not filesystem.exists(VERSION_DIR) then
filesystem.mkdirs(VERSION_DIR)
end
local function toast_formatted(str, ...)
toast(format(str, ...))
end
local function read_version_id(path)
local file = io.open(path)
if file then
local version = file:read()
file:close()
return version
else
toast("Error reading version file.")
end
end
local function write_version_id(path, version_id)
local file = io.open(path, "wb")
if file == nil then
toast("Error saving version ID file: " .. path)
return false
end
file:write(version_id)
file:close()
return true
end
local function replace_current_script(result)
local file = io.open(SCRIPT_PATH, "wb")
if file == nil then
toast("Error updating " .. SCRIPT_PATH .. ". Could not open file for writing.")
return false
end
file:write(result .. "\n")
file:close()
return true
end
local function update_script(url)
local url_host, url_path = parse_url_host_and_path(url)
local function http_success(result, headers, status_code)
WAITING_FOR_HTTP_RESULT = false
-- No update neccessary if true
if status_code == 304 then
if not SCRIPT_SILENT_START then
toast_formatted("%s is up to date! (%s)", SCRIPT_NAME, script_version)
end
-- It is safe to return, the script will not do anything (in terms of updating) and will continue as normal
return
end
-- If we've just updated and GitHub did not give us a version ID / cache ID for some reason, ignore replacing the script and move on
local temp_version_str =
"temp/unknown" -- do not delete this, it is used for a check a little further down other than the next line
if read_version_id(VERSION_PATH) == temp_version_str then
write_version_id(VERSION_PATH, "")
-- It is now safe to resume normal script operation
return
end
-- Otherwise, if GitHub sends out a empty result/data, continue as normal. Something may have broke on GitHub's end.
if not result or result == "" then
toast_formatted("Error updating %s. Found empty script file.", SCRIPT_NAME)
return
end
-- If GitHub has sent us the version ID / cache ID, then store it (so we can verify if we should update in the future),
-- else store something temporary so that when the script restarts right after, it knows not to keep restarting and updating
local saved_version_id = false
if headers then
for header_key, header_value in pairs(headers) do
if header_key:lower() == "etag" then --? header_key:lower() is the same as string.lower(header_key)
write_version_id(VERSION_PATH, header_value)
saved_version_id = true
end
end
end
if not saved_version_id then
write_version_id(VERSION_PATH, temp_version_str)
--toast("Was not able to write the version ID to file. This may cause the script to update upon relaunch.")
end
-- We have done our safety checks, it is safe to replace the script.
replace_current_script(result) -- this writes the result (the file contents) to the current script path.
toast_formatted("Updated %s. Restarting...", SCRIPT_NAME)
wait_for_restart = true
util.yield(2900) -- Avoid restart loops by giving time for any other scripts to also complete updates
wait_for_restart = false
util.restart_script()
end
local function http_fail()
WAITING_FOR_HTTP_RESULT = false
toast_formatted("Error updating %s. Failed to download update.", SCRIPT_NAME)
end
local function http_add_cache_header_if_cached()
-- Only use cached version if the file still exists on disk
if filesystem.exists(VERSION_PATH) then
-- Use ETags to only fetch files if they have been updated
-- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
local cached_version_id = read_version_id(VERSION_PATH)
if cached_version_id then
async_http.add_header("If-None-Match", cached_version_id)
end
end
end
async_http.init(url_host, url_path, http_success, http_fail)
http_add_cache_header_if_cached() --* if applicable, adds header to http before it is dispatched
async_http.dispatch() --* sends out the http request and does either http_success or http_fail
end
-- http_success in English terms:
-- if it recieves status 304 (ONLY WHEN HEADER "If-None-Match" IS SENT DURING DISPATCH) it will NOT replace or restart the script
-- else, it
update_script(script_url)
while WAITING_FOR_HTTP_RESULT or wait_for_restart do
util.yield()
end
menu.delete(please_wait_while_updating_menu)
-- End of auto-updater
--#endregion auto-updater
util.require_natives("3095a")
util.keep_running()
local store = filesystem.store_dir()
local AndyScript_store = store .. SCRIPT_NAME
local shortcut_path = AndyScript_store .. "/shortcuts.txt"
local notif_prefix = format("[%s] ", SCRIPT_NAME)
local og_toast = util.toast
local og_log = util.log
util.toast = function(str, flag) ---@diagnostic disable-line
assert(str ~= nil, "No string given")
if flag ~= nil then
og_toast(notif_prefix .. tostring(str), flag)
else
og_toast(notif_prefix .. tostring(str))
end
end
util.log = function(str) ---@diagnostic disable-line
assert(str ~= nil, "No string given.")
og_log(notif_prefix .. tostring(str))
end
--On Script Start
local settings_filepath = AndyScript_store .. "/settings.txt"
if not filesystem.exists(settings_filepath) then
local filehandle = io.open(settings_filepath, "w")
if filehandle then
filehandle:close()
end
end
local playtime_filepath = AndyScript_store .. "/playtime.txt"
if not filesystem.exists(playtime_filepath) then
local filehandle = io.open(playtime_filepath, "w")
if filehandle then
filehandle:write(0)
filehandle:close()
end
end
local function read_playtime_file(filepath)
local filehandle = io.open(filepath)
local time = 0
if filehandle then
time = filehandle:read("a")
filehandle:close()
return time
else
util.toast("Error reading playtime file.")
end
end
local script_playtime = tonumber(read_playtime_file(playtime_filepath)) -- reading current playtime
util.create_tick_handler(function()
script_playtime += 1
util.yield(1000)
end)
local function save_playtime_to_file(playtime)
local filehandle = io.open(playtime_filepath, "w")
if filehandle then
filehandle:write(playtime)
filehandle:close()
else
util.toast("Error writing to playtime file.")
end
end
local function read_settings_file()
local filehandle = io.open(settings_filepath)
local tbl = {}
if filehandle then
for line_text in filehandle:lines() do ---@diagnostic disable-next-line
local prefix, suffix = string.partition(line_text, "=")
tbl[prefix] = suffix ==
"true" -- since the setting is imported as a string ("true" or "false"), the == serves as a logical test to convert it to a boolean
end
return tbl
else
util.toast("Error reading settings file.")
end
end
local settings = read_settings_file() -- input settings state from file
local user_name = settings.hide_name_on_script_startup and "User" or players.get_name(players.user())
local possible_welcome_phrases = { -- 12 normal, 1 rare
"Glad you're here, %s.",
"Welcome, %s. We hope you brought pizza.",
"%s just slid into the script.",
"Welcome, %s. Hi!",
"%s joined the party.",
"Glad you're here, %s.",
"Yay you made it, %s!",
"%s just landed.",
"Good to see you, %s.",
"%s just showed up!",
"%s is here.",
"%s hopped into the script.",
"Hey %s, you found the rare welcome phrase! Feel free to flex it in AndyScript Discord. :D"
}
local chosen_welcome_phrase_index = math.random(1, 100) == 1 and #possible_welcome_phrases or
math.random(#possible_welcome_phrases - 1)
local welcome_phrase = string.format(possible_welcome_phrases[chosen_welcome_phrase_index], user_name)
if not SCRIPT_SILENT_START then util.toast("Loaded " .. SCRIPT_NAME .. "\n\n" .. welcome_phrase) end
--Functions // Defining
local function format_time(time, longer) -- shoutout to ma boy da sussy man
local seconds_in_minute = 60
local seconds_in_hour = seconds_in_minute * 60
local seconds_in_day = seconds_in_hour * 24
local days = (time // seconds_in_day)
local hours = (time % seconds_in_day) // seconds_in_hour
local minutes = (time % seconds_in_hour) // seconds_in_minute
local seconds = (time % seconds_in_minute)
local word_days = days == 1 and "day" or "days"
local word_hours = hours == 1 and "hour" or "hours"
local word_minutes = minutes == 1 and "minute" or "minutes"
local word_seconds = seconds == 1 and "second" or "seconds"
if longer then
if time >= seconds_in_day then
return string.format("%d %s, %d %s, %d %s, and %d %s", days, word_days, hours, word_hours, minutes,
word_minutes, seconds, word_seconds)
elseif time >= seconds_in_hour then
return string.format("%d %s, %d %s, and %d %s", hours, word_hours, minutes, word_minutes, seconds,
word_seconds)
elseif time >= seconds_in_minute then
return string.format("%d %s and %d %s", minutes, word_minutes, seconds, word_seconds)
else
return string.format("%d %s", seconds, word_seconds)
end
end
return string.format("%.2d" .. ":" .. "%.2d" .. ":" .. "%.2d" .. ":" .. "%.2d", days, hours, minutes, seconds)
end
local explosion_names = {
[0] = "Off",
"Grenade",
"Grenade Launcher",
"Sticky Bomb",
"Molotov",
"Rocket",
"Tankshell",
"Octane",
"Car",
"Plane",
"Petrol Pump",
"Bike",
"Steam",
"Flame",
"Water Hydrant",
"Gas Canister",
"Boat",
"Ship Destroyed",
"Truck",
"Bullet",
"Smoke Grenade Launcer",
"Smoke Grenade",
"BZ Gas",
"Flare",
"Gas Canister",
"Extinguisher",
"Programmable AR",
"Train",
"Barrel",
"Propane",
"Blimp",
"Flame Explosion",
"Tanker",
"Plane Rocket",
"Vehicle Bullet",
"Gas Tanker",
"Bird Crap",
"Railgun",
"Blimp 2",
"Firework",
"Snowball",
"Proximity Mine",
"Valkyrie Cannon",
"Air Defense",
"Pipebomb",
"Vehicle Mine",
"Explosive Ammo",
"APC Shell",
"Cluster Bomb",
"Gas Bomb",
"Incendiary Bomb",
"Standard Bomb",
"Torpedo",
"Underwater Torpedo",
"Bombushka Cannon",
"Secondary Bomb Cluster",
"Hunter Barrage",
"Hunter Cannon",
"Rogue Cannon",
"Underwater Mine",
"Orbital Cannon",
"Wide Standard Bomb",
"Explosive Ammo Shotgun",
"Oppressor MK2 Cannon",
"Kinetic Mortar",
"Kinetic Vehicle Mine",
"EMP Vehicle Mine",
"Spike Vehicle Mine",
"Slick Vehicle Mine",
"TAR Vehicle Mine",
"Drone",
"Raygun",
"Buried Mine",
"Script Missile",
}
local function save_settings_to_file()
local filehandle = io.open(settings_filepath, "w")
if filehandle then
for setting, value in pairs(settings) do
filehandle:write(setting .. "=" .. tostring(value) .. "\n")
end
filehandle:close()
else
util.toast("Error saving settings to settings file.")
end
end
local function announce(string)
if settings.announce_actions then
util.toast(string)
end
end
local function request_model(hash, timeout)
local end_time = os.time() + (timeout or 5)
STREAMING.REQUEST_MODEL(hash)
while not STREAMING.HAS_MODEL_LOADED(hash) and end_time >= os.time() do
util.yield()
end
return STREAMING.HAS_MODEL_LOADED(hash)
end
local function request_control(entity, timeout)
local end_time = os.time() + (timeout or 5)
NETWORK.NETWORK_REQUEST_CONTROL_OF_ENTITY(entity)
while not NETWORK.NETWORK_HAS_CONTROL_OF_ENTITY(entity) and end_time >= os.time() do
NETWORK.NETWORK_REQUEST_CONTROL_OF_ENTITY(entity)
util.yield()
end
return NETWORK.NETWORK_HAS_CONTROL_OF_ENTITY(entity)
end
local some_ped_list = {
"a_m_m_bevhills_02", --1
"a_m_m_business_01", --2
"a_m_m_bevhills_01", --3
"a_m_m_farmer_01", --4
"a_m_m_paparazzi_01", --5
"a_m_m_prolhost_01", --6
"a_m_m_stlat_02" --7
}
local function get_vehicle_ped_is_in(ped, includeLastVehicle)
if includeLastVehicle or PED.IS_PED_IN_ANY_VEHICLE(ped, false) then
return PED.GET_VEHICLE_PED_IS_IN(ped, false)
end
return 0
end
local was_in_transition = false
local announce_transition_end = false
local give_weapons_after_transition = false
local function on_transition_exit()
if announce_transition_end then
util.toast("No longer in transition!")
end
if give_weapons_after_transition then
util.yield(1000)
menu.trigger_command(menu.ref_by_path("Self>Weapons>Get Weapons>All Weapons", 38), "")
announce("All weapons given.")
end
end
--Main Menu
menu.divider(menu.my_root(), "Main")
local self_tab = menu.list(menu.my_root(), "Self", {}, "")
local online_tab = menu.list(menu.my_root(), "Online", {}, "")
menu.action(menu.my_root(), "Players shortcut", {}, 'Takes you to "Players" list.', function()
menu.trigger_command(menu.ref_by_path('Players'), "")
end)
local vehicles_tab = menu.list(menu.my_root(), "Vehicles", {}, "")
local world_tab = menu.list(menu.my_root(), "World", {}, "")
local fun_tab = menu.list(menu.my_root(), "Fun", {},
"Most of these are suggestions on my Discord. You should join! Link is in \"About\" tab.")
local settings_tab = menu.list(menu.my_root(), "Settings", {}, "")
menu.divider(menu.my_root(), "Information")
local info_tab = menu.list(menu.my_root(), "About", {}, "")
--Self tab
--Weapons tab
local weapons_in_self_tab = menu.list(self_tab, "Weapons", {}, "", function() end)
--Loops tab
local loops_in_self_tab = menu.list(self_tab, "Loops", {}, "", function() end)
--Explosive bullets
do
local current
local coords = v3.new()
menu.list_select(weapons_in_self_tab, "Explosive Ammo", {}, "", explosion_names, 0, function(index)
current = index - 1
local explosion_id =
current -- this SHOULD have a -1 because lua starts indexes at 1, not 0 BUT! if you look at the table definition, ma boy the sus man told me how to make it 0 based to my brain can rest easy
if current ~= -1 then
while current + 1 == index do
current = index - 1
if WEAPON.GET_PED_LAST_WEAPON_IMPACT_COORD(players.user_ped(), coords) then
local x, y, z = v3.get(coords)
FIRE.ADD_OWNED_EXPLOSION(players.user_ped(), x, y, z, explosion_id, 1.0, true, false, 0)
end
util.yield()
end
else
announce("Explosive Ammo is off.")
end
end)
end
--Godmode
menu.toggle(self_tab, "Godmode", { "andygodmode" },
"Toggles several Stand features such as Godmode, Gracefulness, and Vehicle Godmode all at the same time to make you invincible against mortals.",
function(state)
local switch_for_godmode = state and "On" or "Off"
menu.trigger_command(menu.ref_by_path("Self>Immortality", 38), switch_for_godmode)
menu.trigger_command(menu.ref_by_path("Self>Gracefulness", 38), switch_for_godmode)
menu.trigger_command(menu.ref_by_path("Self>Auto Heal", 38), switch_for_godmode)
menu.trigger_command(menu.ref_by_path("Vehicle>Indestructible", 38), switch_for_godmode)
menu.trigger_command(menu.ref_by_path("Self>Glued To Seats", 38), switch_for_godmode)
menu.trigger_command(menu.ref_by_path("Stand>Lua Scripts>" .. SCRIPT_NAME .. ">Self>Clean Loop", 38),
switch_for_godmode)
announce("Godmode " .. switch_for_godmode)
end
)
--Ghost
menu.toggle(self_tab, "Ghost", { "andyghostmode" },
"Toggles several Stand features such as Invisibility and Off The Radar all at the same time to make you fully invisible.",
function(state)
menu.trigger_command(
menu.ref_by_path("Self>Appearance>Invisibility>" .. (state and "Enabled" or "Disabled"), 38), "")
menu.set_value(menu.ref_by_path("Online>Off The Radar", 38), state)
announce("Ghostmode " .. (state and "On" or "Off"))
end
)
--Heal
menu.action(self_tab, "Max Health", { "healself" }, "Heals your ped to its max health.",
function()
local max_health = ENTITY.GET_ENTITY_MAX_HEALTH(players.user_ped())
ENTITY.SET_ENTITY_HEALTH(players.user_ped(), max_health, 0)
announce("Health maxed.")
end
)
--Semigodmode heal loop
local is_heal_loop_on = false
menu.toggle_loop(loops_in_self_tab, "Heal Loop", { "healloop" }, "",
function()
if not is_heal_loop_on then
announce("Healing ped.")
is_heal_loop_on = true
end
if ENTITY.GET_ENTITY_HEALTH(players.user_ped()) ~= 0 then
local max_health = ENTITY.GET_ENTITY_MAX_HEALTH(players.user_ped())
ENTITY.SET_ENTITY_HEALTH(players.user_ped(), max_health, 0)
end
util.yield()
end, function() is_heal_loop_on = false end
)
--Clean
menu.action(self_tab, "Clean", { "cleanself" }, "Cleans your ped from all visible blood.",
function()
PED.CLEAR_PED_BLOOD_DAMAGE(players.user_ped())
announce("Ped cleaned.")
end
)
--Clean loop
menu.toggle(loops_in_self_tab, "Clean Loop", {}, "Kepes your ped clean at all costs.",
function(state)
local is_on = state
if state then announce("Cleaning ped.") end
while is_on do
PED.CLEAR_PED_BLOOD_DAMAGE(players.user_ped())
util.yield()
end
end)
--Max armor
menu.action(self_tab, "Max Armor", {}, "Maxes out your armor.",
function()
PED.SET_PED_ARMOUR(players.user_ped(), 100)
announce("Armor filled.")
end
)
--Armor loop
local is_armor_loop_on = false
menu.toggle_loop(loops_in_self_tab, "Armor Loop", {}, "Keeps your armor full at all costs.",
function()
if not is_armor_loop_on then
announce("Filling ped's armor.")
is_armor_loop_on = true
end
PED.SET_PED_ARMOUR(players.user_ped(), 100)
end, function() is_armor_loop_on = false end)
--Revive ped
menu.action(self_tab, "Revive Ped", { "revive" }, "Revives your ped.",
function()
if ENTITY.GET_ENTITY_HEALTH(players.user_ped()) == 0 then
local coordsv3 = ENTITY.GET_ENTITY_COORDS(players.user_ped())
NETWORK.NETWORK_RESURRECT_LOCAL_PLAYER(coordsv3["x"], coordsv3["y"], coordsv3["z"],
ENTITY.GET_ENTITY_HEADING(players.user_ped()), true, false, false, 0, 0)
-- CAM.SET_CAM_DEATH_FAIL_EFFECT_STATE(0)
end
end
)
--Loop revive ped
menu.toggle_loop(loops_in_self_tab, "Revive Ped Loop", {}, "Constantly revives your ped if you die.",
function()
local ped = players.user_ped()
if ENTITY.GET_ENTITY_HEALTH(ped) == 0 or PED.IS_PED_DEAD_OR_DYING(ped) then
PED.SET_PED_CAN_RAGDOLL(ped, false)
local coordsv3 = ENTITY.GET_ENTITY_COORDS(ped)
NETWORK.NETWORK_RESURRECT_LOCAL_PLAYER(coordsv3["x"], coordsv3["y"], coordsv3["z"],
ENTITY.GET_ENTITY_HEADING(ped), true, false, false, 0, 0)
end
-- util.yield() -- not necessary in menu.toggle_loop()
end, function()
PED.SET_PED_CAN_RAGDOLL(players.user_ped(), true)
end
)
--Angry mode
menu.toggle_loop(self_tab, "Disable \"Angry Mode\"", {},
"Disables the state where the ped is angry and moves quickly after getting shot nearby or directly.", function()
PED.SET_MOVEMENT_MODE_OVERRIDE(players.user_ped(), "DEFAULT")
end, function()
PED.SET_MOVEMENT_MODE_OVERRIDE(players.user_ped(), 0)
end)
--Online tab
--Weapons
menu.toggle(online_tab, "Give All Weapons After Joining A Session", {},
"As soon as the transition is over, get all weapons.",
function(state)
give_weapons_after_transition = state
end
)
--Popularity loop
local popularity_loop_command_ref = menu.ref_by_path("Online>Quick Progress>Set Nightclub Popularity", 38)
menu.toggle_loop(online_tab, "Nightclub Popularity Loop", { "ncpopularityloop" },
"Toggles the Nightclub popularity loop to always keep it at 100%",
function()
menu.trigger_command(popularity_loop_command_ref, "100")
util.toast("Popularity set")
util.yield(2000)
end
)
--Transition
menu.toggle(online_tab, "Notification When Transition Is Over", { "notifyontransitionend" },
"Toasts a notification when the main transition is over.",
function(state)
announce_transition_end = state
end
)
--Vehicles tab
--Include last vehicle
menu.toggle(vehicles_tab, "Include Last Vehicle For Vehicle Functions", {},
"Option to include last vehicle if you're not in a vehicle at the time of running a function.",
function(state) Include_last_vehicle_for_vehicle_functions = state end)
--Options divider
menu.divider(vehicles_tab, "Options")
--Radio off automatically
local last_vehicle_with_radio_off = 0
menu.toggle_loop(vehicles_tab, "Turn Off Radio Automatically", {}, "Turns off the radio each time you get in a vehicle.",
function()
local current_vehicle = get_vehicle_ped_is_in(players.user_ped())
if current_vehicle ~= 0 then
if last_vehicle_with_radio_off ~= current_vehicle and VEHICLE.GET_IS_VEHICLE_ENGINE_RUNNING(current_vehicle) then
if AUDIO.IS_VEHICLE_RADIO_ON(current_vehicle) then
util.yield(1000)
AUDIO.SET_RADIO_TO_STATION_NAME("OFF")
announce("Radio off")
end
last_vehicle_with_radio_off = current_vehicle
end
else
last_vehicle_with_radio_off = 0
end
end
)
--Auto-flip vehicle
menu.toggle_loop(vehicles_tab, "Auto-flip Vehicle", {},
"Automatically flips your car the right way if you land upside-down or sideways.", function()
local player_vehicle = get_vehicle_ped_is_in(players.user_ped(), false)
local rotation = CAM.GET_GAMEPLAY_CAM_ROT(2)
local heading = v3.getHeading(v3.new(rotation))
local vehicle_distance_to_ground = ENTITY.GET_ENTITY_HEIGHT_ABOVE_GROUND(player_vehicle)
local am_i_on_ground = vehicle_distance_to_ground < 2 --and true or false
local speed = ENTITY.GET_ENTITY_SPEED(player_vehicle)
if not VEHICLE.IS_VEHICLE_ON_ALL_WHEELS(player_vehicle) and ENTITY.IS_ENTITY_UPSIDEDOWN(player_vehicle) and am_i_on_ground then
VEHICLE.SET_VEHICLE_ON_GROUND_PROPERLY(player_vehicle, 5.0)
ENTITY.SET_ENTITY_HEADING(player_vehicle, heading)
util.yield()
VEHICLE.SET_VEHICLE_FORWARD_SPEED(player_vehicle, speed)
end
end)
--Vehicle accel
menu.text_input(vehicles_tab, "Alter Vehicle's Acceleration", { "vehiclespeed" },
"Changes how fast the car goes. 0 = Default",
function(string)
local input = tonumber(string)
if type(input) == "nil" then
util.toast("Input must be a number. Try again!")
else
local vehicle = get_vehicle_ped_is_in(players.user_ped(), Include_last_vehicle_for_vehicle_functions)
if vehicle == 0 then
util.toast("Get in a car first.")
else
local number = tonumber(input) or 0
request_control(vehicle)
VEHICLE.MODIFY_VEHICLE_TOP_SPEED(vehicle, number)
announce("Acceleration altered. Give it a try!")
end
end
end, "0"
)
--Random tuning
menu.action(vehicles_tab, "Tune Vehicle Randomly", { "randomtune" }, "Applies random tuning to your vehicle.", function()
local vehicle = get_vehicle_ped_is_in(players.user_ped(), Include_last_vehicle_for_vehicle_functions)
if vehicle == 0 then
util.toast("You are not in a vehicle.")
else
VEHICLE.SET_VEHICLE_MOD_KIT(vehicle, 0) -- needed for most modifications through SET_VEHICLE_MOD to take effect
for mod_type = 0, 48 do
local num_of_mods = VEHICLE.GET_NUM_VEHICLE_MODS(vehicle, mod_type)
local random_tune = math.random(-1, num_of_mods - 1)
VEHICLE.TOGGLE_VEHICLE_MOD(vehicle, mod_type, math.random(0, 1) == 1)
VEHICLE.SET_VEHICLE_MOD(vehicle, mod_type, random_tune, false)
end
VEHICLE.SET_VEHICLE_COLOURS(vehicle, math.random(0, 160), math.random(0, 160))
VEHICLE.SET_VEHICLE_TYRE_SMOKE_COLOR(vehicle, math.random(0, 255), math.random(0, 255), math.random(0, 255))
VEHICLE.SET_VEHICLE_WINDOW_TINT(vehicle, math.random(0, 6))
for index = 0, 3 do
VEHICLE.SET_VEHICLE_NEON_ENABLED(vehicle, index, math.random(0, 1) == 1)
end
VEHICLE.SET_VEHICLE_NEON_COLOUR(vehicle, math.random(0, 255), math.random(0, 255), math.random(0, 255))
-- menu.trigger_command(menu.ref_by_path("Vehicle>Los Santos Customs>Appearance>Wheels>Wheels Colour", 42),
-- tostring(math.random(0, 160)))
end
end)
menu.text_input(vehicles_tab, "Loop Random Tune", { "randomtuneloop" },
"Applies random tuning to your vehicle every \"x\" miliseconds. 0 is equal to off.", function(str)
if tonumber(str) then
Option = tonumber(str)
while Option ~= 0 do
local vehicle = get_vehicle_ped_is_in(players.user_ped(), Include_last_vehicle_for_vehicle_functions)
if vehicle ~= 0 then
VEHICLE.SET_VEHICLE_MOD_KIT(vehicle, 0) -- needed for most modifications through SET_VEHICLE_MOD to take effect
for mod_type = 0, 48 do
local num_of_mods = VEHICLE.GET_NUM_VEHICLE_MODS(vehicle, mod_type)
local random_tune = math.random(-1, num_of_mods - 1)
VEHICLE.TOGGLE_VEHICLE_MOD(vehicle, mod_type, math.random(0, 1) == 1)
VEHICLE.SET_VEHICLE_MOD(vehicle, mod_type, random_tune, false)
end
VEHICLE.SET_VEHICLE_COLOURS(vehicle, math.random(0, 160), math.random(0, 160))
VEHICLE.SET_VEHICLE_TYRE_SMOKE_COLOR(vehicle, math.random(0, 255), math.random(0, 255),
math.random(0, 255))
VEHICLE.SET_VEHICLE_WINDOW_TINT(vehicle, math.random(0, 6))
for index = 0, 3 do
VEHICLE.SET_VEHICLE_NEON_ENABLED(vehicle, index, math.random(0, 1) == 1)
end
VEHICLE.SET_VEHICLE_NEON_COLOUR(vehicle, math.random(0, 255), math.random(0, 255),
math.random(0, 255))
-- menu.trigger_command(
-- menu.ref_by_path("Vehicle>Los Santos Customs>Appearance>Wheels>Wheels Colour", 42),
-- tostring(math.random(0, 160)))
end
util.yield(Option)
end
else
util.toast("Please enter a number.")
end
end, "0")
-- Measuring speed
local measuring_speed_list = menu.list(vehicles_tab, "Measure Speed", {}, "")
local unit = "km/h"
local function convert_speed(speed)
if unit == "km/h" then
return speed * 3.6
elseif unit == "mph" then
return speed * 2.236936
end
end
menu.list_select(measuring_speed_list, "Unit for speed", {}, "", {
{ 1, "KM/H" },
{ 2, "MPH" },
}, 1, function(value)
if value == 1 then
unit = "km/h"
elseif value == 2 then
unit = "mph"
end
end)
local send_speed_results_in_chat
measuring_speed_list:toggle("Send results in chat", {}, "Whether to send the results in team chat or not.",
function(state)
send_speed_results_in_chat = state
end)
-- Top speed
menu.divider(measuring_speed_list, "Top Speed")
local topspeed_is_loop_on = false
local top_speed = 0
local last_topspeed_reported = 0
local function send_topspeed_to_chat_thread()
util.create_thread(function()
while topspeed_is_loop_on do
if last_topspeed_reported < top_speed then
local text = "New top speed: " .. convert_speed(top_speed) .. " " .. unit
if send_speed_results_in_chat then
chat.send_message(text, true, true, true)
end
util.toast(text)
last_topspeed_reported = top_speed
end
util.yield(2000)
end
end)
end
measuring_speed_list:toggle_loop("Measure Top Speed", { "topspeedcalc" },
"Sends a message in chat every time a new top speed is found.", function()
if not topspeed_is_loop_on then
topspeed_is_loop_on = true
send_topspeed_to_chat_thread()
end
local speed = ENTITY.GET_ENTITY_SPEED(PLAYER.PLAYER_PED_ID())
if speed > top_speed then
top_speed = speed
end
end, function()
topspeed_is_loop_on = false
end)
measuring_speed_list:action("Reset Top Speed", { "resettopspeedcalc" }, "Resets the top speed to 0.", function()
top_speed = 0
last_topspeed_reported = 0
end)
-- Acceleration
local speed, last_speed, time_to_acceleration = 0, 0, 0
local starting_acceleration_point = { x = 0, y = 0, z = 0, init = false }
local eighth_mile, quarter_mile, first, second = false, false, false, false
measuring_speed_list:divider("Acceleration")
measuring_speed_list:toggle_loop("Measure Acceleration", { "measureacceleration" },
"Measures your acceleration depending on the selected unit.", function()
speed = ENTITY.GET_ENTITY_SPEED(PLAYER.PLAYER_PED_ID())
while speed < 0.03 do -- wait for player to move
speed = ENTITY.GET_ENTITY_SPEED(PLAYER.PLAYER_PED_ID())
util.yield()
end
if time_to_acceleration == 0 or not starting_acceleration_point.init then -- start timer and distance
time_to_acceleration = os.clock()
local coords = ENTITY.GET_ENTITY_COORDS(PLAYER.PLAYER_PED_ID(), true)
starting_acceleration_point = { x = coords.x, y = coords.y, z = coords.z, init = true }
end
local coords = ENTITY.GET_ENTITY_COORDS(PLAYER.PLAYER_PED_ID(), true)
local distance = v3.distance(v3.new(starting_acceleration_point), v3.new(coords))
if distance >= 201.168 and not eighth_mile then
eighth_mile = true
local result_time = os.clock() - time_to_acceleration
local text = "Eighth mile: " .. string.format("%.3f", result_time) .. " seconds."
if send_speed_results_in_chat then
chat.send_message(text, true, true, true)
end
util.toast(text)
end
if distance >= 402.336 and not quarter_mile then
quarter_mile = true
local result_time = os.clock() - time_to_acceleration
local text = "Quarter mile: " .. string.format("%.3f", result_time) .. " seconds."
if send_speed_results_in_chat then
chat.send_message(text, true, true, true)
end
util.toast(text)
end
if unit == "km/h" then
if convert_speed(speed) >= 50 and convert_speed(last_speed) < 50 and not first then
first = true
local result_time = os.clock() - time_to_acceleration
local text = "0-50 KM/H: " .. string.format("%.3f", result_time) .. " seconds."
if send_speed_results_in_chat then
chat.send_message(text, true, true, true)
end
util.toast(text)
end
if convert_speed(speed) >= 100 and convert_speed(last_speed) < 100 and not second then
second = true
local result_time = os.clock() - time_to_acceleration
local text = "0-100 KM/H: " .. string.format("%.3f", result_time) .. " seconds."
if send_speed_results_in_chat then
chat.send_message(text, true, true, true)
end
util.toast(text)
end
elseif unit == "mph" then
if convert_speed(speed) >= 30 and convert_speed(last_speed) < 30 and not first then
first = true
local result_time = os.clock() - time_to_acceleration
local text = "0-30 MPH: " .. string.format("%.3f", result_time) .. " seconds."
if send_speed_results_in_chat then
chat.send_message(text, true, true, true)
end
util.toast(text)
end
if convert_speed(speed) >= 60 and convert_speed(last_speed) < 60 and not second then
second = true
local result_time = os.clock() - time_to_acceleration
local text = "0-60 MPH: " .. string.format("%.3f", result_time) .. " seconds."
if send_speed_results_in_chat then
chat.send_message(text, true, true, true)
end
util.toast(text)
end
end
last_speed = speed
end, function()
speed, last_speed, time_to_acceleration, eighth_mile, quarter_mile, starting_acceleration_point, first, second =
0, 0,
0,
false, false, { x = 0, y = 0, z = 0, init = false }, false, false --? restarting all 8 values
end)
measuring_speed_list:action("Reset Acceleration Values", {}, "", function()
speed, last_speed, time_to_acceleration, eighth_mile, quarter_mile, starting_acceleration_point, first, second = 0, 0,
0,
false, false, { x = 0, y = 0, z = 0, init = false }, false, false --? restarting all 8 values
end)
--World tab
--Change local gravity
local function request_control_of_table_once(tbl)
for index, entity in ipairs(tbl) do
NETWORK.NETWORK_REQUEST_CONTROL_OF_ENTITY(entity)
end
end
local gravity_current_index
menu.list_select(world_tab, "World Gravity", { "worldgravity" },
"Changes world's gravity. This option works best with other AndyScript users with the same mode. Can be really annoying/broken for other players (takes control of everything). Recommended to use only around friends to not ruin anyone elses fun. :)",
{
{ "Default", { "default" }, "" },
{ "Low", { "low" }, "" },
{ "Very low", { "verylow" }, "" },
{ "No gravity", { "none" }, "" },
}, 1,
function(option_index, menu_name, previous_option, click_type)
gravity_current_index = option_index
if click_type ~= CLICK_BULK then --[[this so that way the user does not get a notification when stand resets the option at script stop]]
toast_formatted("Set the world's gravity to %s.", string.lower(menu_name))
end
if option_index ~= 1 then
while gravity_current_index == option_index do
request_control_of_table_once(entities.get_all_vehicles_as_handles())
request_control_of_table_once(entities.get_all_objects_as_handles())
request_control_of_table_once(entities.get_all_peds_as_handles())
request_control_of_table_once(entities.get_all_pickups_as_handles())
MISC.SET_GRAVITY_LEVEL(option_index - 1)
util.yield()
end
else
MISC.SET_GRAVITY_LEVEL(option_index - 1)
end
end)
menu.toggle_loop(world_tab, "Chaos", {},
"Makes nearby cars go goblin-goblin mode. Can be really annoying/broken for other players (takes control of everything). Recommended to use only around friends to not ruin anyone elses fun. :)",
function()
for i, veh in ipairs(entities.get_all_vehicles_as_handles()) do
request_control(veh)
ENTITY.APPLY_FORCE_TO_ENTITY_CENTER_OF_MASS(veh, 1, 0.0, 10.0, 0.0, true, true, true, true) --[[ alternatively, ]] --VEHICLE.SET_VEHICLE_FORWARD_SPEED(...) -- not tested
end
end
)
--spooner
local spooner_divider = 0
local spooner_all_entities = 0
local spooner_main_list = menu.list(world_tab, "Andy's Spooner", {}, "")
local spooned = {} -- {{list_handle, entity_handle}, {list_handle, entity_handle}, {list_handle, entity_handle}}
local function generate_entity_spooner_features(list, handle)
local teleport = menu.action(list, "Teleport To Me", {}, "", function()
request_control(handle)
local coords = ENTITY.GET_ENTITY_COORDS(players.user_ped())
ENTITY.SET_ENTITY_COORDS(handle, coords.x, coords.y, coords.z, 0, 0, 0, 0)
ENTITY.SET_ENTITY_ROTATION(handle, 0, 0, 0, 1, true)
end)
menu.action(list, "Delete", {}, "", function()
local function where_is()
for i, tbl in ipairs(spooned) do
if tbl[1] == list then
return i
end
end
end
request_control(handle)
entities.delete_by_handle(handle)
menu.delete(list)
table.remove(spooned, where_is())
announce("Entity removed.")