Difference between revisions of "Lua:buildable ondamage"

From Fortress Forever Wiki
Jump to navigationJump to search
(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...")
(No difference)

Revision as of 21:30, 10 November 2014

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