Quote:
Originally Posted by killerZM
ty
@edit
what if need to get message arguments ?
|
then you need to hook WriteByte, WriteCoord etc.. + MessageEnd forwards.
then you need to create bool array where you will which message arguments are you getting from forward WriteXXXX.
Code:
bool MessageHooked[256];
Lets hook health message & get argument (1 Byte Argument) (
https://wiki.alliedmods.net/Half-life_1_game_events)
Code:
#define MESSAGE_HEALTH 70
void OnMessageBegin(int Dest, int Type, const float *pOrigin, edict_t *pPlayer)
{
switch (Type)
{
case MESSAGE_HEALTH:
{
MessageHooked[MESSAGE_HEALTH] = true;
RETURN_META(MRES_IGNORED);
}
}
RETURN_META(MRES_IGNORED);
}
void OnWriteByte(int Value)
{
if (MessageHooked[MESSAGE_HEALTH])
{
// First Value = health
// Wanna Change IT?
// then do like this
WRITE_BYTE(Value * 2);
RETURN_META(MRES_SUPERCEDE);
}
RETURN_META(MRES_IGNORED);
}
void OnMessageEnd(void)
{
MessageHooked[MESSAGE_HEALTH] = false;
RETURN_META(MRES_IGNORED);
}
didnt checked this code, but must work.
ofc you must hook those forwards with g_pengfuncsTable;