Example #1
0
/**
 *  Called when our plugin is first loaded in the system, during the execution of
 * DLLInit() - prior to initializing the GameDLL.
 **/
bool CMetaModPy::Load(PluginId id, ISmmAPI* ismm, char* error, size_t maxlen, bool late)
{
    char *directoryBuffer = new char[MAXIMUM_PATH_LENGTH];
    PyObject *loaderModule;

    PLUGIN_SAVEVARS();

    /* Make sure we build on MM:S 1.4 */
#if defined METAMOD_PLAPI_VERSION
    GET_V_IFACE_ANY(GetServerFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
#else
    GET_V_IFACE_ANY(serverFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
#endif

    // Set up our Python environment
    setenv("PYTHONNOUSERSITE", "1", 1);

    g_SMAPI->PathFormat(directoryBuffer, MAXIMUM_PATH_LENGTH, "%s/%s", g_SMAPI->GetBaseDir(), "addons/metamodpy");
    setenv("PYTHONHOME", directoryBuffer, 1);

    g_SMAPI->PathFormat(directoryBuffer, MAXIMUM_PATH_LENGTH, "%s/%s", directoryBuffer, "plugins");
    setenv("PYTHONPATH", directoryBuffer, 1);

    // We don't need this any more.
    delete directoryBuffer;

    // Create our initialize the Python subsystem
    g_pythonManager = new CPythonManager();

    InitializeHooks();

    return true;
}
bool GlobalApprehensivePlugin::Load(PluginId id, ISmmAPI * ismm, char * error, std::size_t maxlen, bool late)
{
	PLUGIN_SAVEVARS();
	GET_V_IFACE_CURRENT(GetEngineFactory, _engineServer, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
	GET_V_IFACE_CURRENT(GetEngineFactory, _gameEventManager, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
	GET_V_IFACE_ANY(GetServerFactory, _playerInfoManager, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
	_gameEventManager->AddListener(this, playerDeathEvent, true);
	_globalVars = g_SMAPI->GetCGlobals();
	return true;
}
Example #3
0
bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
	PLUGIN_SAVEVARS();

#if !defined METAMOD_PLAPI_VERSION
	GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
	GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
#else
	GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
	GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
#endif

	m_SourceMMLoaded = true;

	return SDK_OnMetamodLoad(ismm, error, maxlen, late);
}
Example #4
0
File: luaex.cpp Project: tetl/LuaEx
bool LuaEx::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
	PLUGIN_SAVEVARS();

	InitGlobals(error, maxlen);
	InitHooks();


	for (auto i = ScriptExtensions().begin(); i != ScriptExtensions().end(); ++i)
	{
		(*i)->Init();
	}


	return true;
}
Example #5
0
bool SamplePlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
	PLUGIN_SAVEVARS();

	GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
	GET_V_IFACE_CURRENT(GetEngineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
	GET_V_IFACE_CURRENT(GetEngineFactory, helpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
	GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);
	GET_V_IFACE_ANY(GetServerFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
	GET_V_IFACE_ANY(GetServerFactory, gameclients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
	GET_V_IFACE_ANY(GetServerFactory, playerinfomanager, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);

	gpGlobals = ismm->GetCGlobals();

	META_LOG(g_PLAPI, "Starting plugin.");

	/* Load the VSP listener.  This is usually needed for IServerPluginHelpers. */
	if ((vsp_callbacks = ismm->GetVSPInfo(NULL)) == NULL)
	{
		ismm->AddListener(this, this);
		ismm->EnableVSPListener();
	}

	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, server, this, &SamplePlugin::Hook_LevelInit, true);
	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, server, this, &SamplePlugin::Hook_ServerActivate, true);
	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, GameFrame, server, this, &SamplePlugin::Hook_GameFrame, true);
	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, server, this, &SamplePlugin::Hook_LevelShutdown, false);
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientActive, gameclients, this, &SamplePlugin::Hook_ClientActive, true);
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, gameclients, this, &SamplePlugin::Hook_ClientDisconnect, true);
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientPutInServer, gameclients, this, &SamplePlugin::Hook_ClientPutInServer, true);
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, SetCommandClient, gameclients, this, &SamplePlugin::Hook_SetCommandClient, true);
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientSettingsChanged, gameclients, this, &SamplePlugin::Hook_ClientSettingsChanged, false);
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientConnect, gameclients, this, &SamplePlugin::Hook_ClientConnect, false);
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientCommand, gameclients, this, &SamplePlugin::Hook_ClientCommand, false);

	ENGINE_CALL(LogPrint)("All hooks started!\n");

#if SOURCE_ENGINE >= SE_ORANGEBOX
	g_pCVar = icvar;
	ConVar_Register(0, &s_BaseAccessor);
#else
	ConCommandBaseMgr::OneTimeInit(&s_BaseAccessor);
#endif

	return true;
}
Example #6
0
bool StubPlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
	PLUGIN_SAVEVARS();

#if defined METAMOD_PLAPI_VERSION
	GET_V_IFACE_ANY(GetServerFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
	GET_V_IFACE_ANY(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
#else
	GET_V_IFACE_ANY(serverFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
	GET_V_IFACE_ANY(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
#endif

	SH_ADD_HOOK(IServerGameDLL, ServerActivate, server, SH_STATIC(Hook_ServerActivate), true);

	ismm->AddListener(this, this);

	return true;
}
Example #7
0
bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
	PLUGIN_SAVEVARS();

	GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
	GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
	GET_V_IFACE_CURRENT(GetServerFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
	GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);
	GET_V_IFACE_CURRENT(GetEngineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
	GET_V_IFACE_CURRENT(GetEngineFactory, engrandom, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
	GET_V_IFACE_CURRENT(GetFileSystemFactory, basefilesystem, IBaseFileSystem, BASEFILESYSTEM_INTERFACE_VERSION);
	GET_V_IFACE_CURRENT(GetFileSystemFactory, filesystem, IFileSystem, FILESYSTEM_INTERFACE_VERSION);
	GET_V_IFACE_CURRENT(GetEngineFactory, enginesound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
#if SOURCE_ENGINE != SE_DOTA
	GET_V_IFACE_CURRENT(GetEngineFactory, serverpluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
#endif

	/* :TODO: Make this optional and... make it find earlier versions [?] */
	GET_V_IFACE_CURRENT(GetServerFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);

	if ((g_pMMPlugins = (ISmmPluginManager *)g_SMAPI->MetaFactory(MMIFACE_PLMANAGER, NULL, NULL)) == NULL)
	{
		if (error)
		{
			snprintf(error, maxlen, "Unable to find interface %s", MMIFACE_PLMANAGER);
		}
		return false;
	}

	gpGlobals = ismm->GetCGlobals();
	
	ismm->AddListener(this, this);

#if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
	if ((vsp_interface = g_SMAPI->GetVSPInfo(&vsp_version)) == NULL)
#endif
	{
		g_SMAPI->EnableVSPListener();
	}

	return g_SourceMod.InitializeSourceMod(error, maxlen, late);
}
bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
	PLUGIN_SAVEVARS();

#if defined METAMOD_PLAPI_VERSION
	GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
	GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
#else
	GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
	GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
#endif

	GET_V_IFACE_ANY(engineFactory, events, IGameEventManager, INTERFACEVERSION_GAMEEVENTSMANAGER);
	GET_V_IFACE_ANY(serverFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
	GET_V_IFACE_CURRENT(engineFactory, icvar, ICvar, VENGINE_CVAR_INTERFACE_VERSION);
	GET_V_IFACE_ANY(serverFactory, serverents, IServerGameEnts, INTERFACEVERSION_SERVERGAMEENTS);
	GET_V_IFACE_ANY(serverFactory, serverclients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);

	m_SourceMMLoaded = true;

	return SDK_OnMetamodLoad(ismm, error, maxlen, late);
}
Example #9
0
bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
	PLUGIN_SAVEVARS();

#ifndef META_NO_HL2SDK
#if !defined METAMOD_PLAPI_VERSION
	GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
	GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
#else
	GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
#if SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_SDK2013
	// Shim to avoid hooking shims
	engine = (IVEngineServer *) ismm->GetEngineFactory()("VEngineServer023", nullptr);
	if (!engine)
	{
		engine = (IVEngineServer *) ismm->GetEngineFactory()("VEngineServer022", nullptr);
		if (!engine)
		{
			engine = (IVEngineServer *) ismm->GetEngineFactory()("VEngineServer021", nullptr);
			if (!engine)
			{
				if (error && maxlen)
				{
					ismm->Format(error, maxlen, "Could not find interface: VEngineServer023 or VEngineServer022");
				}
				return false;
			}
		}
	}
#else
	GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
#endif // TF2 / CSS / DODS / HL2DM / SDK2013
#endif // !METAMOD_PLAPI_VERSION
#endif //META_NO_HL2SDK

	m_SourceMMLoaded = true;

	return SDK_OnMetamodLoad(ismm, error, maxlen, late);
}
Example #10
0
bool l4dtoolz::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
#ifdef WIN32
	hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE, GetCurrentProcessId());
#endif
	PLUGIN_SAVEVARS();

	GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
	GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);


#if defined METAMOD_PLAPI_VERSION
	if ((vsp_callbacks = ismm->GetVSPInfo(NULL)) == NULL)
#endif
	{
		ismm->AddListener(this, this);
		ismm->EnableVSPListener();
	}


#if !defined METAMOD_PLAPI_VERSION
	m_EngineCC = SH_GET_CALLCLASS(engine);
#endif

#if SOURCE_ENGINE >= SE_ORANGEBOX
	g_pCVar = icvar;
	ConVar_Register(0, &s_BaseAccessor);
#else
	ConCommandBaseMgr::OneTimeInit(&s_BaseAccessor);
#endif

	char* base_addr = NULL;
	size_t base_len = 0;

	find_base(matchmaking_dll, base_addr, base_len);

#ifdef WIN32
	if(base_addr == NULL)
		find_base("matchmaking.dll", base_addr, base_len);
#endif

	if(lobby_match_ptr == NULL){
		lobby_match_ptr = (char*)FindSignature(lobby_match, base_addr, base_len, true);
		get_org_sig(lobby_match, (const char*)lobby_match_new, lobby_match_org);
	}

	find_base(engine_dll, base_addr, base_len);
	if(max_players_friend_lobby == NULL){
		max_players_friend_lobby = (char*)FindSignature(friends_lobby, base_addr, base_len);
		get_org_sig(max_players_friend_lobby, (const char*)friends_lobby_new, friends_lobby_org);
	}
	if(max_players_connect == NULL){
		max_players_connect = (char*)FindSignature(max_players, base_addr, base_len);
		if(max_players_connect != NULL){
			get_org_sig(max_players_connect, (const char*)max_players_new, max_players_org);
		}
	}
	if(lobby_sux_ptr==NULL){

#ifdef WIN32
		lobby_sux_ptr = max_players_connect;
#else
		lobby_sux_ptr = (char*)FindSignature(lobby_sux, base_addr, base_len);
#endif
		if(lobby_sux_ptr!=NULL){
			get_org_sig(lobby_sux_ptr, lobby_sux_new, lobby_sux_org);
		}
	}
#ifdef WIN32
	if(max_players_server_browser == NULL){
		max_players_server_browser = (char*)FindSignature(server_bplayers, base_addr, base_len);
		get_org_sig(max_players_server_browser, (const char*)server_bplayers_new, server_bplayers_org);
	}
#endif
	if(tmp_player == NULL){
		tmp_player = (char*)FindSignature(players, base_addr, base_len);
		if(tmp_player != NULL){
#ifdef WIN32
			tmp_player2 = (char*)FindSignature(players2, base_addr, base_len);
#else
			tmp_player2 = tmp_player;
#endif
			if(tmp_player2 != NULL){
				get_org_sig(tmp_player, players_new, players_org);
				WriteSignature(tmp_player, players_new);
				get_org_sig(tmp_player2, players_new2, players_org2);
				WriteSignature(tmp_player2, players_new2);
				engine->ServerCommand("maxplayers 32\n");
				engine->ServerCommand("L4DToolZ [email protected]\n");
			}
		}
	}
	if(unreserved_ptr==NULL){
		unreserved_ptr = (char*)FindSignature(unreserved, base_addr, base_len);
		get_org_sig(unreserved_ptr, unreserved_new, unreserved_org);
	}

	find_base(server_dll, base_addr, base_len);

	if(chuman_limit == NULL){
		chuman_limit = (char*)FindSignature(human_limit, base_addr, base_len);
		get_org_sig(chuman_limit, human_limit_new, human_limit_org);
	}

#ifndef WIN32
	if(max_players_server_browser == NULL){
		max_players_server_browser = (char*)FindSignature(server_bplayers, base_addr, base_len);
		get_org_sig(max_players_server_browser, (const char*)server_bplayers_new, server_bplayers_org);
	}
#endif

	return true;
}
Example #11
0
bool l4dtoolz::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{

	PLUGIN_SAVEVARS();

	GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
	GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);


#if defined METAMOD_PLAPI_VERSION
	if ((vsp_callbacks = ismm->GetVSPInfo(NULL)) == NULL)
#endif
	{
		ismm->AddListener(this, this);
		ismm->EnableVSPListener();
	}


#if !defined METAMOD_PLAPI_VERSION
	m_EngineCC = SH_GET_CALLCLASS(engine);
#endif

#if SOURCE_ENGINE >= SE_ORANGEBOX
	g_pCVar = icvar;
	ConVar_Register(0, &s_BaseAccessor);
#else
	ConCommandBaseMgr::OneTimeInit(&s_BaseAccessor);
#endif

	struct base_addr_t base_addr;
	base_addr.addr = NULL;
	base_addr.len = 0;

	find_base_from_list(matchmaking_dll, &base_addr);

	if(!lobby_match_ptr) {
		lobby_match_ptr = find_signature(lobby_match, &base_addr, 1);
		get_original_signature(lobby_match_ptr, lobby_match_new, lobby_match_org);
	}

	find_base_from_list(engine_dll, &base_addr);
#ifdef L4D1
	if(!max_players_friend_lobby) {
		max_players_friend_lobby = find_signature(friends_lobby, &base_addr, 0);
		get_original_signature(max_players_friend_lobby, friends_lobby_new, friends_lobby_org);
	}
#endif
	if(!max_players_connect) {
		max_players_connect = find_signature(max_players, &base_addr, 0);
		get_original_signature(max_players_connect, max_players_new, max_players_org);
	}
	if(!lobby_sux_ptr) {

#ifdef WIN32
		lobby_sux_ptr = max_players_connect;
#else
		lobby_sux_ptr = find_signature(lobby_sux, &base_addr, 0);
#endif
		get_original_signature(lobby_sux_ptr, lobby_sux_new, lobby_sux_org);
	}
#ifdef L4D1
#ifdef WIN32
	if(!max_players_server_browser) {
		max_players_server_browser = find_signature(server_bplayers, &base_addr, 0);
		get_original_signature(max_players_server_browser, server_bplayers_new, server_bplayers_org);
	}
#endif
#endif
	if(!tmp_player) {
		tmp_player = find_signature(players, &base_addr, 0);
		if(tmp_player) {
			tmp_player2 = find_signature(players2, &base_addr, 0);
			if(tmp_player2) {
				get_original_signature(tmp_player, players_new, players_org);
				write_signature(tmp_player, players_new);
				get_original_signature(tmp_player2, players_new2, players_org2);
				write_signature(tmp_player2, players_new2);
				engine->ServerCommand("maxplayers 32\n");
				engine->ServerCommand("L4DToolZ [email protected]\n");
			}
		}
	}
	if(!unreserved_ptr) {
		unreserved_ptr = find_signature(unreserved, &base_addr, 0);
		get_original_signature(unreserved_ptr, unreserved_new, unreserved_org);
	}

	find_base_from_list(server_dll, &base_addr);
#ifdef L4D1
	if(!chuman_limit) {
		chuman_limit = find_signature(human_limit, &base_addr, 0);
		get_original_signature(chuman_limit, human_limit_new, human_limit_org);
	}
#ifndef WIN32
	if(!max_players_server_browser) {
		max_players_server_browser = find_signature(server_bplayers, &base_addr, 0);
		get_original_signature(max_players_server_browser, server_bplayers_new, server_bplayers_org);
	}
#endif
#else
	if(!max_players_server_browser) {
		max_players_server_browser = find_signature(server_bplayers, &base_addr, 0);
		get_original_signature(max_players_server_browser, server_bplayers_new, server_bplayers_org);
	}
#endif

	return true;
}
bool CSourceMMMAP::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
	PLUGIN_SAVEVARS();

	//char iface_buffer[255];
	//int num = 0;
#ifdef GAME_ORANGE
	GET_V_IFACE(GetServerFactory, playerinfomanager, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
	GET_V_IFACE(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
	GET_V_IFACE(GetEngineFactory, gameeventmanager, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
	GET_V_IFACE(GetEngineFactory, filesystem, IFileSystem, FILESYSTEM_INTERFACE_VERSION);
	GET_V_IFACE(GetEngineFactory, helpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
	GET_V_IFACE(GetEngineFactory, networkstringtable, INetworkStringTableContainer, INTERFACENAME_NETWORKSTRINGTABLESERVER);
	GET_V_IFACE(GetEngineFactory, enginetrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER);
	GET_V_IFACE(GetEngineFactory, randomStr, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
	GET_V_IFACE(GetServerFactory, serverents, IServerGameEnts, INTERFACEVERSION_SERVERGAMEENTS);
	GET_V_IFACE(GetServerFactory, effects, IEffects, IEFFECTS_INTERFACE_VERSION);
	GET_V_IFACE(GetEngineFactory, esounds, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
	GET_V_IFACE(GetServerFactory, serverdll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
	GET_V_IFACE(GetEngineFactory, voiceserver, IVoiceServer, INTERFACEVERSION_VOICESERVER);
	GET_V_IFACE(GetServerFactory, serverclients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
	g_pCVar = GetICVar();
#else
	GET_V_IFACE(serverFactory, playerinfomanager, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
	GET_V_IFACE(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
	GET_V_IFACE(engineFactory, gameeventmanager, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
	GET_V_IFACE(engineFactory, filesystem, IFileSystem, FILESYSTEM_INTERFACE_VERSION);
	GET_V_IFACE(engineFactory, helpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
	GET_V_IFACE(engineFactory, networkstringtable, INetworkStringTableContainer, INTERFACENAME_NETWORKSTRINGTABLESERVER);
	GET_V_IFACE(engineFactory, enginetrace, IEngineTrace, INTERFACEVERSION_ENGINETRACE_SERVER);
	GET_V_IFACE(engineFactory, randomStr, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
	GET_V_IFACE(serverFactory, serverents, IServerGameEnts, INTERFACEVERSION_SERVERGAMEENTS);
	GET_V_IFACE(serverFactory, effects, IEffects, IEFFECTS_INTERFACE_VERSION);
	GET_V_IFACE(engineFactory, esounds, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
	GET_V_IFACE(engineFactory, g_pCVar, ICvar, VENGINE_CVAR_INTERFACE_VERSION);
	GET_V_IFACE(serverFactory, serverdll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
	GET_V_IFACE(engineFactory, voiceserver, IVoiceServer, INTERFACEVERSION_VOICESERVER);
	GET_V_IFACE(serverFactory, serverclients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
#endif
	ConVar *testload = g_pCVar->FindVar("mani_admin_plugin_version");
	if ( testload ) {
		MMsg( "Error:  Version %s of Mani Admin Plugin is already loaded.\n", testload->GetString() );
		return false;
	}

	META_LOG(g_PLAPI, "Starting plugin.\n");

	ismm->AddListener(this, &g_Listener);

	//Init our cvars/concmds
#if defined GAME_ORANGE
	ConVar_Register(0, this);
#else
	ConCommandBaseMgr::OneTimeInit(this);
#endif
	//We're hooking the following things as POST, in order to seem like Server Plugins.
	//However, I don't actually know if Valve has done server plugins as POST or not.
	//Change the last parameter to 'false' in order to change this to PRE.
	//SH_ADD_HOOK_MEMFUNC means "SourceHook, Add Hook, Member Function".

	//Hook LevelInit to our function
	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, serverdll, &g_ManiCallback, &CSourceMMMAP::LevelInit, false);
	//Hook ServerActivate to our function
	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, serverdll, &g_ManiCallback, &CSourceMMMAP::ServerActivate, true);
	//Hook GameFrame to our function
	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, GameFrame, serverdll, &g_ManiCallback, &CSourceMMMAP::GameFrame, true);
	//Hook LevelShutdown to our function -- this makes more sense as pre I guess
	SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, serverdll, &g_ManiCallback, &CSourceMMMAP::LevelShutdown, false);
	//Hook ClientActivate to our function
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientActive, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientActive, false);
	//Hook ClientDisconnect to our function
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientDisconnect, false);
	//Hook ClientPutInServer to our function
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientPutInServer, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientPutInServer, true);
	//Hook SetCommandClient to our function
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, SetCommandClient, serverclients, &g_ManiCallback, &CSourceMMMAP::SetCommandClient, true);
	//Hook ClientSettingsChanged to our function
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientSettingsChanged, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientSettingsChanged, true);

	//The following functions are pre handled, because that's how they are in IServerPluginCallbacks
	//Hook ClientConnect to our function
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientConnect, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientConnect, false);
	//Hook ClientCommand to our function
	SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientCommand, serverclients, &g_ManiCallback, &CSourceMMMAP::ClientCommand, false);

	//This hook is a static hook, no member function
	//SH_ADD_HOOK_STATICFUNC(IGameEventManager2, FireEvent, gameeventmanager, FireEvent_Handler, false); 
#if !defined GAME_ORANGE && defined SOURCEMM
	//Get the call class for IVServerEngine so we can safely call functions without
	// invoking their hooks (when needed).
	engine_cc = SH_GET_CALLCLASS(engine);
	voiceserver_cc = SH_GET_CALLCLASS(voiceserver);
	serverdll_cc = SH_GET_CALLCLASS(serverdll);
#endif


#ifdef GAME_ORANGE 
	gamedll = g_SMAPI->GetServerFactory(false);
#else
	gamedll = g_SMAPI->serverFactory(false);
#endif

	g_SMAPI->AddListener(g_PLAPI, this);

#ifdef GAME_ORANGE 
	gpGlobals = g_SMAPI->GetCGlobals();
#else
	gpGlobals = g_SMAPI->pGlobals();
#endif

	FindConPrintf();

	MMsg("********************************************************\n");
	MMsg(" Loading ");
	MMsg("%s\n", mani_version);
	MMsg("\n");

	if (!UTIL_InterfaceMsg(playerinfomanager,"IPlayerInfoManager", INTERFACEVERSION_PLAYERINFOMANAGER)) return false;
	if (!UTIL_InterfaceMsg(engine,"IVEngineServer", INTERFACEVERSION_VENGINESERVER)) return false;
	if (!UTIL_InterfaceMsg(gameeventmanager,"IGameEventManager2", INTERFACEVERSION_GAMEEVENTSMANAGER2)) return false;
	if (!UTIL_InterfaceMsg(filesystem,"IFileSystem", FILESYSTEM_INTERFACE_VERSION)) return false;
	if (!UTIL_InterfaceMsg(helpers,"IServerPluginHelpers", INTERFACEVERSION_ISERVERPLUGINHELPERS)) return false;
	if (!UTIL_InterfaceMsg(networkstringtable,"INetworkStringTableContainer", INTERFACENAME_NETWORKSTRINGTABLESERVER)) return false;
	if (!UTIL_InterfaceMsg(enginetrace,"IEngineTrace", INTERFACEVERSION_ENGINETRACE_SERVER)) return false;
	if (!UTIL_InterfaceMsg(randomStr,"IUniformRandomStream", VENGINE_SERVER_RANDOM_INTERFACE_VERSION)) return false;
	if (!UTIL_InterfaceMsg(serverents,"IServerGameEnts", INTERFACEVERSION_SERVERGAMEENTS)) return false;
	if (!UTIL_InterfaceMsg(effects,"IEffects", IEFFECTS_INTERFACE_VERSION)) return false;
	if (!UTIL_InterfaceMsg(esounds,"IEngineSound", IENGINESOUND_SERVER_INTERFACE_VERSION)) return false;

#ifdef GAME_ORANGE 
	if (!UTIL_InterfaceMsg(g_pCVar,"ICvar", CVAR_INTERFACE_VERSION)) return false;
#else
	if (!UTIL_InterfaceMsg(g_pCVar,"ICvar", VENGINE_CVAR_INTERFACE_VERSION)) return false;
#endif

	if (!UTIL_InterfaceMsg(serverdll,"IServerGameDLL", "ServerGameDLL003")) return false;
	if (!UTIL_InterfaceMsg(voiceserver,"IVoiceServer", INTERFACEVERSION_VOICESERVER)) return false;
	//if (!UTIL_InterfaceMsg(partition,"ISpatialPartition", INTERFACEVERSION_SPATIALPARTITION)) return false;

	MMsg("********************************************************\n");

	// max players = 0 on first load, > 0 on late load
	max_players = gpGlobals->maxClients;
	if (late)
	{
		HookConCommands();
	}

	gpManiAdminPlugin->Load();

	return true;
}