i want to handle cs:go events in the metamod:source plugin. but the server gives me a message below in the server console:
Code:
GameEventListener2 callback in list that should NOT be - weapon_reload!
My Code:
Code:
#include <stdio.h>
#include "stub_mm.h"
SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, int, int);
SH_DECL_HOOK1_void(IGameEventListener2, FireGameEvent, SH_NOATTRIB, 0, IGameEvent *);
SH_DECL_HOOK3(IGameEventManager2, AddListener, SH_NOATTRIB, 0, bool, IGameEventListener2 *, const char *, bool);
SH_DECL_HOOK2(IGameEventManager2, FindListener, SH_NOATTRIB, 0, bool, IGameEventListener2 *, const char *);
SH_DECL_HOOK2(IGameEventManager2, FireEvent, SH_NOATTRIB, 0, bool, IGameEvent *, bool);
StubPlugin g_StubPlugin;
IServerGameDLL *server = NULL;
IGameEventListener2 *eventListener = NULL;
IGameEventManager2 *eventManager = NULL;
PLUGIN_EXPOSE(StubPlugin, g_StubPlugin);
bool StubPlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
PLUGIN_SAVEVARS();
GET_V_IFACE_CURRENT(GetServerFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
GET_V_IFACE_CURRENT(GetEngineFactory, eventListener, IGameEventListener2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
GET_V_IFACE_CURRENT(GetEngineFactory, eventManager, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
SH_ADD_HOOK_STATICFUNC(IServerGameDLL, ServerActivate, server, Hook_ServerActivate, true);
//SH_ADD_HOOK(IGameEventListener2, FireGameEvent, eventListener, SH_STATIC(Hook_FireGameEvent), true);
//SH_ADD_HOOK_STATICFUNC(IGameEventManager2, FindListener, eventManager, Hook_FindListener, true);
//SH_ADD_HOOK(IGameEventManager2, FireEvent, eventManager, SH_STATIC(Hook_FireEvent), true);
g_SMAPI->EnableVSPListener();
g_SMAPI->AddListener(this, this);
g_SMAPI->ConPrintf("Plugin::Load\n");
return true;
}
void StubPlugin::FireGameEvent( IGameEvent *event ) {
g_SMAPI->ConPrintf("event..: %s", event->GetName());
}
int StubPlugin::GetEventDebugID() {}
void StubPlugin::OnVSPListening(IServerPluginCallbacks *iface) {
g_SMAPI->ConPrintf("Plugin::ONVSPListening\n");
}
bool StubPlugin::Unload(char *error, size_t maxlen)
{
SH_REMOVE_HOOK_STATICFUNC(IServerGameDLL, ServerActivate, server, Hook_ServerActivate, true);
g_SMAPI->ConPrintf("Plugin::UnLoad\n");
return true;
}
bool Hook_FindListener( IGameEventListener2 * listener, const char *name ) {
g_SMAPI->ConPrintf("hook_Listener..: %s\n", name);
}
void Hook_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
{
g_SMAPI->ConPrintf("Hello World - %s - %d\n", g_PLAPI->GetAuthor(), g_PLID);
eventManager->AddListener( &g_StubPlugin, "weapon_reload", true );
}
void Hook_FireGameEvent( IGameEvent *event )
{
g_SMAPI->ConPrintf("Event..: %s\n", event->GetName());
}
bool Hook_FireEvent( IGameEvent *event, bool bDontBroadCast )
{
g_SMAPI->ConPrintf("Plugin::FireEvent\n");
}
void StubPlugin::AllPluginsLoaded()
{
g_SMAPI->ConPrintf("Plugin::AllPluginsLoaded\n");
}
bool StubPlugin::Pause(char *error, size_t maxlen)
{
return true;
}
bool StubPlugin::Unpause(char *error, size_t maxlen)
{
return true;
}
const char *StubPlugin::GetLicense()
{
return "Public Domain";
}
const char *StubPlugin::GetVersion()
{
return "1.0.0.0";
}
const char *StubPlugin::GetDate()
{
return __DATE__;
}
const char *StubPlugin::GetLogTag()
{
return "STUB";
}
const char *StubPlugin::GetAuthor()
{
return "@aaa";
}
const char *StubPlugin::GetDescription()
{
return "Sample empty plugin";
}
const char *StubPlugin::GetName()
{
return "Stub Plugin";
}
const char *StubPlugin::GetURL()
{
return "http://www.sourcemm.net/";
}
My Plugin is :
Code:
class StubPlugin : public ISmmPlugin, public IMetamodListener, public IGameEventListener2
My Another questions...:
What is differences between GET_V_IFACE_CURRENT and GET_V_IFACE_ANY ?
What is GetEngineFactory and GetServerFactory, why do i use IServerGameDLL with GetServerFactory and IGameEventListener2 with GetEngineFactory ?
and
How to access game api like give weapon or entity apis, spawn entity like in sourcemod?
Thank you so much for your help...