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

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