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 score has changed.

Fix syntax error in enumeration declaration.
Fix compilation error on const correctness in player method for changing player world.
This commit is contained in:
Sandu Liviu Catalin
2016-08-17 16:10:43 +03:00
parent c6c17e9396
commit 3d8417759b
6 changed files with 41 additions and 12 deletions

View File

@@ -947,21 +947,33 @@ Int32 CPlayer::GetAlpha() const
}
// ------------------------------------------------------------------------------------------------
void CPlayer::SetAlpha(Int32 alpha) const
void CPlayer::SetAlpha(Int32 alpha)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetPlayerAlpha(m_ID, alpha, 0);
SetAlphaEx(alpha, 0);
}
// ------------------------------------------------------------------------------------------------
void CPlayer::SetAlphaEx(Int32 alpha, Int32 fade) const
void CPlayer::SetAlphaEx(Int32 alpha, Int32 fade)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
// Grab the current value for this property
const Int32 current = _Func->GetPlayerAlpha(m_ID);
// Don't even bother if it's the same value
if (current == alpha)
{
return;
}
// Avoid property unwind from a recursive call
_Func->SetPlayerAlpha(m_ID, alpha, fade);
// Avoid infinite recursive event loops
if (!(m_CircularLocks & PCL_EMIT_PLAYER_ALPHA))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, PCL_EMIT_PLAYER_ALPHA);
// Now forward the event call
Core::Get().EmitPlayerAlpha(m_ID, current, alpha, fade);
}
}
// ------------------------------------------------------------------------------------------------

View File

@@ -13,7 +13,7 @@ namespace SqMod {
*/
enum PlayerCircularLocks
{
PCL_EMIT_PLAYER_OPTION = (1 << 0)
PCL_EMIT_PLAYER_OPTION = (1 << 0),
PCL_EMIT_PLAYER_ADMIN = (2 << 0),
PCL_EMIT_PLAYER_WORLD = (3 << 0),
PCL_EMIT_PLAYER_TEAM = (4 << 0),
@@ -22,6 +22,7 @@ enum PlayerCircularLocks
PCL_EMIT_PLAYER_SCORE = (7 << 0),
PCL_EMIT_PLAYER_WANTED_LEVEL = (8 << 0),
PCL_EMIT_PLAYER_IMMUNITY = (9 << 0),
PCL_EMIT_PLAYER_ALPHA = (10 << 0)
};
/* ------------------------------------------------------------------------------------------------
@@ -346,7 +347,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the secondary world of the managed player entity.
*/
void SetSecondaryWorld(Int32 world) const;
void SetSecondaryWorld(Int32 world);
/* --------------------------------------------------------------------------------------------
* Retrieve the unique world of the managed player entity.
@@ -551,12 +552,12 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the alpha of the managed player entity.
*/
void SetAlpha(Int32 alpha) const;
void SetAlpha(Int32 alpha);
/* --------------------------------------------------------------------------------------------
* Modify the alpha of the managed player entity.
*/
void SetAlphaEx(Int32 alpha, Int32 fade) const;
void SetAlphaEx(Int32 alpha, Int32 fade);
/* --------------------------------------------------------------------------------------------
* Retrieve the aim position of the managed player entity.
@@ -996,4 +997,4 @@ public:
} // Namespace:: SqMod
#endif // _ENTITY_PLAYER_HPP_
#endif // _ENTITY_PLAYER_HPP_