ds@1952: /**
ds@1952: * vim: set ts=4 :
ds@1952: * =============================================================================
ds@1952: * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
ds@1952: * =============================================================================
ds@1952: *
ds@1952: * This file is part of the SourceMod/SourcePawn SDK.
ds@1952: *
ds@1952: * This program is free software; you can redistribute it and/or modify it under
ds@1952: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1952: * Free Software Foundation.
ds@1952: *
ds@1952: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1952: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1952: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1952: * details.
ds@1952: *
ds@1952: * You should have received a copy of the GNU General Public License along with
ds@1952: * this program. If not, see .
ds@1952: *
ds@1952: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1952: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1952: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1952: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1952: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1952: * this exception to all derivative works. AlliedModders LLC defines further
ds@1952: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1952: * or .
ds@1952: *
ds@1952: * Version: $Id$
ds@1952: */
ds@1952:
ds@1952: #if defined _admin_included
ds@1952: #endinput
ds@1952: #endif
ds@1952: #define _admin_included
ds@1952:
ds@1952: /**
ds@1952: * Access levels (flags) for admins.
ds@1952: */
ds@1952: enum AdminFlag
ds@1952: {
ds@1952: Admin_Reservation = 0, /**< Reserved slot */
ds@1952: Admin_Generic, /**< Generic admin abilities */
ds@1952: Admin_Kick, /**< Kick another user */
ds@1952: Admin_Ban, /**< Ban another user */
ds@1952: Admin_Unban, /**< Unban another user */
ds@1952: Admin_Slay, /**< Slay/kill/damage another user */
ds@1952: Admin_Changemap, /**< Change the map */
ds@1952: Admin_Convars, /**< Change basic convars */
ds@1952: Admin_Config, /**< Change configuration */
ds@1952: Admin_Chat, /**< Special chat privileges */
ds@1952: Admin_Vote, /**< Special vote privileges */
ds@1952: Admin_Password, /**< Set a server password */
ds@1952: Admin_RCON, /**< Use RCON */
ds@1952: Admin_Cheats, /**< Change sv_cheats and use its commands */
ds@1952: Admin_Root, /**< All access by default */
ds@1952: Admin_Custom1, /**< First custom flag type */
ds@1952: Admin_Custom2, /**< Second custom flag type */
ds@1952: Admin_Custom3, /**< Third custom flag type */
ds@1952: Admin_Custom4, /**< Fourth custom flag type */
ds@1952: Admin_Custom5, /**< Fifth custom flag type */
ds@1952: Admin_Custom6, /**< Sixth custom flag type */
ds@1952: /* --- */
ds@1952: };
ds@1952:
ds@1952: #define AdminFlags_TOTAL 21 /**< Total number of admin flags */
ds@1952:
ds@1952: /**
ds@1952: * @section Bitwise values definitions for admin flags.
ds@1952: */
ds@1952: #define ADMFLAG_RESERVATION (1<<0) /**< Convenience macro for Admin_Reservation as a FlagBit */
ds@1952: #define ADMFLAG_GENERIC (1<<1) /**< Convenience macro for Admin_Generic as a FlagBit */
ds@1952: #define ADMFLAG_KICK (1<<2) /**< Convenience macro for Admin_Kick as a FlagBit */
ds@1952: #define ADMFLAG_BAN (1<<3) /**< Convenience macro for Admin_Ban as a FlagBit */
ds@1952: #define ADMFLAG_UNBAN (1<<4) /**< Convenience macro for Admin_Unban as a FlagBit */
ds@1952: #define ADMFLAG_SLAY (1<<5) /**< Convenience macro for Admin_Slay as a FlagBit */
ds@1952: #define ADMFLAG_CHANGEMAP (1<<6) /**< Convenience macro for Admin_Changemap as a FlagBit */
ds@1952: #define ADMFLAG_CONVARS (1<<7) /**< Convenience macro for Admin_Convars as a FlagBit */
ds@1952: #define ADMFLAG_CONFIG (1<<8) /**< Convenience macro for Admin_Config as a FlagBit */
ds@1952: #define ADMFLAG_CHAT (1<<9) /**< Convenience macro for Admin_Chat as a FlagBit */
ds@1952: #define ADMFLAG_VOTE (1<<10) /**< Convenience macro for Admin_Vote as a FlagBit */
ds@1952: #define ADMFLAG_PASSWORD (1<<11) /**< Convenience macro for Admin_Password as a FlagBit */
ds@1952: #define ADMFLAG_RCON (1<<12) /**< Convenience macro for Admin_RCON as a FlagBit */
ds@1952: #define ADMFLAG_CHEATS (1<<13) /**< Convenience macro for Admin_Cheats as a FlagBit */
ds@1952: #define ADMFLAG_ROOT (1<<14) /**< Convenience macro for Admin_Root as a FlagBit */
ds@1952: #define ADMFLAG_CUSTOM1 (1<<15) /**< Convenience macro for Admin_Custom1 as a FlagBit */
ds@1952: #define ADMFLAG_CUSTOM2 (1<<16) /**< Convenience macro for Admin_Custom2 as a FlagBit */
ds@1952: #define ADMFLAG_CUSTOM3 (1<<17) /**< Convenience macro for Admin_Custom3 as a FlagBit */
ds@1952: #define ADMFLAG_CUSTOM4 (1<<18) /**< Convenience macro for Admin_Custom4 as a FlagBit */
ds@1952: #define ADMFLAG_CUSTOM5 (1<<19) /**< Convenience macro for Admin_Custom5 as a FlagBit */
ds@1952: #define ADMFLAG_CUSTOM6 (1<<20) /**< Convenience macro for Admin_Custom6 as a FlagBit */
ds@1952:
ds@1952: /**
ds@1952: * @endsection
ds@1952: */
ds@1952:
ds@1952: /**
ds@1952: * @section Hardcoded authentication methods
ds@1952: */
ds@1952: #define AUTHMETHOD_STEAM "steam" /**< SteamID based authentication */
ds@1952: #define AUTHMETHOD_IP "ip" /**< IP based authentication */
ds@1952: #define AUTHMETHOD_NAME "name" /**< Name based authentication */
ds@1952:
ds@1952: /**
ds@1952: * @endsection
ds@1952: */
ds@1952:
ds@1952: /**
ds@1952: * Access override types.
ds@1952: */
ds@1952: enum OverrideType
ds@1952: {
ds@1952: Override_Command = 1, /**< Command */
ds@1952: Override_CommandGroup, /**< Command group */
ds@1952: };
ds@1952:
ds@1952: /**
ds@1952: * Access override rules.
ds@1952: */
ds@1952: enum OverrideRule
ds@1952: {
ds@1952: Command_Deny = 0,
ds@1952: Command_Allow = 1,
ds@1952: };
ds@1952:
ds@1952: /**
ds@1952: * DEPRECATED, do not use.
ds@1952: */
ds@1952: enum ImmunityType
ds@1952: {
ds@1952: Immunity_Default = 1, /**< Deprecated. */
ds@1952: Immunity_Global, /**< Deprecated. */
ds@1952: };
ds@1952:
ds@1952: /**
ds@1952: * Identifies a unique entry in the group permissions cache. These are not Handles.
ds@1952: */
ds@1952: enum GroupId
ds@1952: {
ds@1952: INVALID_GROUP_ID = -1, /**< An invalid/nonexistant group */
ds@1952: };
ds@1952:
ds@1952: /**
ds@1952: * Identifies a unique entry in the admin permissions cache. These are not Handles.
ds@1952: */
ds@1952: enum AdminId
ds@1952: {
ds@1952: INVALID_ADMIN_ID = -1, /**< An invalid/nonexistant admin */
ds@1952: };
ds@1952:
ds@1952: /**
ds@1952: * Methods of computing access permissions.
ds@1952: */
ds@1952: enum AdmAccessMode
ds@1952: {
ds@1952: Access_Real, /**< Access the user has inherently */
ds@1952: Access_Effective, /**< Access the user has from their groups */
ds@1952: };
ds@1952:
ds@1952: /**
ds@1952: * Represents the various cache regions.
ds@1952: */
ds@1952: enum AdminCachePart
ds@1952: {
ds@1952: AdminCache_Overrides = 0, /**< Global overrides */
ds@1952: AdminCache_Groups = 1, /**< All groups (automatically invalidates admins too) */
ds@1952: AdminCache_Admins = 2, /**< All admins */
ds@1952: };
ds@1952:
ds@1952: /**
ds@1952: * Called when part of the cache which needs to be rebuilt.
ds@1952: *
ds@1952: * @param part Part of the admin cache to rebuild.
ds@1952: */
ds@1952: forward OnRebuildAdminCache(AdminCachePart:part);
ds@1952:
ds@1952: /**
ds@1952: * Tells the admin system to dump a portion of the cache.
ds@1952: *
ds@1952: * @param part Part of the cache to dump. Specifying groups also dumps admins.
ds@1952: * @param rebuild If true, the rebuild forwards will fire.
ds@1952: * @noreturn
ds@1952: */
ds@1952: native DumpAdminCache(AdminCachePart:part, bool:rebuild);
ds@1952:
ds@1952: /**
ds@1952: * Adds a global command flag override. Any command registered with this name
ds@1952: * will assume the new flag. This is applied retroactively as well.
ds@1952: *
ds@1952: * @param cmd String containing command name (case sensitive).
ds@1952: * @param type Override type (specific command or group).
ds@1952: * @param flags New admin flag.
ds@1952: * @noreturn
ds@1952: */
ds@1952: native AddCommandOverride(const String:cmd[], OverrideType:type, flags);
ds@1952:
ds@1952: /**
ds@1952: * Returns a command override.
ds@1952: *
ds@1952: * @param cmd String containing command name (case sensitive).
ds@1952: * @param type Override type (specific command or group).
ds@1952: * @param flags By-reference cell to store the flag (undefined if not found).
ds@1952: * @return True if there is an override, false otherwise.
ds@1952: */
ds@1952: native bool:GetCommandOverride(const String:cmd[], OverrideType:type, &flags);
ds@1952:
ds@1952: /**
ds@1952: * Unsets a command override.
ds@1952: *
ds@1952: * @param cmd String containing command name (case sensitive).
ds@1952: * @param type Override type (specific command or group).
ds@1952: * @noreturn
ds@1952: */
ds@1952: native UnsetCommandOverride(const String:cmd[], OverrideType:type);
ds@1952:
ds@1952: /**
ds@1952: * Adds a new group. Name must be unique.
ds@1952: *
ds@1952: * @param group_name String containing the group name.
ds@1952: * @return A new group id, INVALID_GROUP_ID if it already exists.
ds@1952: */
ds@1952: native GroupId:CreateAdmGroup(const String:group_name[]);
ds@1952:
ds@1952: /**
ds@1952: * Finds a group by name.
ds@1952: *
ds@1952: * @param group_name String containing the group name.
ds@1952: * @return A group id, or INVALID_GROUP_ID if not found.
ds@1952: */
ds@1952: native GroupId:FindAdmGroup(const String:group_name[]);
ds@1952:
ds@1952: /**
ds@1952: * Adds or removes a flag from a group's flag set.
ds@1952: * @note These are called "add flags" because they add to a user's flags.
ds@1952: *
ds@1952: * @param id Group id.
ds@1952: * @param flag Admin flag to toggle.
ds@1952: * @param enabled True to set the flag, false to unset/disable.
ds@1952: * @noreturn
ds@1952: */
ds@1952: native SetAdmGroupAddFlag(GroupId:id, AdminFlag:flag, bool:enabled);
ds@1952:
ds@1952: /**
ds@1952: * Gets the set value of an add flag on a group's flag set.
ds@1952: * @note These are called "add flags" because they add to a user's flags.
ds@1952: *
ds@1952: * @param id Group id.
ds@1952: * @param flag Admin flag to retrieve.
ds@1952: * @return True if enabled, false otherwise,
ds@1952: */
ds@1952: native bool:GetAdmGroupAddFlag(GroupId:id, AdminFlag:flag);
ds@1952:
ds@1952: /**
ds@1952: * Returns the flag set that is added to a user from their group.
ds@1952: * @note These are called "add flags" because they add to a user's flags.
ds@1952: *
ds@1952: * @param id GroupId of the group.
ds@1952: * @return Bitstring containing the flags enabled.
ds@1952: */
ds@1952: native GetAdmGroupAddFlags(GroupId:id);
ds@1952:
ds@1952: /**
ds@1952: * @deprecated Functionality removed.
ds@1952: */
ds@1952: #pragma deprecated Use SetAdmGroupImmunityLevel() instead.
ds@1952: native SetAdmGroupImmunity(GroupId:id, ImmunityType:type, bool:enabled);
ds@1952:
ds@1952: /**
ds@1952: * @deprecated Functionality removed.
ds@1952: */
ds@1952: #pragma deprecated Use GetAdmGroupImmunityLevel() instead.
ds@1952: native bool:GetAdmGroupImmunity(GroupId:id, ImmunityType:type);
ds@1952:
ds@1952: /**
ds@1952: * Adds immunity to a specific group.
ds@1952: *
ds@1952: * @param id Group id.
ds@1952: * @param other_id Group id to receive immunity to.
ds@1952: * @noreturn
ds@1952: */
ds@1952: native SetAdmGroupImmuneFrom(GroupId:id, GroupId:other_id);
ds@1952:
ds@1952: /**
ds@1952: * Returns the number of specific group immunities.
ds@1952: *
ds@1952: * @param id Group id.
ds@1952: * @return Number of group immunities.
ds@1952: */
ds@1952: native GetAdmGroupImmuneCount(GroupId:id);
ds@1952:
ds@1952: /**
ds@1952: * Returns a group that this group is immune to given an index.
ds@1952: *
ds@1952: * @param id Group id.
ds@1952: * @param number Index from 0 to N-1, from GetAdmGroupImmuneCount().
ds@1952: * @return GroupId that this group is immune to, or INVALID_GROUP_ID on failure.
ds@1952: */
ds@1952: native GroupId:GetAdmGroupImmuneFrom(GroupId:id, number);
ds@1952:
ds@1952: /**
ds@1952: * Adds a group-specific override type.
ds@1952: *
ds@1952: * @param id Group id.
ds@1952: * @param name String containing command name (case sensitive).
ds@1952: * @param type Override type (specific command or group).
ds@1952: * @param rule Override allow/deny setting.
ds@1952: * @noreturn
ds@1952: */
ds@1952: native AddAdmGroupCmdOverride(GroupId:id, const String:name[], OverrideType:type, OverrideRule:rule);
ds@1952:
ds@1952: /**
ds@1952: * Retrieves a group-specific command override.
ds@1952: *
ds@1952: * @param id Group id.
ds@1952: * @param name String containing command name (case sensitive).
ds@1952: * @param type Override type (specific command or group).
ds@1952: * @param rule Optional pointer to store allow/deny setting.
ds@1952: * @return True if an override exists, false otherwise.
ds@1952: */
ds@1952: native bool:GetAdmGroupCmdOverride(GroupId:id, const String:name[], OverrideType:type, &OverrideRule:rule);
ds@1952:
ds@1952: /**
ds@1952: * Registers an authentication identity type. You normally never need to call this except for
ds@1952: * very specific systems.
ds@1952: *
ds@1952: * @param codename Codename to use for your authentication type.
ds@1952: * @noreturn
ds@1952: */
ds@1952: native RegisterAuthIdentType(const String:name[]);
ds@1952:
ds@1952: /**
ds@1952: * Creates a new admin entry in the permissions cache.
ds@1952: *
ds@1952: * @param name Name for this entry (does not have to be unique).
ds@1952: * Specify an empty string for an anonymous admin.
ds@1952: */
ds@1952: native AdminId:CreateAdmin(const String:name[]="");
ds@1952:
ds@1952: /**
ds@1952: * Retrieves an admin's user name as made with CreateAdmin().
ds@1952: *
ds@1952: * @note This function can return UTF-8 strings, and will safely chop UTF-8 strings.
ds@1952: *
ds@1952: * @param id AdminId of the admin.
ds@1952: * @param name String buffer to store name.
ds@1952: * @param maxlength Maximum size of string buffer.
ds@1952: * @return Number of bytes written.
ds@1952: */
ds@1952: native GetAdminUsername(AdminId:id, const String:name[], maxlength);
ds@1952:
ds@1952: /**
ds@1952: * Binds an admin to an identity for fast lookup later on. The bind must be unique.
ds@1952: *
ds@1952: * @param id AdminId of the admin.
ds@1952: * @param auth Auth method to use, predefined or from RegisterAuthIdentType().
ds@1952: * @param ident String containing the arbitrary, unique identity.
ds@1952: * @return True on success, false if the auth method was not found,
ds@1952: * or ident was already taken.
ds@1952: */
ds@1952: native bool:BindAdminIdentity(AdminId:id, const String:auth[], const String:ident[]);
ds@1952:
ds@1952: /**
ds@1952: * Sets whether or not a flag is enabled on an admin.
ds@1952: *
ds@1952: * @param id AdminId index of the admin.
ds@1952: * @param flag Admin flag to use.
ds@1952: * @param enabled True to enable, false to disable.
ds@1952: * @noreturn
ds@1952: */
ds@1952: native SetAdminFlag(AdminId:id, AdminFlag:flag, bool:enabled);
ds@1952:
ds@1952: /**
ds@1952: * Returns whether or not a flag is enabled on an admin.
ds@1952: *
ds@1952: * @param id AdminId index of the admin.
ds@1952: * @param flag Admin flag to use.
ds@1952: * @param mode Access mode to check.
ds@1952: * @return True if enabled, false otherwise.
ds@1952: */
ds@1952: native bool:GetAdminFlag(AdminId:id, AdminFlag:flag, AdmAccessMode:mode=Access_Effective);
ds@1952:
ds@1952: /**
ds@1952: * Returns the bitstring of access flags on an admin.
ds@1952: *
ds@1952: * @param id AdminId index of the admin.
ds@1952: * @param mode Access mode to use.
ds@1952: * @return A bitstring containing which flags are enabled.
ds@1952: */
ds@1952: native GetAdminFlags(AdminId:id, AdmAccessMode:mode);
ds@1952:
ds@1952: /**
ds@1952: * Adds a group to an admin's inherited group list. Any flags the group has
ds@1952: * will be added to the admin's effective flags.
ds@1952: *
ds@1952: * @param id AdminId index of the admin.
ds@1952: * @param gid GroupId index of the group.
ds@1952: * @return True on success, false on invalid input or duplicate membership.
ds@1952: */
ds@1952: native bool:AdminInheritGroup(AdminId:id, GroupId:gid);
ds@1952:
ds@1952: /**
ds@1952: * Returns the number of groups this admin is a member of.
ds@1952: *
ds@1952: * @param id AdminId index of the admin.
ds@1952: * @return Number of groups this admin is a member of.
ds@1952: */
ds@1952: native GetAdminGroupCount(AdminId:id);
ds@1952:
ds@1952: /**
ds@1952: * Returns group information from an admin.
ds@1952: *
ds@1952: * @param id AdminId index of the admin.
ds@1952: * @param index Group number to retrieve, from 0 to N-1, where N
ds@1952: * is the value of GetAdminGroupCount(id).
ds@1952: * @param name Buffer to store the group's name.
ds@1952: * Note: This will safely chop UTF-8 strings.
ds@1952: * @param maxlength Maximum size of the output name buffer.
ds@1952: * @return A GroupId index and a name pointer, or
ds@1952: * INVALID_GROUP_ID and NULL if an error occurred.
ds@1952: */
ds@1952: native GroupId:GetAdminGroup(AdminId:id, index, const String:name[], maxlength);
ds@1952:
ds@1952: /**
ds@1952: * Sets a password on an admin.
ds@1952: *
ds@1952: * @param id AdminId index of the admin.
ds@1952: * @param passwd String containing the password.
ds@1952: * @noreturn
ds@1952: */
ds@1952: native SetAdminPassword(AdminId:id, const String:password[]);
ds@1952:
ds@1952: /**
ds@1952: * Gets an admin's password.
ds@1952: *
ds@1952: * @param id AdminId index of the admin.
ds@1952: * @param name Optional buffer to store the admin's password.
ds@1952: * @param maxlength Maximum size of the output name buffer.
ds@1952: * Note: This will safely chop UTF-8 strings.
ds@1952: * @return True if there was a password set, false otherwise.
ds@1952: */
ds@1952: native bool:GetAdminPassword(AdminId:id, const String:buffer[]="", maxlength=0);
ds@1952:
ds@1952: /**
ds@1952: * Attempts to find an admin by an auth method and an identity.
ds@1952: *
ds@1952: * @param auth Auth method to try.
ds@1952: * @param identity Identity string to look up.
ds@1952: * @return An AdminId index if found, INVALID_ADMIN_ID otherwise.
ds@1952: */
ds@1952: native AdminId:FindAdminByIdentity(const String:auth[], const String:identity[]);
ds@1952:
ds@1952: /**
ds@1952: * Removes an admin entry from the cache.
ds@1952: *
ds@1952: * @note This will remove any bindings to a specific user.
ds@1952: *
ds@1952: * @param id AdminId index to remove/invalidate.
ds@1952: * @return True on success, false otherwise.
ds@1952: */
ds@1952: native bool:RemoveAdmin(AdminId:id);
ds@1952:
ds@1952: /**
ds@1952: * Converts a flag bit string to a bit array.
ds@1952: *
ds@1952: * @param bits Bit string containing the flags.
ds@1952: * @param array Array to write the flags to. Enabled flags will be 'true'.
ds@1952: * @param maxSize Maximum number of flags the array can store.
ds@1952: * @return Number of flags written.
ds@1952: */
ds@1952: native FlagBitsToBitArray(bits, bool:array[], maxSize);
ds@1952:
ds@1952: /**
ds@1952: * Converts a flag array to a bit string.
ds@1952: *
ds@1952: * @param array Array containing true or false for each AdminFlag.
ds@1952: * @param maxSize Maximum size of the flag array.
ds@1952: * @return A bit string composed of the array bits.
ds@1952: */
ds@1952: native FlagBitArrayToBits(const bool:array[], maxSize);
ds@1952:
ds@1952: /**
ds@1952: * Converts an array of flags to bits.
ds@1952: *
ds@1952: * @param array Array containing flags that are enabled.
ds@1952: * @param numFlags Number of flags in the array.
ds@1952: * @return A bit string composed of the array flags.
ds@1952: */
ds@1952: native FlagArrayToBits(const AdminFlag:array[], numFlags);
ds@1952:
ds@1952: /**
ds@1952: * Converts a bit string to an array of flags.
ds@1952: *
ds@1952: * @param bits Bit string containing the flags.
ds@1952: * @param array Output array to write flags.
ds@1952: * @param maxSize Maximum size of the flag array.
ds@1952: * @return Number of flags written.
ds@1952: */
ds@1952: native FlagBitsToArray(bits, AdminFlag:array[], maxSize);
ds@1952:
ds@1952: /**
ds@1952: * Finds a flag by its string name.
ds@1952: *
ds@1952: * @param name Flag name (like "kick"), case sensitive.
ds@1952: * @param flag Variable to store flag in.
ds@1952: * @return True on success, false if not found.
ds@1952: */
ds@1952: native bool:FindFlagByName(const String:name[], &AdminFlag:flag);
ds@1952:
ds@1952: /**
ds@1952: * Finds a flag by a given character.
ds@1952: *
ds@1952: * @param c Flag ASCII character/token.
ds@1952: * @param flag Variable to store flag in.
ds@1952: * @return True on success, false if not found.
ds@1952: */
ds@1952: native bool:FindFlagByChar(c, &AdminFlag:flag);
ds@1952:
ds@1952: /**
ds@1952: * Converts a string of flag characters to a bit string.
ds@1952: *
ds@1952: * @param flags Flag ASCII string.
ds@1952: * @param numchars Optional variable to store the number of bytes read.
ds@1952: * @return Bit string of ADMFLAG values.
ds@1952: */
ds@1952: native ReadFlagString(const String:flags[], &numchars=0);
ds@1952:
ds@1952: /**
ds@1952: * Tests whether one admin can target another.
ds@1952: *
ds@1952: * The hueristics for this check are as follows:
ds@1952: * 0. If the targeting AdminId is INVALID_ADMIN_ID, targeting fails.
ds@1952: * 1. If the targeted AdminId is INVALID_ADMIN_ID, targeting succeeds.
ds@1952: * 2. If the targeted AdminId is the same as the targeting AdminId,
ds@1952: * (self) targeting succeeds.
ds@1952: * 3. If the targeting admin is root, targeting succeeds.
ds@1952: * 4. If the targeted admin has access higher (as interpreted by
ds@1952: * (sm_immunity_mode) than the targeting admin, then targeting fails.
ds@1952: * 5. If the targeted admin has specific immunity from the
ds@1952: * targeting admin via group immunities, targeting fails.
ds@1952: * 6. Targeting succeeds.
ds@1952: *
ds@1952: * @param admin Admin doing the targetting (may be INVALID_ADMIN_ID).
ds@1952: * @param target Target admin (may be INVALID_ADMIN_ID).
ds@1952: * @return True if targetable, false if immune.
ds@1952: */
ds@1952: native CanAdminTarget(AdminId:admin, AdminId:target);
ds@1952:
ds@1952: /**
ds@1952: * Creates an admin auth method. This does not need to be called more than once
ds@1952: * per method, ever.
ds@1952: *
ds@1952: * @param method Name of the authentication method.
ds@1952: * @return True on success, false on failure.
ds@1952: */
ds@1952: native bool:CreateAuthMethod(const String:method[]);
ds@1952:
ds@1952: /**
ds@1952: * Sets a group's immunity level.
ds@1952: *
ds@1952: * @param gid Group Id.
ds@1952: * @param level Immunity level value.
ds@1952: * @return Old immunity level value.
ds@1952: */
ds@1952: native SetAdmGroupImmunityLevel(GroupId:gid, level);
ds@1952:
ds@1952: /**
ds@1952: * Gets a group's immunity level (defaults to 0).
ds@1952: *
ds@1952: * @param gid Group Id.
ds@1952: * @return Immunity level value.
ds@1952: */
ds@1952: native GetAdmGroupImmunityLevel(GroupId:gid);
ds@1952:
ds@1952: /**
ds@1952: * Sets an admin's immunity level.
ds@1952: *
ds@1952: * @param id Admin Id.
ds@1952: * @param level Immunity level value.
ds@1952: * @return Old immunity level value.
ds@1952: */
ds@1952: native SetAdminImmunityLevel(AdminId:id, level);
ds@1952:
ds@1952: /**
ds@1952: * Gets an admin's immunity level.
ds@1952: *
ds@1952: * @param id Admin Id.
ds@1952: * @return Immunity level value.
ds@1952: */
ds@1952: native GetAdminImmunityLevel(AdminId:id);
ds@1952:
ds@1952: /**
ds@1952: * Converts a flag to its single bit.
ds@1952: *
ds@1952: * @param flag Flag to convert.
ds@1952: * @return Bit representation of the flag.
ds@1952: */
ds@1952: stock FlagToBit(AdminFlag:flag)
ds@1952: {
ds@1952: return (1<<_:flag);
ds@1952: }
ds@1952:
ds@1952: /**
ds@1952: * Converts a bit to an AdminFlag.
ds@1952: *
ds@1952: * @param bit Bit to convert.
ds@1952: * @param flag Stores the converted flag by reference.
ds@1952: * @return True on success, false otherwise.
ds@1952: */
ds@1952: stock bool:BitToFlag(bit, &AdminFlag:flag)
ds@1952: {
ds@1952: new AdminFlag:array[1];
ds@1952:
ds@1952: if (FlagBitsToArray(bit, array, 1))
ds@1952: {
ds@1952: flag = array[0];
ds@1952: return true;
ds@1952: }
ds@1952:
ds@1952: return false;
ds@1952: }
ds@1952: