1
0
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:
Sandu Liviu Catalin
2016-08-17 16:07:31 +03:00
parent 8f78b0a852
commit c6c17e9396
6 changed files with 30 additions and 3 deletions

View File

@@ -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);
}
}
// ------------------------------------------------------------------------------------------------

View File

@@ -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.