Lua:buildable ondamage

From Fortress Forever Wiki
Revision as of 21:30, 10 November 2014 by R00Ki3 (talk | contribs) (Created page with "===Example=== A player shooting nails at a buildable will do no damage. <pre> function buildable_ondamage(buildable, damageinfo) local weapon = damageinfo:GetInflictor():Get...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Example

A player shooting nails at a buildable will do no damage.

function buildable_ondamage(buildable, damageinfo)

	local weapon = damageinfo:GetInflictor():GetClassName()
        local attacking_player = damageinfo:GetAttacker()
	local attacker = CastToPlayer( attacking_player )
	
	-- Take no damage from Nail shooting weapons
	if weapon == "ff_projectile_nail" then
		damageinfo:SetDamage(0)
		ChatToPlayer(attacker, "Nope!")
	end
	ConsoleToAll(attacker:GetName().." attacked with "..weapon)
end