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