diff --git a/gradle.properties b/gradle.properties index edbd712b..1507d1f0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ majorVersion=5 -minorVersion=8 +minorVersion=9 maintenanceVersion=0 diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index a531781f..581f58f8 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -823,3 +823,16 @@ native rg_set_iteminfo(const entity, ItemInfo:type, any:...); * */ native rg_get_iteminfo(const ent, ItemInfo:type, any:...); + +/* +* Adds hint message to the queue. +* +* @param index Client index +* @param message The message hint +* @param duration The time duration in seconds stays on screen +* @param bDisplayIfPlayerDead Whether to print hint for dead players? +* @param bOverride Whether to override previous messages? +* +* @return true if prints, false otherwise +*/ +native bool:rg_hint_message(const index, const message[], Float:duration = 6.0, bool:bDisplayIfPlayerDead = false, bool:bOverride = false); diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index 66ca9230..55a3b058 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -375,7 +375,7 @@ enum GamedllFunc * Params: (const index, Float:vecStart[3], Float:vecVelocity[3]) */ RG_PlantBomb, - + /* * Description: Called when a player hit to entity. * Return type: bool @@ -733,20 +733,27 @@ enum GamedllFunc_CBasePlayer * Params: (const this, const grenade, Float:vecSrc[3], Float:vecThrow[3], Float:time, const usEvent) */ RG_CBasePlayer_ThrowGrenade, - + /* * Description: Called when a player's set protection. * Return type: void * Params: (const this, Float:time) */ RG_CBasePlayer_SetSpawnProtection, - + /* * Description: Called when a player's remove protection. * Return type: void * Params: (const this) */ RG_CBasePlayer_RemoveSpawnProtection, + + /* + * Description: Called when the game prints hint message into DHUD. + * Return type: bool + * Params: (const this, const message[], Float:duration, bool:bDisplayIfPlayerDead, bool:bOverride) + */ + RG_CBasePlayer_HintMessageEx, }; /** @@ -3499,7 +3506,31 @@ enum CBasePlayer_Members * Get params: Float:get_member(index, member, element); * Set params: set_member(index, member, Float:value, element); */ - m_flLastCommandTime + m_flLastCommandTime, + + /* + * Description: The amount of money sent to the client last time. + * Member type: int + * Get params: get_member(index, member); + * Set params: set_member(index, member, value); + */ + m_iLastAccount, + + /* + * Description: The amount of health sent to the client last time. + * Member type: int + * Get params: get_member(index, member); + * Set params: set_member(index, member, Float:value); + */ + m_iLastClientHealth, + + /* + * Description: Waiting time for update fields into scoreboard. + * Member type: float + * Get params: Float:get_member(index, member); + * Set params: set_member(index, member, Float:value); + */ + m_tmNextAccountHealthUpdate, }; /** diff --git a/reapi/include/cssdk/dlls/API/CSInterfaces.h b/reapi/include/cssdk/dlls/API/CSInterfaces.h index 74c541e4..98e9ea14 100644 --- a/reapi/include/cssdk/dlls/API/CSInterfaces.h +++ b/reapi/include/cssdk/dlls/API/CSInterfaces.h @@ -226,4 +226,8 @@ class CCSTriggerCamera: public CCSDelay {}; class CCSWeather: public CCSTrigger {}; class CCSClientFog: public CCSEntity {}; class CCSTriggerSetOrigin: public CCSDelay {}; +class CCSTriggerRandom: public CCSDelay {}; class CCSItemAirBox: public CCSArmoury {}; +class CCSPointBaseCommand: public CCSPointEntity {}; +class CCSPointClientCommand: public CCSPointBaseCommand {}; +class CCSPointServerCommand: public CCSPointBaseCommand {}; diff --git a/reapi/include/cssdk/dlls/API/CSPlayer.h b/reapi/include/cssdk/dlls/API/CSPlayer.h index fc31c512..debe0bc7 100644 --- a/reapi/include/cssdk/dlls/API/CSPlayer.h +++ b/reapi/include/cssdk/dlls/API/CSPlayer.h @@ -82,9 +82,20 @@ class CCSPlayer: public CCSMonster { virtual bool RemovePlayerItemEx(const char* pszItemName, bool bRemoveAmmo); virtual void SetSpawnProtection(float flProtectionTime); virtual void RemoveSpawnProtection(); + virtual bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false); CBasePlayer *BasePlayer() const; +public: + enum EProtectionState + { + ProtectionSt_NoSet, + ProtectionSt_Active, + ProtectionSt_Expired, + }; + + EProtectionState GetProtectionState() const; + public: char m_szModel[32]; bool m_bForceShowMenu; @@ -97,3 +108,17 @@ inline CBasePlayer *CCSPlayer::BasePlayer() const { return reinterpret_cast(this->m_pContainingEntity); } + +inline CCSPlayer::EProtectionState CCSPlayer::GetProtectionState() const +{ + // no protection set + if (m_flSpawnProtectionEndTime <= 0.0f) + return ProtectionSt_NoSet; + + // check if end time of protection isn't expired yet + if (m_flSpawnProtectionEndTime >= gpGlobals->time) + return ProtectionSt_Active; + + // has expired + return ProtectionSt_Expired; +} diff --git a/reapi/include/cssdk/dlls/player.h b/reapi/include/cssdk/dlls/player.h index 2e948d5f..113bf061 100644 --- a/reapi/include/cssdk/dlls/player.h +++ b/reapi/include/cssdk/dlls/player.h @@ -584,6 +584,9 @@ class CBasePlayer: public CBaseMonster { float m_silentTimestamp; MusicState m_musicState; float m_flLastCommandTime[COMMANDS_TO_TRACK]; + int m_iLastAccount; + int m_iLastClientHealth; + float m_tmNextAccountHealthUpdate; }; class CWShield: public CBaseEntity { diff --git a/reapi/include/cssdk/dlls/regamedll_api.h b/reapi/include/cssdk/dlls/regamedll_api.h index 224fa1e8..cd258ab3 100644 --- a/reapi/include/cssdk/dlls/regamedll_api.h +++ b/reapi/include/cssdk/dlls/regamedll_api.h @@ -38,7 +38,7 @@ #include #define REGAMEDLL_API_VERSION_MAJOR 5 -#define REGAMEDLL_API_VERSION_MINOR 8 +#define REGAMEDLL_API_VERSION_MINOR 9 // CBasePlayer::Spawn hook typedef IHookChainClass IReGameHook_CBasePlayer_Spawn; @@ -436,6 +436,10 @@ typedef IHookChainRegistryClass IReGameHookRegistry_CBa typedef IHookChain IReGameHook_IsPenetrableEntity; typedef IHookChainRegistry IReGameHookRegistry_IsPenetrableEntity; +// CBasePlayer::HintMessageEx hook +typedef IHookChainClass IReGameHook_CBasePlayer_HintMessageEx; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_HintMessageEx; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -544,6 +548,7 @@ class IReGameHookchains { virtual IReGameHookRegistry_CBasePlayer_RemoveSpawnProtection *CBasePlayer_RemoveSpawnProtection() = 0; virtual IReGameHookRegistry_CBasePlayer_SetSpawnProtection *CBasePlayer_SetSpawnProtection() = 0; virtual IReGameHookRegistry_IsPenetrableEntity *IsPenetrableEntity() = 0; + virtual IReGameHookRegistry_CBasePlayer_HintMessageEx *CBasePlayer_HintMessageEx() = 0; }; struct ReGameFuncs_t { diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index d33eb945..bde510d4 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -532,6 +532,16 @@ void CBasePlayer_RemoveSpawnProtection(IReGameHook_CBasePlayer_RemoveSpawnProtec callVoidForward(RG_CBasePlayer_RemoveSpawnProtection, original, indexOfEdict(pthis->pev)); } +bool CBasePlayer_HintMessageEx(IReGameHook_CBasePlayer_HintMessageEx *chain, CBasePlayer *pthis, const char *pMessage, float duration, bool bDisplayIfPlayerDead, bool bOverride) +{ + auto original = [chain](int _pthis, const char *_pMessage, float _duration, bool _bDisplayIfPlayerDead, bool _bOverride) + { + return chain->callNext(getPrivate(_pthis), _pMessage, _duration, _bDisplayIfPlayerDead, _bOverride); + }; + + return callForward(RG_CBasePlayer_HintMessageEx, original, indexOfEdict(pthis->pev), pMessage, duration, bDisplayIfPlayerDead, bOverride); +} + void CBaseAnimating_ResetSequenceInfo(IReGameHook_CBaseAnimating_ResetSequenceInfo *chain, CBaseAnimating *pthis) { auto original = [chain](int _pthis) diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 9b2e6f65..65dde996 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -380,6 +380,7 @@ bool CBasePlayer_CanSwitchTeam(IReGameHook_CBasePlayer_CanSwitchTeam *chain, CBa CGrenade *CBasePlayer_ThrowGrenade(IReGameHook_CBasePlayer_ThrowGrenade *chain, CBasePlayer *pthis, CBasePlayerWeapon *pWeapon, Vector &vecSrc, Vector &vecThrow, float time, unsigned short usEvent); void CBasePlayer_SetSpawnProtection(IReGameHook_CBasePlayer_SetSpawnProtection *chain, CBasePlayer *pthis, float flProtectionTime); void CBasePlayer_RemoveSpawnProtection(IReGameHook_CBasePlayer_RemoveSpawnProtection *chain, CBasePlayer *pthis); +bool CBasePlayer_HintMessageEx(IReGameHook_CBasePlayer_HintMessageEx *chain, CBasePlayer *pthis, const char *pMessage, float duration, bool bDisplayIfPlayerDead, bool bOverride); void CBaseAnimating_ResetSequenceInfo(IReGameHook_CBaseAnimating_ResetSequenceInfo *chain, CBaseAnimating *pthis); diff --git a/reapi/src/hook_list.cpp b/reapi/src/hook_list.cpp index 92b9176b..ea82b576 100644 --- a/reapi/src/hook_list.cpp +++ b/reapi/src/hook_list.cpp @@ -153,6 +153,7 @@ hook_t hooklist_player[] = { DLL(CBasePlayer_ThrowGrenade), DLL(CBasePlayer_SetSpawnProtection), DLL(CBasePlayer_RemoveSpawnProtection), + DLL(CBasePlayer_HintMessageEx), }; hook_t hooklist_gamerules[] = { diff --git a/reapi/src/hook_list.h b/reapi/src/hook_list.h index ae7705c8..21ee71bf 100644 --- a/reapi/src/hook_list.h +++ b/reapi/src/hook_list.h @@ -175,6 +175,7 @@ enum GamedllFunc_CBasePlayer RG_CBasePlayer_ThrowGrenade, RG_CBasePlayer_SetSpawnProtection, RG_CBasePlayer_RemoveSpawnProtection, + RG_CBasePlayer_HintMessageEx, // [...] }; diff --git a/reapi/src/member_list.cpp b/reapi/src/member_list.cpp index bc4f7320..5ff04388 100644 --- a/reapi/src/member_list.cpp +++ b/reapi/src/member_list.cpp @@ -476,6 +476,9 @@ member_t memberlist_player[] = { PL_MEMBERS(m_silentTimestamp), PL_MEMBERS(m_musicState), PL_MEMBERS(m_flLastCommandTime), + PL_MEMBERS(m_iLastAccount), + PL_MEMBERS(m_iLastClientHealth), + PL_MEMBERS(m_tmNextAccountHealthUpdate), }; member_t memberlist_entvars[] = { diff --git a/reapi/src/member_list.h b/reapi/src/member_list.h index 58cb279f..f14c7141 100644 --- a/reapi/src/member_list.h +++ b/reapi/src/member_list.h @@ -466,7 +466,10 @@ enum CBasePlayer_Members m_intenseTimestamp, m_silentTimestamp, m_musicState, - m_flLastCommandTime + m_flLastCommandTime, + m_iLastAccount, + m_iLastClientHealth, + m_tmNextAccountHealthUpdate, }; // entvars diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index b98ddca1..41509295 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -2112,6 +2112,40 @@ cell AMX_NATIVE_CALL rg_get_iteminfo(AMX *amx, cell *params) return TRUE; } +/* +* Adds hint message to the queue. +* +* @param index Client index +* @param message The message hint +* @param duration The time duration in seconds stays on screen +* @param bDisplayIfPlayerDead Whether to print hint for dead players? +* @param bOverride Whether to override previous messages? +* +* @return true if prints, false otherwise +* +* native bool:rg_hint_message(const index, const message[], Float:duration = 6.0, bool:bDisplayIfPlayerDead = false, bool:bOverride = false); +*/ +cell AMX_NATIVE_CALL rg_hint_message(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_index, arg_message, arg_duration, arg_displayIfPlayerDead, arg_override }; + + CHECK_ISPLAYER(arg_index); + + CBasePlayer *pPlayer = UTIL_PlayerByIndex(params[arg_index]); + CHECK_CONNECTED(pPlayer, arg_index); + + char messagebuf[190]; + const char *message = getAmxString(amx, params[arg_message], messagebuf); + + if (!message || message[0] == '\0') { + AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: sending an empty hint message is meaningless. rework your code.", __FUNCTION__); + return FALSE; + } + + CAmxArgs args(amx, params); + return pPlayer->CSPlayer()->HintMessageEx(message, args[arg_duration], args[arg_displayIfPlayerDead], args[arg_override]) ? TRUE : FALSE; +} + AMX_NATIVE_INFO Misc_Natives_RG[] = { { "rg_set_animation", rg_set_animation }, @@ -2190,6 +2224,8 @@ AMX_NATIVE_INFO Misc_Natives_RG[] = { "rg_set_iteminfo", rg_set_iteminfo }, { "rg_get_iteminfo", rg_get_iteminfo }, + { "rg_hint_message", rg_hint_message }, + { nullptr, nullptr } };