I want to hook CBasePlayer::ObserverStart with Orpheu, since Okapi is having some issues especially on Linux and with virtual functions mostly, so I don't wanna use it at all anymore, as my server eprforms much betetr since I got rid of it.
Plugin test:
PHP Code:
#include <amxmodx>
#include <orpheu>
new const g_szPluginName[] = "Observer Spectator Test";
new const g_szPluginVersion[] = "1.0";
new const g_szPluginAuthor[] = "DarthMan";
new OrpheuFunction: g_hFuncStartObserver;
new OrpheuHook: g_hStartObserver;
const OrpheuInvalidHook = OrpheuHook: 0;
#define PLUGIN_NAME g_szPluginName
#define PLUGIN_VERSION g_szPluginVersion
#define PLUGIN_AUTHOR g_szPluginAuthor
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
RegisterForward();
}
public plugin_precache()
{
g_hFuncStartObserver = OrpheuGetFunction("StartObserver", "CBasePlayer");
}
RegisterForward()
{
if(g_hFuncStartObserver != OrpheuInvalidFunction)
{
if(g_hStartObserver == OrpheuInvalidHook)
{
g_hStartObserver = OrpheuRegisterHook(g_hFuncStartObserver, "OnPlayerSpectate_Post", OrpheuHookPost);
}
}
}
UnregisterForward()
{
if(g_hStartObserver != OrpheuInvalidHook)
{
OrpheuUnregisterHook(g_hStartObserver);
}
}
public plugin_unpause()
{
RegisterForward();
}
public plugin_pause()
{
UnregisterForward();
}
public plugin_end()
{
UnregisterForward();
}
public OnPlayerSpectate_Post(const iID)
{
new szPlayerName[32];
get_user_name(iID, szPlayerName, charsmax(szPlayerName));
server_print("%s joined team 'SPECTATORS'.", szPlayerName);
new iPlayers[32], iPlayer, iNum;
get_players(iPlayers, iNum);
if(iNum > 1)
{
for(new i = 0; i < iNum; i++)
{
iPlayer = iPlayers[i];
if(iPlayer != iID)
{
client_print(iPlayer, print_chat, "* %s joined team 'SPECTATORS'.", szPlayerName);
}
}
}
}
Signature file:
PHP Code:
{
"name" : "StartObserver",
"class" : "CBasePlayer",
"library" : "mod",
"arguments" :
[
{
"type" : "Vector"
},
{
"type" : "Vector"
}
],
"identifiers" :
[
{
"os" : "windows",
"mod" : "tfc",
"value" : [0x53,0x56,0x8B,"*",0x57,0x33,"*",0x8B,"*","*",0x57,0x83,"*","*",0x50,0x6A]
},
{
"os" : "linux",
"mod" : "tfc",
"value" : "_ZN11CBasePlayer13StartObserverE6VectorS0_"
}
]
}
The funcion has Params as Vectos as args as per HLSDK. So, is there a way I can hook it with Orpheu?