Solved OnPlayerAttack(attacker, hitinfo) doesnt work anymore?
Discussion in 'Rust Development' started by TheRotAG, Feb 9, 2015.
-
Wulf Community Admin
http://oxidemod.org/downloads/oxide-for-rust-experimental.714/update?update=3703
The method that the hook used was split/removed from Rust. It was decided that OnEntityAttacked should be sufficient. We'll see though. -
Code:
function PLUGIN:OnEntityAttacked( ent, hitinfo ) if(hitinfo == nil) then return end if(hitinfo.Initiator == nil) then return end if(hitinfo.Initiator.GetComponent(global.BasePlayer._type)) then var attacker = hitinfo.Initiator.GetComponent(global.BasePlayer._type) rust.SendChatMessage(attacker, "Test) end end
-
Yay, I was already using OnEntityAttacked for a separate type of funcs, but gonna use it for everything now, tnx guys
-
Wulf Community Admin
The latest builds have OnPlayerAttacked added back, just letting you know.
-
Hmmm that could be useful.
OnPlayerAttacked would be better than Entity cuz that way I can manage my friendly fire mode separately from the Shield and Armor skills that I've created. -
-
That depends Colonel. I've skills on my RPG plugin (WIP) where players increase their damage, so if I could calc with "OnPlayerAttack" that would be better. But since Attacked is almost the same for Player and Entity, dont mind in keep only entity
-
c#:
void OnEntityAttacked(MonoBehaviour entity, HitInfo info)
{
if (entity != null && info != null && info.HitEntity && (string)info.HitEntity.ToString() == "player/player (BasePlayer)")//i assume you need it for players
{
// do what ever
}
}