-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathKek's menu.lua
8549 lines (8073 loc) · 343 KB
/
Kek's menu.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Copyright © 2020-2024 Kektram
if __kek_menu then
menu.notify("Kek's menu is already loaded!", "Initialization cancelled.", 3, 0xff0000ff)
return
end
menu.create_thread(function()
local paths <const> = {
home = utils.get_appdata_path("PopstarDevs", "2Take1Menu").."\\"
}
paths.kek_menu_stuff = paths.home.."scripts\\kek_menu_stuff\\"
paths.kek_menu_data = paths.kek_menu_stuff.."kekMenuData"
paths.kek_menu_logs = paths.kek_menu_stuff.."kekMenuLogs"
paths.blacklist = paths.kek_menu_stuff.."kekMenuLogs\\Blacklist.log"
paths.player_history_all_players = paths.kek_menu_stuff.."kekMenuLogs\\All players.log"
paths.kek_settings = paths.kek_menu_stuff.."keksettings.ini"
paths.chat_spam_text = paths.kek_menu_stuff.."kekMenuData\\Spam text.txt"
paths.chat_bot = paths.kek_menu_stuff.."kekMenuData\\Kek's chat bot.txt"
paths.chat_judger = paths.kek_menu_stuff.."kekMenuData\\custom_chat_judge_data.txt"
paths.debugger = paths.kek_menu_stuff.."kekMenuLibs\\Debugger.lua"
paths.ini_vehicles = paths.home.."scripts\\Ini vehicles"
paths.menyoo_vehicles = paths.home.."scripts\\Menyoo vehicles"
paths.menyoo_maps = paths.home.."scripts\\Menyoo maps"
collectgarbage("incremental", 110, 100)
math.randomseed(math.floor(os.clock()) + os.time())
if not (package.path or ""):find(paths.kek_menu_stuff.."kekMenuLibs\\?.lua;", 1, true) then
package.path = paths.kek_menu_stuff.."kekMenuLibs\\?.lua;"..package.path
end
__kek_menu = {
version = "0.4.9.3",
debug_mode = false,
participate_in_betas = false,
check_for_updates = false,
original_require = require,
require = function(...)
local name <const> = ...
assert(utils.file_exists(paths.kek_menu_stuff.."kekMenuLibs\\"..name..".lua"), "Tried to require a file that doesn't exist.")
assert(name:find("^Kek's %u"), "Invalid library name. [kekMenuLibs\\"..name.."]: format should be \"Kek's <Uppercase letter><rest of lib name>\"")
if not package.loaded[name] then
clear_lib_cache(name)
package.loaded[name] = __kek_menu.original_require(name)
end
return package.loaded[name]
end
}
require = __kek_menu.require
for name, version in pairs({
["Kek's Language"] = "1.0.0",
["Kek's Enums"] = "1.0.7",
["Kek's Settings"] = "1.0.2",
["Kek's Memoize"] = "1.0.1",
["Kek's Essentials"] = "1.6.6"
}) do
local missing_file_msg <const> = "You're missing a file in kekMenuLibs. Please reinstall Kek's menu."
local wrong_version_msg <const> = "There's a library file which is the wrong version, please reinstall kek's menu."
if not utils.file_exists(paths.kek_menu_stuff.."kekMenuLibs\\"..name..".lua") then
local msg
if package.loaded["Kek's Language"] then
msg = package.loaded["Kek's Language"].lang[missing_file_msg]
else
msg = missing_file_msg
end
menu.notify(string.format("%s [%s]", msg, name), "Kek's "..__kek_menu.version, 12, 0xff0000ff)
error(msg)
else
require(name)
end
if package.loaded[name].version ~= version then
menu.notify(string.format("%s [%s]", package.loaded["Kek's Language"].lang[wrong_version_msg], name), "Kek's "..__kek_menu.version, 12, 0xff0000ff)
error(package.loaded["Kek's Language"].lang[wrong_version_msg])
end
end
require = __kek_menu.original_require
local language <const> = package.loaded["Kek's Language"]
local lang <const> = language.lang
local settings <const> = package.loaded["Kek's Settings"]
local essentials <const> = package.loaded["Kek's Essentials"]
local memoize <const> = package.loaded["Kek's Memoize"]
local enums <const> = package.loaded["Kek's Enums"]
if not menu.is_trusted_mode_enabled(1 << 2) then
essentials.msg(lang["You must turn on trusted mode->Natives to use this script."], "red", 6)
return
end
if not menu.is_trusted_mode_enabled(1 << 3) then
essentials.msg(lang["You must turn on trusted mode->Http to use this script."], "red", 6)
return
end
if not menu.is_trusted_mode_enabled(1 << 4) then
essentials.msg(lang["You must turn on trusted mode->memory to use this script."], "red", 6)
return
end
if utils.file_exists(paths.kek_settings) then
local file = io.open(paths.kek_settings)
if file then
local str <const> = file:read("*a")
file:close()
if utils.file_exists(paths.debugger) and str:match("Debug mode=(%a%a%a%a)") == "true" then
__kek_menu.debug_mode = true
dofile(paths.debugger)
end
if str:match("Participate in betas=(%a%a%a%a)") == "true" then
__kek_menu.participate_in_betas = true
end
if str:match("Check for updates=(%a%a%a%a)") == "true" then
__kek_menu.check_for_updates = true
end
end
else
__kek_menu.check_for_updates = true
local file <const> = io.open(paths.kek_settings, "w+")
file:close()
end
if __kek_menu.check_for_updates then
if essentials.update_keks_menu() == "has updated" then
return
end
end
essentials.create_thread(function()
essentials.post_to_keks_menu_site("https://keks-menu-stats.kektram.com?increment=true&FROM_KEKS=true&version="..web.urlencode(__kek_menu.version)) -- Increments number of times Kek's menu has been executed
while true do
system.yield(16 * 60 * 1000)
essentials.post_to_keks_menu_site("https://keks-menu-stats.kektram.com?FROM_KEKS=true&version="..web.urlencode(__kek_menu.version))
end
end)
local u <const> = {}
local player_feat_ids <const> = {}
require = __kek_menu.require
for name, version in pairs({
["Kek's Vehicle mapper"] = "1.4.3",
["Kek's Ped mapper"] = "1.3.0",
["Kek's Object mapper"] = "1.2.8",
["Kek's Globals"] = "1.4.5",
["Kek's Weapon mapper"] = "1.0.8",
["Kek's Location mapper"] = "1.0.2",
["Kek's Keys and input"] = "1.0.7",
["Kek's Drive style mapper"] = "1.0.5",
["Kek's Menyoo spawner"] = "2.3.0",
["Kek's Entity functions"] = "1.2.9",
["Kek's Trolling entities"] = "1.0.7",
["Kek's Custom upgrades"] = "1.0.2",
["Kek's Menyoo saver"] = "1.0.9",
["Kek's Natives"] = "1.0.6"
}) do
if not utils.file_exists(paths.kek_menu_stuff.."kekMenuLibs\\"..name..".lua") then
menu.notify(string.format("%s [%s]", lang["You're missing a file in kekMenuLibs. Please reinstall Kek's menu."], name), "Kek's "..__kek_menu.version, 12, 0xff0000ff)
error(lang["You're missing a file in kekMenuLibs. Please reinstall Kek's menu."])
else
require(name)
end
if package.loaded[name].version ~= version then
menu.notify(string.format("%s [%s]", lang["There's a library file which is the wrong version, please reinstall kek's menu."], name), "Kek's "..__kek_menu.version, 12, 0xff0000ff)
error(lang["There's a library file which is the wrong version, please reinstall kek's menu."])
end
end
require = __kek_menu.original_require
local weapon_mapper <const> = package.loaded["Kek's Weapon mapper"]
local location_mapper <const> = package.loaded["Kek's Location mapper"]
local keys_and_input <const> = package.loaded["Kek's Keys and input"]
local drive_style_mapper <const> = package.loaded["Kek's Drive style mapper"]
local globals <const> = package.loaded["Kek's Globals"]
local vehicle_mapper <const> = package.loaded["Kek's Vehicle mapper"]
local ped_mapper <const> = package.loaded["Kek's Ped mapper"]
local object_mapper <const> = package.loaded["Kek's Object mapper"]
local menyoo <const> = package.loaded["Kek's Menyoo spawner"]
local kek_entity <const> = package.loaded["Kek's Entity functions"]
local troll_entity <const> = package.loaded["Kek's Trolling entities"]
local custom_upgrades <const> = package.loaded["Kek's Custom upgrades"]
local menyoo_saver <const> = package.loaded["Kek's Menyoo saver"]
local natives <const> = package.loaded["Kek's Natives"]
local menu_settings <const> = IniParser(paths.home.."\\2Take1Menu.ini")
menu_settings:read()
local function read_keybind(key_name)
local status <const>, entry <const> = menu_settings:get_s("Keys", key_name)
essentials.assert(status, "This entry doesn't exist.", key_name)
return entry:gsub("NOMOD%+", "")
end
local commonly_used_lang_strings <const> = {
set_hotkey = lang["Recommended to set a hotkey on this. Press %s to set a hotkey."]:format(read_keybind("HotKeyBind")),
goto_settings_vehicle = lang["Go to \"%s\" >> \"%s\" >> \"%s\" to change what vehicle is used for this feature.\n\nIt's recommended you set a hotkey on \"%s\"."]:format(lang["Kek's menu"], lang["Settings"], lang["Set vehicle in use"], lang["Set vehicle in use"]),
goto_settings_ped = lang["Go to \"%s\" >> \"%s\" >> \"%s\" to change what ped is used for this feature.\n\nIt's recommended you set a hotkey on \"%s\"."]:format(lang["Kek's menu"], lang["Settings"], lang["Set ped in use"], lang["Set ped in use"]),
goto_settings_object = lang["Go to \"%s\" >> \"%s\" >> \"%s\" to change what object is used for this feature.\n\nIt's recommended you set a hotkey on \"%s\"."]:format(lang["Kek's menu"], lang["Settings"], lang["Set object in use"], lang["Set object in use"]),
click_to_type = lang["Click on this feature to input a value."],
clear_owned = lang["Owned entities are objects, peds and vehicles you've spawned / gotten control of via Kek's menu."]
}
do -- What kek's menu modifies in the global space. The natives library adds to the global space, but never modifies anything.
do
local function check_msg_valid(message)
--[[
Attempting to use https://en.wikipedia.org/wiki/Mao_Zedong as a message, getting the string via utils.from_clipboard, causes crash.
Most concerning would be grabbing data from files. There could be all kinds of corruption.
This will apply to all scripts loaded.
If these wrappers cause problems with your script, please report it.
--]]
if message and not utf8.len(message) then
message = message:gsub("[\0-\x7F\xC2-\xFD][\x80-\xBF]+", "")
message = message:gsub("[\x80-\xFF]", "")
end
return message
end
local original <const> = menu.notify
menu.notify = function(message, title, seconds, color)
original(check_msg_valid(message), title, seconds, color)
end
local original <const> = error
error = function(message, level)
if type(message) ~= "number" and type(message) ~= "string" then
original("Error message must be a number or a string.", (level and level + 1 or 2))
end
original(check_msg_valid(message), (level and level + 1 or 2))
end
local original <const> = assert
assert = function(condition, message)
if not condition then -- Done like this to not have to concatenate unless needed
print("If you see this error, check the full traceback. Kek's menu wraps the error, assert and notify function to fix certain crashes.")
end
return original(condition, check_msg_valid(message))
end
end
do
--[[
This sets the __close metamethod for all files.
When local variables storing a file object goes out of scope,
the file is automatically closed with this metamethod.
--]]
local file <close> = io.open(debug.getinfo(1).source:sub(2, -1))
assert(io.type(file) == "file", "Failed to get file metatable.")
getmetatable(file).__close = function(file)
if io.type(file) == "file" then
file:close()
end
end
end
do
local originals <const> = essentials.const({
create_vehicle = vehicle.create_vehicle,
create_ped = ped.create_ped,
clone_ped = ped.clone_ped,
create_object = object.create_object,
create_world_object = object.create_world_object,
request_control_of_entity = network.request_control_of_entity,
})
vehicle.create_vehicle = function(...)
local model <const>,
pos <const>,
heading <const>,
networked <const>,
alwaysFalse <const>,
weight <const> = ...
if weight == 0 or kek_entity.entity_manager:update().is_vehicle_limit_not_breached then
local Vehicle <const> = originals.create_vehicle(model, pos, heading, networked, alwaysFalse)
kek_entity.entity_manager[Vehicle] = math.tointeger(weight) or 10
return Vehicle
end
return 0
end
ped.create_ped = function(...)
local type <const>,
model <const>,
pos <const>,
heading <const>,
isNetworked <const>,
unk1 <const>,
weight <const> = ...
if weight == 0 or kek_entity.entity_manager:update().is_ped_limit_not_breached then
local Ped <const> = originals.create_ped(type, model, pos, heading, isNetworked, unk1)
kek_entity.entity_manager[Ped] = math.tointeger(weight) or 15
return Ped
end
return 0
end
ped.clone_ped = function(Ped)
if kek_entity.entity_manager:update().is_ped_limit_not_breached then
local clone <const> = originals.clone_ped(Ped)
if entity.is_entity_a_ped(clone) then
kek_entity.entity_manager[clone] = 15
end
return clone
else
return 0
end
end
object.create_object = function(...)
if weight == 0 or kek_entity.entity_manager:update().is_object_limit_not_breached then
local Object <const> = originals.create_object(...)
local weight <const> = select(5, ...)
kek_entity.entity_manager[Object] = math.tointeger(weight) or 10
return Object
end
return 0
end
object.create_world_object = function(...)
if weight == 0 or kek_entity.entity_manager:update().is_object_limit_not_breached then
local world_object <const> = originals.create_world_object(...)
local weight <const> = select(5, ...)
kek_entity.entity_manager[world_object] = math.tointeger(weight) or 10
return world_object
end
return 0
end
network.request_control_of_entity = function(...)
local Entity <const>, no_condition <const> = ...
local is_entity_limit_not_breached <const> = kek_entity.entity_manager:update()[kek_entity.entity_manager.entity_type_to_return_type[entity.get_entity_type(Entity)]]
if no_condition
or kek_entity.entity_manager.entities[Entity] -- Is entity accounted for, but you don't have control?
or is_entity_limit_not_breached then
return originals.request_control_of_entity(Entity)
else
return false
end
end
end
end
local player_history <const> = {
year_parents = {},
month_parents = {},
day_parents = {},
hour_parents = {},
searched_players = {},
players_added_to_history = setmetatable({
__get_duplicate_check_string = function(pid)
return string.format("|%s| &%d& ^%s^", player.get_player_name(pid), player.get_player_scid(pid), essentials.dec_to_ipv4(player.get_player_ip(pid)))
end
}, {
__call = function(Table, pid)
return Table[Table.__get_duplicate_check_string(pid)]
end,
__newindex = function(Table, pid_or_str, value)
essentials.rawset(
Table,
type(pid_or_str) == "number" and Table.__get_duplicate_check_string(pid_or_str)
or type(pid_or_str) == "string" and pid_or_str,
value
)
end
})
}
for _, folder_name in pairs({
"",
"kekMenuData",
"profiles",
"kekMenuLogs",
"kekMenuLibs",
"Player history",
"kekMenuLibs\\Languages",
"Chat judger profiles",
"Chatbot profiles"
}) do
if not utils.dir_exists(paths.kek_menu_stuff..folder_name) then
utils.make_dir(paths.kek_menu_stuff..folder_name)
end
end
for _, folder_name in pairs({
"Menyoo Vehicles",
"Race ghosts",
"Menyoo Maps",
"Ini vehicles"
}) do
if not utils.dir_exists(paths.kek_menu_stuff..folder_name) then
utils.make_dir(paths.home.."scripts\\"..folder_name)
end
end
for _, file_name in pairs({
"kekMenuData\\custom_chat_judge_data.txt",
"kekMenuLogs\\Blacklist.log",
"kekMenuData\\Kek's chat bot.txt",
"kekMenuData\\Spam text.txt",
"kekMenuLogs\\All players.log",
"kekMenuLogs\\Chat log.log"
}) do
if not utils.file_exists(paths.kek_menu_stuff..file_name) then
essentials.create_empty_file(paths.kek_menu_stuff..file_name)
end
end
for _, file_name in pairs({
"kekMenuLibs\\data\\Truck.xml"
}) do
if not utils.file_exists(paths.kek_menu_stuff..file_name) then
essentials.msg(string.format("[%s]: %s", file_name, lang["Missing necessarry file. Please reinstall. Read the README that comes with the script for more information."]), "red")
error(lang["Missing necessarry file. Please reinstall. Read the README that comes with the script for more information."])
end
end
if utils.file_exists(paths.kek_settings) and essentials.get_file_string(paths.kek_settings):match("Script quick access=(%a%a%a%a)") == "true" then
u.kekMenu, u.kekMenuP = 0, 0
else
u.kekMenu = essentials.add_feature(lang["Kek's menu"], "parent", 0).id
u.kekMenuP = essentials.add_player_feature(lang["Kek's menu"], "parent", 0).id
end
u.player_history = essentials.add_feature(lang["Player history"], "parent", u.kekMenu)
u.gvehicle = essentials.add_feature(lang["Vehicle"], "parent", u.kekMenu)
u.self_options = essentials.add_feature(lang["Self options"], "parent", u.kekMenu)
u.weapons_self = essentials.add_feature(lang["Weapons"], "parent", u.self_options.id)
u.search_menu_features = essentials.add_feature(lang["Search features"], "parent", u.kekMenu)
u.chat_stuff = essentials.add_feature(lang["Chat"], "parent", u.kekMenu)
essentials.add_feature(lang["Send clipboard to chat"], "action", u.chat_stuff.id, function()
essentials.send_message(utils.from_clipboard())
end)
u.chat_spammer = essentials.add_feature(lang["Chat spamming"], "parent", u.chat_stuff.id)
u.custom_chat_judger = essentials.add_feature(lang["Custom chat judger"], "parent", u.chat_stuff.id)
u.chat_bot = essentials.add_feature(lang["Chat bot"], "parent", u.chat_stuff.id)
u.chat_commands = essentials.add_feature(lang["Chat commands"], "parent", u.chat_stuff.id)
u.translate_chat = essentials.add_feature(lang["Translate chat"], "parent", u.chat_stuff.id)
for _, properties in pairs({
{
folder = paths.menyoo_vehicles,
folder_name = "Menyoo vehicles",
extension = "xml",
parent = u.gvehicle,
func = menyoo.spawn_xml_vehicle,
save_func = menyoo_saver.save_vehicle,
str_data = {
lang["Search"],
lang["Create new folder"],
lang["Refresh files & folders"],
lang["Save"]
}
},
{
folder = paths.ini_vehicles,
folder_name = "Ini vehicles",
extension = "ini",
parent = u.gvehicle,
func = menyoo.spawn_ini_vehicle,
str_data = {
lang["Search"],
lang["Create new folder"],
lang["Refresh files & folders"]
}
}
}) do
local feat_str_data <const> = {
lang["Spawn"],
lang["Delete"],
lang["Change name"]
}
local function create_custom_vehicle_feature(name, folder_path, feat_name_map, parent)
local safe_feat_name <const> = essentials.get_safe_feat_name(name)
if name ~= safe_feat_name or name:find("..", 1, true) or name:find(".", -1, true) then
return
end
feat_name_map[safe_feat_name.."."..properties.extension] = essentials.add_feature(safe_feat_name, "action_value_str", parent.id, function(f)
if not utils.dir_exists(folder_path) then
essentials.msg(lang["This folder no longer exists."], "red", 8)
return
end
if essentials.is_str(f, "Spawn") then
if settings.toggle["Delete old #vehicle#"].on then
kek_entity.clear_owned_vehicles()
end
local Vehicle <const> = properties.func(folder_path.."\\"..f.name.."."..properties.extension, player.player_id())
if entity.is_entity_a_vehicle(Vehicle) then
kek_entity.teleport(Vehicle, kek_entity.vehicle_get_vec_rel_to_dims(entity.get_entity_model_hash(Vehicle), player.get_player_ped(player.player_id())))
kek_entity.vehicle_preferences(Vehicle)
kek_entity.user_vehicles[Vehicle] = Vehicle
end
elseif essentials.is_str(f, "Delete") then
if utils.file_exists(folder_path.."\\"..f.name.."."..properties.extension) then
io.remove(folder_path.."\\"..f.name.."."..properties.extension)
end
feat_name_map[f.name.."."..properties.extension] = nil
menu.delete_feature(f.id)
elseif essentials.is_str(f, "Change name") then
local input, status = f.name
while true do
input, status = keys_and_input.get_input(lang["Type in name of menyoo vehicle."], input, 128, 0)
if status == 2 then
return
elseif not essentials.is_file_name_change_is_invalid(folder_path, input, properties.extension) then
break
end
system.yield(0)
end
io.rename(
folder_path.."\\"..f.name.."."..properties.extension,
folder_path.."\\"..input.."." ..properties.extension
)
feat_name_map[f.name.."."..properties.extension] = nil
f.name = input
feat_name_map[f.name.."."..properties.extension] = f
end
end)
feat_name_map[safe_feat_name.."."..properties.extension]:set_str_data(feat_str_data)
end
local get_new_feat_map_object
local function create_main_feat(feat_name_map, parent, folder_path)
essentials.add_feature(lang[properties.folder_name], "action_value_str", parent.id, function(f)
if not essentials.is_str(f, "Refresh files & folders") and not utils.dir_exists(folder_path) then
essentials.msg(lang["This folder no longer exists."], "red", 8)
return
end
if essentials.is_str(f, "Search") then
local input, status <const> = keys_and_input.get_input(lang["Type in name of menyoo vehicle."], "", 128, 0)
if status == 2 then
return
end
input = essentials.make_string_case_insensitive(essentials.remove_special(input))
for feat_name, feat in pairs(feat_name_map) do
if type(feat) == "userdata" then
feat.hidden = not feat.name:find(input)
end
end
elseif essentials.is_str(f, "Refresh files & folders") then
feat_name_map:empty() -- It's ~3x faster to delete all features & then rebuild every feature, instead of checking if files exists.
feat_name_map:rebuild()
elseif essentials.is_str(f, "Create new folder") then
local input, status
while true do
input, status = keys_and_input.get_input(lang["Type in name of the folder."], input, 128, 0)
if status == 2 then
return
elseif not essentials.is_file_name_change_is_invalid(folder_path, input, "FOLDER") then
break
end
system.yield(0)
end
local folder_path <const> = folder_path.."\\"..input
utils.make_dir(folder_path)
if not utils.dir_exists(folder_path) then
essentials.msg(lang["Failed to create folder."], "red", 8)
return
end
local new_parent <const> = essentials.add_feature(input, "parent", parent.id)
feat_name_map[folder_path] = get_new_feat_map_object(folder_path, new_parent, feat_name_map)
create_main_feat(feat_name_map[folder_path], new_parent, folder_path)
feat_name_map:empty()
feat_name_map:rebuild()
elseif properties.save_func and essentials.is_str(f, "Save") then -- essentials.is_str raises error if attempting to check for a string that isn't in the str_data
if not entity.is_entity_a_vehicle(player.get_player_vehicle(player.player_id())) then
essentials.msg(lang["Found no vehicle to save."], "red")
return
end
local input, status
while true do
input, status = keys_and_input.get_input(lang["Type in name of menyoo vehicle."], input, 128, 0)
if status == 2 then
return
elseif not essentials.is_file_name_change_is_invalid(folder_path, input, properties.extension) then
break
end
system.yield(0)
end
properties.save_func(player.get_player_vehicle(player.player_id()), folder_path.."\\"..input.."."..properties.extension)
create_custom_vehicle_feature(input, folder_path, feat_name_map, parent)
end
end):set_str_data(properties.str_data)
end
function get_new_feat_map_object(folder_path, parent, feat_name_map) -- Defined as local above
local object <const> = setmetatable({}, { -- It must be a metatable. "belongs_to" and "parent" disrupt logic.
folder_path = folder_path,
parent = parent,
belongs_to = feat_name_map
})
local object_mt <const> = getmetatable(object)
function object:empty()
for feat_name, feat in pairs(self) do
if type(feat) == "userdata" then
menu.delete_feature(feat.id)
self[feat_name] = nil
elseif type(feat) == "table" then
feat:empty()
end
end
end
function object:rebuild()
if utils.dir_exists(object_mt.folder_path) then
for folder_path, object in pairs(self) do
if type(object) == "table" then
object:rebuild()
end
end
for _, folder_name in pairs(utils.get_all_sub_directories_in_directory(object_mt.folder_path)) do
local folder_path <const> = object_mt.folder_path.."\\"..folder_name
if not self[folder_path] then
local new_parent <const> = essentials.add_feature(folder_name, "parent", object_mt.parent.id)
self[folder_path] = get_new_feat_map_object(folder_path, new_parent, self)
create_main_feat(self[folder_path], new_parent, folder_path)
self[folder_path]:rebuild()
end
end
local End <const> = -1 - #("."..properties.extension)
local files <const> = utils.get_all_files_in_directory(object_mt.folder_path, properties.extension)
for i = 1, #files do
create_custom_vehicle_feature(files[i]:sub(1, End), object_mt.folder_path, self, object_mt.parent)
end
else
self:empty() -- Delete features
local feats <const> = essentials.get_descendants(object_mt.parent, {}, true)
for i = 1, #feats do -- Deletes parents
menu.delete_feature(feats[i].id)
end
object_mt.belongs_to[object_mt.folder_path] = nil -- Final part of updating feat map
end
end
return object
end
local function create_vehicle_features(folder_path, feat_name_map, parent)
create_main_feat(feat_name_map, parent, folder_path)
for _, folder_name in pairs(utils.get_all_sub_directories_in_directory(folder_path)) do
local folder_path <const> = folder_path.."\\"..folder_name
local new_parent <const> = essentials.add_feature(folder_name, "parent", parent.id)
feat_name_map[folder_path] = get_new_feat_map_object(folder_path, new_parent, feat_name_map)
create_vehicle_features(
folder_path,
feat_name_map[folder_path],
new_parent
)
end
end
local new_parent <const> = essentials.add_feature(lang[properties.folder_name], "parent", properties.parent.id)
local feat_name_map <const> = get_new_feat_map_object(properties.folder, new_parent, {})
create_vehicle_features(
properties.folder,
feat_name_map,
new_parent
)
feat_name_map:rebuild()
end
u.settingsUI = essentials.add_feature(lang["Settings"], "parent", u.kekMenu)
u.setting_profiles = essentials.add_feature(lang["Profiles"], "parent", u.settingsUI.id)
u.setting_profiles.hint = lang["Save your Kek's menu settings here."]
u.vehicleSettings = essentials.add_feature(lang["Vehicle settings"], "parent", u.settingsUI.id)
u.language_config = essentials.add_feature(lang["Language settings"], "parent", u.settingsUI.id)
u.ai_drive = essentials.add_feature(lang["Ai driving"], "parent", u.gvehicle.id)
u.drive_style_cfg = essentials.add_feature(lang["Drive style"], "parent", u.gvehicle.id)
u.protections = essentials.add_feature(lang["Protections"], "parent", u.self_options.id)
u.modder_detection = essentials.add_feature(lang["Modder detection"], "parent", u.kekMenu)
u.flagsTolog = essentials.add_feature(lang["Modder logging settings"], "parent", u.modder_detection.id)
u.flagsToKick = essentials.add_feature(lang["Auto kicker settings"], "parent", u.modder_detection.id)
u.vehicle_friendly = essentials.add_feature(lang["Vehicle peaceful"], "parent", u.gvehicle.id)
u.vehicle_blacklist = essentials.add_feature(lang["Vehicle blacklist"], "parent", u.gvehicle.id)
u.debug = essentials.add_feature("Debugging", "parent", u.settingsUI.id)
u.session_trolling = essentials.add_feature(lang["Session trolling"], "parent", u.kekMenu)
u.session_malicious = essentials.add_feature(lang["Session malicious"], "parent", u.kekMenu)
u.weapon_blacklist = essentials.add_feature(lang["Weapon blacklist"], "parent", u.session_malicious.id)
u.session_peaceful = essentials.add_feature(lang["Session peaceful"], "parent", u.kekMenu)
u.kek_utilities = essentials.add_feature(lang["Kek's utilities"], "parent", u.kekMenu)
u.player_vehicle_features = essentials.add_player_feature(lang["Vehicle"], "parent", u.kekMenuP).id
u.malicious_player_features = essentials.add_player_feature(lang["Malicious"], "parent", u.kekMenuP).id
u.script_stuff = essentials.add_player_feature(lang["Scripts"], "parent", u.kekMenuP).id
u.pWeapons = essentials.add_player_feature(lang["Weapons"], "parent", u.kekMenuP).id
u.player_misc_features = essentials.add_player_feature(lang["Misc"], "parent", u.kekMenuP).id
u.player_peaceful = essentials.add_player_feature(lang["Peaceful"], "parent", u.kekMenuP).id
u.player_trolling_features = essentials.add_player_feature(lang["Trolling"], "parent", u.kekMenuP).id
local keks_custom_modder_flags =
{
["Has-Suspicious-Stats"] = 0,
["Blacklist"] = 0,
["Godmode"] = 0,
["Modded-Name"] = 0
}
u.modder_flag_setting_properties =
{
["Log people with "] = {
feat_name = "Log:",
parent = u.flagsTolog,
bits = 0
},
["Kick people with "] = {
feat_name = "Kick:",
parent = u.flagsToKick,
bits = 0
}
}
local modIdStuff = {}
do
local i = 0
repeat
modIdStuff[#modIdStuff + 1] = 1 << i
i = i + 1
until 1 << i == player.get_modder_flag_ends()
for flag_name, _ in pairs(keks_custom_modder_flags) do
local ends <const> = player.get_modder_flag_ends()
local flag_int <const> = player.add_modder_flag(flag_name)
if flag_int == ends then
modIdStuff[#modIdStuff + 1] = flag_int
end
keks_custom_modder_flags[flag_name] = flag_int
end
end
for _, properties in pairs({
{
setting_name = "Clear before spawning xml map",
setting = true
},
{
setting_name = "Force host",
setting = false
},
{
setting_name = "Automatically check player stats",
setting = false
},
{
setting_name = "Auto kicker",
setting = false
},
{
setting_name = "Auto kicker notifications",
setting = 0
},
{
setting_name = "Log modders",
setting = true
},
{
setting_name = "Blacklist",
setting = false
},
{
setting_name = "Custom chat judger",
setting = false
},
{
setting_name = "Chat judge reaction",
setting = 1
},
{
setting_name = "User vehicle",
setting = "krieger"
},
{
setting_name = "User ped",
setting = "u_m_m_jesus_01"
},
{
setting_name = "User object",
setting = "prop_asteroid_01"
},
{
setting_name = "Exclude friends from attacks",
setting = true
},
{
setting_name = "Exclude yourself from trolling",
setting = true
},
{
setting_name = "Plate vehicle text",
setting = "Kektram"
},
{
setting_name = "Vehicle fly speed",
setting = 150
},
{
setting_name = "Vehicle blacklist",
setting = false
},
{
setting_name = "Spam text",
setting = "Kektram"
},
{
setting_name = "Echo chat",
setting = false
},
{
setting_name = "Kick any vote kickers",
setting = false
},
{
setting_name = "chat bot",
setting = false
},
{
setting_name = "chat bot delay",
setting = 0
},
{
setting_name = "Spam speed",
setting = 100
},
{
setting_name = "Echo delay",
setting = 100
},
{
setting_name = "Player history",
setting = true
},
{
setting_name = "Random weapon camos",
setting = false
},
{
setting_name = "Max number of people to kick in force host",
setting = 31
},
{
setting_name = "Vehicle clear distance",
setting = 500
},
{
setting_name = "Ped clear distance",
setting = 500
},
{
setting_name = "Object clear distance",
setting = 500
},
{
setting_name = "Pickup clear distance",
setting = 500
},
{
setting_name = "Ptfx clear distance",
setting = 500
},
{
setting_name = "Drive style",
setting = 557
},
{
setting_name = "Cops clear distance",
setting = 500
},
{
setting_name = "Chat logger",
setting = true
},
{
setting_name = "Script quick access",
setting = false
},
{
setting_name = "Chat commands",
setting = false
},
{
setting_name = "Send command info",
setting = false
},
{
setting_name = "Godmode detection",
setting = false
},
{
setting_name = "Horn boost speed",
setting = 25
},
{
setting_name = "Horn boost",
setting = false
},
{
setting_name = "Bounty amount",
setting = 10000
},
{
setting_name = "Friends can't be targeted by chat commands",
setting = true
},
{
setting_name = "You can't be targeted",
setting = true
},
{
setting_name = "Auto tp to waypoint",
setting = false
},
{
setting_name = "Random weapon camos speed",
setting = 500
},
{
setting_name = "Chance to reply",
setting = 100
},
{
setting_name = "Aim protection",
setting = false
},
{
setting_name = "Aim protection mode",
setting = 1
},
{
setting_name = "Revenge",
setting = false
},
{
setting_name = "Revenge mode",
setting = 1
},
{
setting_name = "Anti stuck measures",
setting = true
},
{
setting_name = "Time OSD",
setting = false
},
{
setting_name = "Time OSD option",
setting = 0
},
{
setting_name = "Display 2take1 notifications",
setting = false
},
{
setting_name = "Display 2take1 notifications filter",
setting = 0
},
{
setting_name = "Number of notifications to display",
setting = 15
},
{
setting_name = "Max characters per line",
setting = 100
},
{
setting_name = "Log 2take1 notifications to console",
setting = false
},
{
setting_name = "Log 2take1 notifications to console filter",
setting = 0
},
{
setting_name = "Help interval",
setting = 14
},
{
setting_name = "Weapon blacklist",
setting = false
},
{