local ffi = require("ffi")
local images = require "gamesense/images"
local crossfire_mode = ui.new_checkbox("VISUALS", "Effects", "Crossfire mode")
local headshot_image, first_image, second_image, third_image, fourth_image, fifth_image, sixth_image = images.load_png(readfile("hs.png")), images.load_png(readfile("first.png")), images.load_png(readfile("second.png")), images.load_png(readfile("third.png")),images.load_png(readfile("fourth.png")), images.load_png(readfile("fifth.png")), images.load_png(readfile("sixth.png"))
local killstreak = 0
local set_headshot = false
local w,h = client.screen_size()
local file_crc_status_e = {cant_open_file = 0,got_crc = 1,file_in_vpk = 2}
local vftable_e = {filesystem = {check_cached_file_hash = 56}}
local IFileSystem = ffi.cast("int*", client.create_interface("filesystem_stdio.dll", "VFileSystem017") or error("IFileSystem could not be accessed through filesystem_stdio.dll!CreateInterface(\"VFileSystem017\")"))
client.set_event_callback("paint_ui", function()
IFileSystem[vftable_e.filesystem.check_cached_file_hash] = file_crc_status_e.got_crc
end)
client.set_event_callback("setup_command", function()
IFileSystem[vftable_e.filesystem.check_cached_file_hash] = file_crc_status_e.got_crc
end)
-- Reset at every round start
client.set_event_callback("round_start", function(cmd)
killstreak = 0
set_headshot = false
end)
-- Show image painting callback
client.set_event_callback("paint", function(cmd)
if set_headshot then
headshot_image:draw(w/2-76,h/2+h/3-h/24,158,158,255,255,255,255,false,"f")
elseif killstreak == 1 then
first_image:draw(w/2-79,h/2+h/3-h/24,158,158,255,255,255,255,false,"f")
elseif killstreak == 2 then
second_image:draw(w/2-79,h/2+h/3-h/24,158,158,255,255,255,255,false,"f")
elseif killstreak == 3 then
third_image:draw(w/2-79,h/2+h/3-h/24,158,158,255,255,255,255,false,"f")
elseif killstreak == 4 then
fourth_image:draw(w/2-79,h/2+h/3-h/24,158,158,255,255,255,255,false,"f")
elseif killstreak == 5 then
fifth_image:draw(w/2-79,h/2+h/3-h/24,158,158,255,255,255,255,false,"f")
elseif killstreak > 5 then
sixth_image:draw(w/2-79,h/2+h/3-h/24,158,158,255,255,255,255,false,"f")
end
end)
-- Play sound function
local function play_sound(was_headshot)
if was_headshot then
set_headshot = true
cvar.play:invoke_callback("crossfire\\hes.wav")
return
else
set_headshot = false
end
if killstreak == 1 then
cvar.play:invoke_callback("crossfire\\hit.wav")
elseif killstreak == 2 then
cvar.play:invoke_callback("crossfire\\dbl.wav")
elseif killstreak == 3 then
cvar.play:invoke_callback("crossfire\\mul.wav")
elseif killstreak == 4 then
cvar.play:invoke_callback("crossfire\\ult.wav")
elseif killstreak == 5 then
cvar.play:invoke_callback("crossfire\\stp.wav")
elseif killstreak > 5 then
cvar.play:invoke_callback("crossfire\\unb.wav")
end
end
-- Check things at player death event
client.set_event_callback("player_death", function(data)
if not ui.get(crossfire_mode) or not entity.get_local_player() == client.userid_to_entindex(data.attacker) then
return
elseif client.userid_to_entindex(data.userid) == entity.get_local_player() then
killstreak = 0
set_headshot = false
elseif entity.get_local_player() == client.userid_to_entindex(data.attacker) then
killstreak = killstreak + 1
play_sound(data.headshot)
end
end)