mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-08-20 06:47:09 +02:00
Implement a new event to notify on player admin status change.
This commit is contained in:
@@ -194,12 +194,27 @@ bool CPlayer::GetAdmin() const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CPlayer::SetAdmin(bool toggle) const
|
||||
void CPlayer::SetAdmin(bool toggle)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
// Grab the current value for this property
|
||||
const bool current = _Func->IsPlayerAdmin(m_ID);
|
||||
// Don't even bother if it's the same value
|
||||
if (current == toggle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Avoid property unwind from a recursive call
|
||||
_Func->SetPlayerAdmin(m_ID, toggle);
|
||||
// Avoid infinite recursive event loops
|
||||
if (!(m_CircularLocks & PCL_EMIT_PLAYER_ADMIN))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, PCL_EMIT_PLAYER_ADMIN);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitPlayerAdmin(m_ID, current, toggle);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@@ -13,7 +13,8 @@ namespace SqMod {
|
||||
*/
|
||||
enum PlayerCircularLocks
|
||||
{
|
||||
PCL_EMIT_PLAYER_OPTION = (1 << 0)
|
||||
PCL_EMIT_PLAYER_OPTION = (1 << 0)
|
||||
PCL_EMIT_PLAYER_ADMIN = (2 << 0),
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@@ -248,7 +249,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Set whether the managed player entity has administrator privileges.
|
||||
*/
|
||||
void SetAdmin(bool toggle) const;
|
||||
void SetAdmin(bool toggle);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the ip address of the managed player entity.
|
||||
|
Reference in New Issue
Block a user