-
Автор темы
- #1
code_language.lua:
local fonts = {
verdana = render.load_font("Verdana", 11, "a")
}
local screen = render.screen_size() /2
local group5 = ui.create("Logs.")
local MultiColorString = group5:switch("Logs", false)
local menu = {
timer = group5:slider("Time to show", 3, 15, 5),
centered = group5:switch("Centered", true),
neutral_text_color = group5:color_picker("Neutral color", color(255, 255, 255, 255)),
hit_color = group5:color_picker("Hit color", color(148, 199, 58, 255)),
correction_color = group5:color_picker("Correction color", color(255, 0, 0, 255)),
spread_color = group5:color_picker("Spread color", color(255, 199, 0, 255)),
prediction_error_color = group5:color_picker("Prediction error color", color(255, 199, 0, 255)),
lagcomp_failure_color = group5: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)
как сделать это в одну функцию по кнопке? Я Уже все пробовал не получается