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 wanted level has changed.
This commit is contained in:
@@ -734,12 +734,27 @@ Int32 CPlayer::GetWantedLevel() const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CPlayer::SetWantedLevel(Int32 level) const
|
||||
void CPlayer::SetWantedLevel(Int32 level)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
// Grab the current value for this property
|
||||
const Int32 current = _Func->GetPlayerWantedLevel(m_ID);
|
||||
// Don't even bother if it's the same value
|
||||
if (current == level)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Avoid property unwind from a recursive call
|
||||
_Func->SetPlayerWantedLevel(m_ID, level);
|
||||
// Avoid infinite recursive event loops
|
||||
if (!(m_CircularLocks & PCL_EMIT_PLAYER_WANTED_LEVEL))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, PCL_EMIT_PLAYER_WANTED_LEVEL);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitPlayerWantedLevel(m_ID, current, level);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@@ -20,6 +20,7 @@ enum PlayerCircularLocks
|
||||
PCL_EMIT_PLAYER_SKIN = (5 << 0),
|
||||
PCL_EMIT_PLAYER_MONEY = (6 << 0),
|
||||
PCL_EMIT_PLAYER_SCORE = (7 << 0),
|
||||
PCL_EMIT_PLAYER_WANTED_LEVEL = (8 << 0),
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@@ -449,7 +450,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Modify the wanted level of the managed player entity.
|
||||
*/
|
||||
void SetWantedLevel(Int32 level) const;
|
||||
void SetWantedLevel(Int32 level);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the connection latency of the managed player entity.
|
||||
|
Reference in New Issue
Block a user