03-04-2010, 09:46 AM | #1 |
Banned
Join Date: Sep 2008
Class/Position: Soldier Gametype: AVD Affiliations: TALOS Posts Rated Helpful 5 Times
|
Question about player_ondamage()
Does player_ondamage() still get called if someone hits a team mate and friendly fire is on? I need to make an effect similar to the Engineer's wrench repairing team mate's armor. Is there any other way to do this? If not, then I suggest player_onrepair( player, inflictor ) for Engineer's wrench. Maybe a more general function player_meleefriendly( player, inflictor ) or something like that.
|
|
03-10-2010, 05:58 PM | #2 |
internet user
Fortress Forever Staff
Join Date: Jun 2007
Posts Rated Helpful 42 Times
|
You could try this. No promises, I type this over vnc so I can't really test
Code:
function player_ondamage( player, damageinfo ) local attacker = damageinfo:GetAttacker() -- If no attacker do nothing if not attacker then damageinfo:SetDamage(0) return end -- If attacker not a player do nothing if not IsPlayer(attacker) then damageinfo:SetDamage(0) return end local playerAttacker = CastToPlayer(attacker) -- if you need to know which weapon .. local weapon = damageinfo:GetInflictor():GetClassName() local team = playerAttacker:GetTeam() -- if same team if player:GetTeamId() == playerAttacker:GetTeamId() then -- do whatever, this will give to the victim damageinfo:SetDamage(0) player:AddHealth( 1 ) player:AddArmor( 23 ) end end
__________________
9:17 PM - DEXTER: can you teach me how to play o 9:17 PM - squeek.: you jump a lot 9:18 PM - squeek.: and do sweet moves 8:55 PM - FDA: fart in you fridge and blame it on wild animals |
|
03-10-2010, 06:17 PM | #3 |
internet user
Fortress Forever Staff
Join Date: Jun 2007
Posts Rated Helpful 42 Times
|
I lied I got it cooking on laptop, while its hard to test friendly fire alone, player_ondamage() appears to always be called so you should be good
__________________
9:17 PM - DEXTER: can you teach me how to play o 9:17 PM - squeek.: you jump a lot 9:18 PM - squeek.: and do sweet moves 8:55 PM - FDA: fart in you fridge and blame it on wild animals |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|