mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01: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:
parent
c6c17e9396
commit
3d8417759b
@ -430,6 +430,7 @@ protected:
|
||||
Function mOnScore;
|
||||
Function mOnWantedLevel;
|
||||
Function mOnImmunity;
|
||||
Function mOnAlpha;
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@ -1008,6 +1009,7 @@ public:
|
||||
void EmitPlayerScore(Int32 player_id, Int32 old_score, Int32 new_score);
|
||||
void EmitPlayerWantedLevel(Int32 player_id, Int32 old_level, Int32 new_level);
|
||||
void EmitPlayerImmunity(Int32 player_id, Int32 old_immunity, Int32 new_immunity);
|
||||
void EmitPlayerAlpha(Int32 player_id, Int32 old_alpha, Int32 new_alpha, Int32 fade);
|
||||
void EmitVehicleColour(Int32 vehicle_id, Int32 changed);
|
||||
void EmitVehicleHealth(Int32 vehicle_id, Float32 old_health, Float32 new_health);
|
||||
void EmitVehiclePosition(Int32 vehicle_id);
|
||||
@ -1153,6 +1155,7 @@ private:
|
||||
Function mOnPlayerScore;
|
||||
Function mOnPlayerWantedLevel;
|
||||
Function mOnPlayerImmunity;
|
||||
Function mOnPlayerAlpha;
|
||||
Function mOnVehicleColour;
|
||||
Function mOnVehicleHealth;
|
||||
Function mOnVehiclePosition;
|
||||
|
@ -789,6 +789,14 @@ void Core::EmitPlayerImmunity(Int32 player_id, Int32 old_immunity, Int32 new_imm
|
||||
Emit(mOnPlayerImmunity, _player.mObj, old_immunity, new_immunity);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Core::EmitPlayerAlpha(Int32 player_id, Int32 old_alpha, Int32 new_alpha, Int32 fade)
|
||||
{
|
||||
PlayerInst & _player = m_Players.at(player_id);
|
||||
Emit(_player.mOnAlpha, old_alpha, new_alpha, fade);
|
||||
Emit(mOnPlayerAlpha, _player.mObj, old_alpha, new_alpha, fade);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Core::EmitVehicleColour(Int32 vehicle_id, Int32 changed)
|
||||
{
|
||||
|
@ -235,6 +235,7 @@ void Core::ResetFunc(PlayerInst & inst)
|
||||
inst.mOnScore.ReleaseGently();
|
||||
inst.mOnWantedLevel.ReleaseGently();
|
||||
inst.mOnImmunity.ReleaseGently();
|
||||
inst.mOnAlpha.ReleaseGently();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@ -357,6 +358,7 @@ void Core::ResetFunc()
|
||||
Core::Get().mOnPlayerScore.ReleaseGently();
|
||||
Core::Get().mOnPlayerWantedLevel.ReleaseGently();
|
||||
Core::Get().mOnPlayerImmunity.ReleaseGently();
|
||||
Core::Get().mOnPlayerAlpha.ReleaseGently();
|
||||
Core::Get().mOnVehicleColour.ReleaseGently();
|
||||
Core::Get().mOnVehicleHealth.ReleaseGently();
|
||||
Core::Get().mOnVehiclePosition.ReleaseGently();
|
||||
@ -471,6 +473,7 @@ Function & Core::GetEvent(Int32 evid)
|
||||
case EVT_PLAYERSCORE: return mOnPlayerScore;
|
||||
case EVT_PLAYERWANTEDLEVEL: return mOnPlayerWantedLevel;
|
||||
case EVT_PLAYERIMMUNITY: return mOnPlayerImmunity;
|
||||
case EVT_PLAYERALPHA: return mOnPlayerAlpha;
|
||||
case EVT_VEHICLECOLOUR: return mOnVehicleColour;
|
||||
case EVT_VEHICLEHEALTH: return mOnVehicleHealth;
|
||||
case EVT_VEHICLEPOSITION: return mOnVehiclePosition;
|
||||
@ -635,6 +638,7 @@ Function & Core::GetPlayerEvent(Int32 id, Int32 evid)
|
||||
case EVT_PLAYERSCORE: return inst.mOnScore;
|
||||
case EVT_PLAYERWANTEDLEVEL: return inst.mOnWantedLevel;
|
||||
case EVT_PLAYERIMMUNITY: return inst.mOnImmunity;
|
||||
case EVT_PLAYERALPHA: return inst.mOnAlpha;
|
||||
default: return NullFunction();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -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_
|
||||
|
@ -384,6 +384,7 @@ enum EventType
|
||||
EVT_PLAYERSCORE,
|
||||
EVT_PLAYERWANTEDLEVEL,
|
||||
EVT_PLAYERIMMUNITY,
|
||||
EVT_PLAYERALPHA,
|
||||
EVT_VEHICLECOLOUR,
|
||||
EVT_VEHICLEHEALTH,
|
||||
EVT_VEHICLEPOSITION,
|
||||
|
Loading…
Reference in New Issue
Block a user