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