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 notify on player admin status change.

This commit is contained in:
Sandu Liviu Catalin
2016-08-17 15:40:48 +03:00
parent b4abe9dfc7
commit c5ef8018ae
6 changed files with 36 additions and 4 deletions

View File

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

View File

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