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