mirror of
https://github.com/rehlds/reapi.git
synced 2025-03-13 05:50:16 +03:00
Implemented hook CBasePlayer::HintMessageEx. Closes #133
Add native rg_hint_message Add news CBasePlayer members Bump minor version API
This commit is contained in:
parent
4834b7a117
commit
0eed4cd833
@ -1,3 +1,3 @@
|
||||
majorVersion=5
|
||||
minorVersion=8
|
||||
minorVersion=9
|
||||
maintenanceVersion=0
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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 {};
|
||||
|
@ -82,9 +82,20 @@ public:
|
||||
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<CBasePlayer *>(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;
|
||||
}
|
||||
|
@ -584,6 +584,9 @@ public:
|
||||
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 {
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <API/CSInterfaces.h>
|
||||
|
||||
#define REGAMEDLL_API_VERSION_MAJOR 5
|
||||
#define REGAMEDLL_API_VERSION_MINOR 8
|
||||
#define REGAMEDLL_API_VERSION_MINOR 9
|
||||
|
||||
// CBasePlayer::Spawn hook
|
||||
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
|
||||
@ -436,6 +436,10 @@ typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBa
|
||||
typedef IHookChain<bool, Vector &, Vector &, entvars_t *, edict_t *> IReGameHook_IsPenetrableEntity;
|
||||
typedef IHookChainRegistry<bool, Vector &, Vector &, entvars_t *, edict_t *> IReGameHookRegistry_IsPenetrableEntity;
|
||||
|
||||
// CBasePlayer::HintMessageEx hook
|
||||
typedef IHookChainClass<bool, class CBasePlayer, const char *, float, bool, bool> IReGameHook_CBasePlayer_HintMessageEx;
|
||||
typedef IHookChainRegistryClass<bool, class CBasePlayer, const char *, float, bool, bool> IReGameHookRegistry_CBasePlayer_HintMessageEx;
|
||||
|
||||
class IReGameHookchains {
|
||||
public:
|
||||
virtual ~IReGameHookchains() {}
|
||||
@ -544,6 +548,7 @@ public:
|
||||
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 {
|
||||
|
@ -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<CBasePlayer>(_pthis), _pMessage, _duration, _bDisplayIfPlayerDead, _bOverride);
|
||||
};
|
||||
|
||||
return callForward<bool>(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)
|
||||
|
@ -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);
|
||||
|
||||
|
@ -153,6 +153,7 @@ hook_t hooklist_player[] = {
|
||||
DLL(CBasePlayer_ThrowGrenade),
|
||||
DLL(CBasePlayer_SetSpawnProtection),
|
||||
DLL(CBasePlayer_RemoveSpawnProtection),
|
||||
DLL(CBasePlayer_HintMessageEx),
|
||||
};
|
||||
|
||||
hook_t hooklist_gamerules[] = {
|
||||
|
@ -175,6 +175,7 @@ enum GamedllFunc_CBasePlayer
|
||||
RG_CBasePlayer_ThrowGrenade,
|
||||
RG_CBasePlayer_SetSpawnProtection,
|
||||
RG_CBasePlayer_RemoveSpawnProtection,
|
||||
RG_CBasePlayer_HintMessageEx,
|
||||
|
||||
// [...]
|
||||
};
|
||||
|
@ -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[] = {
|
||||
|
@ -466,7 +466,10 @@ enum CBasePlayer_Members
|
||||
m_intenseTimestamp,
|
||||
m_silentTimestamp,
|
||||
m_musicState,
|
||||
m_flLastCommandTime
|
||||
m_flLastCommandTime,
|
||||
m_iLastAccount,
|
||||
m_iLastClientHealth,
|
||||
m_tmNextAccountHealthUpdate,
|
||||
};
|
||||
|
||||
// entvars
|
||||
|
@ -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 }
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user