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...") |
|||
| Line 1: | Line 1: | ||
| + | |||
| + | {{Infobox manual/Header}} | ||
| + | ==buildable_ondamage(buildable, damageinfo)== | ||
| + | This function is called whenever a buildable takes damage. | ||
| + | |||
===Example=== | ===Example=== | ||
A player shooting nails at a buildable will do no damage. | A player shooting nails at a buildable will do no damage. | ||
Latest revision as of 21:33, 10 November 2014
|
buildable_ondamage(buildable, damageinfo)This function is called whenever a buildable takes damage. ExampleA 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
|