1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/plugins/include/admin.inc Wed Jan 24 23:43:31 2007 +0000
1.3 @@ -0,0 +1,214 @@
1.4 +#if defined _admin_included
1.5 + #endinput
1.6 +#endif
1.7 +#define _admin_included
1.8 +
1.9 +enum AdminFlag
1.10 +{
1.11 + Admin_None = 0, /* Unused */
1.12 + Admin_Reservation, /* Reserved slot */
1.13 + Admin_Kick, /* Kick another user */
1.14 + Admin_Ban, /* Ban another user */
1.15 + Admin_Unban, /* Unban another user */
1.16 + Admin_Slay, /* Slay/kill/damage another user */
1.17 + Admin_Changemap, /* Change the map */
1.18 + Admin_Convars, /* Change basic convars */
1.19 + Admin_Configs, /* Change configs */
1.20 + Admin_Chat, /* Special chat privileges */
1.21 + Admin_Vote, /* Special vote privileges */
1.22 + Admin_Password, /* Set a server password */
1.23 + Admin_RCON, /* Use RCON */
1.24 + Admin_Cheats, /* Change sv_cheats and use its commands */
1.25 + /* --- */
1.26 + AdminFlags_TOTAL,
1.27 +};
1.28 +
1.29 +enum OverrideType
1.30 +{
1.31 + Override_Command = 1, /* Command */
1.32 + Override_CommandGroup, /* Command group */
1.33 +};
1.34 +
1.35 +enum OverrideRule
1.36 +{
1.37 + Command_Deny = 0,
1.38 + Command_Allow = 1,
1.39 +};
1.40 +
1.41 +enum ImmunityType
1.42 +{
1.43 + Immunity_Default = 1, /* Immune from everyone with no immunity */
1.44 + Immunity_Global, /* Immune from everyone (except root admins) */
1.45 +};
1.46 +
1.47 +/** Note: Groups are not Handles, nor are they indexes */
1.48 +enum GroupId
1.49 +{
1.50 + INVALID_GROUP_ID = -1,
1.51 +};
1.52 +
1.53 +#define ADMIN_CACHE_OVERRIDES (1<<0)
1.54 +#define ADMIN_CACHE_ADMINS (1<<1)
1.55 +#define ADMIN_CACHE_GROUPS ((1<<2)|ADMIN_CACHE_ADMINS)
1.56 +
1.57 +/**
1.58 + * Called when part of the admin cache needs to be rebuilt.
1.59 + * @note Groups should always be rebuilt before admins.
1.60 + *
1.61 + * @param cache_flags Flags for which cache to dump.
1.62 + */
1.63 +forward OnRebuildAdminCache(cache_flags);
1.64 +
1.65 +/**
1.66 + * Tells the admin system to dump a portion of the cache.
1.67 + *
1.68 + * @param cache_flags Flags for which cache to dump. Specifying groups also dumps admins.
1.69 + * @param rebuild If true, the rebuild forwards will fire.
1.70 + * @noreturn
1.71 + */
1.72 +native DumpAdminCache(cache_flags, bool:rebuild);
1.73 +
1.74 +/**
1.75 + * Adds a global command flag override. Any command registered with this name
1.76 + * will assume the new flag. This is applied retroactively as well.
1.77 + *
1.78 + * @param cmd String containing command name (case sensitive).
1.79 + * @param type Override type (specific command or group).
1.80 + * @param flag New admin flag.
1.81 + * @noreturn
1.82 + */
1.83 +native AddCommandOverride(const String:cmd[], OverrideType:type, AdminFlag:flag);
1.84 +
1.85 +/**
1.86 + * Returns a command override.
1.87 + *
1.88 + * @param cmd String containing command name (case sensitive).
1.89 + * @param type Override type (specific command or group).
1.90 + * @param pFlag By-reference cell to store the flag (undefined if not found).
1.91 + * @return True if there is an override, false otherwise.
1.92 + */
1.93 +native bool:GetCommandOverride(const String:cmd[], OverrideType:type, &AdminFlag:flag);
1.94 +
1.95 +/**
1.96 + * Unsets a command override.
1.97 + *
1.98 + * @param cmd String containing command name (case sensitive).
1.99 + * @param type Override type (specific command or group).
1.100 + * @noreturn
1.101 + */
1.102 +native UnsetCommandOverride(const String:cmd[], OverrideType:type);
1.103 +
1.104 +/**
1.105 + * Adds a new group. Name must be unique.
1.106 + *
1.107 + * @param group_name String containing the group name.
1.108 + * @return A new group id, INVALID_GROUP_ID if it already exists.
1.109 + */
1.110 +native GroupId:CreateAdmGroup(const String:group_name[]);
1.111 +
1.112 +/**
1.113 + * @brief Finds a group by name.
1.114 + *
1.115 + * @param group_name String containing the group name.
1.116 + * @return A group id, or INVALID_GROUP_ID if not found.
1.117 + */
1.118 +native FindAdmGroup(const String:group_name[]);
1.119 +
1.120 +/**
1.121 + * Adds or removes a flag from a group's flag set.
1.122 + * @note These are called "add flags" because they add to a user's flags.
1.123 + *
1.124 + * @param id Group id.
1.125 + * @param flag Admin flag to toggle.
1.126 + * @param enabled True to set the flag, false to unset/disable.
1.127 + * @noreturn
1.128 + */
1.129 +native SetAdmGroupAddFlag(GroupId:id, AdminFlag:flag, bool:enabled);
1.130 +
1.131 +/**
1.132 + * Gets the set value of an add flag on a group's flag set.
1.133 + * @note These are called "add flags" because they add to a user's flags.
1.134 + *
1.135 + * @param id Group id.
1.136 + * @param flag Admin flag to retrieve.
1.137 + * @return True if enabled, false otherwise,
1.138 + */
1.139 +native bool:GetAdmGroupAddFlag(GroupId:id, AdminFlag:flag);
1.140 +
1.141 +/**
1.142 + * Returns the flag set that is added to a user from their group.
1.143 + * @note These are called "add flags" because they add to a user's flags.
1.144 + *
1.145 + * @param id GroupId of the group.
1.146 + * @param flags Array to store flags in.
1.147 + * @param total Total number of flags that can be stored in the array (AdminFlags_TOTAL, usually).
1.148 + * @return Number of flags that were written to the array.
1.149 + */
1.150 +native GetAdmGroupAddFlagBits(GroupId:id, bool flags[], total);
1.151 +
1.152 +/**
1.153 + * Toggles a generic immunity type.
1.154 + *
1.155 + * @param id Group id.
1.156 + * @param type Generic immunity type.
1.157 + * @param enabled True to enable, false otherwise.
1.158 + * @noreturn
1.159 + */
1.160 +native SetAdmGroupImmunity(GroupId:id, ImmunityType:type, bool:enabled);
1.161 +
1.162 +/**
1.163 + * Returns whether or not a group has global immunity.
1.164 + *
1.165 + * @param id Group id.
1.166 + * @param type Generic immunity type.
1.167 + * @return True if the group has this immunity, false otherwise.
1.168 + */
1.169 +native bool:GetAdmGroupImmunity(GroupId:id, ImmunityType:type);
1.170 +
1.171 +/**
1.172 + * Adds immunity to a specific group.
1.173 + *
1.174 + * @param id Group id.
1.175 + * @param other_id Group id to receive immunity to.
1.176 + * @noreturn
1.177 + */
1.178 +native SetAdmGroupImmuneFrom(GroupId:id, GroupId:other_id);
1.179 +
1.180 +/**
1.181 + * Returns the number of specific group immunities.
1.182 + *
1.183 + * @param id Group id.
1.184 + * @return Number of group immunities.
1.185 + */
1.186 +native GetAdmGroupImmuneCount(GroupId:id);
1.187 +
1.188 +/**
1.189 + * Returns a group that this group is immune to given an index.
1.190 + *
1.191 + * @param id Group id.
1.192 + * @param number Index from 0 to N-1, from GetAdmGroupImmuneCount().
1.193 + * @return GroupId that this group is immune to, or INVALID_GROUP_ID on failure.
1.194 + */
1.195 +native GroupId:GetAdmGroupImmuneFrom(GroupId:id, number);
1.196 +
1.197 +/**
1.198 + * Adds a group-specific override type.
1.199 + *
1.200 + * @param id Group id.
1.201 + * @param name String containing command name (case sensitive).
1.202 + * @param type Override type (specific command or group).
1.203 + * @param rule Override allow/deny setting.
1.204 + * @noreturn
1.205 + */
1.206 +native AddAdmGroupCmdOverride(GroupId:id, const String:name[], OverrideType:type, OverrideRule:rule);
1.207 +
1.208 +/**
1.209 + * Retrieves a group-specific command override.
1.210 + *
1.211 + * @param id Group id.
1.212 + * @param name String containing command name (case sensitive).
1.213 + * @param type Override type (specific command or group).
1.214 + * @param rule Optional pointer to store allow/deny setting.
1.215 + * @return True if an override exists, false otherwise.
1.216 + */
1.217 +native bool:GetAdmGroupCmdOverride(GroupId:id, const String:name[], OverrideType:type, &OverrideRule:rule);