Get cPlayer object in OnTakeDamage hook
#2
The second parameter of OnTakeDamage is a TakeDamageInfo struct. This struct contains an Attacker value. The value is of a cEntity object, but you can cast it to a cPlayer if you are sure it is a player.
If you're just wondering about the casting, use this:
local AttackerPlayer = tolua.cast(TDI.Attacker,"cPlayer")

Be sure you are actually dealing with a cPlayer object by checking it with TDI.Attacker:IsPlayer() or TDI.Attacker:IsA("cPlayer"). The former is faster than the latter but both work.
Reply
Thanks given by:


Messages In This Thread
RE: Get cPlayer object in OnTakeDamage hook - by FakeTruth - 09-22-2013, 09:16 AM



Users browsing this thread: 1 Guest(s)