-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbest.lua
More file actions
873 lines (652 loc) · 19.1 KB
/
Copy pathbest.lua
File metadata and controls
873 lines (652 loc) · 19.1 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
local base64 = require("gamesense/base64")
local clipboard = require("gamesense/clipboard")
local weapons = require("gamesense/csgo_weapons")
-- refs
local ref = {
qp = {ui.reference("RAGE", "Other", "Quick peek assist")},
dt = {ui.reference("RAGE", "Aimbot", "Double tap")},
air = ui.reference("MISC", "Movement", "Air strafe"),
yaw_base = ui.reference("AA", "Anti-aimbot angles", "Yaw base"),
yaw = ui.reference("AA", "Anti-aimbot angles", "Yaw"),
yaw_offset = select(2, ui.reference("AA", "Anti-aimbot angles", "Yaw")),
bodyyaw = {
ui.reference(
"AA",
"Anti-aimbot angles",
"Body yaw"
)
},
fsby = ui.reference(
"AA",
"Anti-aimbot angles",
"Freestanding body yaw"
),
}
-- menu
local menu = {
tab = ui.new_combobox("LUA", "A", "Melancholia.ws", {
"Home", "Rage", "Anti-Aim", "Visual", "Misc"
}),
home = {
label = ui.new_label("LUA", "A", "Config"),
cfg = ui.new_textbox("LUA", "A", "Config name")
},
rage = {
discharge = ui.new_checkbox("LUA", "A", "Auto discharge"),
mode = ui.new_combobox("LUA", "A", "Mode", {"Instant", "Ideal"}),
predict = ui.new_checkbox("LUA", "A", "Predict L/R"),
hotexp = ui.new_checkbox("LUA", "A", "Exploit Predict"),
pingpos = ui.new_combobox("LUA", "A", "Ping Position", {"Low", "High"}),
slidescout = ui.new_combobox("LUA", "A", "Scout Interp Adjust", {"Disabled", "Medium", "Maximum", "Extreme"}),
slideawp = ui.new_combobox("LUA", "A", "AWP Interp Adjust", {"Disabled", "Medium", "Maximum", "Extreme"}),
slideauto = ui.new_combobox("LUA", "A", "Auto Interp Adjust", {"Disabled", "Medium", "Maximum", "Extreme"}),
slider8 = ui.new_combobox("LUA", "A", "Heavy Pistol Interp Adjust", {"Disabled", "Medium", "Maximum", "Extreme"})
},
aa = {
peek = ui.new_checkbox("LUA", "A", "Defensive peek"),
predict = ui.new_slider("LUA", "A", "Prediction", 8, 32, 24),
},
visual = {
arrows = ui.new_checkbox("LUA", "A", "Manual arrows"),
l_text = ui.new_label("LUA", "A", "Left"),
left = ui.new_hotkey("LUA", "A", "\nleft", true),
r_text = ui.new_label("LUA", "A", "Right"),
right = ui.new_hotkey("LUA", "A", "\nright", true),
notify = ui.new_multiselect("LUA", "A", "Notifications", {
"Hit", "Miss", "Shot", "Reset", "Buy"
})
},
misc = {
jumpscout = ui.new_checkbox("LUA", "A", "Jumpscout"),
clantag = ui.new_checkbox("LUA", "A", "Clan tag"),
ladder = ui.new_checkbox("LUA", "A", "Fast ladder"),
-- Buy bot
buy_bot_enabled = ui.new_checkbox("LUA", "A", "Enable buy bot"),
buy_bot_primary = ui.new_combobox("LUA", "A", "Primary weapon", {
"None", "Autosnipers", "Scout", "AWP", "AK-47 / M4",
"AUG / SG553", "Famas", "Negev", "M249", "MP7 / MP5",
"MP9 / Mac-10", "UMP-45", "P90", "Bizon", "Nova",
"XM1014", "Mag7 / Sawed-Off"
}),
buy_bot_secondary = ui.new_combobox("LUA", "A", "Secondary weapon", {
"None", "R8 / Deagle", "Tec-9 / Five-S / CZ-75", "P-250", "Duals"
}),
buy_bot_utility = ui.new_multiselect("LUA", "A", "Utility items", {
"Kevlar", "Helmet", "Defuser", "Taser", "HE", "Molotov",
"Smoke", "Flashbang", "Decoy"
})
}
}
-- helpers
local function contains(t,v)
for i=1,#t do
if t[i] == v then
return true
end
end
end
local function visible(state, tbl)
state = state == true
for _, v in pairs(tbl) do
if v ~= nil then
ui.set_visible(v, state)
end
end
end
local function get_cfg()
local data = {}
for cat, tbl in pairs(menu) do
if type(tbl) == "table" then
data[cat] = {}
for k,v in pairs(tbl) do
local ok,val = pcall(ui.get, v)
if ok then
data[cat][k] = val
end
end
end
end
return data
end
local function load_cfg(data)
for cat,tbl in pairs(data) do
if menu[cat] then
for k,v in pairs(tbl) do
if menu[cat][k] then
pcall(ui.set, menu[cat][k], v)
end
end
end
end
end
-- notifications
local notifications = {}
local last_shot = 0
local function notify(text)
table.insert(notifications, 1, {
text = text,
alpha = 0,
y = 0,
life = globals.realtime() + 4
})
end
client.set_event_callback("paint", function()
local sw, sh = client.screen_size()
for i=#notifications,1,-1 do
local n = notifications[i]
n.alpha = globals.realtime() > n.life
and math.max(n.alpha - 7, 0)
or math.min(n.alpha + 15, 255)
if n.alpha <= 0 then
table.remove(notifications, i)
else
n.y = n.y + (((i-1)*26)-n.y)*0.08
local w = renderer.measure_text("", n.text)
local x = sw/2 - (w+30)/2
local y = sh/2 + 180 + n.y
renderer.rectangle(x,y,w+30,22,35,35,35,n.alpha)
renderer.text(
x+10,y+4,
179,255,18,n.alpha,
"",0,"L"
)
renderer.text(
x+22,y+4,
255,255,255,n.alpha,
"",0,n.text
)
end
end
end)
-- config buttons
menu.home.save = ui.new_button("LUA","A","Save",function()
local name = ui.get(menu.home.cfg)
if name == "" then
notify("Enter config name")
return
end
database.write(
"melancholia_"..name,
base64.encode(json.stringify(get_cfg()))
)
notify("Saved "..name)
end)
menu.home.load = ui.new_button("LUA","A","Load",function()
local name = ui.get(menu.home.cfg)
local raw = database.read("melancholia_"..name)
if not raw then
notify("Config not found")
return
end
load_cfg(
json.parse(base64.decode(raw))
)
notify("Loaded "..name)
end)
menu.home.export = ui.new_button("LUA","A","Export",function()
clipboard.set(
base64.encode(
json.stringify(get_cfg())
)
)
notify("Exported config")
end)
menu.home.import = ui.new_button("LUA","A","Import",function()
local ok,data = pcall(function()
return json.parse(
base64.decode(
clipboard.get()
)
)
end)
if not ok then
notify("Invalid config")
return
end
load_cfg(data)
notify("Imported config")
end)
-- predict
local interp_values = {
["Disabled"] = 0.015625,
["Medium"] = 0.028000,
["Maximum"] = 0.029125,
["Extreme"] = 0.031000
}
local weapon_sliders = {
["CWeaponSSG08"] = rage.slidescout,
["CWeaponAWP"] = rage.slideawp,
["CWeaponSCAR20"] = rage.slideauto,
["CWeaponG3SG1"] = rage.slideauto,
["CDEagle"] = rage.slider8
}
local function run_predict()
if not ui.get(rage.predict) or not ui.get(rage.hotexp) then
cvar.cl_interp:set_float(0.015625)
cvar.cl_interp_ratio:set_int(2)
cvar.cl_interpolate:set_int(1)
return
end
local lp = entity.get_local_player()
if not lp or not entity.is_alive(lp) then return end
local gun = entity.get_player_weapon(lp)
if not gun then return end
local classname = entity.get_classname(gun)
local ping_mode = ui.get(rage.pingpos)
if ping_mode == "Low" then
cvar.cl_interpolate:set_int(0)
cvar.cl_interp_ratio:set_int(1)
-- Получаем нужный комбобокс из таблицы оружия
local slider = weapon_sliders[classname]
if slider then
local mode = ui.get(slider)
local interp_val = interp_values[mode]
if interp_val then
cvar.cl_interp:set_float(interp_val)
end
else
cvar.cl_interp:set_float(0.015625)
end
elseif ping_mode == "High" then
cvar.cl_interp:set_float(0.020000)
cvar.cl_interp_ratio:set_int(0)
cvar.cl_interpolate:set_int(0)
end
end
-- defensive peek
local hitboxes = {0,2,3}
local function can_fire()
local lp = entity.get_local_player()
local wpn = lp and entity.get_player_weapon(lp)
if not wpn then
return false
end
return entity.get_prop(
wpn,
"m_flNextPrimaryAttack"
) <= globals.curtime()
end
local function will_peek()
local lp = entity.get_local_player()
if not lp or not can_fire() then
return false
end
local ex,ey,ez = client.eye_position()
local vx,vy,vz = entity.get_prop(lp,"m_vecVelocity")
local t = globals.tickinterval()*ui.get(menu.aa.predict)
ex,ey,ez = ex+vx*t, ey+vy*t, ez+vz*t
for _,enemy in pairs(entity.get_players(true)) do
if entity.is_alive(enemy) then
local evx,evy,evz =
entity.get_prop(enemy,"m_vecVelocity")
for _,hb in pairs(hitboxes) do
local x,y,z =
entity.hitbox_position(enemy,hb)
x,y,z =
x+evx*t,
y+evy*t,
z+evz*t
local _,dmg =
client.trace_bullet(
lp,ex,ey,ez,x,y,z
)
if dmg > 0 then
return true
end
end
end
end
return false
end
-- manuals
local side, delay = 0, 0
local backup = {}
local function update_manuals()
if not ui.get(menu.visual.arrows) then
side = 0
return
end
local tick = globals.tickcount()
if ui.get(menu.visual.left) and delay < tick then
side = side == -90 and 0 or -90
delay = tick + 10
end
if ui.get(menu.visual.right) and delay < tick then
side = side == 90 and 0 or 90
delay = tick + 10
end
end
-- clantag
local tag = "Melancholia.ws"
local prev = ""
local start = 0
local enabled = false
local function update_tag()
if not ui.get(menu.misc.clantag) then
if enabled then
client.set_clan_tag("")
enabled = false
prev = ""
end
return
end
if not enabled then
enabled = true
start = globals.curtime()
end
local len = #tag
local step =
math.floor(
(globals.curtime()-start)/0.25
) % ((len*2)+1)
local text =
step == 0 and " "
or step <= len
and tag:sub(1,step)
or tag:sub(1,len-(step-len))
if text ~= prev then
client.set_clan_tag(text)
prev = text
end
end
-- paint
client.set_event_callback("paint", function()
update_tag()
if ui.get(menu.visual.arrows) then
local sw,sh = client.screen_size()
sw,sh = sw/2, sh/2
renderer.text(
sw-50,sh,
255,255,255,
side == -90 and 255 or 70,
"c+",0,"<"
)
renderer.text(
sw+50,sh,
255,255,255,
side == 90 and 255 or 70,
"c+",0,">"
)
end
end)
-- notifications
client.set_event_callback("aim_hit", function(e)
if contains(ui.get(menu.visual.notify),"Hit") then
notify(
"Hit "..entity.get_player_name(e.target)
.." for "..e.damage
)
end
end)
client.set_event_callback("aim_miss", function(e)
if contains(ui.get(menu.visual.notify),"Miss") then
notify(
"Missed "..entity.get_player_name(e.target)
)
end
end)
client.set_event_callback("bullet_impact", function(e)
if not contains(ui.get(menu.visual.notify),"Shot") then
return
end
local shooter =
client.userid_to_entindex(e.userid)
if not entity.is_enemy(shooter) then
return
end
if globals.curtime()-last_shot < 0.5 then
return
end
last_shot = globals.curtime()
notify("Enemy shot detected")
end)
client.set_event_callback("round_start", function()
if contains(ui.get(menu.visual.notify),"Reset") then
notify("Round restarted")
end
end)
-- buy bot
local primary_console = {
["Autosnipers"] = "scar20",
["Scout"] = "ssg08",
["AWP"] = "awp",
["AK-47 / M4"] = "ak47",
["AUG / SG553"] = "sg556",
['Famas'] = 'famas',
["Negev"] = "negev",
['M249'] = 'm249',
['MP7 / MP5'] = 'mp7',
['MP9 / Mac-10'] = 'mp9',
['UMP-45'] = 'ump45',
['P90'] = 'p90',
['Bizon'] = 'bizon',
['Nova'] = 'nova',
['XM1014'] = 'XM1014',
['Mag7 / Sawed-Off'] = 'mag7'
}
local secondary_console = {
["R8 / Deagle"] = "deagle",
["Tec-9 / Five-S / CZ-75"] = "tec9",
["P-250"] = "p250",
["Duals"] = "elite"
}
local utility_console = {
["Kevlar"] = "vest",
['Helmet'] = 'vesthelm',
["Defuser"] = "defuser",
["Taser"] = "taser",
["HE"] = "hegrenade",
["Molotov"] = "molotov",
["Smoke"] = "smokegrenade",
["Flashbang"] = "flashbang",
["Decoy"] = "decoy"
}
client.set_event_callback("round_prestart", function()
if not ui.get(menu.misc.buy_bot_enabled) then
return
end
local money = entity.get_prop(entity.get_local_player(), "m_iAccount") or 0
if money <= 800 then
return
end
local primary = ui.get(menu.misc.buy_bot_primary)
local secondary = ui.get(menu.misc.buy_bot_secondary)
local util = ui.get(menu.misc.buy_bot_utility)
if primary ~= 'None' and primary_console[primary] then
client.exec("buy " .. primary_console[primary])
end
if secondary ~= 'None' and secondary_console[secondary] then
client.exec("buy " .. secondary_console[secondary])
end
for i = 1, #util do
local item = utility_console[util[i]]
if item then
client.exec("buy " .. item)
end
end
if contains(ui.get(menu.visual.notify), "Buy") and primary ~= 'None' then
notify("Bought " .. primary)
end
end)
-- visibility
client.set_event_callback("paint_ui", function()
local t = ui.get(menu.tab)
-- home
visible(t=="Home", {
menu.home.label,
menu.home.cfg,
menu.home.save,
menu.home.load,
menu.home.export,
menu.home.import
})
-- rage
visible(t=="Rage", {
menu.rage.discharge,
menu.rage.predict
})
ui.set_visible(
menu.rage.mode,
t=="Rage"
and ui.get(menu.rage.discharge)
)
local is_predict_on = t == "Rage" and ui.get(menu.rage.predict)
visible(is_predict_on, {
menu.rage.hotexp,
menu.rage.pingpos
})
local is_low_ping = is_predict_on and ui.get(menu.rage.pingpos) == "Low"
visible(is_low_ping, {
menu.rage.slidescout,
menu.rage.slideawp,
menu.rage.slideauto,
menu.rage.slider8
})
-- anti-aim
visible(t=="Anti-Aim", {
menu.aa.peek,
})
ui.set_visible(
menu.aa.predict,
t=="Anti-Aim"
and ui.get(menu.aa.peek)
)
-- visual
visible(t=="Visual", {
menu.visual.arrows,
menu.visual.notify
})
visible(
t=="Visual" and ui.get(menu.visual.arrows),
{
menu.visual.l_text,
menu.visual.left,
menu.visual.r_text,
menu.visual.right
}
)
-- misc
visible(t=="Misc", {
menu.misc.jumpscout,
menu.misc.clantag,
menu.misc.ladder,
menu.misc.buy_bot_enabled,
menu.misc.buy_bot_primary,
menu.misc.buy_bot_secondary,
menu.misc.buy_bot_utility
})
visible(
t=="Misc" and ui.get(menu.misc.buy_bot_enabled),
{
menu.misc.buy_bot_primary,
menu.misc.buy_bot_secondary,
menu.misc.buy_bot_utility
}
)
end)
-- setup_command
client.set_event_callback("setup_command", function(cmd)
run_predict()
update_manuals()
-- discharge
if ui.get(menu.rage.discharge)
and not ui.get(ref.qp[2])
and ui.get(ref.dt[2]) then
local wpn =
entity.get_classname(
entity.get_player_weapon(
entity.get_local_player()
)
)
if wpn == "CWeaponSSG08"
or wpn == "CWeaponAWP" then
local z =
math.floor(
entity.get_prop(
entity.get_local_player(),
"m_vecVelocity[2]"
)
)
local vulnerable = false
for _,v in ipairs(entity.get_players(true)) do
local flags =
entity.get_esp_data(v).flags
if bit.band(flags, bit.lshift(1,11)) ~= 0 then
vulnerable = true
end
end
if vulnerable then
if ui.get(menu.rage.mode) == "Ideal"
and z > 20 then
return
end
cmd.in_jump = false
cmd.discharge_pending = true
end
end
end
-- defensive
if ui.get(menu.aa.peek)
and ui.get(ref.dt[1])
and ui.get(ref.dt[2]) then
cmd.force_defensive = will_peek()
end
-- jumpscout
if ui.get(menu.misc.jumpscout) then
local x,y =
entity.get_prop(
entity.get_local_player(),
"m_vecVelocity"
)
ui.set(
ref.air,
not (
cmd.in_jump
and math.sqrt(x^2+y^2) < 10
)
or ui.is_menu_open()
)
end
-- fast ladder
if ui.get(menu.misc.ladder) then
local lp = entity.get_local_player()
if lp and entity.get_prop(lp,"m_MoveType") == 9 then
cmd.yaw = math.floor(cmd.yaw+0.5)
if cmd.forwardmove ~= 0 then
cmd.pitch = 89
local back = cmd.forwardmove > 0
cmd.in_forward = back and 0 or 1
cmd.in_back = back and 1 or 0
cmd.in_moveleft = back and 0 or 1
cmd.in_moveright = back and 1 or 0
cmd.yaw =
cmd.yaw +
(
cmd.sidemove == 0 and 90
or cmd.sidemove > 0 and 30
or 150
)
end
end
end
-- manuals
if side ~= 0 then
if not backup.active then
backup.base = ui.get(ref.yaw_base)
backup.yaw = ui.get(ref.yaw)
backup.offset = ui.get(ref.yaw_offset)
backup.active = true
end
ui.set(ref.yaw_base,"Local view")
ui.set(ref.yaw,"180")
ui.set(ref.yaw_offset,side)
elseif backup.active then
ui.set(ref.yaw_base,backup.base)
ui.set(ref.yaw,backup.yaw)
ui.set(ref.yaw_offset,backup.offset)
backup.active = false
end
end)
client.set_event_callback("shutdown", function()
client.set_clan_tag("")
end)