How i can use this code in BLT because is not working:
Code credit: B1313
code:
Code:
local ColorList = {
civpickup = 'FFFF00', -- YELLOW
enepickup = '660066', -- PURPLE
}
function getUnitColor(unit)
local unitType = unit:base()._tweak_table
if unit:base().has_civpickup then unitType = 'civpickup'
elseif unit:base().has_enepickup then unitType = 'enepickup'
else return nil end
-- if not unitType then return nil end
return Color(ColorList[unitType] and ColorList[unitType] or ColorList['default'])
end
if inGame() and isPlaying() and not inChat() then
--Contour Overrides
if ContourExt then
if not _nhUpdateColor then _nhUpdateColor = ContourExt._upd_color end
function ContourExt:_upd_color()
if toggleMark then
local color = getUnitColor(self._unit)
if color then
self._materials = self._materials or self._unit:get_objects_by_type(Idstring("material"))
for _, material in ipairs(self._materials) do
material:set_variable(Idstring( "contour_color" ), color)
end
return
end
end
_nhUpdateColor(self)
end
function ContourExt:setData(data)
if not data or not type(data) == 'table' then return end
for k, v in pairs(data) do self._unit:base()[k] = v end
end
function ContourExt:remove_all()
while self._contour_list ~= nil do
self:_remove(1)
end
end
--Remove contours on death for host
if not _dieBase then _dieBase = CopDamage.die end
function CopDamage:die( variant )
if self._unit:contour() then
self._unit:contour():remove_all()
end
_dieBase(self, variant)
end
--Remove contours on death for client
if not _huskDieBase then _huskDieBase = HuskCopDamage.die end
function HuskCopDamage:die( variant )
if self._unit:contour() then
self._unit:contour():remove_all()
end
_huskDieBase(self, variant)
end
--Remove contours for camera destruction, only works for host?
if not _camDieBase then _camDieBase = ElementSecurityCamera.on_destroyed end
function ElementSecurityCamera:on_destroyed()
local camera_unit = self:_fetch_unit_by_unit_id( self._values.camera_u_id )
if camera_unit:contour() then
camera_unit:contour():remove_all()
end
_camDieBase(self)
end
end
function markEnemies()
if not toggleMark then return end
for u_key,u_data in pairs(managers.enemy:all_civilians()) do
if u_data.uni*****ntour and alive(u_data.unit) then
if isHost() and u_data.unit:character_damage():pickup() then
u_data.unit:contour():setData({has_civpickup = true})
u_data.unit:contour():add( "mark_enemy", syncMark, 0 )
end
end
end
for u_key,u_data in pairs(managers.enemy:all_enemies()) do
if u_data.uni*****ntour and alive(u_data.unit) then
if isHost() and u_data.unit:character_damage():pickup() and u_data.unit:character_damage():pickup() ~= "ammo" then
u_data.unit:contour():setData({has_enepickup = true})
end
u_data.unit:contour():add( "mark_enemy", syncMark, 0 )
end
end
if isHost() then
for u_key, u_data in pairs( managers.groupai:state()._security_cameras ) do
if u_dat*****ntour then u_data:contour():add( "mark_unit", syncMark, 0 ) end
end
else
for _, unit in ipairs( SecurityCamera.cameras ) do
if unit and unit:contour() and unit:enabled() and unit:base() and not unit:base():destroyed() then
unit:contour():add("mark_unit", syncMark, 0 )
end
end
end
end
function UnitNetworkHandler:mark_enemy( unit, marking_strength, sender )
end
if GameSetup then
if not _gameUpdate then _gameUpdate = GameSetup.update end
local _gameUpdateLastMark
function GameSetup:update(t, dt)
_gameUpdate(self, t, dt)
if not _gameUpdateLastMark or t - _gameUpdateLastMark > 4 then
_gameUpdateLastMark = t
markData()
end
end
end
function markData()
markEnemies()
end
function markClear()
if not inGame() then return end
if isHost() then
for u_key, u_data in pairs(managers.groupai:state()._security_cameras) do
if u_dat*****ntour then u_data:contour():remove( "mark_unit", syncMark ) end
end
else
for _, unit in ipairs( SecurityCamera.cameras ) do
unit:contour():remove( "mark_unit", syncMark )
end
end
for u_key,u_data in pairs(managers.enemy:all_civilians()) do
if u_data.uni*****ntour then u_data.unit:contour():remove( "mark_enemy", syncMark ) end
end
for u_key,u_data in pairs(managers.enemy:all_enemies()) do
if u_data.uni*****ntour then u_data.unit:contour():remove( "mark_enemy", syncMark ) end
end
end
function markToggle(toggleSync)
if not inGame() then return end
if toggleSync then
syncMark = not syncMark
else
toggleMark = not toggleMark
if not toggleMark then markClear() end
end
markData()
end
if not toggleMark then toggleMark = false end
if not syncMark then syncMark = false end
markToggle()
end
mod.txt:
Code:
{
"name" : "XRay",
"description" : "",
"author" : "",
"contact" : "",
"hooks" : [
{ "hook_id" : "",
"script_path" : "XRay.lua"
}
],
"keybinds" :
[
{
"keybind_id" : "VK_F1"
"name" : "XRay"
"description" : "X-Ray"
"script_path" : "XRay.lua"
"run_in_menu" : false,
"run_in_game" : true,
}
]
}