1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2024-12-03 15:24:15 +01:00
HLMetaModOfficial/sourcemm/sample_mm/SamplePlugin.cpp
David Anderson 7eecefe875 Updated for API 004, also added sourcehook stuff again
--HG--
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%4021
2005-04-18 19:33:44 +00:00

51 lines
1.4 KiB
C++

#include <oslink.h>
#include "SamplePlugin.h"
SamplePlugin g_SamplePlugin;
PLUGIN_EXPOSE(SamplePlugin, g_SamplePlugin);
SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, 0, bool, char const *, char const *, char const *, char const *, bool, bool);
bool LevelInit_handler( char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background );
bool SamplePlugin::Load(PluginId id, ISmmAPI *ismm, factories *list, char *error, size_t maxlen)
{
PLUGIN_SAVEVARS();
IServerGameDLL *isgd = (IServerGameDLL *)((ismm->serverFactory())(INTERFACEVERSION_SERVERGAMEDLL, NULL));
if (!isgd)
{
snprintf(error, maxlen, "Could not find interface %s", INTERFACEVERSION_SERVERGAMEDLL);
return false;
}
SH_ADD_HOOK_STATICFUNC(IServerGameDLL, LevelInit, isgd, LevelInit_handler, false);
return true;
}
bool SamplePlugin::Unload(char *error, size_t maxlen)
{
return true;
}
void SamplePlugin::AllPluginsLoaded()
{
//we don't really care
}
bool LevelInit_handler( char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background )
{
FILE *fp = fopen("c:\\dump.txt", "at");
if (!fp)
RETURN_META_VALUE(MRES_IGNORED, false);
fprintf(fp, "Map name: %s (old level: %s)\n", pMapName?pMapName:"", pOldLevel?pOldLevel:"");
fclose(fp);
RETURN_META_VALUE(MRES_IGNORED, false);
}