Эксперт
-
Автор темы
- #1
Мне стало интересно изучть джава скрипт, т.к. пишу в основном на луа, и я ахуел 12312 раз с того, какой джава скрипт привередливый, там скобку поставь там
вобщем хотелось бы узнать мнение +- хороших кодеров на джава скриптинге, узнать мои ошибки и недостатки
некоторые функи не используются потому что я вырезал кейбинды, были багаными
вобщем хотелось бы узнать мнение +- хороших кодеров на джава скриптинге, узнать мои ошибки и недостатки
некоторые функи не используются потому что я вырезал кейбинды, были багаными
JavaScript:
//vars
var damage_GENERAL_value = UI.GetValue("Rage", "GENERAL", "Targeting", "Minimum damage")
var damage_PISTOL_value = UI.GetValue("Rage", "PISTOL", "Targeting", "Minimum damage")
var damage_HEAVY_PISTOL_value = UI.GetValue("Rage", "HEAVY PISTOL", "Targeting", "Minimum damage")
var damage_SCOUT_value = UI.GetValue("Rage", "SCOUT", "Targeting", "Minimum damage")
var damage_AWP_value = UI.GetValue("Rage", "AWP", "Targeting", "Minimum damage")
var damage_AUTOSNIPER_value = UI.GetValue("Rage", "AUTOSNIPER", "Targeting", "Minimum damage")
var drag = 0
var dmgmem = 0
var screen = Global.GetScreenSize();
var memory = [0, 0];
var removals_cache = UI.GetValue("Visual", "WORLD", "Entities", "Removals");
UI.AddDropdown("Section", [ "Rage", "Anti-aim", "Visuals", "Misc"]);
UI.AddCheckbox("Enable Scope lines")
UI.AddColorPicker("Scope color")
UI.AddSliderInt("Scope lenght",0,100)
UI.AddSliderInt("Scope start",0,100)
UI.AddCheckbox("Enable weapon in scope")
UI.AddCheckbox("Enable Aspect ratio")
UI.AddSliderFloat("Aspect ratio value",0,5)
UI.AddHotkey("Damage override")
UI.AddSliderInt("Damage override value",0,130)
UI.AddCheckbox("Enable aa")
UI.AddMultiDropdown("Esp",[ "Name", "Hp", "Armor"])
UI.AddCheckbox("Custom color Hp")
UI.AddColorPicker("Hp color")
UI.AddColorPicker("Name color")
UI.AddColorPicker("Armor color")
function tabs(){
var Rage_tab = UI.GetValue("Script items", "Section") == 0;
var Anti_aim_tab = UI.GetValue("Script items", "Section") == 1;
var Visual_tab = UI.GetValue("Script items", "Section") == 2;
var Misc_tab = UI.GetValue("Script items", "Section") == 3;
UI.SetEnabled("Script items","Enable aa",Anti_aim_tab);
UI.SetEnabled("Script items","Damage override",Rage_tab);
UI.SetEnabled("Script items","Damage override value",Rage_tab);
UI.SetEnabled("Script items","Enable Aspect ratio",Misc_tab);
UI.SetEnabled("Script items","Enable weapon in scope",Visual_tab);
UI.SetEnabled("Script items","Esp",Visual_tab );
UI.SetEnabled("Script items","Custom color Hp",Visual_tab );
UI.SetEnabled("Script items","Hp color",Visual_tab && (UI.GetValue("Script items","Esp") == 2 ||UI.GetValue("Script items","Esp") == 3 ||UI.GetValue("Script items","Esp") == 7 || UI.GetValue("Script items","Esp") == 6) && UI.GetValue("Script items","Custom color Hp"));
UI.SetEnabled("Script items","Name color",Visual_tab && (UI.GetValue("Script items","Esp") == 1 ||UI.GetValue("Script items","Esp") == 3 ||UI.GetValue("Script items","Esp") == 7 ||UI.GetValue("Script items","Esp") == 5));
UI.SetEnabled("Script items","Armor color",Visual_tab && (UI.GetValue("Script items","Esp") == 4 ||UI.GetValue("Script items","Esp") == 5 || UI.GetValue("Script items","Esp") ==6 ||UI.GetValue("Script items","Esp") == 7 ));
UI.SetEnabled("Script items","Enable Scope lines",Visual_tab);
UI.SetEnabled("Script items","Aspect ratio value",Misc_tab && UI.GetValue("Script items","Enable Aspect ratio"));
UI.SetEnabled("Script items","Scope start",Visual_tab && UI.GetValue("Script items","Enable Scope lines"));
UI.SetEnabled("Script items","Scope lenght",Visual_tab && UI.GetValue("Script items","Enable Scope lines"));
UI.SetEnabled("Script items","Scope color",Visual_tab && UI.GetValue("Script items","Enable Scope lines"));
}
const Render_outlined = function(x, y, a, text, color, font){
Render.StringCustom(x + 1, y, a, text, [0, 0, 0, 255], font );
Render.StringCustom(x - 1, y, a, text, [0, 0, 0, 255], font );
Render.StringCustom(x, y + 1, a, text, [0, 0, 0, 255], font );
Render.StringCustom(x, y - 1, a, text, [0, 0, 0, 255], font );
Render.StringCustom(x, y, a, text, color, font );
}
const Renderline_outlined = function(x, y, x2, y2, color){
Render.Line(x , y, x ,y+1 , [0, 0, 0, 255] );
Render.Line(x2 , y2, x2 ,y2-1 , [0, 0, 0, 255] );
Render.Line(x + 1, y, x2 + 1,y2 , [0, 0, 0, 255] );
Render.Line(x - 1, y, x2 - 1,y2 , [0, 0, 0, 255] );
Render.Line(x, y, x2,y2 ,color);
}
function move(x,y,w,h,name){
var mouse = Input.GetCursorPosition()
if (Input.IsKeyPressed(0x01)) {
if ((mouse[0] >= x) && (mouse[0] <= x + w) && (mouse[1] <= y + h) && (mouse[1] >= y) && (drag == 0)) {
memory[0] = x - mouse[0]
memory[1] = y - mouse[1]
drag = 1
}
}
else {
drag = 0
}
if (drag == 1) {
UI.SetValue('Script items', name+"_x", Math.min(mouse[0] + memory[0],screen[0]-w))
UI.SetValue('Script items', name+"_y", Math.min(mouse[1] + memory[1],screen[1]-h))
}
}
function set_dropdown_value(value, index, enable) {
var mask = 1 << index;
return enable ? (value | mask) : (value & ~mask);
}
function DistTo(a, vOther){
var delta = [0,0,0]
delta[0] = a[0] - vOther[0];
delta[1] = a[1] - vOther[1];
delta[2] = a[2] - vOther[2];
return Math.sqrt(delta[0]*delta[0]+delta[1]*delta[1]+delta[2]*delta[2])/100
}
function MAGIC() {
var lc = Entity.GetLocalPlayer()
var players = Entity.GetEnemies();
var lcpos = Entity.GetRenderOrigin(lc)
var esp_custom = UI.GetValue("Script Items","Esp")
for ( i = 0; i < players.length; i++ ){
if ( Entity.IsAlive( players[i] ) ){
var name_enemy = Entity.GetName(players[i])
var renderenemy = Entity.GetRenderOrigin(players[i])
var dist = DistTo(lcpos,renderenemy)
var font = Render.AddFont("Verdana", 8, 100)
var hss = Math.round(Render.TextSizeCustom(name_enemy.toString(), font)[0])
var hpenemy = Entity.GetProp(players[i], "CBasePlayer","m_iHealth")
var armorenemy = Entity.GetProp(players[i], "CCSPlayerResource","m_iArmor")
var red_hp_color = 130-hpenemy*1.3
var green_hp_color = hpenemy*2.55
if (Entity.IsDormant(players[i]) == false) {
var name_color = UI.GetColor("Script Items","Name color")
var armor_color = UI.GetColor("Script Items","Armor color")
if (UI.GetValue("Script items","Custom color Hp") == 1){
var hp_color = UI.GetColor("Script items","Hp color")
}else {
var hp_color = [red_hp_color,green_hp_color,0,255]
}
} else {
var hp_color = [100,100,100,255]
var armor_color = [100,100,100,255]
var name_color = [100,100,100,255]
}
var hsa = Math.round(Render.TextSizeCustom(hpenemy.toString(), font)[0])
var startpos = Render.WorldToScreen([renderenemy[0],renderenemy[1],renderenemy[2]])
var end_posz = Render.WorldToScreen([renderenemy[0],renderenemy[1],renderenemy[2]+Math.min(75*(armorenemy/100),75)])
var end_pos = Render.WorldToScreen([renderenemy[0],renderenemy[1],renderenemy[2]+Math.min(75*(hpenemy/100),75)])
var ends_pos = Render.WorldToScreen([renderenemy[0],renderenemy[1],renderenemy[2]+75])
var endpos = Render.WorldToScreen([renderenemy[0],renderenemy[1],renderenemy[2]+85])
if (esp_custom == 1 ||esp_custom == 3 ||esp_custom == 7 ||esp_custom == 5) {
Render_outlined(endpos[0]-hss/2, endpos[1], 0, name_enemy.toString(), name_color, font)
}
//
if (esp_custom == 2 ||esp_custom == 3 ||esp_custom == 7 ||esp_custom == 6) {
Renderline_outlined(startpos[0]-150/dist, startpos[1], ends_pos[0]-150/dist, ends_pos[1], [75,75,75,100])
Render.Line(startpos[0]-150/dist, startpos[1], end_pos[0]-150/dist, end_pos[1], hp_color)
Render_outlined(endpos[0]-hsa-160/dist, endpos[1]+70/dist, 0, hpenemy.toString(), hp_color, font)
}
//
if (armorenemy > 0 && (esp_custom == 4 ||esp_custom == 5 || esp_custom ==6 ||esp_custom == 7 )) {
Renderline_outlined(startpos[0]+150/dist, startpos[1], ends_pos[0]+150/dist, ends_pos[1], [75,75,75,100])
Render.Line(startpos[0]+150/dist, startpos[1], end_posz[0]+150/dist, end_posz[1], armor_color)
Render_outlined(endpos[0]+160/dist, endpos[1]+70/dist, 0, armorenemy.toString(), armor_color, font)
}
Cheat.Print(esp_custom.toString()+"\n")
}
}
}
function AspectRatio() {
var arenable = UI.GetValue("Script items","Enable Aspect ratio");
var arvalue = UI.GetValue("Script items","Aspect ratio value");
if (arenable) {
Convar.SetString("r_aspectratio", arvalue.toString());
} else {
Convar.SetString("r_aspectratio", "0");
}
}
function Scope(){
var lc = Entity.GetLocalPlayer();
var in_scope = Entity.GetProp(lc, "DT_CSPlayer", "m_bIsScoped");
var scope_wep = UI.GetValue("Script items","Enable weapon in scope");
var scope_lines = UI.GetValue("Script items","Enable Scope lines");
var start_pos = UI.GetValue("Script items","Scope start");
var scope_color = UI.GetColor("Script items","Scope color");
var scope_lenght = UI.GetValue("Script items","Scope lenght");
var sw = start_pos*(screen[0]/400)
var sh = start_pos*(screen[1]/400)
var sx = scope_lenght*(screen[0]/200)
var sy = scope_lenght*(screen[1]/200)
if (scope_lines){
UI.SetValue("Visual", "WORLD", "Entities", "Removals", set_dropdown_value(removals_cache, 2, false));
if (in_scope) {
Convar.SetString("r_drawvgui", "0");
Render.GradientRect(screen[0]/2,screen[1]/2+sh, 1, sy, 0, scope_color, [255,255,255,0])
Render.GradientRect(screen[0]/2,screen[1]/2-sy+1-sh, 1, sy, 0, [255,255,255,0], scope_color)
Render.GradientRect(screen[0]/2+sw,screen[1]/2, sx, 1, 1, scope_color, [255,255,255,0])
Render.GradientRect(screen[0]/2-sx+1-sw,screen[1]/2, sx, 1, 1, [255,255,255,0], scope_color)
} else {
Convar.SetString("r_drawvgui", "1");
}
} else {
Convar.SetString("r_drawvgui", "1")
}
if (scope_wep == true) {
Convar.SetString("fov_cs_debug", "90")
} else {
Convar.SetString("fov_cs_debug", "0")
}
}
function overridedmg(){
var damage_override_enable = UI.IsHotkeyActive("Script items","Damage override");
var damage_override_value = UI.GetValue("Script items","Damage override value");
if (damage_override_enable){
if (dmgmem) {
UI.SetValue("Rage", "GENERAL", "Targeting", "Minimum damage", damage_override_value)
UI.SetValue("Rage", "PISTOL", "Targeting", "Minimum damage", damage_override_value)
UI.SetValue("Rage", "HEAVY PISTOL", "Targeting", "Minimum damage", damage_override_value)
UI.SetValue("Rage", "SCOUT", "Targeting", "Minimum damage", damage_override_value)
UI.SetValue("Rage", "AWP", "Targeting", "Minimum damage", damage_override_value)
UI.SetValue("Rage", "AUTOSNIPER", "Targeting", "Minimum damage", damage_override_value)
dmgmem = false
}
} else {
if (dmgmem == false) {
UI.SetValue("Rage", "GENERAL", "Targeting", "Minimum damage", damage_GENERAL_value)
UI.SetValue("Rage", "PISTOL", "Targeting", "Minimum damage", damage_PISTOL_value)
UI.SetValue("Rage", "HEAVY PISTOL", "Targeting", "Minimum damage", damage_HEAVY_PISTOL_value)
UI.SetValue("Rage", "SCOUT", "Targeting", "Minimum damage", damage_SCOUT_value)
UI.SetValue("Rage", "AWP", "Targeting", "Minimum damage", damage_AWP_value)
UI.SetValue("Rage", "AUTOSNIPER", "Targeting", "Minimum damage", damage_AUTOSNIPER_value)
dmgmem = true
}
damage_GENERAL_value = UI.GetValue("Rage", "GENERAL", "Targeting", "Minimum damage")
damage_PISTOL_value = UI.GetValue("Rage", "PISTOL", "Targeting", "Minimum damage")
damage_HEAVY_PISTOL_value = UI.GetValue("Rage", "HEAVY PISTOL", "Targeting", "Minimum damage")
damage_SCOUT_value = UI.GetValue("Rage", "SCOUT", "Targeting", "Minimum damage")
damage_AWP_value = UI.GetValue("Rage", "AWP", "Targeting", "Minimum damage")
damage_AUTOSNIPER_value = UI.GetValue("Rage", "AUTOSNIPER", "Targeting", "Minimum damage")
}
}
function anti_aims(){
var enable_aa = UI.GetValue("Script Items","Enable aa")
var slow_walk = UI.IsHotkeyActive("Anti-Aim","Extra","Slow walk")
var move = Entity.GetProp(Entity.GetLocalPlayer(), "CBasePlayer", "m_vecVelocity[0]");
var speed = Math.sqrt(move[0] * move[0] + move[1] * move[1]);
if (enable_aa){
AntiAim.SetOverride(1)
if (slow_walk) {
AntiAim.SetRealOffset(-19)
AntiAim.SetFakeOffset(5)
} else if (speed > 30) {
if (Math.floor(Math.random()*2) == 1){
AntiAim.SetRealOffset(-23)
AntiAim.SetFakeOffset(22)
} else {
AntiAim.SetRealOffset(23)
AntiAim.SetFakeOffset(-22)
}
} else {
AntiAim.SetRealOffset(0)
AntiAim.SetFakeOffset(0)
}
} else {
AntiAim.SetOverride(0)
}
}
//callbacks
function on_paint(){
UI.SetValue("Miscellaneous","Force sv_cheats", true)
tabs()
Scope()
AspectRatio()
MAGIC()
}
function on_cm(){
overridedmg()
anti_aims()
}
function on_unload(){
UI.SetValue("Rage", "GENERAL", "Targeting", "Minimum damage", damage_GENERAL_value)
UI.SetValue("Rage", "PISTOL", "Targeting", "Minimum damage", damage_PISTOL_value)
UI.SetValue("Rage", "HEAVY PISTOL", "Targeting", "Minimum damage", damage_HEAVY_PISTOL_value)
UI.SetValue("Rage", "SCOUT", "Targeting", "Minimum damage", damage_SCOUT_value)
UI.SetValue("Rage", "AWP", "Targeting", "Minimum damage", damage_AWP_value)
UI.SetValue("Rage", "AUTOSNIPER", "Targeting", "Minimum damage", damage_AUTOSNIPER_value)
Convar.SetString("fov_cs_debug", "0")
Convar.SetString("r_drawvgui", "1")
UI.SetValue("Visual", "WORLD", "Entities", "Removals", removals_cache);
Convar.SetString("r_aspectratio", "0");
}
Cheat.RegisterCallback("Unload", "on_unload")
Cheat.RegisterCallback("CreateMove", "on_cm")
Cheat.RegisterCallback("Draw", "on_paint")