mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-08-20 06:47:09 +02:00
Implement a new event to receive notifications when a player immunity has changed.
This commit is contained in:
@@ -821,12 +821,22 @@ Int32 CPlayer::GetImmunity() const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CPlayer::SetImmunity(Int32 flags) const
|
||||
void CPlayer::SetImmunity(Int32 flags)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
// Grab the current value for this property
|
||||
const Int32 current = _Func->GetPlayerImmunityFlags(m_ID);
|
||||
// Avoid property unwind from a recursive call
|
||||
_Func->SetPlayerImmunityFlags(m_ID, flags);
|
||||
// Avoid infinite recursive event loops
|
||||
if (!(m_CircularLocks & PCL_EMIT_PLAYER_IMMUNITY))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, PCL_EMIT_PLAYER_IMMUNITY);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitPlayerImmunity(m_ID, current, flags);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@@ -21,6 +21,7 @@ enum PlayerCircularLocks
|
||||
PCL_EMIT_PLAYER_MONEY = (6 << 0),
|
||||
PCL_EMIT_PLAYER_SCORE = (7 << 0),
|
||||
PCL_EMIT_PLAYER_WANTED_LEVEL = (8 << 0),
|
||||
PCL_EMIT_PLAYER_IMMUNITY = (9 << 0),
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@@ -490,7 +491,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the immunity flags of the managed player entity.
|
||||
*/
|
||||
void SetImmunity(Int32 flags) const;
|
||||
void SetImmunity(Int32 flags);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the position of the managed player entity.
|
||||
|
Reference in New Issue
Block a user