1
0
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:
Sandu Liviu Catalin
2016-08-17 16:04:14 +03:00
parent 203dd9802e
commit 8f78b0a852
6 changed files with 35 additions and 3 deletions

View File

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

View File

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