plugins/include/admin.inc
changeset 433 d699e31199ad
parent 421 81aa2cce0002
child 436 ffadb284461e
     1.1 --- a/plugins/include/admin.inc	Mon Feb 05 08:58:03 2007 +0000
     1.2 +++ b/plugins/include/admin.inc	Mon Feb 05 09:14:40 2007 +0000
     1.3 @@ -17,27 +17,71 @@
     1.4  #endif
     1.5  #define _admin_included
     1.6  
     1.7 +/**
     1.8 + * Access levels (flags) for admins.
     1.9 + */
    1.10  enum AdminFlag
    1.11  {
    1.12 -	Admin_None = 0,			/* Unused */
    1.13 -	Admin_Reservation,		/* Reserved slot */
    1.14 -	Admin_Kick,				/* Kick another user */
    1.15 -	Admin_Ban,				/* Ban another user */
    1.16 -	Admin_Unban,			/* Unban another user */
    1.17 -	Admin_Slay,				/* Slay/kill/damage another user */
    1.18 -	Admin_Changemap,		/* Change the map */
    1.19 -	Admin_Convars,			/* Change basic convars */
    1.20 -	Admin_Configs,			/* Change configs */
    1.21 -	Admin_Chat,				/* Special chat privileges */
    1.22 -	Admin_Vote,				/* Special vote privileges */
    1.23 -	Admin_Password,			/* Set a server password */
    1.24 -	Admin_RCON,				/* Use RCON */
    1.25 -	Admin_Cheats,			/* Change sv_cheats and use its commands */
    1.26 -	Admin_Root,				/* Root access */
    1.27 +	Admin_Reservation = 0,	/**< Reserved slot */
    1.28 +	Admin_Generic,			/**< Generic admin abilities */
    1.29 +	Admin_Kick,				/**< Kick another user */
    1.30 +	Admin_Ban,				/**< Ban another user */
    1.31 +	Admin_Unban,			/**< Unban another user */
    1.32 +	Admin_Slay,				/**< Slay/kill/damage another user */
    1.33 +	Admin_Changemap,		/**< Change the map */
    1.34 +	Admin_Convars,			/**< Change basic convars */
    1.35 +	Admin_Config,			/**< Change configuration */
    1.36 +	Admin_Chat,				/**< Special chat privileges */
    1.37 +	Admin_Vote,				/**< Special vote privileges */
    1.38 +	Admin_Password,			/**< Set a server password */
    1.39 +	Admin_RCON,				/**< Use RCON */
    1.40 +	Admin_Cheats,			/**< Change sv_cheats and use its commands */
    1.41 +	Admin_Root,				/**< All access by default */
    1.42 +	Admin_Custom1,			/**< First custom flag type */
    1.43 +	Admin_Custom2,			/**< Second custom flag type */
    1.44 +	Admin_Custom3,			/**< Third custom flag type */
    1.45 +	Admin_Custom4,			/**< Fourth custom flag type */
    1.46 +	Admin_Custom5,			/**< Fifth custom flag type */
    1.47 +	Admin_Custom6,			/**< Sixth custom flag type */
    1.48  	/* --- */
    1.49  	AdminFlags_TOTAL,
    1.50  };
    1.51  
    1.52 +/**
    1.53 + * These define bitwise values for bitstrings (numbers containing bitwise flags).
    1.54 + */
    1.55 +#define ADMFLAG_RESERVATION			(1<<0)		/**< Convenience macro for Admin_Reservation as a FlagBit */
    1.56 +#define ADMFLAG_GENERIC				(1<<1)		/**< Convenience macro for Admin_Generic as a FlagBit */
    1.57 +#define ADMFLAG_KICK				(1<<2)		/**< Convenience macro for Admin_Kick as a FlagBit */
    1.58 +#define ADMFLAG_BAN					(1<<3)		/**< Convenience macro for Admin_Ban as a FlagBit */
    1.59 +#define ADMFLAG_UNBAN				(1<<4)		/**< Convenience macro for Admin_Unban as a FlagBit */
    1.60 +#define ADMFLAG_SLAY				(1<<5)		/**< Convenience macro for Admin_Slay as a FlagBit */
    1.61 +#define ADMFLAG_CHANGEMAP			(1<<6)		/**< Convenience macro for Admin_Changemap as a FlagBit */
    1.62 +#define ADMFLAG_CONVARS				(1<<7)		/**< Convenience macro for Admin_Convars as a FlagBit */
    1.63 +#define ADMFLAG_CONFIG				(1<<8)		/**< Convenience macro for Admin_Config as a FlagBit */
    1.64 +#define ADMFLAG_CHAT				(1<<9)		/**< Convenience macro for Admin_Chat as a FlagBit */
    1.65 +#define ADMFLAG_VOTE				(1<<10)		/**< Convenience macro for Admin_Vote as a FlagBit */
    1.66 +#define ADMFLAG_PASSWORD			(1<<11)		/**< Convenience macro for Admin_Password as a FlagBit */
    1.67 +#define ADMFLAG_RCON				(1<<12)		/**< Convenience macro for Admin_RCON as a FlagBit */
    1.68 +#define ADMFLAG_CHEATS				(1<<13)		/**< Convenience macro for Admin_Cheats as a FlagBit */
    1.69 +#define ADMFLAG_ROOT				(1<<14)		/**< Convenience macro for Admin_Root as a FlagBit */
    1.70 +#define ADMFLAG_CUSTOM1				(1<<15)		/**< Convenience macro for Admin_Custom1 as a FlagBit */
    1.71 +#define ADMFLAG_CUSTOM2				(1<<16)		/**< Convenience macro for Admin_Custom2 as a FlagBit */
    1.72 +#define ADMFLAG_CUSTOM3				(1<<17)		/**< Convenience macro for Admin_Custom3 as a FlagBit */
    1.73 +#define ADMFLAG_CUSTOM4				(1<<18)		/**< Convenience macro for Admin_Custom4 as a FlagBit */
    1.74 +#define ADMFLAG_CUSTOM5				(1<<19)		/**< Convenience macro for Admin_Custom5 as a FlagBit */
    1.75 +#define ADMFLAG_CUSTOM6				(1<<20)		/**< Convenience macro for Admin_Custom6 as a FlagBit */
    1.76 +
    1.77 +stock FlagToBit(AdminFlag:flag)
    1.78 +{
    1.79 +	return (1<<_:flag);
    1.80 +}
    1.81 +
    1.82 +stock AdminFlag:BitToFlag(bit)
    1.83 +{
    1.84 +	/* :TODO: implement */
    1.85 +}
    1.86 +
    1.87  enum OverrideType
    1.88  {
    1.89  	Override_Command = 1,	/* Command */
    1.90 @@ -95,20 +139,20 @@
    1.91   *
    1.92   * @param cmd			String containing command name (case sensitive).
    1.93   * @param type			Override type (specific command or group).
    1.94 - * @param flag			New admin flag.
    1.95 + * @param flags			New admin flag.
    1.96   * @noreturn
    1.97   */
    1.98 -native AddCommandOverride(const String:cmd[], OverrideType:type, AdminFlag:flag);
    1.99 +native AddCommandOverride(const String:cmd[], OverrideType:type, flags);
   1.100  
   1.101  /**
   1.102   * Returns a command override.
   1.103   *
   1.104   * @param cmd			String containing command name (case sensitive).
   1.105   * @param type			Override type (specific command or group).
   1.106 - * @param pFlag			By-reference cell to store the flag (undefined if not found).
   1.107 + * @param flags			By-reference cell to store the flag (undefined if not found).
   1.108   * @return				True if there is an override, false otherwise.
   1.109   */
   1.110 -native bool:GetCommandOverride(const String:cmd[], OverrideType:type, &AdminFlag:flag);
   1.111 +native bool:GetCommandOverride(const String:cmd[], OverrideType:type, &flags);
   1.112  
   1.113  /**
   1.114   * Unsets a command override.
   1.115 @@ -161,11 +205,9 @@
   1.116   * @note These are called "add flags" because they add to a user's flags.
   1.117   *
   1.118   * @param id			GroupId of the group.
   1.119 - * @param flags			Array to store flags in.
   1.120 - * @param total			Total number of flags that can be stored in the array (AdminFlags_TOTAL, usually).
   1.121 - * @return				Number of flags that were written to the array.
   1.122 + * @return				Bitstring containing the flags enabled.
   1.123   */
   1.124 -native GetAdmGroupAddFlagBits(GroupId:id, bool:flags[], total);
   1.125 +native GetAdmGroupAddFlags(GroupId:id);
   1.126  
   1.127  /**
   1.128   * Toggles a generic immunity type.