Here’s a Player Hit Marker:
Would like to request an NPC one.
Here’s a Player Hit Marker:
Would like to request an NPC one.
I am on my phone here but if you post the script in that addon I will modify it to work for Npc’s.
[lua]
–===========================================================================–
local bHitActive = false
local bHitSound = false
local flFrameTime = 0
local x
local y
local Underwater = {}
Underwater.BulletImpact =
{
“physics/surfaces/underwater_impact_bullet1.wav”,
“physics/surfaces/underwater_impact_bullet2.wav”,
“physics/surfaces/underwater_impact_bullet3.wav”
}
hook.Add( “PlayerTraceAttack”, “PlayerHitMarker”, function( ply, dmginfo, dir, trace )
if ( dmginfo:GetAttacker() == LocalPlayer() ) then
bHitActive = true
bHitSound = true
flFrameTime = CurTime() + FrameTime() * 10
end
end )
hook.Add( “HUDPaint”, “CHitMarker”, function()
local player = LocalPlayer()
if ( !player:Alive() ) then return end
// Ask the gamemode if it’s ok to do this
if ( !gamemode.Call( “HUDShouldDraw”, “CHitMarker” ) ) then return end
if ( bHitSound ) then
bHitSound = false
surface.PlaySound( table.Random( Underwater.BulletImpact ) )
end
if ( bHitActive and flFrameTime > CurTime() ) then
x = ScrW() / 2
y = ScrH() / 2
surface.SetDrawColor( 255, 220, 0, 200 )
surface.DrawLine( x - 6, y - 5, x - 11, y - 10 )
surface.DrawLine( x + 5, y - 5, x + 10, y - 10 )
surface.DrawLine( x - 6, y + 5, x - 11, y + 10 )
surface.DrawLine( x + 5, y + 5, x + 10, y + 10 )
else
bHitActive = false
end
end )
[/lua]
An easy task for a lua scripter. Bump.
Use this:
[lua]
hitmarker_con = CreateClientConVar(“cl_hitmarker”,1,true,false)
function Hitmarker(ent,inf,att,am,dmginfo)
if att:IsPlayer() and (ent:IsNPC() or ent:IsPlayer() or ent:IsVehicle()) then
att:SetNWBool(“hitmarker”,false)
att:SetNWBool(“hitmarker”,true)
att:SetNWFloat(“hitmarker_time”,CurTime()+0.35)
end
end
function Hitmarker_draw()
if hitmarker_con:GetInt() != 1 then return end
ply = LocalPlayer()
hitmarker = ply:GetNWBool(“hitmarker”)
hitmarker_time = ply:GetNWFloat(“hitmarker_time”)
if hitmarker and CurTime() < hitmarker_time then
–gets the center of the screen
local x = ScrW() / 2
local y = ScrH() / 2
–set the drawcolor
surface.SetDrawColor( 225, 225, 225, 255 )
–draw the crosshair
surface.DrawLine( x+7, y-7, x+15, y-15 )
surface.DrawLine( x-7, y+7, x-15, y+15 )
surface.DrawLine( x+7, y+7, x+15, y+15 )
surface.DrawLine( x-7, y-7, x-15, y-15 )
end
end
hook.Add(“EntityTakeDamage”,“hitmarker”,Hitmarker)
hook.Add(“HUDPaint”,“Hitmarker_draw”,Hitmarker_draw)
[/lua]
It’s alot simpler and it works on NPCs, Vehicles, and Players
Thank you ROFLBURGER
I will credit you definitely for this code.