extensions/batsupport/BATInterface.h
author Scott Ehlert <ds@alliedmods.net>
Sun Jul 15 08:00:26 2007 +0000 (2007-07-15)
changeset 1116 40cc5e9f0f1b
parent 543 191d60152a7b
child 1947 e73a1e51833b
permissions -rw-r--r--
Removed strange debugging code
     1 /* ======== Basic Admin tool ========
     2 * Copyright (C) 2004-2006 Erling K. S�terdal
     3 * No warranties of any kind
     4 *
     5 * License: zlib/libpng
     6 *
     7 * Author(s): Erling K. S�terdal ( EKS )
     8 * Credits:
     9 *	Menu code based on code from CSDM ( http://www.tcwonline.org/~dvander/cssdm ) Created by BAILOPAN
    10 *	Helping on misc errors/functions: BAILOPAN,LDuke,sslice,devicenull,PMOnoTo,cybermind ( most who idle in #sourcemod on GameSurge realy )
    11 * ============================ */
    12 
    13 #ifndef _INCLUDE_BATINTERFACE
    14 #define _INCLUDE_BATINTERFACE
    15 #include <ISmmPlugin.h>
    16 
    17 #define ADMININTERFACE_VERSION 0
    18 #define ADMININTERFACE_MAXACCESSLENGTHTEXT 50		// This is the maximum length of a "flag" access text.
    19 
    20 //#include "BATMenu.h"
    21 
    22 //extern menuId g_AdminMenu;
    23 class AdminInterfaceListner
    24 {
    25 public:
    26 	virtual void OnAdminInterfaceUnload()=0;
    27 	virtual void Client_Authorized(int id)=0;
    28 };
    29 
    30 class AdminInterface
    31 {
    32 public:
    33 	virtual bool RegisterFlag(const char *Class,const char *Flag,const char *Description) = 0; // Registers a new admin access
    34 	virtual bool IsClient(int id) = 0;				// returns false if client is bot, or NOT connected
    35 	virtual bool HasFlag(int id,const char *Flag) = 0;	// returns true if the player has this access flag, lower case only
    36 	virtual int GetInterfaceVersion() = 0 ;		// Returns the interface version of the admin mod
    37 	virtual const char* GetModName() = 0;			// Returns the name of the current admin mod
    38 	virtual void AddEventListner(AdminInterfaceListner *ptr) = 0; // You should ALLWAYS set this, so you know when the "server"  plugin gets unloaded
    39 	virtual void RemoveListner(AdminInterfaceListner *ptr) = 0;   // You MUST CALL this function in your plugin unloads function, or the admin plugin will crash on next client connect.
    40 };
    41 
    42 class BATAdminInterface : public AdminInterface
    43 {
    44 public:
    45 	bool RegisterFlag(const char *Class,const char *Flag,const char *Description); // Max 1 admin access at the time, returns true if done successfully
    46 	bool IsClient(int id);		// returns false if client is bot, or NOT connected
    47 	bool HasFlag(int id,const char *Flag);	// returns true if the player has this access flag
    48 	int GetInterfaceVersion() { return ADMININTERFACE_VERSION; } // Returns the interface version of the admin mod
    49 	const char* GetModName() { return "BAT"; }		// Returns the name of the current admin mod
    50 	void AddEventListner(AdminInterfaceListner *ptr); // You should ALLWAYS set this, so you know when the "server"  plugin gets unloaded
    51 	void RemoveListner(AdminInterfaceListner *ptr);
    52 private:
    53 	char GetFlagFromInt(int CharIndex);
    54 	bool CustomAccessExistence(const char *Flag);
    55 };
    56 class MyListener : public IMetamodListener
    57 {
    58 public:
    59 	virtual void *OnMetamodQuery(const char *iface, int *ret);
    60 };
    61 #endif
    62