plugins/include/admin.inc
author Scott Ehlert <ds@alliedmods.net>
Fri Apr 11 17:16:36 2008 +0000 (2008-04-11)
changeset 1990 de135d1f05b1
parent 1952 b7aa2b626807
child 2289 44045ead61cd
permissions -rw-r--r--
Added more missing svn:keywords properties to some files (this should be the last of them before I never have to do this again)
Moved sm_memtable files in sqlite extension to sdk directory (to be consistent with topmenus)
Some extension source files had an incorrect extension name in their headers
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     5  * =============================================================================
     6  *
     7  * This file is part of the SourceMod/SourcePawn SDK.
     8  *
     9  * This program is free software; you can redistribute it and/or modify it under
    10  * the terms of the GNU General Public License, version 3.0, as published by the
    11  * Free Software Foundation.
    12  * 
    13  * This program is distributed in the hope that it will be useful, but WITHOUT
    14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    16  * details.
    17  *
    18  * You should have received a copy of the GNU General Public License along with
    19  * this program.  If not, see <http://www.gnu.org/licenses/>.
    20  *
    21  * As a special exception, AlliedModders LLC gives you permission to link the
    22  * code of this program (as well as its derivative works) to "Half-Life 2," the
    23  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    24  * by the Valve Corporation.  You must obey the GNU General Public License in
    25  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    26  * this exception to all derivative works.  AlliedModders LLC defines further
    27  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    28  * or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32  
    33 #if defined _admin_included
    34  #endinput
    35 #endif
    36 #define _admin_included
    37 
    38 /**
    39  * Access levels (flags) for admins.
    40  */
    41 enum AdminFlag
    42 {
    43 	Admin_Reservation = 0,	/**< Reserved slot */
    44 	Admin_Generic,			/**< Generic admin abilities */
    45 	Admin_Kick,				/**< Kick another user */
    46 	Admin_Ban,				/**< Ban another user */
    47 	Admin_Unban,			/**< Unban another user */
    48 	Admin_Slay,				/**< Slay/kill/damage another user */
    49 	Admin_Changemap,		/**< Change the map */
    50 	Admin_Convars,			/**< Change basic convars */
    51 	Admin_Config,			/**< Change configuration */
    52 	Admin_Chat,				/**< Special chat privileges */
    53 	Admin_Vote,				/**< Special vote privileges */
    54 	Admin_Password,			/**< Set a server password */
    55 	Admin_RCON,				/**< Use RCON */
    56 	Admin_Cheats,			/**< Change sv_cheats and use its commands */
    57 	Admin_Root,				/**< All access by default */
    58 	Admin_Custom1,			/**< First custom flag type */
    59 	Admin_Custom2,			/**< Second custom flag type */
    60 	Admin_Custom3,			/**< Third custom flag type */
    61 	Admin_Custom4,			/**< Fourth custom flag type */
    62 	Admin_Custom5,			/**< Fifth custom flag type */
    63 	Admin_Custom6,			/**< Sixth custom flag type */
    64 	/* --- */
    65 };
    66 
    67 #define AdminFlags_TOTAL	21		/**< Total number of admin flags */
    68 
    69 /**
    70  * @section Bitwise values definitions for admin flags.
    71  */
    72 #define ADMFLAG_RESERVATION			(1<<0)		/**< Convenience macro for Admin_Reservation as a FlagBit */
    73 #define ADMFLAG_GENERIC				(1<<1)		/**< Convenience macro for Admin_Generic as a FlagBit */
    74 #define ADMFLAG_KICK				(1<<2)		/**< Convenience macro for Admin_Kick as a FlagBit */
    75 #define ADMFLAG_BAN					(1<<3)		/**< Convenience macro for Admin_Ban as a FlagBit */
    76 #define ADMFLAG_UNBAN				(1<<4)		/**< Convenience macro for Admin_Unban as a FlagBit */
    77 #define ADMFLAG_SLAY				(1<<5)		/**< Convenience macro for Admin_Slay as a FlagBit */
    78 #define ADMFLAG_CHANGEMAP			(1<<6)		/**< Convenience macro for Admin_Changemap as a FlagBit */
    79 #define ADMFLAG_CONVARS				(1<<7)		/**< Convenience macro for Admin_Convars as a FlagBit */
    80 #define ADMFLAG_CONFIG				(1<<8)		/**< Convenience macro for Admin_Config as a FlagBit */
    81 #define ADMFLAG_CHAT				(1<<9)		/**< Convenience macro for Admin_Chat as a FlagBit */
    82 #define ADMFLAG_VOTE				(1<<10)		/**< Convenience macro for Admin_Vote as a FlagBit */
    83 #define ADMFLAG_PASSWORD			(1<<11)		/**< Convenience macro for Admin_Password as a FlagBit */
    84 #define ADMFLAG_RCON				(1<<12)		/**< Convenience macro for Admin_RCON as a FlagBit */
    85 #define ADMFLAG_CHEATS				(1<<13)		/**< Convenience macro for Admin_Cheats as a FlagBit */
    86 #define ADMFLAG_ROOT				(1<<14)		/**< Convenience macro for Admin_Root as a FlagBit */
    87 #define ADMFLAG_CUSTOM1				(1<<15)		/**< Convenience macro for Admin_Custom1 as a FlagBit */
    88 #define ADMFLAG_CUSTOM2				(1<<16)		/**< Convenience macro for Admin_Custom2 as a FlagBit */
    89 #define ADMFLAG_CUSTOM3				(1<<17)		/**< Convenience macro for Admin_Custom3 as a FlagBit */
    90 #define ADMFLAG_CUSTOM4				(1<<18)		/**< Convenience macro for Admin_Custom4 as a FlagBit */
    91 #define ADMFLAG_CUSTOM5				(1<<19)		/**< Convenience macro for Admin_Custom5 as a FlagBit */
    92 #define ADMFLAG_CUSTOM6				(1<<20)		/**< Convenience macro for Admin_Custom6 as a FlagBit */
    93 
    94 /**
    95  * @endsection
    96  */
    97 
    98 /**
    99  * @section Hardcoded authentication methods 
   100  */
   101 #define AUTHMETHOD_STEAM			"steam"		/**< SteamID based authentication */
   102 #define AUTHMETHOD_IP				"ip"		/**< IP based authentication */
   103 #define AUTHMETHOD_NAME				"name"		/**< Name based authentication */
   104 
   105 /**
   106  * @endsection
   107  */
   108 
   109 /**
   110  * Access override types.
   111  */
   112 enum OverrideType
   113 {
   114 	Override_Command = 1,	/**< Command */
   115 	Override_CommandGroup,	/**< Command group */
   116 };
   117 
   118 /**
   119  * Access override rules.
   120  */
   121 enum OverrideRule
   122 {
   123 	Command_Deny = 0,
   124 	Command_Allow = 1,
   125 };
   126 
   127 /**
   128  * DEPRECATED, do not use.
   129  */
   130 enum ImmunityType
   131 {
   132 	Immunity_Default = 1,	/**< Deprecated. */
   133 	Immunity_Global,		/**< Deprecated. */
   134 };
   135 
   136 /** 
   137  * Identifies a unique entry in the group permissions cache.  These are not Handles.
   138  */
   139 enum GroupId
   140 {
   141 	INVALID_GROUP_ID = -1,	/**< An invalid/nonexistant group */
   142 };
   143 
   144 /** 
   145  * Identifies a unique entry in the admin permissions cache.  These are not Handles.
   146  */
   147 enum AdminId
   148 {
   149 	INVALID_ADMIN_ID = -1,	/**< An invalid/nonexistant admin */
   150 };
   151 
   152 /**
   153  * Methods of computing access permissions.
   154  */
   155 enum AdmAccessMode
   156 {
   157 	Access_Real,		/**< Access the user has inherently */
   158 	Access_Effective,	/**< Access the user has from their groups */
   159 };
   160 
   161 /**
   162  * Represents the various cache regions.
   163  */
   164 enum AdminCachePart
   165 {
   166 	AdminCache_Overrides = 0,		/**< Global overrides */
   167 	AdminCache_Groups = 1,			/**< All groups (automatically invalidates admins too) */
   168 	AdminCache_Admins = 2,			/**< All admins */
   169 };
   170 
   171 /**
   172  * Called when part of the cache which needs to be rebuilt.
   173  *
   174  * @param part			Part of the admin cache to rebuild.
   175  */
   176 forward OnRebuildAdminCache(AdminCachePart:part);
   177 
   178 /**
   179  * Tells the admin system to dump a portion of the cache.
   180  *
   181  * @param part			Part of the cache to dump.  Specifying groups also dumps admins.
   182  * @param rebuild		If true, the rebuild forwards will fire.
   183  * @noreturn
   184  */
   185 native DumpAdminCache(AdminCachePart:part, bool:rebuild);
   186 
   187 /**
   188  * Adds a global command flag override.  Any command registered with this name
   189  * will assume the new flag.  This is applied retroactively as well.
   190  *
   191  * @param cmd			String containing command name (case sensitive).
   192  * @param type			Override type (specific command or group).
   193  * @param flags			New admin flag.
   194  * @noreturn
   195  */
   196 native AddCommandOverride(const String:cmd[], OverrideType:type, flags);
   197 
   198 /**
   199  * Returns a command override.
   200  *
   201  * @param cmd			String containing command name (case sensitive).
   202  * @param type			Override type (specific command or group).
   203  * @param flags			By-reference cell to store the flag (undefined if not found).
   204  * @return				True if there is an override, false otherwise.
   205  */
   206 native bool:GetCommandOverride(const String:cmd[], OverrideType:type, &flags);
   207 
   208 /**
   209  * Unsets a command override.
   210  *
   211  * @param cmd			String containing command name (case sensitive).
   212  * @param type			Override type (specific command or group).
   213  * @noreturn
   214  */
   215 native UnsetCommandOverride(const String:cmd[], OverrideType:type);
   216 
   217 /**
   218  * Adds a new group.  Name must be unique.
   219  *
   220  * @param group_name	String containing the group name.
   221  * @return				A new group id, INVALID_GROUP_ID if it already exists.
   222  */
   223 native GroupId:CreateAdmGroup(const String:group_name[]);
   224 
   225 /**
   226  * Finds a group by name.
   227  *
   228  * @param group_name	String containing the group name.
   229  * @return				A group id, or INVALID_GROUP_ID if not found.
   230  */
   231 native GroupId:FindAdmGroup(const String:group_name[]);
   232 
   233 /**
   234  * Adds or removes a flag from a group's flag set.
   235  * @note These are called "add flags" because they add to a user's flags.
   236  *
   237  * @param id			Group id.
   238  * @param flag			Admin flag to toggle.
   239  * @param enabled		True to set the flag, false to unset/disable.
   240  * @noreturn
   241  */
   242 native SetAdmGroupAddFlag(GroupId:id, AdminFlag:flag, bool:enabled);
   243 
   244 /**
   245  * Gets the set value of an add flag on a group's flag set.
   246  * @note These are called "add flags" because they add to a user's flags.
   247  *
   248  * @param id			Group id.
   249  * @param flag			Admin flag to retrieve.
   250  * @return				True if enabled, false otherwise,
   251  */
   252 native bool:GetAdmGroupAddFlag(GroupId:id, AdminFlag:flag);
   253 
   254 /**
   255  * Returns the flag set that is added to a user from their group.
   256  * @note These are called "add flags" because they add to a user's flags.
   257  *
   258  * @param id			GroupId of the group.
   259  * @return				Bitstring containing the flags enabled.
   260  */
   261 native GetAdmGroupAddFlags(GroupId:id);
   262 
   263 /**
   264  * @deprecated			Functionality removed.
   265  */
   266 #pragma deprecated Use SetAdmGroupImmunityLevel() instead.
   267 native SetAdmGroupImmunity(GroupId:id, ImmunityType:type, bool:enabled);
   268 
   269 /**
   270  * @deprecated			Functionality removed.
   271  */
   272 #pragma deprecated Use GetAdmGroupImmunityLevel() instead.
   273 native bool:GetAdmGroupImmunity(GroupId:id, ImmunityType:type);
   274 
   275 /**
   276  * Adds immunity to a specific group.
   277  *
   278  * @param id			Group id.
   279  * @param other_id		Group id to receive immunity to.
   280  * @noreturn
   281  */
   282 native SetAdmGroupImmuneFrom(GroupId:id, GroupId:other_id);
   283 
   284 /**
   285  * Returns the number of specific group immunities.
   286  *
   287  * @param id			Group id.
   288  * @return				Number of group immunities.
   289  */
   290 native GetAdmGroupImmuneCount(GroupId:id);
   291 
   292 /**
   293  * Returns a group that this group is immune to given an index.
   294  *
   295  * @param id			Group id.
   296  * @param number		Index from 0 to N-1, from GetAdmGroupImmuneCount().
   297  * @return				GroupId that this group is immune to, or INVALID_GROUP_ID on failure.
   298  */
   299 native GroupId:GetAdmGroupImmuneFrom(GroupId:id, number); 
   300 
   301 /**
   302  * Adds a group-specific override type.
   303  *
   304  * @param id			Group id.
   305  * @param name			String containing command name (case sensitive).
   306  * @param type			Override type (specific command or group).
   307  * @param rule			Override allow/deny setting.
   308  * @noreturn
   309  */
   310 native AddAdmGroupCmdOverride(GroupId:id, const String:name[], OverrideType:type, OverrideRule:rule);
   311 
   312 /**
   313  * Retrieves a group-specific command override.
   314  *
   315  * @param id			Group id.
   316  * @param name			String containing command name (case sensitive).
   317  * @param type			Override type (specific command or group).
   318  * @param rule			Optional pointer to store allow/deny setting.
   319  * @return				True if an override exists, false otherwise.
   320  */
   321 native bool:GetAdmGroupCmdOverride(GroupId:id, const String:name[], OverrideType:type, &OverrideRule:rule);
   322 
   323 /**
   324  * Registers an authentication identity type.  You normally never need to call this except for 
   325  * very specific systems.
   326  *
   327  * @param codename		Codename to use for your authentication type.
   328  * @noreturn
   329  */
   330 native RegisterAuthIdentType(const String:name[]);
   331 
   332 /**
   333  * Creates a new admin entry in the permissions cache.
   334  *
   335  * @param name			Name for this entry (does not have to be unique).
   336  * 						Specify an empty string for an anonymous admin.
   337  */
   338 native AdminId:CreateAdmin(const String:name[]="");
   339 
   340 /**
   341  * Retrieves an admin's user name as made with CreateAdmin().
   342  *
   343  * @note This function can return UTF-8 strings, and will safely chop UTF-8 strings.
   344  *
   345  * @param id			AdminId of the admin.
   346  * @param name			String buffer to store name.
   347  * @param maxlength		Maximum size of string buffer.
   348  * @return				Number of bytes written.
   349  */
   350 native GetAdminUsername(AdminId:id, const String:name[], maxlength);
   351 
   352 /**
   353  * Binds an admin to an identity for fast lookup later on.  The bind must be unique.
   354  *
   355  * @param id			AdminId of the admin.
   356  * @param auth			Auth method to use, predefined or from RegisterAuthIdentType().
   357  * @param ident			String containing the arbitrary, unique identity.
   358  * @return				True on success, false if the auth method was not found,
   359  *						or ident was already taken.
   360  */
   361 native bool:BindAdminIdentity(AdminId:id, const String:auth[], const String:ident[]);
   362 
   363 /**
   364  * Sets whether or not a flag is enabled on an admin.
   365  *
   366  * @param id			AdminId index of the admin.
   367  * @param flag			Admin flag to use.
   368  * @param enabled		True to enable, false to disable.
   369  * @noreturn
   370  */
   371 native SetAdminFlag(AdminId:id, AdminFlag:flag, bool:enabled);
   372 
   373 /**
   374  * Returns whether or not a flag is enabled on an admin.
   375  *
   376  * @param id			AdminId index of the admin.
   377  * @param flag			Admin flag to use.
   378  * @param mode			Access mode to check.
   379  * @return				True if enabled, false otherwise.
   380  */
   381 native bool:GetAdminFlag(AdminId:id, AdminFlag:flag, AdmAccessMode:mode=Access_Effective);
   382 
   383 /**
   384  * Returns the bitstring of access flags on an admin.
   385  *
   386  * @param id			AdminId index of the admin.
   387  * @param mode			Access mode to use.
   388  * @return				A bitstring containing which flags are enabled.
   389  */
   390 native GetAdminFlags(AdminId:id, AdmAccessMode:mode);
   391 
   392 /**
   393  * Adds a group to an admin's inherited group list.  Any flags the group has 
   394  * will be added to the admin's effective flags.
   395  *
   396  * @param id			AdminId index of the admin.
   397  * @param gid			GroupId index of the group.
   398  * @return				True on success, false on invalid input or duplicate membership.
   399  */
   400 native bool:AdminInheritGroup(AdminId:id, GroupId:gid);
   401 
   402 /**
   403  * Returns the number of groups this admin is a member of.
   404  * 
   405  * @param id			AdminId index of the admin.
   406  * @return				Number of groups this admin is a member of.
   407  */
   408 native GetAdminGroupCount(AdminId:id);
   409 
   410 /**
   411  * Returns group information from an admin.
   412  *
   413  * @param id        	AdminId index of the admin.
   414  * @param index			Group number to retrieve, from 0 to N-1, where N
   415  *						is the value of GetAdminGroupCount(id).
   416  * @param name			Buffer to store the group's name.
   417  *						Note: This will safely chop UTF-8 strings.
   418  * @param maxlength		Maximum size of the output name buffer.
   419  * @return				A GroupId index and a name pointer, or
   420  *						INVALID_GROUP_ID and NULL if an error occurred.
   421 */
   422 native GroupId:GetAdminGroup(AdminId:id, index, const String:name[], maxlength);
   423 
   424 /**
   425  * Sets a password on an admin.
   426  *
   427  * @param id			AdminId index of the admin.
   428  * @param passwd		String containing the password.
   429  * @noreturn
   430  */
   431 native SetAdminPassword(AdminId:id, const String:password[]);
   432 
   433 /**
   434  * Gets an admin's password.
   435  *
   436  * @param id			AdminId index of the admin.
   437  * @param name			Optional buffer to store the admin's password.
   438  * @param maxlength		Maximum size of the output name buffer.
   439  *						Note: This will safely chop UTF-8 strings.
   440  * @return				True if there was a password set, false otherwise.
   441  */
   442 native bool:GetAdminPassword(AdminId:id, const String:buffer[]="", maxlength=0);
   443 
   444 /**
   445  * Attempts to find an admin by an auth method and an identity.
   446  *
   447  * @param auth			Auth method to try.
   448  * @param identity		Identity string to look up.
   449  * @return				An AdminId index if found, INVALID_ADMIN_ID otherwise.
   450  */
   451 native AdminId:FindAdminByIdentity(const String:auth[], const String:identity[]);
   452 
   453 /**
   454  * Removes an admin entry from the cache.
   455  *
   456  * @note This will remove any bindings to a specific user.
   457  *
   458  * @param id			AdminId index to remove/invalidate.
   459  * @return				True on success, false otherwise.
   460  */
   461 native bool:RemoveAdmin(AdminId:id);
   462 
   463 /**
   464  * Converts a flag bit string to a bit array.
   465  *
   466  * @param bits			Bit string containing the flags.
   467  * @param array			Array to write the flags to.  Enabled flags will be 'true'.
   468  * @param maxSize		Maximum number of flags the array can store.
   469  * @return				Number of flags written.
   470  */
   471 native FlagBitsToBitArray(bits, bool:array[], maxSize);
   472 
   473 /**
   474  * Converts a flag array to a bit string.
   475  *
   476  * @param array			Array containing true or false for each AdminFlag.
   477  * @param maxSize		Maximum size of the flag array.
   478  * @return				A bit string composed of the array bits.
   479  */
   480 native FlagBitArrayToBits(const bool:array[], maxSize);
   481 
   482 /**
   483  * Converts an array of flags to bits.
   484  *
   485  * @param array			Array containing flags that are enabled.
   486  * @param numFlags		Number of flags in the array.
   487  * @return				A bit string composed of the array flags.
   488  */
   489 native FlagArrayToBits(const AdminFlag:array[], numFlags);
   490 
   491 /**
   492  * Converts a bit string to an array of flags.
   493  *
   494  * @param bits			Bit string containing the flags.
   495  * @param array			Output array to write flags.
   496  * @param maxSize		Maximum size of the flag array.
   497  * @return				Number of flags written.
   498  */
   499 native FlagBitsToArray(bits, AdminFlag:array[], maxSize);
   500 
   501 /**
   502  * Finds a flag by its string name.
   503  *
   504  * @param name			Flag name (like "kick"), case sensitive.
   505  * @param flag			Variable to store flag in.
   506  * @return				True on success, false if not found.
   507  */
   508 native bool:FindFlagByName(const String:name[], &AdminFlag:flag);
   509 
   510 /**
   511  * Finds a flag by a given character.
   512  *
   513  * @param c				Flag ASCII character/token.
   514  * @param flag			Variable to store flag in.
   515  * @return				True on success, false if not found.
   516  */
   517 native bool:FindFlagByChar(c, &AdminFlag:flag);
   518 
   519 /**
   520  * Converts a string of flag characters to a bit string.
   521  *
   522  * @param flags			Flag ASCII string.
   523  * @param numchars		Optional variable to store the number of bytes read.
   524  * @return				Bit string of ADMFLAG values.
   525  */
   526 native ReadFlagString(const String:flags[], &numchars=0);
   527 
   528 /**
   529  * Tests whether one admin can target another.
   530  *
   531  * The hueristics for this check are as follows:
   532  * 0. If the targeting AdminId is INVALID_ADMIN_ID, targeting fails.
   533  * 1. If the targeted AdminId is INVALID_ADMIN_ID, targeting succeeds.
   534  * 2. If the targeted AdminId is the same as the targeting AdminId,
   535  *    (self) targeting succeeds.
   536  * 3. If the targeting admin is root, targeting succeeds.
   537  * 4. If the targeted admin has access higher (as interpreted by 
   538  *    (sm_immunity_mode) than the targeting admin, then targeting fails.
   539  * 5. If the targeted admin has specific immunity from the
   540  *    targeting admin via group immunities, targeting fails.
   541  * 6. Targeting succeeds.
   542  *
   543  * @param admin			Admin doing the targetting (may be INVALID_ADMIN_ID).
   544  * @param target		Target admin (may be INVALID_ADMIN_ID).
   545  * @return				True if targetable, false if immune.
   546  */
   547 native CanAdminTarget(AdminId:admin, AdminId:target);
   548 
   549 /**
   550  * Creates an admin auth method.  This does not need to be called more than once
   551  * per method, ever.
   552  *
   553  * @param method		Name of the authentication method.
   554  * @return				True on success, false on failure.
   555  */
   556 native bool:CreateAuthMethod(const String:method[]);
   557 
   558 /**
   559  * Sets a group's immunity level.
   560  *
   561  * @param gid			Group Id.
   562  * @param level			Immunity level value.
   563  * @return				Old immunity level value.
   564  */
   565 native SetAdmGroupImmunityLevel(GroupId:gid, level);
   566 
   567 /**
   568  * Gets a group's immunity level (defaults to 0).
   569  *
   570  * @param gid			Group Id.
   571  * @return				Immunity level value.
   572  */
   573 native GetAdmGroupImmunityLevel(GroupId:gid);
   574 
   575 /**
   576  * Sets an admin's immunity level.
   577  *
   578  * @param id			Admin Id.
   579  * @param level			Immunity level value.
   580  * @return				Old immunity level value.
   581  */
   582 native SetAdminImmunityLevel(AdminId:id, level);
   583 
   584 /**
   585  * Gets an admin's immunity level.
   586  *
   587  * @param id			Admin Id.
   588  * @return				Immunity level value.
   589  */
   590 native GetAdminImmunityLevel(AdminId:id);
   591 
   592 /**
   593  * Converts a flag to its single bit.
   594  * 
   595  * @param flag			Flag to convert.
   596  * @return				Bit representation of the flag.
   597  */
   598 stock FlagToBit(AdminFlag:flag)
   599 {
   600 	return (1<<_:flag);
   601 }
   602 
   603 /**
   604  * Converts a bit to an AdminFlag.
   605  *
   606  * @param bit			Bit to convert.
   607  * @param flag			Stores the converted flag by reference.
   608  * @return				True on success, false otherwise.
   609  */
   610 stock bool:BitToFlag(bit, &AdminFlag:flag)
   611 {
   612 	new AdminFlag:array[1];
   613 	
   614 	if (FlagBitsToArray(bit, array, 1))
   615 	{
   616 		flag = array[0];
   617 		return true;
   618 	}
   619 	
   620 	return false;
   621 }
   622