sourcemm/sample_mm/SamplePlugin.h
author David Anderson <dvander@alliedmods.net>
Sat Apr 30 18:45:41 2005 +0000 (2005-04-30)
changeset 44 935c3ec3baf5
parent 35 78188da97068
child 68 5433659a62ae
permissions -rw-r--r--
committed new callclass code
     1 /* ======== sample_mm ========
     2 * Copyright (C) 2004-2005 Metamod:Source Development Team
     3 * No warranties of any kind
     4 *
     5 * License: zlib/libpng
     6 *
     7 * Author(s): David "BAILOPAN" Anderson
     8 * ============================
     9 */
    10 
    11 #ifndef _INCLUDE_SAMPLEPLUGIN_H
    12 #define _INCLUDE_SAMPLEPLUGIN_H
    13 
    14 #include <ISmmPlugin.h>
    15 #include <sourcehook/sourcehook.h>
    16 
    17 class SamplePlugin : public ISmmPlugin
    18 {
    19 public:
    20 	bool Load(PluginId id, ISmmAPI *ismm, factories *list, char *error, size_t maxlen);
    21 	bool Unload(char *error, size_t maxlen);
    22 	void AllPluginsLoaded();
    23 	bool Pause(char *error, size_t maxlen)
    24 	{
    25 		return true;
    26 	}
    27 	bool Unpause(char *error, size_t maxlen)
    28 	{
    29 		return true;
    30 	}
    31 public:
    32 	int GetApiVersion() { return PLAPI_VERSION; }
    33 public:
    34 	const char *GetAuthor()
    35 	{
    36 		return "BAILOPAN";
    37 	}
    38 	const char *GetName()
    39 	{
    40 		return "Sample Plugin";
    41 	}
    42 	const char *GetDescription()
    43 	{
    44 		return "Sample plugin that hooks basic things";
    45 	}
    46 	const char *GetURL()
    47 	{
    48 		return "http://www.sourcemm.net/";
    49 	}
    50 	const char *GetLicense()
    51 	{
    52 		return "zlib/libpng";
    53 	}
    54 	const char *GetVersion()
    55 	{
    56 		return "1.00";
    57 	}
    58 	const char *GetDate()
    59 	{
    60 		return __DATE__;
    61 	}
    62 	const char *GetLogTag()
    63 	{
    64 		return "SAMPLE";
    65 	}
    66 public:
    67 	//These functions are from IServerPluginCallbacks
    68 	//Note, the parameters might be a little different to match the actual calls!
    69 
    70 	//Called on LevelInit.  Server plugins only have pMapName
    71 	bool LevelInit(const char *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
    72 
    73 	//Called on ServerActivate.  Same definition as server plugins
    74 	void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
    75 
    76 	//Called on a game tick.  Same definition as server plugins
    77 	void GameFrame(bool simulating);
    78 
    79 	//Called on level shutdown.  Same definition as server plugins 
    80 	void LevelShutdown(void);
    81 
    82 	//Client is activate (whatever that means).  We get an extra parameter...
    83 	// "If bLoadGame is true, don't spawn the player because its state is already setup."
    84 	void ClientActive(edict_t *pEntity, bool bLoadGame);
    85 
    86 	//Client disconnects - same as server plugins
    87 	void ClientDisconnect(edict_t *pEntity);
    88 
    89 	//Client is put in server - same as server plugins
    90 	void ClientPutInServer(edict_t *pEntity, char const *playername);
    91 
    92 	//Sets the client index - same as server plugins
    93 	void SetCommandClient(int index);
    94 
    95 	//Called on client settings changed (duh) - same as server plugins
    96 	void ClientSettingsChanged(edict_t *pEdict);
    97 
    98 	//Called on client connect.  Unlike server plugins, we return whether the 
    99 	// connection is allowed rather than set it through a pointer in the first parameter.
   100 	// You can still supercede the GameDLL through RETURN_META_VALUE(MRES_SUPERCEDE, true/false)
   101 	bool ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
   102 
   103 	//Called when a client uses a command.  Unlike server plugins, it's void.
   104 	// You can still supercede the gamedll through RETURN_META(MRES_SUPERCEDE).
   105 	void ClientCommand(edict_t *pEntity);
   106 
   107 private:
   108 	IVEngineServer *m_Engine;
   109 	IServerGameDLL *m_ServerDll;
   110 	IServerGameClients *m_ServerClients;
   111 	SourceHook::CallClass<IVEngineServer> *m_Engine_CC;
   112 };
   113 
   114 extern SamplePlugin g_SamplePlugin;
   115 PLUGIN_GLOBALVARS();
   116 
   117 #endif //_INCLUDE_SAMPLEPLUGIN_H