mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-10-15 07:27:19 +02:00
Implement a new event to receive notifications when a player skin has changed.
This commit is contained in:
@@ -546,15 +546,30 @@ Int32 CPlayer::GetSkin() const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CPlayer::SetSkin(Int32 skin) const
|
||||
void CPlayer::SetSkin(Int32 skin)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
if (_Func->SetPlayerSkin(m_ID, skin) == vcmpErrorArgumentOutOfBounds)
|
||||
// Grab the current value for this property
|
||||
const Int32 current = _Func->GetPlayerSkin(m_ID);
|
||||
// Don't even bother if it's the same value
|
||||
if (current == skin)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Avoid property unwind from a recursive call
|
||||
else if (_Func->SetPlayerSkin(m_ID, skin) == vcmpErrorArgumentOutOfBounds)
|
||||
{
|
||||
STHROWF("Invalid skin identifier: %d", skin);
|
||||
}
|
||||
// Avoid infinite recursive event loops
|
||||
else if (!(m_CircularLocks & PCL_EMIT_PLAYER_SKIN))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, PCL_EMIT_PLAYER_SKIN);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitPlayerSkin(m_ID, current, skin);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@@ -17,6 +17,7 @@ enum PlayerCircularLocks
|
||||
PCL_EMIT_PLAYER_ADMIN = (2 << 0),
|
||||
PCL_EMIT_PLAYER_WORLD = (3 << 0),
|
||||
PCL_EMIT_PLAYER_TEAM = (4 << 0),
|
||||
PCL_EMIT_PLAYER_SKIN = (5 << 0),
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@@ -376,7 +377,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the skin identifier of the managed player entity.
|
||||
*/
|
||||
void SetSkin(Int32 skin) const;
|
||||
void SetSkin(Int32 skin);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the color of the managed player entity.
|
||||
|
Reference in New Issue
Block a user