Is there some sort of function that I can use to detect when a player is hit by a bullet. (While in godmode)
For example:
[lua]
function hitbybullet()
ply:Print(“owch”)
end
[/lua]
Well, I assume by the title of the thread, you want to detect it in a weapon alone, and not universally.
Check for it in the bullet callback.
[lua]bullet = {}
bullet.Src = entity:GetPos()
bullet.Attacker = entity
bullet.Dir = entity:GetAngles():Forward()
bullet.Spread = Vector(0.01,0.01,0)
bullet.Num = 1
bullet.Damage = 1
bullet.Force = 2
bullet.Tracer = 1
bullet.TracerName = “Tracer”
bullet.Callback = function ( attacker, tr, dmginfo )
if tr.Entity && tr.Entity:IsPlayer()
print(“owch”)
end
end
[/lua]
[editline]11:08AM[/editline]
Ninja’d. :ninja:
“Is there some sort of function that I can use to detect when a player is hit by a bullet. (While in godmode)”
this implies you are in god mode and you want to detect when someone else shoots you with a bullet (from any weapon i assume), correct?
“SWEP act on player?”
why do you post
Now, now, don’t turn this thread into a flame war.
Exactly this.
You’d have to add Player:IsInGodMode(). Then detect from there.
[lua]local meta = FindMetaTable( “Player” )
local GodEnable = meta.GodEnable
local GodDisable = meta.GodDisable
function meta:GodEnable()
self.m_bInGodMode = true
GodEnable( self )
end
function meta:GodDisable()
self.m_bInGodMode = false
GodDisable( self )
end
if ( !meta.IsInGodMode ) then
function meta:IsInGodMode()
return self.m_bInGodMode
end
end
[/lua]