Examples
Kill counter
Your kills this round, this map and of all time in a HUD chip. The chip flashes white for a moment on every kill.
Needs: Allow game scripting for the kill events. Without it the chip stays at zero.
Lua
-- @name Kill counter
-- @author evasive
-- @version 1.0
-- @description Round / map / all-time kills in a HUD chip, with a short flash on each kill.
local enabled = ui.checkbox("Enabled", true)
local show_all = ui.checkbox("Show all-time total", true)
local accent = ui.color("Accent", ui.accent())
ui.button("Reset all-time total", function()
storage.set("total", 0)
log.info("all-time total reset")
end)
local round, map_kills = 0, 0
local flash_until = 0
events.on("local_kill", function(e)
round = round + 1
map_kills = map_kills + 1
storage.set("total", storage.get("total", 0) + 1)
flash_until = time.now() + 0.6
log.info("kill: " .. (e.player.name or "?"))
end)
events.on("round_start", function() round = 0 end)
events.on("map_change", function() round, map_kills = 0, 0 end)
events.on("paint", function()
if not enabled:get() then return end
local sw, sh = draw.screen_size()
local value = string.format("%d / %d", round, map_kills)
if show_all:get() then value = value .. string.format(" / %d", storage.get("total", 0)) end
local flash = math.clamp((flash_until - time.now()) / 0.6, 0, 1)
local col = color.lerp(accent:get(), color(255, 255, 255), flash)
draw.chip({x = 20, y = math.floor(sh * 0.62), label = "KILLS", value = value, accent = col, value_color = col,
meter = flash > 0 and flash or nil})
end)How it works
local_killfires for every death the game credits to you. The round and map counts live in local variables, the all time count instorage, so it survives restarts.round_startandmap_changereset the counters.round_startis a guess made from several players coming back alive at once, which is close enough for a counter.- The flash is a number that falls from 1 to 0 over 0.6 seconds.
color.lerpblends the accent colour toward white by that much, and the chip's meter shows it running out. - The reset button runs on the next frame and writes 0 to the store.
Try this
- Count headshots too, with the
local_hitevent and itsheadshotandkilledfields. - Play with the chip's look:
draw.chipalso takeslabel_colorand aniconimage.