LUA скрипт [NL | Source] Sigma`s hitlogs

Nike.lua
Олдфаг
Статус
Оффлайн
Регистрация
13 Окт 2020
Сообщения
2,746
Реакции[?]
1,465
Поинты[?]
2K
Ну кароч хитлоги, похожие на хитлоги асидтеча
1658169760424.png

code_language.lua:
local Render_InitFont, Menu_Switch, Menu_SliderInt, Menu_ColorEdit, Color_new, Render_CalcTextSize, Render_Text, Vector2_new, EntityList_GetPlayer, Cheat_RegisterCallback, EngineClient_GetScreenSize = Render.InitFont, Menu.Switch, Menu.SliderInt, Menu.ColorEdit, Color.new, Render.CalcTextSize, Render.Text, Vector2.new, EntityList.GetPlayer, Cheat.RegisterCallback, EngineClient.GetScreenSize

local fonts = {
    verdana = Render_InitFont("Verdana", 11, {"r"})
}

local screen = EngineClient_GetScreenSize() /2

local menu = {
    timer = Menu_SliderInt("Sigma`s hitlogs", "Time to show", 5, 3, 15),
    centered = Menu_Switch("Sigma`s hitlogs", "Centered", true),
    neutral_text_color = Menu_ColorEdit("Sigma`s hitlogs", "Neutral color", Color_new(1.0, 1.0, 1.0, 1.0)),
    hit_color = Menu_ColorEdit("Sigma`s hitlogs", "Hit color", Color_new(0.58, 0.78, 0.23, 1.0)),
    resolver_color = Menu_ColorEdit("Sigma`s hitlogs", "Resolver color", Color_new(1.0, 0.0, 0.0, 1.0)),
    spread_color = Menu_ColorEdit("Sigma`s hitlogs", "Spread color", Color_new(1.0,    0.78, 0.0, 1.0)),
    occlusion_color = Menu_ColorEdit("Sigma`s hitlogs", "Occlusion color", Color_new(1.0, 0.78, 0.0, 1.0)),
    prediction_color = Menu_ColorEdit("Sigma`s hitlogs", "Prediction color", Color_new(1.0,    0.50, 0.50, 1.0))
}

local CRender = {}

CRender.MultiColorString = function(table, x, y, size, font, centered, shadow)
    outline = outline or false
    centered = centered or false
    shadow = shadow or false
  
    if #table == 0 then return end

    local text = ""
    for i = 1, #table do
        text = text..tostring(table[i][1])
    end
  
    local text_size = centered and -Render_CalcTextSize(text, size, font).x /2 or 0

    for i = 1, #table do
        if type(table[i][1]) ~= "string" then table[i][1] = tostring(table[i][1]) end

        if shadow then
            Render_Text(table[i][1], Vector2_new(x + text_size + 1, y + 1), Color_new(0,0,0,table[i][2].a), size, font)
        end

        Render_Text(table[i][1], Vector2_new(x + text_size, y), table[i][2], size, font)

        text_size = text_size + Render_CalcTextSize(table[i][1], size, font).x
    end
end

local Hitlogs = { Data = {} }

Hitlogs.Hitboxes = { [0] = "generic", [1] = "head", [2] = "chest", [3] = "stomach", [4] = "left arm", [5] = "right arm", [6] = "left leg", [7] = "right leg", [10] = "gear" }
Hitlogs.Reasons = { [1] = "unknown", [2] = "spread", [3] = "occlusion",  [4] = "prediction error" }
Hitlogs.MissColors = { [1] = menu.resolver_color, [2] = menu.spread_color, [3] = menu.occlusion_color, [4] = menu.prediction_color }

Hitlogs.OnHit = function(shot)
    if shot.reason ~= 0 then return end

    local target = EntityList_GetPlayer(shot.target_index)
    local health = target:GetProp("m_iHealth")
    local remaining = health - shot.damage < 0 and 0 or health - shot.damage

    local neutral_color = menu.neutral_text_color:GetColor()
    local hit_color = menu.hit_color:GetColor()

    table.insert(Hitlogs.Data, 1, {
        {
            { "Hit ", neutral_color },
            { target:GetName().." ", hit_color },
            { "in the ", neutral_color },
            { Hitlogs.Hitboxes[shot.hitgroup].." ", hit_color },
            { "for ", neutral_color },
            { shot.damage.." ", hit_color },
            { "damage ", neutral_color },
            { "(", neutral_color },
            { remaining.." ", hit_color },
            { "health remaining)", neutral_color }
        },
        event_time = GlobalVars.curtime,
    })
end

Hitlogs.OnMiss = function(shot)
    if shot.reason == 0 then return end

    local target = EntityList_GetPlayer(shot.target_index)

    local neutral_color = menu.neutral_text_color:GetColor()
    local miss = Hitlogs.MissColors[shot.reason]:GetColor()

    table.insert(Hitlogs.Data, 1, {
        {
            { "Missed ", neutral_color },
            { target:GetName(), miss },
            { "`s ", neutral_color },
            { Hitlogs.Hitboxes[shot.wanted_hitgroup].." ", miss },
            { "due to ", neutral_color },
            { Hitlogs.Reasons[shot.reason].." ", miss },
            { "(", neutral_color },
            { shot.hitchance, miss },
            { "% hitchance)", neutral_color }
        },
        event_time = GlobalVars.curtime,
    })
end

Cheat_RegisterCallback("registered_shot", function(shot)
    Hitlogs.OnHit(shot)
    Hitlogs.OnMiss(shot)
end)

Hitlogs.OnRoundStart = function(event)
    if event:GetName() == "round_start" then
        Hitlogs.Data = {}
    end
end

Cheat_RegisterCallback("events", function(event)
    Hitlogs.OnRoundStart(event)
end)

Hitlogs.Draw = function()
    local localplayer = EntityList.GetLocalPlayer()
    if localplayer == nil then
        Hitlogs.Data = {}
        return
    end

    local time = menu.timer:Get()
    local offset = 0
    for i, this in pairs(Hitlogs.Data) do
        CRender.MultiColorString(this[1], screen.x, screen.y + 160 + (13 * offset), 11, fonts.verdana, menu.centered:Get(), true)

        if GlobalVars.curtime - this.event_time > time then
            table.remove(Hitlogs.Data, i)
        end

        offset = offset + 1
    end
end

Cheat_RegisterCallback("draw", function()
    Hitlogs.Draw()
end)
 
Последнее редактирование:
Забаненный
Статус
Оффлайн
Регистрация
4 Май 2021
Сообщения
228
Реакции[?]
39
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Я искренне благодарен тебе за функцию мультицвета которая мне уже 3 раз мозги делает
 
Забаненный
Статус
Оффлайн
Регистрация
30 Мар 2019
Сообщения
32
Реакции[?]
2
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Credits. Shelzy
 
Эксперт
Статус
Оффлайн
Регистрация
10 Фев 2021
Сообщения
1,739
Реакции[?]
559
Поинты[?]
2K
Забаненный
Статус
Оффлайн
Регистрация
6 Ноя 2020
Сообщения
5
Реакции[?]
1
Поинты[?]
1K
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Nike.lua
Олдфаг
Статус
Оффлайн
Регистрация
13 Окт 2020
Сообщения
2,746
Реакции[?]
1,465
Поинты[?]
2K
Бутылка мельника и жижка 50 мг соли сделали свое дело:
1669883917812.png
Никаких фиксов под \a форматирование, только перенос под новое апи

code_language.lua:
local fonts = {
  verdana = render.load_font("Verdana", 11, "a")
}
local screen = render.screen_size() /2
local menu_tab = ui.create("Huypaches inc.")
local menu = {
  timer = menu_tab:slider("Time to show", 3, 15, 5),
  centered = menu_tab:switch("Centered", true),
  neutral_text_color = menu_tab:color_picker("Neutral color", color(255, 255, 255, 255)),
  hit_color = menu_tab:color_picker("Hit color", color(148, 199, 58, 255)),
  correction_color = menu_tab:color_picker("Correction color", color(255, 0, 0, 255)),
  spread_color = menu_tab:color_picker("Spread color", color(255, 199, 0, 255)),
  prediction_error_color = menu_tab:color_picker("Prediction error color", color(255, 199, 0, 255)),
  lagcomp_failure_color = menu_tab:color_picker("Lagcomp failure color", color(255, 113, 133, 255)),
}
local CRender = {}
CRender.MultiColorString = function(table, x, y, font, centered, shadow)
  centered = centered or false
  shadow = shadow or false
  if #table == 0 then return end
  local text = ""
  for i = 1, #table do
      text = text..tostring(table[i][1])
  end
  local text_size = centered and -render.measure_text(font, nil, text).x /2 or 0
  for i = 1, #table do
      if type(table[i][1]) ~= "string" then table[i][1] = tostring(table[i][1]) end
      if shadow then
          render.text(font, vector(x + text_size + 1, y + 1), color(0,0,0, table[i][2].a), "s", table[i][1])
      end
      render.text(font, vector(x + text_size, y), table[i][2], nil, table[i][1])
      text_size = text_size + render.measure_text(font, nil, table[i][1]).x
  end
end
local Hitlogs = { Data = {} }
Hitlogs.Hitboxes = { [0] = 'generic',
'head', 'chest', 'stomach',
'left arm', 'right arm',
'left leg', 'right leg',
'neck', 'generic', 'gear' 
}
Hitlogs.MissColors = { ["correction"] = menu.correction_color, ["spread"] = menu.spread_color, ["prediction error"] = menu.prediction_color, ["lagcomp failure"] = menu.lagcomp_failure_color }
Hitlogs.OnHit = function(shot)
  if shot.state ~= nil then return end
  local target = shot.target
  local health = target.m_iHealth
  local remaining = health - shot.damage < 0 and 0 or health - shot.damage
  local neutral_color = menu.neutral_text_color:get()
  local hit_color = menu.hit_color:get()
  table.insert(Hitlogs.Data, 1, {
      {
          { "Hit ", neutral_color },
          { target:get_name().." ", hit_color },
          { "in the ", neutral_color },
          { Hitlogs.Hitboxes[shot.hitgroup].." ", hit_color },
          { "for ", neutral_color },
          { shot.damage.." ", hit_color },
          { "damage ", neutral_color },
          { "(", neutral_color },
          { remaining.." ", hit_color },
          { "health remaining)", neutral_color }
      },
      event_time = globals.curtime,
  })
end
Hitlogs.OnMiss = function(shot)
  if shot.state == nil then return end
  local target = shot.target
  local neutral_color = menu.neutral_text_color:get()
  local miss = Hitlogs.MissColors[shot.state]:get()
  table.insert(Hitlogs.Data, 1, {
      {
          { "Missed ", neutral_color },
          { target:get_name(), miss },
          { "`s ", neutral_color },
          { Hitlogs.Hitboxes[shot.wanted_hitgroup].." ", miss },
          { "due to ", neutral_color },
          { shot.state.." ", miss },
          { "(", neutral_color },
          { shot.hitchance, miss },
          { "% hitchance)", neutral_color }
      },
      event_time = globals.curtime,
  })
end
events.aim_ack:set(function(shot)
  Hitlogs.OnHit(shot)
  Hitlogs.OnMiss(shot)
end)
events.round_start:set(function(event)
    Hitlogs.Data = {}
end)
Hitlogs.Draw = function()
  local localplayer = entity.get_local_player()
  if localplayer == nil then
      Hitlogs.Data = {}
      return
  end
  local time = menu.timer:get()
  local offset = 0
  for i, this in pairs(Hitlogs.Data) do
      CRender.MultiColorString(this[1], screen.x, screen.y + 160 + (13 * offset), fonts.verdana, menu.centered:get(), true)
      if globals.curtime - this.event_time > time then
          table.remove(Hitlogs.Data, i)
      end
      offset = offset + 1
  end
end
events.render:set(function()
  Hitlogs.Draw()
end)
 
Сверху Снизу