Lua:player ondamage
From Fortress Forever Wiki
Jump to navigationJump to search
player_ondamage(player_id, damageinfo)This function is called whenever a player takes damage. Inputs
VariablesThe following variables are set in the global lua namespace before this function is called:
This function may modify the info_damage global variable in the global scope. If it does, the damage the player takes will be changed. This means that the script for a map can make players recieve more or less damage through scripting. ExampleHere is an example script that makes the player take no damage from the super shotgun. function player_ondamage(player_id, damageinfo) ConsoleToAll(GetPlayerName(info_attacker).." shot "..GetPlayerName(player_id).." with a "..info_classname.." for "..info_damage.." damage") if info_classname == "ff_weapon_supershotgun" then ConsoleToAll("Take no damage from supershotty") info_damage = 0 end end Here's another example in case you wanted to not take damage from your own rockets: function player_ondamage( player_id ) -- Don't take rocket damage from ourselves if ( player_id == info_attacker ) then if ( info_classname == "rocket" ) then info_damage = 0 end end end |