mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-19 08:37:14 +02:00
Implement a new event to receive notifications when a player score has changed.
This commit is contained in:
@ -701,12 +701,27 @@ Int32 CPlayer::GetScore() const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CPlayer::SetScore(Int32 score) const
|
||||
void CPlayer::SetScore(Int32 score)
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Perform the requested operation
|
||||
// Grab the current value for this property
|
||||
const Int32 current = _Func->GetPlayerScore(m_ID);
|
||||
// Don't even bother if it's the same value
|
||||
if (current == score)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Avoid property unwind from a recursive call
|
||||
_Func->SetPlayerScore(m_ID, score);
|
||||
// Avoid infinite recursive event loops
|
||||
if (!(m_CircularLocks & PCL_EMIT_PLAYER_SCORE))
|
||||
{
|
||||
// Prevent this event from triggering while executed
|
||||
BitGuardU32 bg(m_CircularLocks, PCL_EMIT_PLAYER_SCORE);
|
||||
// Now forward the event call
|
||||
Core::Get().EmitPlayerScore(m_ID, current, score);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user