Correct Plugin API Documentation Formatting (#1019)

This commit is contained in:
JoinedSenses 2019-05-28 21:38:58 -04:00 committed by Headline
parent 28036966a6
commit 81dc80fbd1
66 changed files with 6434 additions and 6331 deletions

View File

@ -40,56 +40,55 @@
*/ */
enum AdminFlag enum AdminFlag
{ {
Admin_Reservation = 0, /**< Reserved slot */ Admin_Reservation = 0, /**< Reserved slot */
Admin_Generic, /**< Generic admin abilities */ Admin_Generic, /**< Generic admin abilities */
Admin_Kick, /**< Kick another user */ Admin_Kick, /**< Kick another user */
Admin_Ban, /**< Ban another user */ Admin_Ban, /**< Ban another user */
Admin_Unban, /**< Unban another user */ Admin_Unban, /**< Unban another user */
Admin_Slay, /**< Slay/kill/damage another user */ Admin_Slay, /**< Slay/kill/damage another user */
Admin_Changemap, /**< Change the map */ Admin_Changemap, /**< Change the map */
Admin_Convars, /**< Change basic convars */ Admin_Convars, /**< Change basic convars */
Admin_Config, /**< Change configuration */ Admin_Config, /**< Change configuration */
Admin_Chat, /**< Special chat privileges */ Admin_Chat, /**< Special chat privileges */
Admin_Vote, /**< Special vote privileges */ Admin_Vote, /**< Special vote privileges */
Admin_Password, /**< Set a server password */ Admin_Password, /**< Set a server password */
Admin_RCON, /**< Use RCON */ Admin_RCON, /**< Use RCON */
Admin_Cheats, /**< Change sv_cheats and use its commands */ Admin_Cheats, /**< Change sv_cheats and use its commands */
Admin_Root, /**< All access by default */ Admin_Root, /**< All access by default */
Admin_Custom1, /**< First custom flag type */ Admin_Custom1, /**< First custom flag type */
Admin_Custom2, /**< Second custom flag type */ Admin_Custom2, /**< Second custom flag type */
Admin_Custom3, /**< Third custom flag type */ Admin_Custom3, /**< Third custom flag type */
Admin_Custom4, /**< Fourth custom flag type */ Admin_Custom4, /**< Fourth custom flag type */
Admin_Custom5, /**< Fifth custom flag type */ Admin_Custom5, /**< Fifth custom flag type */
Admin_Custom6, /**< Sixth custom flag type */ Admin_Custom6 /**< Sixth custom flag type */
/* --- */
}; };
#define AdminFlags_TOTAL 21 /**< Total number of admin flags */ #define AdminFlags_TOTAL 21 /**< Total number of admin flags */
/** /**
* @section Bitwise values definitions for admin flags. * @section Bitwise values definitions for admin flags.
*/ */
#define ADMFLAG_RESERVATION (1<<0) /**< Convenience macro for Admin_Reservation as a FlagBit */ #define ADMFLAG_RESERVATION (1<<0) /**< Convenience macro for Admin_Reservation as a FlagBit */
#define ADMFLAG_GENERIC (1<<1) /**< Convenience macro for Admin_Generic as a FlagBit */ #define ADMFLAG_GENERIC (1<<1) /**< Convenience macro for Admin_Generic as a FlagBit */
#define ADMFLAG_KICK (1<<2) /**< Convenience macro for Admin_Kick as a FlagBit */ #define ADMFLAG_KICK (1<<2) /**< Convenience macro for Admin_Kick as a FlagBit */
#define ADMFLAG_BAN (1<<3) /**< Convenience macro for Admin_Ban as a FlagBit */ #define ADMFLAG_BAN (1<<3) /**< Convenience macro for Admin_Ban as a FlagBit */
#define ADMFLAG_UNBAN (1<<4) /**< Convenience macro for Admin_Unban as a FlagBit */ #define ADMFLAG_UNBAN (1<<4) /**< Convenience macro for Admin_Unban as a FlagBit */
#define ADMFLAG_SLAY (1<<5) /**< Convenience macro for Admin_Slay as a FlagBit */ #define ADMFLAG_SLAY (1<<5) /**< Convenience macro for Admin_Slay as a FlagBit */
#define ADMFLAG_CHANGEMAP (1<<6) /**< Convenience macro for Admin_Changemap as a FlagBit */ #define ADMFLAG_CHANGEMAP (1<<6) /**< Convenience macro for Admin_Changemap as a FlagBit */
#define ADMFLAG_CONVARS (1<<7) /**< Convenience macro for Admin_Convars as a FlagBit */ #define ADMFLAG_CONVARS (1<<7) /**< Convenience macro for Admin_Convars as a FlagBit */
#define ADMFLAG_CONFIG (1<<8) /**< Convenience macro for Admin_Config as a FlagBit */ #define ADMFLAG_CONFIG (1<<8) /**< Convenience macro for Admin_Config as a FlagBit */
#define ADMFLAG_CHAT (1<<9) /**< Convenience macro for Admin_Chat as a FlagBit */ #define ADMFLAG_CHAT (1<<9) /**< Convenience macro for Admin_Chat as a FlagBit */
#define ADMFLAG_VOTE (1<<10) /**< Convenience macro for Admin_Vote as a FlagBit */ #define ADMFLAG_VOTE (1<<10) /**< Convenience macro for Admin_Vote as a FlagBit */
#define ADMFLAG_PASSWORD (1<<11) /**< Convenience macro for Admin_Password as a FlagBit */ #define ADMFLAG_PASSWORD (1<<11) /**< Convenience macro for Admin_Password as a FlagBit */
#define ADMFLAG_RCON (1<<12) /**< Convenience macro for Admin_RCON as a FlagBit */ #define ADMFLAG_RCON (1<<12) /**< Convenience macro for Admin_RCON as a FlagBit */
#define ADMFLAG_CHEATS (1<<13) /**< Convenience macro for Admin_Cheats as a FlagBit */ #define ADMFLAG_CHEATS (1<<13) /**< Convenience macro for Admin_Cheats as a FlagBit */
#define ADMFLAG_ROOT (1<<14) /**< Convenience macro for Admin_Root as a FlagBit */ #define ADMFLAG_ROOT (1<<14) /**< Convenience macro for Admin_Root as a FlagBit */
#define ADMFLAG_CUSTOM1 (1<<15) /**< Convenience macro for Admin_Custom1 as a FlagBit */ #define ADMFLAG_CUSTOM1 (1<<15) /**< Convenience macro for Admin_Custom1 as a FlagBit */
#define ADMFLAG_CUSTOM2 (1<<16) /**< Convenience macro for Admin_Custom2 as a FlagBit */ #define ADMFLAG_CUSTOM2 (1<<16) /**< Convenience macro for Admin_Custom2 as a FlagBit */
#define ADMFLAG_CUSTOM3 (1<<17) /**< Convenience macro for Admin_Custom3 as a FlagBit */ #define ADMFLAG_CUSTOM3 (1<<17) /**< Convenience macro for Admin_Custom3 as a FlagBit */
#define ADMFLAG_CUSTOM4 (1<<18) /**< Convenience macro for Admin_Custom4 as a FlagBit */ #define ADMFLAG_CUSTOM4 (1<<18) /**< Convenience macro for Admin_Custom4 as a FlagBit */
#define ADMFLAG_CUSTOM5 (1<<19) /**< Convenience macro for Admin_Custom5 as a FlagBit */ #define ADMFLAG_CUSTOM5 (1<<19) /**< Convenience macro for Admin_Custom5 as a FlagBit */
#define ADMFLAG_CUSTOM6 (1<<20) /**< Convenience macro for Admin_Custom6 as a FlagBit */ #define ADMFLAG_CUSTOM6 (1<<20) /**< Convenience macro for Admin_Custom6 as a FlagBit */
/** /**
* @endsection * @endsection
@ -98,9 +97,9 @@ enum AdminFlag
/** /**
* @section Hardcoded authentication methods * @section Hardcoded authentication methods
*/ */
#define AUTHMETHOD_STEAM "steam" /**< SteamID based authentication */ #define AUTHMETHOD_STEAM "steam" /**< SteamID based authentication */
#define AUTHMETHOD_IP "ip" /**< IP based authentication */ #define AUTHMETHOD_IP "ip" /**< IP based authentication */
#define AUTHMETHOD_NAME "name" /**< Name based authentication */ #define AUTHMETHOD_NAME "name" /**< Name based authentication */
/** /**
* @endsection * @endsection
@ -111,8 +110,8 @@ enum AdminFlag
*/ */
enum OverrideType enum OverrideType
{ {
Override_Command = 1, /**< Command */ Override_Command = 1, /**< Command */
Override_CommandGroup, /**< Command group */ Override_CommandGroup /**< Command group */
}; };
/** /**
@ -121,7 +120,7 @@ enum OverrideType
enum OverrideRule enum OverrideRule
{ {
Command_Deny = 0, Command_Deny = 0,
Command_Allow = 1, Command_Allow = 1
}; };
/** /**
@ -129,8 +128,8 @@ enum OverrideRule
*/ */
enum ImmunityType enum ImmunityType
{ {
Immunity_Default = 1, /**< Deprecated. */ Immunity_Default = 1, /**< Deprecated. */
Immunity_Global, /**< Deprecated. */ Immunity_Global /**< Deprecated. */
}; };
/** /**
@ -138,7 +137,7 @@ enum ImmunityType
*/ */
enum GroupId enum GroupId
{ {
INVALID_GROUP_ID = -1, /**< An invalid/non-existent group */ INVALID_GROUP_ID = -1 /**< An invalid/non-existent group */
}; };
/** /**
@ -146,7 +145,7 @@ enum GroupId
*/ */
enum AdminId enum AdminId
{ {
INVALID_ADMIN_ID = -1, /**< An invalid/non-existent admin */ INVALID_ADMIN_ID = -1 /**< An invalid/non-existent admin */
}; };
/** /**
@ -154,8 +153,8 @@ enum AdminId
*/ */
enum AdmAccessMode enum AdmAccessMode
{ {
Access_Real, /**< Access the user has inherently */ Access_Real, /**< Access the user has inherently */
Access_Effective, /**< Access the user has from their groups */ Access_Effective /**< Access the user has from their groups */
}; };
/** /**
@ -163,9 +162,9 @@ enum AdmAccessMode
*/ */
enum AdminCachePart enum AdminCachePart
{ {
AdminCache_Overrides = 0, /**< Global overrides */ AdminCache_Overrides = 0, /**< Global overrides */
AdminCache_Groups = 1, /**< All groups (automatically invalidates admins too) */ AdminCache_Groups = 1, /**< All groups (automatically invalidates admins too) */
AdminCache_Admins = 2, /**< All admins */ AdminCache_Admins = 2 /**< All admins */
}; };
methodmap AdminId { methodmap AdminId {
@ -269,45 +268,45 @@ methodmap AdminId {
methodmap GroupId { methodmap GroupId {
// Gets whether or not a flag is enabled on a group's flag set. // Gets whether or not a flag is enabled on a group's flag set.
// //
// @param flag Admin flag to retrieve. // @param flag Admin flag to retrieve.
// @return True if enabled, false otherwise, // @return True if enabled, false otherwise,
public native bool HasFlag(AdminFlag flag); public native bool HasFlag(AdminFlag flag);
// Adds or removes a flag from a group's flag set. // Adds or removes a flag from a group's flag set.
// //
// @param flag Admin flag to toggle. // @param flag Admin flag to toggle.
// @param enabled True to set the flag, false to unset/disable. // @param enabled True to set the flag, false to unset/disable.
public native void SetFlag(AdminFlag flag, bool enabled); public native void SetFlag(AdminFlag flag, bool enabled);
// Returns the flag set that is added to users from this group. // Returns the flag set that is added to users from this group.
// //
// @return Bitstring containing the flags enabled. // @return Bitstring containing the flags enabled.
public native int GetFlags(); public native int GetFlags();
// Returns a group that this group is immune to given an index. // Returns a group that this group is immune to given an index.
// //
// @param number Index from 0 to N-1, from GroupImmunitiesCount. // @param number Index from 0 to N-1, from GroupImmunitiesCount.
// @return GroupId that this group is immune to, or INVALID_GROUP_ID on failure. // @return GroupId that this group is immune to, or INVALID_GROUP_ID on failure.
public native GroupId GetGroupImmunity(int index); public native GroupId GetGroupImmunity(int index);
// Adds immunity to a specific group. // Adds immunity to a specific group.
// //
// @param other Group id to receive immunity to. // @param other Group id to receive immunity to.
public native void AddGroupImmunity(GroupId other); public native void AddGroupImmunity(GroupId other);
// Retrieves a group-specific command override. // Retrieves a group-specific command override.
// //
// @param name String containing command name (case sensitive). // @param name String containing command name (case sensitive).
// @param type Override type (specific command or group). // @param type Override type (specific command or group).
// @param rule Optional pointer to store allow/deny setting. // @param rule Optional pointer to store allow/deny setting.
// @return True if an override exists, false otherwise. // @return True if an override exists, false otherwise.
public native bool GetCommandOverride(const char[] name, OverrideType type, OverrideRule &rule); public native bool GetCommandOverride(const char[] name, OverrideType type, OverrideRule &rule);
// Adds a group-specific override type. // Adds a group-specific override type.
// //
// @param name String containing command name (case sensitive). // @param name String containing command name (case sensitive).
// @param type Override type (specific command or group). // @param type Override type (specific command or group).
// @param rule Override allow/deny setting. // @param rule Override allow/deny setting.
public native void AddCommandOverride(const char[] name, OverrideType type, OverrideRule rule); public native void AddCommandOverride(const char[] name, OverrideType type, OverrideRule rule);
// Number of specific group immunities // Number of specific group immunities
@ -325,15 +324,15 @@ methodmap GroupId {
/** /**
* Called when part of the cache needs to be rebuilt. * Called when part of the cache needs to be rebuilt.
* *
* @param part Part of the admin cache to rebuild. * @param part Part of the admin cache to rebuild.
*/ */
forward void OnRebuildAdminCache(AdminCachePart part); forward void OnRebuildAdminCache(AdminCachePart part);
/** /**
* Tells the admin system to dump a portion of the cache. * Tells the admin system to dump a portion of the cache.
* *
* @param part Part of the cache to dump. Specifying groups also dumps admins. * @param part Part of the cache to dump. Specifying groups also dumps admins.
* @param rebuild If true, the rebuild forwards will fire. * @param rebuild If true, the rebuild forwards will fire.
*/ */
native void DumpAdminCache(AdminCachePart part, bool rebuild); native void DumpAdminCache(AdminCachePart part, bool rebuild);
@ -341,43 +340,43 @@ native void DumpAdminCache(AdminCachePart part, bool rebuild);
* Adds a global command flag override. Any command registered with this name * Adds a global command flag override. Any command registered with this name
* will assume the new flag. This is applied retroactively as well. * will assume the new flag. This is applied retroactively as well.
* *
* @param cmd String containing command name (case sensitive). * @param cmd String containing command name (case sensitive).
* @param type Override type (specific command or group). * @param type Override type (specific command or group).
* @param flags New admin flag. * @param flags New admin flag.
*/ */
native void AddCommandOverride(const char[] cmd, OverrideType type, int flags); native void AddCommandOverride(const char[] cmd, OverrideType type, int flags);
/** /**
* Returns a command override. * Returns a command override.
* *
* @param cmd String containing command name (case sensitive). * @param cmd String containing command name (case sensitive).
* @param type Override type (specific command or group). * @param type Override type (specific command or group).
* @param flags By-reference cell to store the flag (undefined if not found). * @param flags By-reference cell to store the flag (undefined if not found).
* @return True if there is an override, false otherwise. * @return True if there is an override, false otherwise.
*/ */
native bool GetCommandOverride(const char[] cmd, OverrideType type, int &flags); native bool GetCommandOverride(const char[] cmd, OverrideType type, int &flags);
/** /**
* Unsets a command override. * Unsets a command override.
* *
* @param cmd String containing command name (case sensitive). * @param cmd String containing command name (case sensitive).
* @param type Override type (specific command or group). * @param type Override type (specific command or group).
*/ */
native void UnsetCommandOverride(const char[] cmd, OverrideType type); native void UnsetCommandOverride(const char[] cmd, OverrideType type);
/** /**
* Adds a new group. Name must be unique. * Adds a new group. Name must be unique.
* *
* @param group_name String containing the group name. * @param group_name String containing the group name.
* @return A new group id, INVALID_GROUP_ID if it already exists. * @return A new group id, INVALID_GROUP_ID if it already exists.
*/ */
native GroupId CreateAdmGroup(const char[] group_name); native GroupId CreateAdmGroup(const char[] group_name);
/** /**
* Finds a group by name. * Finds a group by name.
* *
* @param group_name String containing the group name. * @param group_name String containing the group name.
* @return A group id, or INVALID_GROUP_ID if not found. * @return A group id, or INVALID_GROUP_ID if not found.
*/ */
native GroupId FindAdmGroup(const char[] group_name); native GroupId FindAdmGroup(const char[] group_name);
@ -385,9 +384,9 @@ native GroupId FindAdmGroup(const char[] group_name);
* Adds or removes a flag from a group's flag set. * Adds or removes a flag from a group's flag set.
* @note These are called "add flags" because they add to a user's flags. * @note These are called "add flags" because they add to a user's flags.
* *
* @param id Group id. * @param id Group id.
* @param flag Admin flag to toggle. * @param flag Admin flag to toggle.
* @param enabled True to set the flag, false to unset/disable. * @param enabled True to set the flag, false to unset/disable.
*/ */
native void SetAdmGroupAddFlag(GroupId id, AdminFlag flag, bool enabled); native void SetAdmGroupAddFlag(GroupId id, AdminFlag flag, bool enabled);
@ -395,9 +394,9 @@ native void SetAdmGroupAddFlag(GroupId id, AdminFlag flag, bool enabled);
* Gets the set value of an add flag on a group's flag set. * Gets the set value of an add flag on a group's flag set.
* @note These are called "add flags" because they add to a user's flags. * @note These are called "add flags" because they add to a user's flags.
* *
* @param id Group id. * @param id Group id.
* @param flag Admin flag to retrieve. * @param flag Admin flag to retrieve.
* @return True if enabled, false otherwise, * @return True if enabled, false otherwise,
*/ */
native bool GetAdmGroupAddFlag(GroupId id, AdminFlag flag); native bool GetAdmGroupAddFlag(GroupId id, AdminFlag flag);
@ -405,19 +404,19 @@ native bool GetAdmGroupAddFlag(GroupId id, AdminFlag flag);
* Returns the flag set that is added to a user from their group. * Returns the flag set that is added to a user from their group.
* @note These are called "add flags" because they add to a user's flags. * @note These are called "add flags" because they add to a user's flags.
* *
* @param id GroupId of the group. * @param id GroupId of the group.
* @return Bitstring containing the flags enabled. * @return Bitstring containing the flags enabled.
*/ */
native int GetAdmGroupAddFlags(GroupId id); native int GetAdmGroupAddFlags(GroupId id);
/** /**
* @deprecated Functionality removed. * @deprecated Functionality removed.
*/ */
#pragma deprecated Use SetAdmGroupImmunityLevel() instead. #pragma deprecated Use SetAdmGroupImmunityLevel() instead.
native void SetAdmGroupImmunity(GroupId id, ImmunityType type, bool enabled); native void SetAdmGroupImmunity(GroupId id, ImmunityType type, bool enabled);
/** /**
* @deprecated Functionality removed. * @deprecated Functionality removed.
*/ */
#pragma deprecated Use GetAdmGroupImmunityLevel() instead. #pragma deprecated Use GetAdmGroupImmunityLevel() instead.
native bool GetAdmGroupImmunity(GroupId id, ImmunityType type); native bool GetAdmGroupImmunity(GroupId id, ImmunityType type);
@ -425,46 +424,46 @@ native bool GetAdmGroupImmunity(GroupId id, ImmunityType type);
/** /**
* Adds immunity to a specific group. * Adds immunity to a specific group.
* *
* @param id Group id. * @param id Group id.
* @param other_id Group id to receive immunity to. * @param other_id Group id to receive immunity to.
*/ */
native void SetAdmGroupImmuneFrom(GroupId id, GroupId other_id); native void SetAdmGroupImmuneFrom(GroupId id, GroupId other_id);
/** /**
* Returns the number of specific group immunities. * Returns the number of specific group immunities.
* *
* @param id Group id. * @param id Group id.
* @return Number of group immunities. * @return Number of group immunities.
*/ */
native int GetAdmGroupImmuneCount(GroupId id); native int GetAdmGroupImmuneCount(GroupId id);
/** /**
* Returns a group that this group is immune to given an index. * Returns a group that this group is immune to given an index.
* *
* @param id Group id. * @param id Group id.
* @param number Index from 0 to N-1, from GetAdmGroupImmuneCount(). * @param number Index from 0 to N-1, from GetAdmGroupImmuneCount().
* @return GroupId that this group is immune to, or INVALID_GROUP_ID on failure. * @return GroupId that this group is immune to, or INVALID_GROUP_ID on failure.
*/ */
native GroupId GetAdmGroupImmuneFrom(GroupId id, int number); native GroupId GetAdmGroupImmuneFrom(GroupId id, int number);
/** /**
* Adds a group-specific override type. * Adds a group-specific override type.
* *
* @param id Group id. * @param id Group id.
* @param name String containing command name (case sensitive). * @param name String containing command name (case sensitive).
* @param type Override type (specific command or group). * @param type Override type (specific command or group).
* @param rule Override allow/deny setting. * @param rule Override allow/deny setting.
*/ */
native void AddAdmGroupCmdOverride(GroupId id, const char[] name, OverrideType type, OverrideRule rule); native void AddAdmGroupCmdOverride(GroupId id, const char[] name, OverrideType type, OverrideRule rule);
/** /**
* Retrieves a group-specific command override. * Retrieves a group-specific command override.
* *
* @param id Group id. * @param id Group id.
* @param name String containing command name (case sensitive). * @param name String containing command name (case sensitive).
* @param type Override type (specific command or group). * @param type Override type (specific command or group).
* @param rule Optional pointer to store allow/deny setting. * @param rule Optional pointer to store allow/deny setting.
* @return True if an override exists, false otherwise. * @return True if an override exists, false otherwise.
*/ */
native bool GetAdmGroupCmdOverride(GroupId id, const char[] name, OverrideType type, OverrideRule &rule); native bool GetAdmGroupCmdOverride(GroupId id, const char[] name, OverrideType type, OverrideRule &rule);
@ -472,15 +471,16 @@ native bool GetAdmGroupCmdOverride(GroupId id, const char[] name, OverrideType t
* Registers an authentication identity type. You normally never need to call this except for * Registers an authentication identity type. You normally never need to call this except for
* very specific systems. * very specific systems.
* *
* @param name Codename to use for your authentication type. * @param name Codename to use for your authentication type.
*/ */
native void RegisterAuthIdentType(const char[] name); native void RegisterAuthIdentType(const char[] name);
/** /**
* Creates a new admin entry in the permissions cache. * Creates a new admin entry in the permissions cache and returns the generated AdminId index.
* *
* @param name Name for this entry (does not have to be unique). * @param name Name for this entry (does not have to be unique).
* Specify an empty string for an anonymous admin. * Specify an empty string for an anonymous admin.
* @return New AdminId index or INVALID_ADMIN_ID if name is empty
*/ */
native AdminId CreateAdmin(const char[] name=""); native AdminId CreateAdmin(const char[] name="");
@ -489,49 +489,49 @@ native AdminId CreateAdmin(const char[] name="");
* *
* @note This function can return UTF-8 strings, and will safely chop UTF-8 strings. * @note This function can return UTF-8 strings, and will safely chop UTF-8 strings.
* *
* @param id AdminId of the admin. * @param id AdminId of the admin.
* @param name String buffer to store name. * @param name String buffer to store name.
* @param maxlength Maximum size of string buffer. * @param maxlength Maximum size of string buffer.
* @return Number of bytes written. * @return Number of bytes written.
*/ */
native int GetAdminUsername(AdminId id, char[] name, int maxlength); native int GetAdminUsername(AdminId id, char[] name, int maxlength);
/** /**
* Binds an admin to an identity for fast lookup later on. The bind must be unique. * Binds an admin to an identity for fast lookup later on. The bind must be unique.
* *
* @param id AdminId of the admin. * @param id AdminId of the admin.
* @param auth Auth method to use, predefined or from RegisterAuthIdentType(). * @param auth Auth method to use, predefined or from RegisterAuthIdentType().
* @param ident String containing the arbitrary, unique identity. * @param ident String containing the arbitrary, unique identity.
* @return True on success, false if the auth method was not found, * @return True on success, false if the auth method was not found,
* ident was already taken, or ident invalid for auth method. * ident was already taken, or ident invalid for auth method.
*/ */
native bool BindAdminIdentity(AdminId id, const char[] auth, const char[] ident); native bool BindAdminIdentity(AdminId id, const char[] auth, const char[] ident);
/** /**
* Sets whether or not a flag is enabled on an admin. * Sets whether or not a flag is enabled on an admin.
* *
* @param id AdminId index of the admin. * @param id AdminId index of the admin.
* @param flag Admin flag to use. * @param flag Admin flag to use.
* @param enabled True to enable, false to disable. * @param enabled True to enable, false to disable.
*/ */
native void SetAdminFlag(AdminId id, AdminFlag flag, bool enabled); native void SetAdminFlag(AdminId id, AdminFlag flag, bool enabled);
/** /**
* Returns whether or not a flag is enabled on an admin. * Returns whether or not a flag is enabled on an admin.
* *
* @param id AdminId index of the admin. * @param id AdminId index of the admin.
* @param flag Admin flag to use. * @param flag Admin flag to use.
* @param mode Access mode to check. * @param mode Access mode to check.
* @return True if enabled, false otherwise. * @return True if enabled, false otherwise.
*/ */
native bool GetAdminFlag(AdminId id, AdminFlag flag, AdmAccessMode mode=Access_Effective); native bool GetAdminFlag(AdminId id, AdminFlag flag, AdmAccessMode mode=Access_Effective);
/** /**
* Returns the bitstring of access flags on an admin. * Returns the bitstring of access flags on an admin.
* *
* @param id AdminId index of the admin. * @param id AdminId index of the admin.
* @param mode Access mode to use. * @param mode Access mode to use.
* @return A bitstring containing which flags are enabled. * @return A bitstring containing which flags are enabled.
*/ */
native int GetAdminFlags(AdminId id, AdmAccessMode mode); native int GetAdminFlags(AdminId id, AdmAccessMode mode);
@ -539,59 +539,59 @@ native int GetAdminFlags(AdminId id, AdmAccessMode mode);
* Adds a group to an admin's inherited group list. Any flags the group has * Adds a group to an admin's inherited group list. Any flags the group has
* will be added to the admin's effective flags. * will be added to the admin's effective flags.
* *
* @param id AdminId index of the admin. * @param id AdminId index of the admin.
* @param gid GroupId index of the group. * @param gid GroupId index of the group.
* @return True on success, false on invalid input or duplicate membership. * @return True on success, false on invalid input or duplicate membership.
*/ */
native bool AdminInheritGroup(AdminId id, GroupId gid); native bool AdminInheritGroup(AdminId id, GroupId gid);
/** /**
* Returns the number of groups this admin is a member of. * Returns the number of groups this admin is a member of.
* *
* @param id AdminId index of the admin. * @param id AdminId index of the admin.
* @return Number of groups this admin is a member of. * @return Number of groups this admin is a member of.
*/ */
native int GetAdminGroupCount(AdminId id); native int GetAdminGroupCount(AdminId id);
/** /**
* Returns group information from an admin. * Returns group information from an admin.
* *
* @param id AdminId index of the admin. * @param id AdminId index of the admin.
* @param index Group number to retrieve, from 0 to N-1, where N * @param index Group number to retrieve, from 0 to N-1, where N
* is the value of GetAdminGroupCount(id). * is the value of GetAdminGroupCount(id).
* @param name Buffer to store the group's name. * @param name Buffer to store the group's name.
* Note: This will safely chop UTF-8 strings. * Note: This will safely chop UTF-8 strings.
* @param maxlength Maximum size of the output name buffer. * @param maxlength Maximum size of the output name buffer.
* @return A GroupId index and a name pointer, or * @return A GroupId index and a name pointer, or
* INVALID_GROUP_ID and NULL if an error occurred. * INVALID_GROUP_ID and NULL if an error occurred.
*/ */
native GroupId GetAdminGroup(AdminId id, int index, char[] name, int maxlength); native GroupId GetAdminGroup(AdminId id, int index, char[] name, int maxlength);
/** /**
* Sets a password on an admin. * Sets a password on an admin.
* *
* @param id AdminId index of the admin. * @param id AdminId index of the admin.
* @param password String containing the password. * @param password String containing the password.
*/ */
native void SetAdminPassword(AdminId id, const char[] password); native void SetAdminPassword(AdminId id, const char[] password);
/** /**
* Gets an admin's password. * Gets an admin's password.
* *
* @param id AdminId index of the admin. * @param id AdminId index of the admin.
* @param buffer Optional buffer to store the admin's password. * @param buffer Optional buffer to store the admin's password.
* @param maxlength Maximum size of the output name buffer. * @param maxlength Maximum size of the output name buffer.
* Note: This will safely chop UTF-8 strings. * Note: This will safely chop UTF-8 strings.
* @return True if there was a password set, false otherwise. * @return True if there was a password set, false otherwise.
*/ */
native bool GetAdminPassword(AdminId id, char[] buffer="", int maxlength=0); native bool GetAdminPassword(AdminId id, char[] buffer="", int maxlength=0);
/** /**
* Attempts to find an admin by an auth method and an identity. * Attempts to find an admin by an auth method and an identity.
* *
* @param auth Auth method to try. * @param auth Auth method to try.
* @param identity Identity string to look up. * @param identity Identity string to look up.
* @return An AdminId index if found, INVALID_ADMIN_ID otherwise. * @return An AdminId index if found, INVALID_ADMIN_ID otherwise.
*/ */
native AdminId FindAdminByIdentity(const char[] auth, const char[] identity); native AdminId FindAdminByIdentity(const char[] auth, const char[] identity);
@ -600,82 +600,82 @@ native AdminId FindAdminByIdentity(const char[] auth, const char[] identity);
* *
* @note This will remove any bindings to a specific user. * @note This will remove any bindings to a specific user.
* *
* @param id AdminId index to remove/invalidate. * @param id AdminId index to remove/invalidate.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
native bool RemoveAdmin(AdminId id); native bool RemoveAdmin(AdminId id);
/** /**
* Converts a flag bit string to a bit array. * Converts a flag bit string to a bit array.
* *
* @param bits Bit string containing the flags. * @param bits Bit string containing the flags.
* @param array Array to write the flags to. Enabled flags will be 'true'. * @param array Array to write the flags to. Enabled flags will be 'true'.
* @param maxSize Maximum number of flags the array can store. * @param maxSize Maximum number of flags the array can store.
* @return Number of flags written. * @return Number of flags written.
*/ */
native int FlagBitsToBitArray(int bits, bool[] array, int maxSize); native int FlagBitsToBitArray(int bits, bool[] array, int maxSize);
/** /**
* Converts a flag array to a bit string. * Converts a flag array to a bit string.
* *
* @param array Array containing true or false for each AdminFlag. * @param array Array containing true or false for each AdminFlag.
* @param maxSize Maximum size of the flag array. * @param maxSize Maximum size of the flag array.
* @return A bit string composed of the array bits. * @return A bit string composed of the array bits.
*/ */
native int FlagBitArrayToBits(const bool[] array, int maxSize); native int FlagBitArrayToBits(const bool[] array, int maxSize);
/** /**
* Converts an array of flags to bits. * Converts an array of flags to bits.
* *
* @param array Array containing flags that are enabled. * @param array Array containing flags that are enabled.
* @param numFlags Number of flags in the array. * @param numFlags Number of flags in the array.
* @return A bit string composed of the array flags. * @return A bit string composed of the array flags.
*/ */
native int FlagArrayToBits(const AdminFlag[] array, int numFlags); native int FlagArrayToBits(const AdminFlag[] array, int numFlags);
/** /**
* Converts a bit string to an array of flags. * Converts a bit string to an array of flags.
* *
* @param bits Bit string containing the flags. * @param bits Bit string containing the flags.
* @param array Output array to write flags. * @param array Output array to write flags.
* @param maxSize Maximum size of the flag array. * @param maxSize Maximum size of the flag array.
* @return Number of flags written. * @return Number of flags written.
*/ */
native int FlagBitsToArray(int bits, AdminFlag[] array, int maxSize); native int FlagBitsToArray(int bits, AdminFlag[] array, int maxSize);
/** /**
* Finds a flag by its string name. * Finds a flag by its string name.
* *
* @param name Flag name (like "kick"), case sensitive. * @param name Flag name (like "kick"), case sensitive.
* @param flag Variable to store flag in. * @param flag Variable to store flag in.
* @return True on success, false if not found. * @return True on success, false if not found.
*/ */
native bool FindFlagByName(const char[] name, AdminFlag &flag); native bool FindFlagByName(const char[] name, AdminFlag &flag);
/** /**
* Finds a flag by a given character. * Finds a flag by a given character.
* *
* @param c Flag ASCII character/token. * @param c Flag ASCII character/token.
* @param flag Variable to store flag in. * @param flag Variable to store flag in.
* @return True on success, false if not found. * @return True on success, false if not found.
*/ */
native bool FindFlagByChar(int c, AdminFlag &flag); native bool FindFlagByChar(int c, AdminFlag &flag);
/** /**
* Finds the flag char for a given admin flag. * Finds the flag char for a given admin flag.
* *
* @param flag Flag to look up. * @param flag Flag to look up.
* @param c Variable to store flag char. * @param c Variable to store flag char.
* @return True on success, false if not found. * @return True on success, false if not found.
*/ */
native bool FindFlagChar(AdminFlag flag, int &c); native bool FindFlagChar(AdminFlag flag, int &c);
/** /**
* Converts a string of flag characters to a bit string. * Converts a string of flag characters to a bit string.
* *
* @param flags Flag ASCII string. * @param flags Flag ASCII string.
* @param numchars Optional variable to store the number of bytes read. * @param numchars Optional variable to store the number of bytes read.
* @return Bit string of ADMFLAG values. * @return Bit string of ADMFLAG values.
*/ */
native int ReadFlagString(const char[] flags, int &numchars=0); native int ReadFlagString(const char[] flags, int &numchars=0);
@ -694,9 +694,9 @@ native int ReadFlagString(const char[] flags, int &numchars=0);
* targeting admin via group immunities, targeting fails. * targeting admin via group immunities, targeting fails.
* 6. Targeting succeeds. * 6. Targeting succeeds.
* *
* @param admin Admin doing the targetting (may be INVALID_ADMIN_ID). * @param admin Admin doing the targetting (may be INVALID_ADMIN_ID).
* @param target Target admin (may be INVALID_ADMIN_ID). * @param target Target admin (may be INVALID_ADMIN_ID).
* @return True if targetable, false if immune. * @return True if targetable, false if immune.
*/ */
native bool CanAdminTarget(AdminId admin, AdminId target); native bool CanAdminTarget(AdminId admin, AdminId target);
@ -704,50 +704,50 @@ native bool CanAdminTarget(AdminId admin, AdminId target);
* Creates an admin auth method. This does not need to be called more than once * Creates an admin auth method. This does not need to be called more than once
* per method, ever. * per method, ever.
* *
* @param method Name of the authentication method. * @param method Name of the authentication method.
* @return True on success, false on failure. * @return True on success, false on failure.
*/ */
native bool CreateAuthMethod(const char[] method); native bool CreateAuthMethod(const char[] method);
/** /**
* Sets a group's immunity level. * Sets a group's immunity level.
* *
* @param gid Group Id. * @param gid Group Id.
* @param level Immunity level value. * @param level Immunity level value.
* @return Old immunity level value. * @return Old immunity level value.
*/ */
native int SetAdmGroupImmunityLevel(GroupId gid, int level); native int SetAdmGroupImmunityLevel(GroupId gid, int level);
/** /**
* Gets a group's immunity level (defaults to 0). * Gets a group's immunity level (defaults to 0).
* *
* @param gid Group Id. * @param gid Group Id.
* @return Immunity level value. * @return Immunity level value.
*/ */
native int GetAdmGroupImmunityLevel(GroupId gid); native int GetAdmGroupImmunityLevel(GroupId gid);
/** /**
* Sets an admin's immunity level. * Sets an admin's immunity level.
* *
* @param id Admin Id. * @param id Admin Id.
* @param level Immunity level value. * @param level Immunity level value.
* @return Old immunity level value. * @return Old immunity level value.
*/ */
native int SetAdminImmunityLevel(AdminId id, int level); native int SetAdminImmunityLevel(AdminId id, int level);
/** /**
* Gets an admin's immunity level. * Gets an admin's immunity level.
* *
* @param id Admin Id. * @param id Admin Id.
* @return Immunity level value. * @return Immunity level value.
*/ */
native int GetAdminImmunityLevel(AdminId id); native int GetAdminImmunityLevel(AdminId id);
/** /**
* Converts a flag to its single bit. * Converts a flag to its single bit.
* *
* @param flag Flag to convert. * @param flag Flag to convert.
* @return Bit representation of the flag. * @return Bit representation of the flag.
*/ */
stock int FlagToBit(AdminFlag flag) stock int FlagToBit(AdminFlag flag)
{ {
@ -757,9 +757,9 @@ stock int FlagToBit(AdminFlag flag)
/** /**
* Converts a bit to an AdminFlag. * Converts a bit to an AdminFlag.
* *
* @param bit Bit to convert. * @param bit Bit to convert.
* @param flag Stores the converted flag by reference. * @param flag Stores the converted flag by reference.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
stock bool BitToFlag(int bit, AdminFlag &flag) stock bool BitToFlag(int bit, AdminFlag &flag)
{ {

View File

@ -52,32 +52,32 @@
#endif #endif
/** Category for player commands. */ /** Category for player commands. */
#define ADMINMENU_PLAYERCOMMANDS "PlayerCommands" #define ADMINMENU_PLAYERCOMMANDS "PlayerCommands"
/** Category for server commands. */ /** Category for server commands. */
#define ADMINMENU_SERVERCOMMANDS "ServerCommands" #define ADMINMENU_SERVERCOMMANDS "ServerCommands"
/** Category for voting commands. */ /** Category for voting commands. */
#define ADMINMENU_VOTINGCOMMANDS "VotingCommands" #define ADMINMENU_VOTINGCOMMANDS "VotingCommands"
/** /**
* Called when the admin menu is created and 3rd party plugins can grab * Called when the admin menu is created and 3rd party plugins can grab
* the Handle or add categories. * the Handle or add categories.
* *
* @param topmenu Handle to the admin menu's TopMenu. * @param topmenu Handle to the admin menu's TopMenu.
*/ */
forward void OnAdminMenuCreated(Handle topmenu); forward void OnAdminMenuCreated(Handle topmenu);
/** /**
* Called when the admin menu is ready to have items added. * Called when the admin menu is ready to have items added.
* *
* @param topmenu Handle to the admin menu's TopMenu. * @param topmenu Handle to the admin menu's TopMenu.
*/ */
forward void OnAdminMenuReady(Handle topmenu); forward void OnAdminMenuReady(Handle topmenu);
/** /**
* Retrieves the Handle to the admin top menu. * Retrieves the Handle to the admin top menu.
* *
* @return Handle to the admin menu's TopMenu, * @return Handle to the admin menu's TopMenu,
* or INVALID_HANDLE if not created yet. * or INVALID_HANDLE if not created yet.
*/ */
native TopMenu GetAdminTopMenu(); native TopMenu GetAdminTopMenu();
@ -87,16 +87,16 @@ native TopMenu GetAdminTopMenu();
* Each client is displayed as: name (userid) * Each client is displayed as: name (userid)
* Each item contains the userid as a string for its info. * Each item contains the userid as a string for its info.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param source_client Source client, or 0 to ignore immunity. * @param source_client Source client, or 0 to ignore immunity.
* @param in_game_only True to only select in-game players. * @param in_game_only True to only select in-game players.
* @param alive_only True to only select alive players. * @param alive_only True to only select alive players.
* @return Number of clients added. * @return Number of clients added.
*/ */
native int AddTargetsToMenu(Handle menu, native int AddTargetsToMenu(Handle menu,
int source_client, int source_client,
bool in_game_only=true, bool in_game_only=true,
bool alive_only=false); bool alive_only=false);
/** /**
* Adds targets to an admin menu. * Adds targets to an admin menu.
@ -104,10 +104,10 @@ native int AddTargetsToMenu(Handle menu,
* Each client is displayed as: name (userid) * Each client is displayed as: name (userid)
* Each item contains the userid as a string for its info. * Each item contains the userid as a string for its info.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param source_client Source client, or 0 to ignore immunity. * @param source_client Source client, or 0 to ignore immunity.
* @param flags COMMAND_FILTER flags from commandfilters.inc. * @param flags COMMAND_FILTER flags from commandfilters.inc.
* @return Number of clients added. * @return Number of clients added.
*/ */
native int AddTargetsToMenu2(Handle menu, int source_client, int flags); native int AddTargetsToMenu2(Handle menu, int source_client, int flags);
@ -115,9 +115,9 @@ native int AddTargetsToMenu2(Handle menu, int source_client, int flags);
* Re-displays the admin menu to a client after selecting an item. * Re-displays the admin menu to a client after selecting an item.
* Auto-aborts if the Handle is invalid. * Auto-aborts if the Handle is invalid.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param client Client index. * @param client Client index.
* @return True on success, false on failure. * @return True on success, false on failure.
*/ */
stock bool RedisplayAdminMenu(Handle topmenu, int client) stock bool RedisplayAdminMenu(Handle topmenu, int client)
{ {

View File

@ -39,13 +39,16 @@
* Given a maximum string size (including the null terminator), * Given a maximum string size (including the null terminator),
* returns the number of cells required to fit that string. * returns the number of cells required to fit that string.
* *
* @param size Number of bytes. * @param size Number of bytes.
* @return Minimum number of cells required to fit the byte count. * @return Minimum number of cells required to fit the byte count.
*/ */
stock int ByteCountToCells(int size) stock int ByteCountToCells(int size)
{ {
if (!size) if (!size)
{
return 1; return 1;
}
return (size + 3) / 4; return (size + 3) / 4;
} }
@ -92,7 +95,6 @@ methodmap ArrayList < Handle {
// @param value Value to push. // @param value Value to push.
// @return Index of the new entry. // @return Index of the new entry.
// @error Invalid Handle or out of memory. // @error Invalid Handle or out of memory.
//
public native int Push(any value); public native int Push(any value);
// Pushes a string onto the end of an array, truncating it if it is too big. // Pushes a string onto the end of an array, truncating it if it is too big.
@ -208,20 +210,16 @@ methodmap ArrayList < Handle {
// @error Invalid block index // @error Invalid block index
public native int FindValue(any item, int block=0); public native int FindValue(any item, int block=0);
/** // Sort an ADT Array. Specify the type as Integer, Float, or String.
* Sort an ADT Array. Specify the type as Integer, Float, or String. //
* // @param order Sort order to use, same as other sorts.
* @param order Sort order to use, same as other sorts. // @param type Data type stored in the ADT Array
* @param type Data type stored in the ADT Array
*/
public native void Sort(SortOrder order, SortType type); public native void Sort(SortOrder order, SortType type);
/** // Custom sorts an ADT Array. You must pass in a comparison function.
* Custom sorts an ADT Array. You must pass in a comparison function. //
* // @param sortfunc Sort comparison function to use
* @param sortfunc Sort comparison function to use // @param hndl Optional Handle to pass through the comparison calls.
* @param hndl Optional Handle to pass through the comparison calls.
*/
public native void SortCustom(SortFuncADTArray sortfunc, Handle hndl=INVALID_HANDLE); public native void SortCustom(SortFuncADTArray sortfunc, Handle hndl=INVALID_HANDLE);
// Retrieve the size of the array. // Retrieve the size of the array.
@ -244,20 +242,20 @@ methodmap ArrayList < Handle {
* The "blocksize" determines how many cells each array slot has; it cannot * The "blocksize" determines how many cells each array slot has; it cannot
* be changed after creation. * be changed after creation.
* *
* @param blocksize The number of cells each member of the array can * @param blocksize The number of cells each member of the array can
* hold. For example, 32 cells is equivalent to: * hold. For example, 32 cells is equivalent to:
* new Array[X][32] * new Array[X][32]
* @param startsize Initial size of the array. Note that data will * @param startsize Initial size of the array. Note that data will
* NOT be auto-initialized. * NOT be auto-initialized.
* @return New Handle to the array object. * @return New Handle to the array object.
*/ */
native ArrayList CreateArray(int blocksize=1, int startsize=0); native ArrayList CreateArray(int blocksize=1, int startsize=0);
/** /**
* Clears an array of all entries. This is the same as ResizeArray(0). * Clears an array of all entries. This is the same as ResizeArray(0).
* *
* @param array Array Handle. * @param array Array Handle.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void ClearArray(Handle array); native void ClearArray(Handle array);
@ -266,9 +264,9 @@ native void ClearArray(Handle array);
* be confused with CloneHandle. This is a completely new handle with the same data but * be confused with CloneHandle. This is a completely new handle with the same data but
* no relation to the original. You MUST close it. * no relation to the original. You MUST close it.
* *
* @param array Array handle to be cloned * @param array Array handle to be cloned
* @return New handle to the cloned array object * @return New handle to the cloned array object
* @error Invalid Handle * @error Invalid Handle
*/ */
native Handle CloneArray(Handle array); native Handle CloneArray(Handle array);
@ -277,18 +275,18 @@ native Handle CloneArray(Handle array);
* the array is truncated. If the size is larger than the current size, * the array is truncated. If the size is larger than the current size,
* the data at the additional indexes will not be initialized. * the data at the additional indexes will not be initialized.
* *
* @param array Array Handle. * @param array Array Handle.
* @param newsize New size. * @param newsize New size.
* @error Invalid Handle or out of memory. * @error Invalid Handle or out of memory.
*/ */
native void ResizeArray(Handle array, int newsize); native void ResizeArray(Handle array, int newsize);
/** /**
* Returns the array size. * Returns the array size.
* *
* @param array Array Handle. * @param array Array Handle.
* @return Number of elements in the array. * @return Number of elements in the array.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int GetArraySize(Handle array); native int GetArraySize(Handle array);
@ -298,10 +296,10 @@ native int GetArraySize(Handle array);
* This may safely be used even if the array has a blocksize * This may safely be used even if the array has a blocksize
* greater than 1. * greater than 1.
* *
* @param array Array Handle. * @param array Array Handle.
* @param value Value to push. * @param value Value to push.
* @return Index of the new entry. * @return Index of the new entry.
* @error Invalid Handle or out of memory. * @error Invalid Handle or out of memory.
*/ */
native int PushArrayCell(Handle array, any value); native int PushArrayCell(Handle array, any value);
@ -309,10 +307,10 @@ native int PushArrayCell(Handle array, any value);
* Pushes a string onto the end of an array, truncating it * Pushes a string onto the end of an array, truncating it
* if it is too big. * if it is too big.
* *
* @param array Array Handle. * @param array Array Handle.
* @param value String to push. * @param value String to push.
* @return Index of the new entry. * @return Index of the new entry.
* @error Invalid Handle or out of memory. * @error Invalid Handle or out of memory.
*/ */
native int PushArrayString(Handle array, const char[] value); native int PushArrayString(Handle array, const char[] value);
@ -321,88 +319,88 @@ native int PushArrayString(Handle array, const char[] value);
* are pushed as a block (i.e. the entire array sits at the index), * are pushed as a block (i.e. the entire array sits at the index),
* rather than pushing each cell individually. * rather than pushing each cell individually.
* *
* @param array Array Handle. * @param array Array Handle.
* @param values Block of values to copy. * @param values Block of values to copy.
* @param size If not set, the number of elements copied from the array * @param size If not set, the number of elements copied from the array
* will be equal to the blocksize. If set higher than the * will be equal to the blocksize. If set higher than the
* blocksize, the operation will be truncated. * blocksize, the operation will be truncated.
* @return Index of the new entry. * @return Index of the new entry.
* @error Invalid Handle or out of memory. * @error Invalid Handle or out of memory.
*/ */
native int PushArrayArray(Handle array, const any[] values, int size=-1); native int PushArrayArray(Handle array, const any[] values, int size=-1);
/** /**
* Retrieves a cell value from an array. * Retrieves a cell value from an array.
* *
* @param array Array Handle. * @param array Array Handle.
* @param index Index in the array. * @param index Index in the array.
* @param block Optionally specify which block to read from * @param block Optionally specify which block to read from
* (useful if the blocksize > 0). * (useful if the blocksize > 0).
* @param asChar Optionally read as a byte instead of a cell. * @param asChar Optionally read as a byte instead of a cell.
* @return Value read. * @return Value read.
* @error Invalid Handle, invalid index, or invalid block. * @error Invalid Handle, invalid index, or invalid block.
*/ */
native any GetArrayCell(Handle array, int index, int block=0, bool asChar=false); native any GetArrayCell(Handle array, int index, int block=0, bool asChar=false);
/** /**
* Retrieves a string value from an array. * Retrieves a string value from an array.
* *
* @param array Array Handle. * @param array Array Handle.
* @param index Index in the array. * @param index Index in the array.
* @param buffer Buffer to copy to. * @param buffer Buffer to copy to.
* @param maxlength Maximum size of the buffer. * @param maxlength Maximum size of the buffer.
* @return Number of characters copied. * @return Number of characters copied.
* @error Invalid Handle or invalid index. * @error Invalid Handle or invalid index.
*/ */
native int GetArrayString(Handle array, int index, char[] buffer, int maxlength); native int GetArrayString(Handle array, int index, char[] buffer, int maxlength);
/** /**
* Retrieves an array of cells from an array. * Retrieves an array of cells from an array.
* *
* @param array Array Handle. * @param array Array Handle.
* @param index Index in the array. * @param index Index in the array.
* @param buffer Buffer to store the array in. * @param buffer Buffer to store the array in.
* @param size If not set, assumes the buffer size is equal to the * @param size If not set, assumes the buffer size is equal to the
* blocksize. Otherwise, the size passed is used. * blocksize. Otherwise, the size passed is used.
* @return Number of cells copied. * @return Number of cells copied.
* @error Invalid Handle or invalid index. * @error Invalid Handle or invalid index.
*/ */
native int GetArrayArray(Handle array, int index, any[] buffer, int size=-1); native int GetArrayArray(Handle array, int index, any[] buffer, int size=-1);
/** /**
* Sets a cell value in an array. * Sets a cell value in an array.
* *
* @param array Array Handle. * @param array Array Handle.
* @param index Index in the array. * @param index Index in the array.
* @param value Cell value to set. * @param value Cell value to set.
* @param block Optionally specify which block to write to * @param block Optionally specify which block to write to
* (useful if the blocksize > 0). * (useful if the blocksize > 0).
* @param asChar Optionally set as a byte instead of a cell. * @param asChar Optionally set as a byte instead of a cell.
* @error Invalid Handle, invalid index, or invalid block. * @error Invalid Handle, invalid index, or invalid block.
*/ */
native void SetArrayCell(Handle array, int index, any value, int block=0, bool asChar=false); native void SetArrayCell(Handle array, int index, any value, int block=0, bool asChar=false);
/** /**
* Sets a string value in an array. * Sets a string value in an array.
* *
* @param array Array Handle. * @param array Array Handle.
* @param index Index in the array. * @param index Index in the array.
* @param value String value to set. * @param value String value to set.
* @return Number of characters copied. * @return Number of characters copied.
* @error Invalid Handle or invalid index. * @error Invalid Handle or invalid index.
*/ */
native int SetArrayString(Handle array, int index, const char[] value); native int SetArrayString(Handle array, int index, const char[] value);
/** /**
* Sets an array of cells in an array. * Sets an array of cells in an array.
* *
* @param array Array Handle. * @param array Array Handle.
* @param index Index in the array. * @param index Index in the array.
* @param values Array to copy. * @param values Array to copy.
* @param size If not set, assumes the buffer size is equal to the * @param size If not set, assumes the buffer size is equal to the
* blocksize. Otherwise, the size passed is used. * blocksize. Otherwise, the size passed is used.
* @return Number of cells copied. * @return Number of cells copied.
* @error Invalid Handle or invalid index. * @error Invalid Handle or invalid index.
*/ */
native int SetArrayArray(Handle array, int index, const any[] values, int size=-1); native int SetArrayArray(Handle array, int index, const any[] values, int size=-1);
@ -411,9 +409,9 @@ native int SetArrayArray(Handle array, int index, const any[] values, int size=-
* index are shifted up by one, and the given index is then "free." * index are shifted up by one, and the given index is then "free."
* After shifting, the contents of the given index is undefined. * After shifting, the contents of the given index is undefined.
* *
* @param array Array Handle. * @param array Array Handle.
* @param index Index in the array to shift up from. * @param index Index in the array to shift up from.
* @error Invalid Handle or invalid index. * @error Invalid Handle or invalid index.
*/ */
native void ShiftArrayUp(Handle array, int index); native void ShiftArrayUp(Handle array, int index);
@ -422,19 +420,19 @@ native void ShiftArrayUp(Handle array, int index);
* on. For example, if item 8 of 10 is removed, the last 3 items will then be * on. For example, if item 8 of 10 is removed, the last 3 items will then be
* (6,7,8) instead of (7,8,9), and all indexes before 8 will remain unchanged. * (6,7,8) instead of (7,8,9), and all indexes before 8 will remain unchanged.
* *
* @param array Array Handle. * @param array Array Handle.
* @param index Index in the array to remove at. * @param index Index in the array to remove at.
* @error Invalid Handle or invalid index. * @error Invalid Handle or invalid index.
*/ */
native void RemoveFromArray(Handle array, int index); native void RemoveFromArray(Handle array, int index);
/** /**
* Swaps two items in the array. * Swaps two items in the array.
* *
* @param array Array Handle. * @param array Array Handle.
* @param index1 First index. * @param index1 First index.
* @param index2 Second index. * @param index2 Second index.
* @error Invalid Handle or invalid index. * @error Invalid Handle or invalid index.
*/ */
native void SwapArrayItems(Handle array, int index1, int index2); native void SwapArrayItems(Handle array, int index1, int index2);
@ -442,10 +440,10 @@ native void SwapArrayItems(Handle array, int index1, int index2);
* Returns the index for the first occurrence of the provided string. If the string * Returns the index for the first occurrence of the provided string. If the string
* cannot be located, -1 will be returned. * cannot be located, -1 will be returned.
* *
* @param array Array Handle. * @param array Array Handle.
* @param item String to search for * @param item String to search for
* @return Array index, or -1 on failure * @return Array index, or -1 on failure
* @error Invalid Handle * @error Invalid Handle
*/ */
native int FindStringInArray(Handle array, const char[] item); native int FindStringInArray(Handle array, const char[] item);
@ -453,19 +451,19 @@ native int FindStringInArray(Handle array, const char[] item);
* Returns the index for the first occurrence of the provided value. If the value * Returns the index for the first occurrence of the provided value. If the value
* cannot be located, -1 will be returned. * cannot be located, -1 will be returned.
* *
* @param array Array Handle. * @param array Array Handle.
* @param item Value to search for * @param item Value to search for
* @param block Optionally which block to search in * @param block Optionally which block to search in
* @return Array index, or -1 on failure * @return Array index, or -1 on failure
* @error Invalid Handle or invalid block * @error Invalid Handle or invalid block
*/ */
native int FindValueInArray(Handle array, any item, int block=0); native int FindValueInArray(Handle array, any item, int block=0);
/** /**
* Returns the blocksize the array was created with. * Returns the blocksize the array was created with.
* *
* @param array Array Handle. * @param array Array Handle.
* @return The blocksize of the array. * @return The blocksize of the array.
* @error Invalid Handle * @error Invalid Handle
*/ */
native int GetArrayBlockSize(Handle array); native int GetArrayBlockSize(Handle array);

View File

@ -129,10 +129,10 @@ methodmap ArrayStack < Handle
* The "blocksize" determines how many cells each slot has; it cannot * The "blocksize" determines how many cells each slot has; it cannot
* be changed after creation. * be changed after creation.
* *
* @param blocksize The number of cells each entry in the stack can * @param blocksize The number of cells each entry in the stack can
* hold. For example, 32 cells is equivalent to: * hold. For example, 32 cells is equivalent to:
* new Array[X][32] * new Array[X][32]
* @return New stack Handle. * @return New stack Handle.
*/ */
native ArrayStack CreateStack(int blocksize=1); native ArrayStack CreateStack(int blocksize=1);
@ -142,9 +142,9 @@ native ArrayStack CreateStack(int blocksize=1);
* This may safely be used even if the stack has a blocksize * This may safely be used even if the stack has a blocksize
* greater than 1. * greater than 1.
* *
* @param stack Stack Handle. * @param stack Stack Handle.
* @param value Value to push. * @param value Value to push.
* @error Invalid Handle or out of memory. * @error Invalid Handle or out of memory.
*/ */
native void PushStackCell(Handle stack, any value); native void PushStackCell(Handle stack, any value);
@ -152,9 +152,9 @@ native void PushStackCell(Handle stack, any value);
* Pushes a copy of a string onto the end of a stack, truncating it if it is * Pushes a copy of a string onto the end of a stack, truncating it if it is
* too big. * too big.
* *
* @param stack Stack Handle. * @param stack Stack Handle.
* @param value String to push. * @param value String to push.
* @error Invalid Handle or out of memory. * @error Invalid Handle or out of memory.
*/ */
native void PushStackString(Handle stack, const char[] value); native void PushStackString(Handle stack, const char[] value);
@ -163,66 +163,66 @@ native void PushStackString(Handle stack, const char[] value);
* are pushed as a block (i.e. the entire array takes up one stack slot), * are pushed as a block (i.e. the entire array takes up one stack slot),
* rather than pushing each cell individually. * rather than pushing each cell individually.
* *
* @param stack Stack Handle. * @param stack Stack Handle.
* @param values Block of values to copy. * @param values Block of values to copy.
* @param size If not set, the number of elements copied from the array * @param size If not set, the number of elements copied from the array
* will be equal to the blocksize. If set higher than the * will be equal to the blocksize. If set higher than the
* blocksize, the operation will be truncated. * blocksize, the operation will be truncated.
* @error Invalid Handle or out of memory. * @error Invalid Handle or out of memory.
*/ */
native void PushStackArray(Handle stack, const any[] values, int size=-1); native void PushStackArray(Handle stack, const any[] values, int size=-1);
/** /**
* Pops a cell value from a stack. * Pops a cell value from a stack.
* *
* @param stack Stack Handle. * @param stack Stack Handle.
* @param value Variable to store the value. * @param value Variable to store the value.
* @param block Optionally specify which block to read from * @param block Optionally specify which block to read from
* (useful if the blocksize > 0). * (useful if the blocksize > 0).
* @param asChar Optionally read as a byte instead of a cell. * @param asChar Optionally read as a byte instead of a cell.
* @return True on success, false if the stack is empty. * @return True on success, false if the stack is empty.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool PopStackCell(Handle stack, any &value, int block=0, bool asChar=false); native bool PopStackCell(Handle stack, any &value, int block=0, bool asChar=false);
/** /**
* Pops a string value from a stack. * Pops a string value from a stack.
* *
* @param stack Stack Handle. * @param stack Stack Handle.
* @param buffer Buffer to store string. * @param buffer Buffer to store string.
* @param maxlength Maximum size of the buffer. * @param maxlength Maximum size of the buffer.
* @return True on success, false if the stack is empty. * @return True on success, false if the stack is empty.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool PopStackString(Handle stack, char[] buffer, int maxlength, int &written=0); native bool PopStackString(Handle stack, char[] buffer, int maxlength, int &written=0);
/** /**
* Pops an array of cells from a stack. * Pops an array of cells from a stack.
* *
* @param stack Stack Handle. * @param stack Stack Handle.
* @param buffer Buffer to store the array in. * @param buffer Buffer to store the array in.
* @param size If not set, assumes the buffer size is equal to the * @param size If not set, assumes the buffer size is equal to the
* blocksize. Otherwise, the size passed is used. * blocksize. Otherwise, the size passed is used.
* @return True on success, false if the stack is empty. * @return True on success, false if the stack is empty.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool PopStackArray(Handle stack, any[] buffer, int size=-1); native bool PopStackArray(Handle stack, any[] buffer, int size=-1);
/** /**
* Checks if a stack is empty. * Checks if a stack is empty.
* *
* @param stack Stack Handle. * @param stack Stack Handle.
* @return True if empty, false if not empty. * @return True if empty, false if not empty.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool IsStackEmpty(Handle stack); native bool IsStackEmpty(Handle stack);
/** /**
* Pops a value off a stack, ignoring it completely. * Pops a value off a stack, ignoring it completely.
* *
* @param stack Stack Handle. * @param stack Stack Handle.
* @return True if something was popped, false otherwise. * @return True if something was popped, false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
stock bool PopStack(Handle stack) stock bool PopStack(Handle stack)
{ {
@ -233,8 +233,8 @@ stock bool PopStack(Handle stack)
/** /**
* Returns the blocksize the stack was created with. * Returns the blocksize the stack was created with.
* *
* @param stack Stack Handle. * @param stack Stack Handle.
* @return The blocksize of the stack. * @return The blocksize of the stack.
* @error Invalid Handle * @error Invalid Handle
*/ */
native int GetStackBlockSize(Handle stack); native int GetStackBlockSize(Handle stack);

View File

@ -124,9 +124,11 @@ methodmap StringMap < Handle
} }
}; };
// A StringMapSnapshot is created via StringMap.Snapshot(). It captures the /**
// keys on a map so they can be read. Snapshots must be freed with delete or * A StringMapSnapshot is created via StringMap.Snapshot(). It captures the
// CloseHandle(). * keys on a map so they can be read. Snapshots must be freed with delete or
* CloseHandle().
*/
methodmap StringMapSnapshot < Handle methodmap StringMapSnapshot < Handle
{ {
// Returns the number of keys in the map snapshot. // Returns the number of keys in the map snapshot.
@ -164,111 +166,111 @@ methodmap StringMapSnapshot < Handle
* been internally replaced with hash tables, which have O(1) insertion time * been internally replaced with hash tables, which have O(1) insertion time
* instead of O(n). * instead of O(n).
* *
* @return New Map Handle, which must be freed via CloseHandle(). * @return New Map Handle, which must be freed via CloseHandle().
*/ */
native StringMap CreateTrie(); native StringMap CreateTrie();
/** /**
* Sets a value in a hash map, either inserting a new entry or replacing an old one. * Sets a value in a hash map, either inserting a new entry or replacing an old one.
* *
* @param map Map Handle. * @param map Map Handle.
* @param key Key string. * @param key Key string.
* @param value Value to store at this key. * @param value Value to store at this key.
* @param replace If false, operation will fail if the key is already set. * @param replace If false, operation will fail if the key is already set.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool SetTrieValue(Handle map, const char[] key, any value, bool replace=true); native bool SetTrieValue(Handle map, const char[] key, any value, bool replace=true);
/** /**
* Sets an array value in a Map, either inserting a new entry or replacing an old one. * Sets an array value in a Map, either inserting a new entry or replacing an old one.
* *
* @param map Map Handle. * @param map Map Handle.
* @param key Key string. * @param key Key string.
* @param array Array to store. * @param array Array to store.
* @param num_items Number of items in the array. * @param num_items Number of items in the array.
* @param replace If false, operation will fail if the key is already set. * @param replace If false, operation will fail if the key is already set.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool SetTrieArray(Handle map, const char[] key, const any[] array, int num_items, bool replace=true); native bool SetTrieArray(Handle map, const char[] key, const any[] array, int num_items, bool replace=true);
/** /**
* Sets a string value in a Map, either inserting a new entry or replacing an old one. * Sets a string value in a Map, either inserting a new entry or replacing an old one.
* *
* @param map Map Handle. * @param map Map Handle.
* @param key Key string. * @param key Key string.
* @param value String to store. * @param value String to store.
* @param replace If false, operation will fail if the key is already set. * @param replace If false, operation will fail if the key is already set.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool SetTrieString(Handle map, const char[] key, const char[] value, bool replace=true); native bool SetTrieString(Handle map, const char[] key, const char[] value, bool replace=true);
/** /**
* Retrieves a value in a Map. * Retrieves a value in a Map.
* *
* @param map Map Handle. * @param map Map Handle.
* @param key Key string. * @param key Key string.
* @param value Variable to store value. * @param value Variable to store value.
* @return True on success. False if the key is not set, or the key is set * @return True on success. False if the key is not set, or the key is set
* as an array or string (not a value). * as an array or string (not a value).
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool GetTrieValue(Handle map, const char[] key, any &value); native bool GetTrieValue(Handle map, const char[] key, any &value);
/** /**
* Retrieves an array in a Map. * Retrieves an array in a Map.
* *
* @param map Map Handle. * @param map Map Handle.
* @param key Key string. * @param key Key string.
* @param array Buffer to store array. * @param array Buffer to store array.
* @param max_size Maximum size of array buffer. * @param max_size Maximum size of array buffer.
* @param size Optional parameter to store the number of elements written to the buffer. * @param size Optional parameter to store the number of elements written to the buffer.
* @return True on success. False if the key is not set, or the key is set * @return True on success. False if the key is not set, or the key is set
* as a value or string (not an array). * as a value or string (not an array).
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool GetTrieArray(Handle map, const char[] key, any[] array, int max_size, int &size=0); native bool GetTrieArray(Handle map, const char[] key, any[] array, int max_size, int &size=0);
/** /**
* Retrieves a string in a Map. * Retrieves a string in a Map.
* *
* @param map Map Handle. * @param map Map Handle.
* @param key Key string. * @param key Key string.
* @param value Buffer to store value. * @param value Buffer to store value.
* @param max_size Maximum size of string buffer. * @param max_size Maximum size of string buffer.
* @param size Optional parameter to store the number of bytes written to the buffer. * @param size Optional parameter to store the number of bytes written to the buffer.
* @return True on success. False if the key is not set, or the key is set * @return True on success. False if the key is not set, or the key is set
* as a value or array (not a string). * as a value or array (not a string).
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool GetTrieString(Handle map, const char[] key, char[] value, int max_size, int &size=0); native bool GetTrieString(Handle map, const char[] key, char[] value, int max_size, int &size=0);
/** /**
* Removes a key entry from a Map. * Removes a key entry from a Map.
* *
* @param map Map Handle. * @param map Map Handle.
* @param key Key string. * @param key Key string.
* @return True on success, false if the value was never set. * @return True on success, false if the value was never set.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool RemoveFromTrie(Handle map, const char[] key); native bool RemoveFromTrie(Handle map, const char[] key);
/** /**
* Clears all entries from a Map. * Clears all entries from a Map.
* *
* @param map Map Handle. * @param map Map Handle.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void ClearTrie(Handle map); native void ClearTrie(Handle map);
/** /**
* Retrieves the number of elements in a map. * Retrieves the number of elements in a map.
* *
* @param map Map Handle. * @param map Map Handle.
* @return Number of elements in the trie. * @return Number of elements in the trie.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int GetTrieSize(Handle map); native int GetTrieSize(Handle map);
@ -276,9 +278,9 @@ native int GetTrieSize(Handle map);
* Creates a snapshot of all keys in the map. If the map is changed after this * Creates a snapshot of all keys in the map. If the map is changed after this
* call, the changes are not reflected in the snapshot. Keys are not sorted. * call, the changes are not reflected in the snapshot. Keys are not sorted.
* *
* @param map Map Handle. * @param map Map Handle.
* @return New Map Snapshot Handle, which must be closed via CloseHandle(). * @return New Map Snapshot Handle, which must be closed via CloseHandle().
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native Handle CreateTrieSnapshot(Handle map); native Handle CreateTrieSnapshot(Handle map);
@ -287,9 +289,9 @@ native Handle CreateTrieSnapshot(Handle map);
* different from the size of the map, since the map can change after the * different from the size of the map, since the map can change after the
* snapshot of its keys was taken. * snapshot of its keys was taken.
* *
* @param snapshot Map snapshot. * @param snapshot Map snapshot.
* @return Number of keys. * @return Number of keys.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int TrieSnapshotLength(Handle snapshot); native int TrieSnapshotLength(Handle snapshot);
@ -297,21 +299,21 @@ native int TrieSnapshotLength(Handle snapshot);
* Returns the buffer size required to store a given key. That is, it returns * Returns the buffer size required to store a given key. That is, it returns
* the length of the key plus one. * the length of the key plus one.
* *
* @param snapshot Map snapshot. * @param snapshot Map snapshot.
* @param index Key index (starting from 0). * @param index Key index (starting from 0).
* @return Buffer size required to store the key string. * @return Buffer size required to store the key string.
* @error Invalid Handle or index out of range. * @error Invalid Handle or index out of range.
*/ */
native int TrieSnapshotKeyBufferSize(Handle snapshot, int index); native int TrieSnapshotKeyBufferSize(Handle snapshot, int index);
/** /**
* Retrieves the key string of a given key in a map snapshot. * Retrieves the key string of a given key in a map snapshot.
* *
* @param snapshot Map snapshot. * @param snapshot Map snapshot.
* @param index Key index (starting from 0). * @param index Key index (starting from 0).
* @param buffer String buffer. * @param buffer String buffer.
* @param maxlength Maximum buffer length. * @param maxlength Maximum buffer length.
* @return Number of bytes written to the buffer. * @return Number of bytes written to the buffer.
* @error Invalid Handle or index out of range. * @error Invalid Handle or index out of range.
*/ */
native int GetTrieSnapshotKey(Handle snapshot, int index, char[] buffer, int maxlength); native int GetTrieSnapshotKey(Handle snapshot, int index, char[] buffer, int maxlength);

View File

@ -35,24 +35,24 @@
#endif #endif
#define _banning_included #define _banning_included
#define BANFLAG_AUTO (1<<0) /**< Auto-detects whether to ban by steamid or IP */ #define BANFLAG_AUTO (1<<0) /**< Auto-detects whether to ban by steamid or IP */
#define BANFLAG_IP (1<<1) /**< Always ban by IP address */ #define BANFLAG_IP (1<<1) /**< Always ban by IP address */
#define BANFLAG_AUTHID (1<<2) /**< Always ban by authstring (for BanIdentity) if possible */ #define BANFLAG_AUTHID (1<<2) /**< Always ban by authstring (for BanIdentity) if possible */
#define BANFLAG_NOKICK (1<<3) /**< Does not kick the client */ #define BANFLAG_NOKICK (1<<3) /**< Does not kick the client */
/** /**
* Called for calls to BanClient() with a non-empty command. * Called for calls to BanClient() with a non-empty command.
* *
* @param client Client being banned. * @param client Client being banned.
* @param time Time the client is being banned for (0 = permanent). * @param time Time the client is being banned for (0 = permanent).
* @param flags One if AUTHID or IP will be enabled. If AUTO is also * @param flags One if AUTHID or IP will be enabled. If AUTO is also
* enabled, it means Core autodetected which to use. * enabled, it means Core autodetected which to use.
* @param reason Reason passed via BanClient(). * @param reason Reason passed via BanClient().
* @param kick_message Kick message passed via BanClient(). * @param kick_message Kick message passed via BanClient().
* @param command Command string to identify the ban source. * @param command Command string to identify the ban source.
* @param source Source value passed via BanClient(). * @param source Source value passed via BanClient().
* @return Plugin_Handled to block the actual server banning. * @return Plugin_Handled to block the actual server banning.
* Kicking will still occur. * Kicking will still occur.
*/ */
forward Action OnBanClient(int client, forward Action OnBanClient(int client,
int time, int time,
@ -65,13 +65,13 @@ forward Action OnBanClient(int client,
/** /**
* Called for calls to BanIdentity() with a non-empty command. * Called for calls to BanIdentity() with a non-empty command.
* *
* @param identity Identity string being banned (authstring or ip). * @param identity Identity string being banned (authstring or ip).
* @param time Time the client is being banned for (0 = permanent). * @param time Time the client is being banned for (0 = permanent).
* @param flags Ban flags (only IP or AUTHID are valid here). * @param flags Ban flags (only IP or AUTHID are valid here).
* @param reason Reason passed via BanIdentity(). * @param reason Reason passed via BanIdentity().
* @param command Command string to identify the ban source. * @param command Command string to identify the ban source.
* @param source Source value passed via BanIdentity(). * @param source Source value passed via BanIdentity().
* @return Plugin_Handled to block the actual server banning. * @return Plugin_Handled to block the actual server banning.
*/ */
forward Action OnBanIdentity(const char[] identity, forward Action OnBanIdentity(const char[] identity,
int time, int time,
@ -83,11 +83,11 @@ forward Action OnBanIdentity(const char[] identity,
/** /**
* Called for calls to RemoveBan() with a non-empty command. * Called for calls to RemoveBan() with a non-empty command.
* *
* @param identity Identity string being banned (authstring or ip). * @param identity Identity string being banned (authstring or ip).
* @param flags Ban flags (only IP or AUTHID are valid here). * @param flags Ban flags (only IP or AUTHID are valid here).
* @param command Command string to identify the ban source. * @param command Command string to identify the ban source.
* @param source Source value passed via BanIdentity(). * @param source Source value passed via BanIdentity().
* @return Plugin_Handled to block the actual unbanning. * @return Plugin_Handled to block the actual unbanning.
*/ */
forward Action OnRemoveBan(const char[] identity, forward Action OnRemoveBan(const char[] identity,
int flags, int flags,
@ -97,19 +97,19 @@ forward Action OnRemoveBan(const char[] identity,
/** /**
* Bans a client. * Bans a client.
* *
* @param client Client being banned. * @param client Client being banned.
* @param time Time (in minutes) to ban (0 = permanent). * @param time Time (in minutes) to ban (0 = permanent).
* @param flags Flags for controlling the ban mechanism. If AUTHID * @param flags Flags for controlling the ban mechanism. If AUTHID
* is set and no AUTHID is available, the ban will fail * is set and no AUTHID is available, the ban will fail
* unless AUTO is also flagged. * unless AUTO is also flagged.
* @param reason Reason to ban the client for. * @param reason Reason to ban the client for.
* @param kick_message Message to display to the user when kicking. * @param kick_message Message to display to the user when kicking.
* @param command Command string to identify the source. If this is left * @param command Command string to identify the source. If this is left
* empty, then the OnBanClient forward will not be called. * empty, then the OnBanClient forward will not be called.
* @param source A source value that could be interpreted as a player * @param source A source value that could be interpreted as a player
* index of any sort (not actually checked by Core). * index of any sort (not actually checked by Core).
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid client index or client not in game. * @error Invalid client index or client not in game.
*/ */
native bool BanClient(int client, native bool BanClient(int client,
int time, int time,
@ -122,15 +122,15 @@ native bool BanClient(int client,
/** /**
* Bans an identity (either an IP address or auth string). * Bans an identity (either an IP address or auth string).
* *
* @param identity String to ban (ip or authstring). * @param identity String to ban (ip or authstring).
* @param time Time to ban for (0 = permanent). * @param time Time to ban for (0 = permanent).
* @param flags Flags (only IP and AUTHID are valid flags here). * @param flags Flags (only IP and AUTHID are valid flags here).
* @param reason Ban reason string. * @param reason Ban reason string.
* @param command Command string to identify the source. If this is left * @param command Command string to identify the source. If this is left
* empty, then the OnBanIdentity forward will not be called. * empty, then the OnBanIdentity forward will not be called.
* @param source A source value that could be interpreted as a player * @param source A source value that could be interpreted as a player
* index of any sort (not actually checked by Core). * index of any sort (not actually checked by Core).
* @return True on success, false on failure. * @return True on success, false on failure.
*/ */
native bool BanIdentity(const char[] identity, native bool BanIdentity(const char[] identity,
int time, int time,
@ -142,13 +142,13 @@ native bool BanIdentity(const char[] identity,
/** /**
* Removes a ban that was written to the server (either in memory or on disk). * Removes a ban that was written to the server (either in memory or on disk).
* *
* @param identity String to unban (ip or authstring). * @param identity String to unban (ip or authstring).
* @param flags Flags (only IP and AUTHID are valid flags here). * @param flags Flags (only IP and AUTHID are valid flags here).
* @param command Command string to identify the source. If this is left * @param command Command string to identify the source. If this is left
* empty, then OnRemoveBan will not be called. * empty, then OnRemoveBan will not be called.
* @param source A source value that could be interpreted as a player * @param source A source value that could be interpreted as a player
* index of any sort (not actually checked by Core). * index of any sort (not actually checked by Core).
* @return True on success, false on failure. * @return True on success, false on failure.
*/ */
native bool RemoveBan(const char[] identity, native bool RemoveBan(const char[] identity,
int flags, int flags,

View File

@ -38,50 +38,50 @@
/** /**
* Called when a client is muted or unmuted * Called when a client is muted or unmuted
* *
* @param client Client index * @param client Client index
* @param muteState True if client was muted, false otherwise * @param muteState True if client was muted, false otherwise
*/ */
forward void BaseComm_OnClientMute(int client, bool muteState); forward void BaseComm_OnClientMute(int client, bool muteState);
/** /**
* Called when a client is gagged or ungagged * Called when a client is gagged or ungagged
* *
* @param client Client index * @param client Client index
* @param gagState True if client was gaged, false otherwise * @param gagState True if client was gaged, false otherwise
*/ */
forward void BaseComm_OnClientGag(int client, bool gagState); forward void BaseComm_OnClientGag(int client, bool gagState);
/** /**
* Returns whether or not a client is gagged * Returns whether or not a client is gagged
* *
* @param client Client index. * @param client Client index.
* @return True if client is gagged, false otherwise. * @return True if client is gagged, false otherwise.
*/ */
native bool BaseComm_IsClientGagged(int client); native bool BaseComm_IsClientGagged(int client);
/** /**
* Returns whether or not a client is muted * Returns whether or not a client is muted
* *
* @param client Client index. * @param client Client index.
* @return True if client is muted, false otherwise. * @return True if client is muted, false otherwise.
*/ */
native bool BaseComm_IsClientMuted(int client); native bool BaseComm_IsClientMuted(int client);
/** /**
* Sets a client's gag state * Sets a client's gag state
* *
* @param client Client index. * @param client Client index.
* @param gagState True to gag client, false to ungag. * @param gagState True to gag client, false to ungag.
* @return True if this caused a change in gag state, false otherwise. * @return True if this caused a change in gag state, false otherwise.
*/ */
native bool BaseComm_SetClientGag(int client, bool gagState); native bool BaseComm_SetClientGag(int client, bool gagState);
/** /**
* Sets a client's mute state * Sets a client's mute state
* *
* @param client Client index. * @param client Client index.
* @param muteState True to mute client, false to unmute. * @param muteState True to mute client, false to unmute.
* @return True if this caused a change in mute state, false otherwise. * @return True if this caused a change in mute state, false otherwise.
*/ */
native bool BaseComm_SetClientMute(int client, bool muteState); native bool BaseComm_SetClientMute(int client, bool muteState);

View File

@ -200,72 +200,72 @@ methodmap BfRead < Handle
/** /**
* Writes a single bit to a writable bitbuffer (bf_write). * Writes a single bit to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param bit Bit to write (true for 1, false for 0). * @param bit Bit to write (true for 1, false for 0).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteBool(Handle bf, bool bit); native void BfWriteBool(Handle bf, bool bit);
/** /**
* Writes a byte to a writable bitbuffer (bf_write). * Writes a byte to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param byte Byte to write (value will be written as 8bit). * @param byte Byte to write (value will be written as 8bit).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteByte(Handle bf, int byte); native void BfWriteByte(Handle bf, int byte);
/** /**
* Writes a byte to a writable bitbuffer (bf_write). * Writes a byte to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param chr Character to write. * @param chr Character to write.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteChar(Handle bf, int chr); native void BfWriteChar(Handle bf, int chr);
/** /**
* Writes a 16bit integer to a writable bitbuffer (bf_write). * Writes a 16bit integer to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param num Integer to write (value will be written as 16bit). * @param num Integer to write (value will be written as 16bit).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteShort(Handle bf, int num); native void BfWriteShort(Handle bf, int num);
/** /**
* Writes a 16bit unsigned integer to a writable bitbuffer (bf_write). * Writes a 16bit unsigned integer to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param num Integer to write (value will be written as 16bit). * @param num Integer to write (value will be written as 16bit).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteWord(Handle bf, int num); native void BfWriteWord(Handle bf, int num);
/** /**
* Writes a normal integer to a writable bitbuffer (bf_write). * Writes a normal integer to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param num Integer to write (value will be written as 32bit). * @param num Integer to write (value will be written as 32bit).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteNum(Handle bf, int num); native void BfWriteNum(Handle bf, int num);
/** /**
* Writes a floating point number to a writable bitbuffer (bf_write). * Writes a floating point number to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param num Number to write. * @param num Number to write.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteFloat(Handle bf, float num); native void BfWriteFloat(Handle bf, float num);
/** /**
* Writes a string to a writable bitbuffer (bf_write). * Writes a string to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param string Text string to write. * @param string Text string to write.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteString(Handle bf, const char[] string); native void BfWriteString(Handle bf, const char[] string);
@ -273,134 +273,134 @@ native void BfWriteString(Handle bf, const char[] string);
* Writes an entity to a writable bitbuffer (bf_write). * Writes an entity to a writable bitbuffer (bf_write).
* @note This is a wrapper around BfWriteShort(). * @note This is a wrapper around BfWriteShort().
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param ent Entity index to write. * @param ent Entity index to write.
* @error Invalid or incorrect Handle, or invalid entity. * @error Invalid or incorrect Handle, or invalid entity.
*/ */
native void BfWriteEntity(Handle bf, int ent); native void BfWriteEntity(Handle bf, int ent);
/** /**
* Writes a bit angle to a writable bitbuffer (bf_write). * Writes a bit angle to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param angle Angle to write. * @param angle Angle to write.
* @param numBits Optional number of bits to use. * @param numBits Optional number of bits to use.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteAngle(Handle bf, float angle, int numBits=8); native void BfWriteAngle(Handle bf, float angle, int numBits=8);
/** /**
* Writes a coordinate to a writable bitbuffer (bf_write). * Writes a coordinate to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param coord Coordinate to write. * @param coord Coordinate to write.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteCoord(Handle bf, float coord); native void BfWriteCoord(Handle bf, float coord);
/** /**
* Writes a 3D vector of coordinates to a writable bitbuffer (bf_write). * Writes a 3D vector of coordinates to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param coord Coordinate array to write. * @param coord Coordinate array to write.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteVecCoord(Handle bf, float coord[3]); native void BfWriteVecCoord(Handle bf, float coord[3]);
/** /**
* Writes a 3D normal vector to a writable bitbuffer (bf_write). * Writes a 3D normal vector to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param vec Vector to write. * @param vec Vector to write.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteVecNormal(Handle bf, float vec[3]); native void BfWriteVecNormal(Handle bf, float vec[3]);
/** /**
* Writes a 3D angle vector to a writable bitbuffer (bf_write). * Writes a 3D angle vector to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param angles Angle vector to write. * @param angles Angle vector to write.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfWriteAngles(Handle bf, float angles[3]); native void BfWriteAngles(Handle bf, float angles[3]);
/** /**
* Reads a single bit from a readable bitbuffer (bf_read). * Reads a single bit from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Bit value read. * @return Bit value read.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native bool BfReadBool(Handle bf); native bool BfReadBool(Handle bf);
/** /**
* Reads a byte from a readable bitbuffer (bf_read). * Reads a byte from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Byte value read (read as 8bit). * @return Byte value read (read as 8bit).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native int BfReadByte(Handle bf); native int BfReadByte(Handle bf);
/** /**
* Reads a character from a readable bitbuffer (bf_read). * Reads a character from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Character value read. * @return Character value read.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native int BfReadChar(Handle bf); native int BfReadChar(Handle bf);
/** /**
* Reads a 16bit integer from a readable bitbuffer (bf_read). * Reads a 16bit integer from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Integer value read (read as 16bit). * @return Integer value read (read as 16bit).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native int BfReadShort(Handle bf); native int BfReadShort(Handle bf);
/** /**
* Reads a 16bit unsigned integer from a readable bitbuffer (bf_read). * Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Integer value read (read as 16bit). * @return Integer value read (read as 16bit).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native int BfReadWord(Handle bf); native int BfReadWord(Handle bf);
/** /**
* Reads a normal integer to a readable bitbuffer (bf_read). * Reads a normal integer to a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Integer value read (read as 32bit). * @return Integer value read (read as 32bit).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native int BfReadNum(Handle bf); native int BfReadNum(Handle bf);
/** /**
* Reads a floating point number from a readable bitbuffer (bf_read). * Reads a floating point number from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Floating point value read. * @return Floating point value read.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native float BfReadFloat(Handle bf); native float BfReadFloat(Handle bf);
/** /**
* Reads a string from a readable bitbuffer (bf_read). * Reads a string from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer. * @param maxlength Maximum length of output string buffer.
* @param line If true the buffer will be copied until it reaches a '\n' or a null terminator. * @param line If true the buffer will be copied until it reaches a '\n' or a null terminator.
* @return Number of bytes written to the buffer. If the bitbuffer stream overflowed, * @return Number of bytes written to the buffer. If the bitbuffer stream overflowed,
* that is, had no terminator before the end of the stream, then a negative * that is, had no terminator before the end of the stream, then a negative
* number will be returned equal to the number of characters written to the * number will be returned equal to the number of characters written to the
* buffer minus 1. The buffer will be null terminated regardless of the * buffer minus 1. The buffer will be null terminated regardless of the
* return value. * return value.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native int BfReadString(Handle bf, char[] buffer, int maxlength, bool line=false); native int BfReadString(Handle bf, char[] buffer, int maxlength, bool line=false);
@ -408,63 +408,63 @@ native int BfReadString(Handle bf, char[] buffer, int maxlength, bool line=false
* Reads an entity from a readable bitbuffer (bf_read). * Reads an entity from a readable bitbuffer (bf_read).
* @note This is a wrapper around BfReadShort(). * @note This is a wrapper around BfReadShort().
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Entity index read. * @return Entity index read.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native int BfReadEntity(Handle bf); native int BfReadEntity(Handle bf);
/** /**
* Reads a bit angle from a readable bitbuffer (bf_read). * Reads a bit angle from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @param numBits Optional number of bits to use. * @param numBits Optional number of bits to use.
* @return Angle read. * @return Angle read.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native float BfReadAngle(Handle bf, int numBits=8); native float BfReadAngle(Handle bf, int numBits=8);
/** /**
* Reads a coordinate from a readable bitbuffer (bf_read). * Reads a coordinate from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Coordinate read. * @return Coordinate read.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native float BfReadCoord(Handle bf); native float BfReadCoord(Handle bf);
/** /**
* Reads a 3D vector of coordinates from a readable bitbuffer (bf_read). * Reads a 3D vector of coordinates from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @param coord Destination coordinate array. * @param coord Destination coordinate array.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfReadVecCoord(Handle bf, float coord[3]); native void BfReadVecCoord(Handle bf, float coord[3]);
/** /**
* Reads a 3D normal vector from a readable bitbuffer (bf_read). * Reads a 3D normal vector from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @param vec Destination vector array. * @param vec Destination vector array.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfReadVecNormal(Handle bf, float vec[3]); native void BfReadVecNormal(Handle bf, float vec[3]);
/** /**
* Reads a 3D angle vector from a readable bitbuffer (bf_read). * Reads a 3D angle vector from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @param angles Destination angle vector. * @param angles Destination angle vector.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native void BfReadAngles(Handle bf, float angles[3]); native void BfReadAngles(Handle bf, float angles[3]);
/** /**
* Returns the number of bytes left in a readable bitbuffer (bf_read). * Returns the number of bytes left in a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Number of bytes left unread. * @return Number of bytes left unread.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native int BfGetNumBytesLeft(Handle bf); native int BfGetNumBytesLeft(Handle bf);

View File

@ -40,9 +40,9 @@
*/ */
enum CookieAccess enum CookieAccess
{ {
CookieAccess_Public, /**< Visible and Changeable by users */ CookieAccess_Public, /**< Visible and Changeable by users */
CookieAccess_Protected, /**< Read only to users */ CookieAccess_Protected, /**< Read only to users */
CookieAccess_Private, /**< Completely hidden cookie */ CookieAccess_Private /**< Completely hidden cookie */
}; };
/** /**
@ -50,10 +50,10 @@ enum CookieAccess
*/ */
enum CookieMenu enum CookieMenu
{ {
CookieMenu_YesNo, /**< Yes/No menu with "yes"/"no" results saved into the cookie */ CookieMenu_YesNo, /**< Yes/No menu with "yes"/"no" results saved into the cookie */
CookieMenu_YesNo_Int, /**< Yes/No menu with 1/0 saved into the cookie */ CookieMenu_YesNo_Int, /**< Yes/No menu with 1/0 saved into the cookie */
CookieMenu_OnOff, /**< On/Off menu with "on"/"off" results saved into the cookie */ CookieMenu_OnOff, /**< On/Off menu with "on"/"off" results saved into the cookie */
CookieMenu_OnOff_Int, /**< On/Off menu with 1/0 saved into the cookie */ CookieMenu_OnOff_Int /**< On/Off menu with 1/0 saved into the cookie */
}; };
enum CookieMenuAction enum CookieMenuAction
@ -71,7 +71,7 @@ enum CookieMenuAction
* *
* INPUT : Client index and any data if available. * INPUT : Client index and any data if available.
*/ */
CookieMenuAction_SelectOption = 1, CookieMenuAction_SelectOption = 1
}; };
/** /**
@ -88,12 +88,12 @@ enum CookieMenuAction
* Handles returned by RegClientCookie can be closed via CloseHandle() when * Handles returned by RegClientCookie can be closed via CloseHandle() when
* no longer needed. * no longer needed.
* *
* @param name Name of the new preference cookie. * @param name Name of the new preference cookie.
* @param description Optional description of the preference cookie. * @param description Optional description of the preference cookie.
* @param access What CookieAccess level to assign to this cookie. * @param access What CookieAccess level to assign to this cookie.
* @return A handle to the newly created cookie. If the cookie already * @return A handle to the newly created cookie. If the cookie already
* exists, a handle to it will still be returned. * exists, a handle to it will still be returned.
* @error Cookie name is blank. * @error Cookie name is blank.
*/ */
native Handle RegClientCookie(const char[] name, const char[] description, CookieAccess access); native Handle RegClientCookie(const char[] name, const char[] description, CookieAccess access);
@ -103,66 +103,66 @@ native Handle RegClientCookie(const char[] name, const char[] description, Cooki
* Handles returned by FindClientCookie can be closed via CloseHandle() when * Handles returned by FindClientCookie can be closed via CloseHandle() when
* no longer needed. * no longer needed.
* *
* @param name Name of cookie to find. * @param name Name of cookie to find.
* @return A handle to the cookie if it is found. INVALID_HANDLE otherwise. * @return A handle to the cookie if it is found. INVALID_HANDLE otherwise.
*/ */
native Handle FindClientCookie(const char[] name); native Handle FindClientCookie(const char[] name);
/** /**
* Set the value of a Client preference cookie. * Set the value of a Client preference cookie.
* *
* @param client Client index. * @param client Client index.
* @param cookie Client preference cookie handle. * @param cookie Client preference cookie handle.
* @param value String value to set. * @param value String value to set.
* @error Invalid cookie handle or invalid client index. * @error Invalid cookie handle or invalid client index.
*/ */
native void SetClientCookie(int client, Handle cookie, const char[] value); native void SetClientCookie(int client, Handle cookie, const char[] value);
/** /**
* Retrieve the value of a Client preference cookie. * Retrieve the value of a Client preference cookie.
* *
* @param client Client index. * @param client Client index.
* @param cookie Client preference cookie handle. * @param cookie Client preference cookie handle.
* @param buffer Copyback buffer for value. * @param buffer Copyback buffer for value.
* @param maxlen Maximum length of the buffer. * @param maxlen Maximum length of the buffer.
* @error Invalid cookie handle or invalid client index. * @error Invalid cookie handle or invalid client index.
*/ */
native void GetClientCookie(int client, Handle cookie, char[] buffer, int maxlen); native void GetClientCookie(int client, Handle cookie, char[] buffer, int maxlen);
/** /**
* Sets the value of a Client preference cookie based on an authID string. * Sets the value of a Client preference cookie based on an authID string.
* *
* @param authID String Auth/STEAM ID of player to set. * @param authID String Auth/STEAM ID of player to set.
* @param cookie Client preference cookie handle. * @param cookie Client preference cookie handle.
* @param value String value to set. * @param value String value to set.
* @error Invalid cookie handle. * @error Invalid cookie handle.
*/ */
native void SetAuthIdCookie(const char[] authID, Handle cookie, const char[] value); native void SetAuthIdCookie(const char[] authID, Handle cookie, const char[] value);
/** /**
* Checks if a clients cookies have been loaded from the database. * Checks if a clients cookies have been loaded from the database.
* *
* @param client Client index. * @param client Client index.
* @return True if loaded, false otherwise. * @return True if loaded, false otherwise.
* @error Invalid client index. * @error Invalid client index.
*/ */
native bool AreClientCookiesCached(int client); native bool AreClientCookiesCached(int client);
/** /**
* Called once a client's saved cookies have been loaded from the database. * Called once a client's saved cookies have been loaded from the database.
* *
* @param client Client index. * @param client Client index.
*/ */
forward void OnClientCookiesCached(int client); forward void OnClientCookiesCached(int client);
/** /**
* Cookie Menu Callback prototype * Cookie Menu Callback prototype
* *
* @param client Client index. * @param client Client index.
* @param action CookieMenuAction being performed. * @param action CookieMenuAction being performed.
* @param info Info data passed. * @param info Info data passed.
* @param buffer Outbut buffer. * @param buffer Outbut buffer.
* @param maxlen Max length of the output buffer. * @param maxlen Max length of the output buffer.
*/ */
typedef CookieMenuHandler = function void ( typedef CookieMenuHandler = function void (
int client, int client,
@ -177,12 +177,12 @@ typedef CookieMenuHandler = function void (
* *
* Note: This handles everything automatically and does not require a callback * Note: This handles everything automatically and does not require a callback
* *
* @param cookie Client preference cookie handle. * @param cookie Client preference cookie handle.
* @param type A CookieMenu prefab menu type. * @param type A CookieMenu prefab menu type.
* @param display Text to show on the menu. * @param display Text to show on the menu.
* @param handler Optional handler callback for translations and output on selection * @param handler Optional handler callback for translations and output on selection
* @param info Info data to pass to the callback. * @param info Info data to pass to the callback.
* @error Invalid cookie handle. * @error Invalid cookie handle.
*/ */
native void SetCookiePrefabMenu(Handle cookie, CookieMenu type, const char[] display, CookieMenuHandler handler=INVALID_FUNCTION, any info=0); native void SetCookiePrefabMenu(Handle cookie, CookieMenu type, const char[] display, CookieMenuHandler handler=INVALID_FUNCTION, any info=0);
@ -191,37 +191,37 @@ native void SetCookiePrefabMenu(Handle cookie, CookieMenu type, const char[] dis
* *
* Note: This only adds the top level menu item. You need to handle any submenus from the callback. * Note: This only adds the top level menu item. You need to handle any submenus from the callback.
* *
* @param handler A MenuHandler callback function. * @param handler A MenuHandler callback function.
* @param info Data to pass to the callback. * @param info Data to pass to the callback.
* @param display Text to show on the menu. * @param display Text to show on the menu.
* @error Invalid cookie handle. * @error Invalid cookie handle.
*/ */
native void SetCookieMenuItem(CookieMenuHandler handler, any info, const char[] display); native void SetCookieMenuItem(CookieMenuHandler handler, any info, const char[] display);
/** /**
* Displays the settings menu to a client. * Displays the settings menu to a client.
* *
* @param client Client index. * @param client Client index.
*/ */
native void ShowCookieMenu(int client); native void ShowCookieMenu(int client);
/** /**
* Gets a cookie iterator. Must be freed with CloseHandle(). * Gets a cookie iterator. Must be freed with CloseHandle().
* *
* @return A new cookie iterator. * @return A new cookie iterator.
*/ */
native Handle GetCookieIterator(); native Handle GetCookieIterator();
/** /**
* Reads a cookie iterator, then advances to the next cookie if any. * Reads a cookie iterator, then advances to the next cookie if any.
* *
* @param iter Cookie iterator Handle. * @param iter Cookie iterator Handle.
* @param name Name buffer. * @param name Name buffer.
* @param nameLen Name buffer size. * @param nameLen Name buffer size.
* @param access Access level of the cookie. * @param access Access level of the cookie.
* @param desc Cookie description buffer. * @param desc Cookie description buffer.
* @param descLen Cookie description buffer size. * @param descLen Cookie description buffer size.
* @return True on success, false if there are no more commands. * @return True on success, false if there are no more commands.
*/ */
native bool ReadCookieIterator(Handle iter, native bool ReadCookieIterator(Handle iter,
char[] name, char[] name,
@ -233,18 +233,18 @@ native bool ReadCookieIterator(Handle iter,
/** /**
* Returns the access level of a cookie * Returns the access level of a cookie
* *
* @param cookie Client preference cookie handle. * @param cookie Client preference cookie handle.
* @return CookieAccess access level. * @return CookieAccess access level.
* @error Invalid cookie handle. * @error Invalid cookie handle.
*/ */
native CookieAccess GetCookieAccess(Handle cookie); native CookieAccess GetCookieAccess(Handle cookie);
/** /**
* Returns the last updated timestamp for a client cookie * Returns the last updated timestamp for a client cookie
* *
* @param client Client index. * @param client Client index.
* @param cookie Cookie handle. * @param cookie Cookie handle.
* @return Last updated timestamp. * @return Last updated timestamp.
*/ */
native int GetClientCookieTime(int client, Handle cookie); native int GetClientCookieTime(int client, Handle cookie);

View File

@ -40,9 +40,9 @@
*/ */
enum NetFlow enum NetFlow
{ {
NetFlow_Outgoing = 0, /**< Outgoing traffic */ NetFlow_Outgoing = 0, /**< Outgoing traffic */
NetFlow_Incoming, /**< Incoming traffic */ NetFlow_Incoming, /**< Incoming traffic */
NetFlow_Both, /**< Both values added together */ NetFlow_Both /**< Both values added together */
}; };
/** /**
@ -61,7 +61,7 @@ enum AuthIdType
// The following are only available on games that support Steam authentication. // The following are only available on games that support Steam authentication.
AuthId_Steam2, /**< Steam2 rendered format, ex "STEAM_1:1:4153990" */ AuthId_Steam2, /**< Steam2 rendered format, ex "STEAM_1:1:4153990" */
AuthId_Steam3, /**< Steam3 rendered format, ex "[U:1:8307981]" */ AuthId_Steam3, /**< Steam3 rendered format, ex "[U:1:8307981]" */
AuthId_SteamID64, /**< A SteamID64 (uint64) as a String, ex "76561197968573709" */ AuthId_SteamID64 /**< A SteamID64 (uint64) as a String, ex "76561197968573709" */
}; };
/** /**
@ -69,10 +69,10 @@ enum AuthIdType
* MAXPLAYERS is a hardcoded value as an upper limit. MaxClients changes based on the server. * MAXPLAYERS is a hardcoded value as an upper limit. MaxClients changes based on the server.
*/ */
#define MAXPLAYERS 65 /**< Maximum number of players SourceMod supports */ #define MAXPLAYERS 65 /**< Maximum number of players SourceMod supports */
#define MAX_NAME_LENGTH 128 /**< Maximum buffer required to store a client name */ #define MAX_NAME_LENGTH 128 /**< Maximum buffer required to store a client name */
public const int MaxClients; /**< Maximum number of players the server supports (dynamic) */ public const int MaxClients; /**< Maximum number of players the server supports (dynamic) */
/** /**
* Called on client connection. If you return true, the client will be allowed in the server. * Called on client connection. If you return true, the client will be allowed in the server.
@ -83,17 +83,17 @@ public const int MaxClients; /**< Maximum number of players the server supports
* to the string buffer, it is not defined which plugin's string will be shown to the client, * to the string buffer, it is not defined which plugin's string will be shown to the client,
* but it is guaranteed one of them will. * but it is guaranteed one of them will.
* *
* @param client Client index. * @param client Client index.
* @param rejectmsg Buffer to store the rejection message when the connection is refused. * @param rejectmsg Buffer to store the rejection message when the connection is refused.
* @param maxlen Maximum number of characters for rejection buffer. * @param maxlen Maximum number of characters for rejection buffer.
* @return True to validate client's connection, false to refuse it. * @return True to validate client's connection, false to refuse it.
*/ */
forward bool OnClientConnect(int client, char[] rejectmsg, int maxlen); forward bool OnClientConnect(int client, char[] rejectmsg, int maxlen);
/** /**
* Called once a client successfully connects. This callback is paired with OnClientDisconnect. * Called once a client successfully connects. This callback is paired with OnClientDisconnect.
* *
* @param client Client index. * @param client Client index.
*/ */
forward void OnClientConnected(int client); forward void OnClientConnected(int client);
@ -108,21 +108,21 @@ forward void OnClientConnected(int client);
* GetClientCount() will include clients as they are passed through this * GetClientCount() will include clients as they are passed through this
* function, as clients are already in game at this point. * function, as clients are already in game at this point.
* *
* @param client Client index. * @param client Client index.
*/ */
forward void OnClientPutInServer(int client); forward void OnClientPutInServer(int client);
/** /**
* Called when a client is disconnecting from the server. * Called when a client is disconnecting from the server.
* *
* @param client Client index. * @param client Client index.
*/ */
forward void OnClientDisconnect(int client); forward void OnClientDisconnect(int client);
/** /**
* Called when a client is disconnected from the server. * Called when a client is disconnected from the server.
* *
* @param client Client index. * @param client Client index.
*/ */
forward void OnClientDisconnect_Post(int client); forward void OnClientDisconnect_Post(int client);
@ -132,39 +132,39 @@ forward void OnClientDisconnect_Post(int client);
* As of SourceMod 1.3, the client is guaranteed to be in-game. * As of SourceMod 1.3, the client is guaranteed to be in-game.
* Use command listeners (console.inc) for more advanced hooks. * Use command listeners (console.inc) for more advanced hooks.
* *
* @param client Client index. * @param client Client index.
* @param args Number of arguments. * @param args Number of arguments.
* @return Plugin_Handled blocks the command from being sent, * @return Plugin_Handled blocks the command from being sent,
* and Plugin_Continue resumes normal functionality. * and Plugin_Continue resumes normal functionality.
*/ */
forward Action OnClientCommand(int client, int args); forward Action OnClientCommand(int client, int args);
/** /**
* Called when a client is sending a KeyValues command. * Called when a client is sending a KeyValues command.
* *
* @param client Client index. * @param client Client index.
* @param kv Editable KeyValues data to be sent as the command. * @param kv Editable KeyValues data to be sent as the command.
* (This handle should not be stored and will be closed * (This handle should not be stored and will be closed
* after this forward completes.) * after this forward completes.)
* @return Plugin_Handled blocks the command from being sent, * @return Plugin_Handled blocks the command from being sent,
* and Plugin_Continue resumes normal functionality. * and Plugin_Continue resumes normal functionality.
*/ */
forward Action OnClientCommandKeyValues(int client, KeyValues kv); forward Action OnClientCommandKeyValues(int client, KeyValues kv);
/** /**
* Called after a client has sent a KeyValues command. * Called after a client has sent a KeyValues command.
* *
* @param client Client index. * @param client Client index.
* @param kv KeyValues data sent as the command. * @param kv KeyValues data sent as the command.
* (This handle should not be stored and will be closed * (This handle should not be stored and will be closed
* after this forward completes.) * after this forward completes.)
*/ */
forward void OnClientCommandKeyValues_Post(int client, KeyValues kv); forward void OnClientCommandKeyValues_Post(int client, KeyValues kv);
/** /**
* Called whenever the client's settings are changed. * Called whenever the client's settings are changed.
* *
* @param client Client index. * @param client Client index.
*/ */
forward void OnClientSettingsChanged(int client); forward void OnClientSettingsChanged(int client);
@ -175,8 +175,8 @@ forward void OnClientSettingsChanged(int client);
* *
* This is called by bots, but the ID will be "BOT". * This is called by bots, but the ID will be "BOT".
* *
* @param client Client index. * @param client Client index.
* @param auth Client Steam2 id, if available, else engine auth id. * @param auth Client Steam2 id, if available, else engine auth id.
*/ */
forward void OnClientAuthorized(int client, const char[] auth); forward void OnClientAuthorized(int client, const char[] auth);
@ -193,8 +193,8 @@ forward void OnClientAuthorized(int client, const char[] auth);
* This callback is guaranteed to occur on all clients, and always * This callback is guaranteed to occur on all clients, and always
* after each OnClientPutInServer() call. * after each OnClientPutInServer() call.
* *
* @param client Client index. * @param client Client index.
* @return Plugin_Handled to block admin checks. * @return Plugin_Handled to block admin checks.
*/ */
forward Action OnClientPreAdminCheck(int client); forward Action OnClientPreAdminCheck(int client);
@ -210,7 +210,7 @@ forward Action OnClientPreAdminCheck(int client);
* *
* See OnClientPostAdminCheck() for more information. * See OnClientPostAdminCheck() for more information.
* *
* @param client Client index. * @param client Client index.
*/ */
forward void OnClientPostAdminFilter(int client); forward void OnClientPostAdminFilter(int client);
@ -221,7 +221,7 @@ forward void OnClientPostAdminFilter(int client);
* This callback is guaranteed to occur on all clients, and always * This callback is guaranteed to occur on all clients, and always
* after each OnClientPutInServer() call. * after each OnClientPutInServer() call.
* *
* @param client Client index. * @param client Client index.
*/ */
forward void OnClientPostAdminCheck(int client); forward void OnClientPostAdminCheck(int client);
@ -236,7 +236,8 @@ forward void OnClientPostAdminCheck(int client);
* SourceTV or TF2's arena mode. Use the "MaxClients" dynamic variable documented at the * SourceTV or TF2's arena mode. Use the "MaxClients" dynamic variable documented at the
* top of this file. * top of this file.
* *
* @return Maximum number of clients allowed. * @return Maximum number of clients allowed.
* @deprecated Use MaxClients variable instead.
*/ */
#pragma deprecated Use MaxClients variable instead. #pragma deprecated Use MaxClients variable instead.
native int GetMaxClients(); native int GetMaxClients();
@ -252,52 +253,53 @@ native int GetMaxClients();
* You should not globally cache the value to GetMaxHumanPlayers() because it can change across * You should not globally cache the value to GetMaxHumanPlayers() because it can change across
* game modes. You may still cache it locally. * game modes. You may still cache it locally.
* *
* @return Maximum number of humans allowed. * @return Maximum number of humans allowed.
*/ */
native int GetMaxHumanPlayers(); native int GetMaxHumanPlayers();
/** /**
* Returns the client count put in the server. * Returns the client count put in the server.
* *
* @param inGameOnly If false connecting players are also counted. * @param inGameOnly If false connecting players are also counted.
* @return Client count in the server. * @return Client count in the server.
*/ */
native int GetClientCount(bool inGameOnly=true); native int GetClientCount(bool inGameOnly=true);
/** /**
* Returns the client's name. * Returns the client's name.
* *
* @param client Player index. * @param client Player index.
* @param name Buffer to store the client's name. * @param name Buffer to store the client's name.
* @param maxlen Maximum length of string buffer (includes NULL terminator). * @param maxlen Maximum length of string buffer (includes NULL terminator).
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error If the client is not connected an error will be thrown. * @error If the client is not connected an error will be thrown.
*/ */
native bool GetClientName(int client, char[] name, int maxlen); native bool GetClientName(int client, char[] name, int maxlen);
/** /**
* Retrieves a client's IP address. * Retrieves a client's IP address.
* *
* @param client Player index. * @param client Player index.
* @param ip Buffer to store the client's ip address. * @param ip Buffer to store the client's ip address.
* @param maxlen Maximum length of string buffer (includes NULL terminator). * @param maxlen Maximum length of string buffer (includes NULL terminator).
* @param remport Remove client's port from the ip string (true by default). * @param remport Remove client's port from the ip string (true by default).
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error If the client is not connected or the index is invalid. * @error If the client is not connected or the index is invalid.
*/ */
native bool GetClientIP(int client, char[] ip, int maxlen, bool remport=true); native bool GetClientIP(int client, char[] ip, int maxlen, bool remport=true);
/** /**
* Retrieves a client's authentication string (SteamID). * Retrieves a client's authentication string (SteamID).
* *
* @param client Player index. * @param client Player index.
* @param auth Buffer to store the client's auth string. * @param auth Buffer to store the client's auth string.
* @param maxlen Maximum length of string buffer (includes NULL terminator). * @param maxlen Maximum length of string buffer (includes NULL terminator).
* @param validate Check backend validation status. * @param validate Check backend validation status.
* DO NOT PASS FALSE UNLESS YOU UNDERSTAND THE CONSEQUENCES, * DO NOT PASS FALSE UNLESS YOU UNDERSTAND THE CONSEQUENCES,
* You WILL KNOW if you need to use this, MOST WILL NOT. * You WILL KNOW if you need to use this, MOST WILL NOT.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error If the client is not connected or the index is invalid. * @error If the client is not connected or the index is invalid.
* @deprecated Use GetClientAuthId
*/ */
#pragma deprecated Use GetClientAuthId #pragma deprecated Use GetClientAuthId
native bool GetClientAuthString(int client, char[] auth, int maxlen, bool validate=true); native bool GetClientAuthString(int client, char[] auth, int maxlen, bool validate=true);
@ -305,15 +307,15 @@ native bool GetClientAuthString(int client, char[] auth, int maxlen, bool valida
/** /**
* Retrieves a client's authentication string (SteamID). * Retrieves a client's authentication string (SteamID).
* *
* @param client Player index. * @param client Player index.
* @param authType Auth id type and format to use. * @param authType Auth id type and format to use.
* @param auth Buffer to store the client's auth id. * @param auth Buffer to store the client's auth id.
* @param maxlen Maximum length of string buffer (includes NULL terminator). * @param maxlen Maximum length of string buffer (includes NULL terminator).
* @param validate Check backend validation status. * @param validate Check backend validation status.
* DO NOT PASS FALSE UNLESS YOU UNDERSTAND THE CONSEQUENCES, * DO NOT PASS FALSE UNLESS YOU UNDERSTAND THE CONSEQUENCES,
* You WILL KNOW if you need to use this, MOST WILL NOT. * You WILL KNOW if you need to use this, MOST WILL NOT.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error If the client is not connected or the index is invalid. * @error If the client is not connected or the index is invalid.
*/ */
native bool GetClientAuthId(int client, AuthIdType authType, char[] auth, int maxlen, bool validate=true); native bool GetClientAuthId(int client, AuthIdType authType, char[] auth, int maxlen, bool validate=true);
@ -321,12 +323,12 @@ native bool GetClientAuthId(int client, AuthIdType authType, char[] auth, int ma
* Returns the client's Steam account ID, a number uniquely identifying a given Steam account. * Returns the client's Steam account ID, a number uniquely identifying a given Steam account.
* This number is the basis for the various display SteamID forms, see the AuthIdType enum for examples. * This number is the basis for the various display SteamID forms, see the AuthIdType enum for examples.
* *
* @param client Client Index. * @param client Client Index.
* @param validate Check backend validation status. * @param validate Check backend validation status.
* DO NOT PASS FALSE UNLESS YOU UNDERSTAND THE CONSEQUENCES, * DO NOT PASS FALSE UNLESS YOU UNDERSTAND THE CONSEQUENCES,
* You WILL KNOW if you need to use this, MOST WILL NOT. * You WILL KNOW if you need to use this, MOST WILL NOT.
* @return Steam account ID or 0 if not available. * @return Steam account ID or 0 if not available.
* @error If the client is not connected or the index is invalid. * @error If the client is not connected or the index is invalid.
*/ */
native int GetSteamAccountID(int client, bool validate=true); native int GetSteamAccountID(int client, bool validate=true);
@ -334,26 +336,26 @@ native int GetSteamAccountID(int client, bool validate=true);
* Retrieves a client's user id, which is an index incremented for every client * Retrieves a client's user id, which is an index incremented for every client
* that joins the server. * that joins the server.
* *
* @param client Player index. * @param client Player index.
* @return User id of the client. * @return User id of the client.
* @error If the client is not connected or the index is invalid. * @error If the client is not connected or the index is invalid.
*/ */
native int GetClientUserId(int client); native int GetClientUserId(int client);
/** /**
* Returns if a certain player is connected. * Returns if a certain player is connected.
* *
* @param client Player index. * @param client Player index.
* @return True if player is connected to the server, false otherwise. * @return True if player is connected to the server, false otherwise.
*/ */
native bool IsClientConnected(int client); native bool IsClientConnected(int client);
/** /**
* Returns if a certain player has entered the game. * Returns if a certain player has entered the game.
* *
* @param client Player index (index does not have to be connected). * @param client Player index (index does not have to be connected).
* @return True if player has entered the game, false otherwise. * @return True if player has entered the game, false otherwise.
* @error Invalid client index. * @error Invalid client index.
*/ */
native bool IsClientInGame(int client); native bool IsClientInGame(int client);
@ -361,15 +363,15 @@ native bool IsClientInGame(int client);
* Returns if a client is in the "kick queue" (i.e. the client will be kicked * Returns if a client is in the "kick queue" (i.e. the client will be kicked
* shortly and thus they should not appear as valid). * shortly and thus they should not appear as valid).
* *
* @param client Player index (must be connected). * @param client Player index (must be connected).
* @return True if in the kick queue, false otherwise. * @return True if in the kick queue, false otherwise.
* @error Invalid client index. * @error Invalid client index.
*/ */
native bool IsClientInKickQueue(int client); native bool IsClientInKickQueue(int client);
/** /**
* Backwards compatibility stock - use IsClientInGame * Backwards compatibility stock - use IsClientInGame
* @deprecated Renamed to IsClientInGame * @deprecated Renamed to IsClientInGame
*/ */
#pragma deprecated Use IsClientInGame() instead #pragma deprecated Use IsClientInGame() instead
stock bool IsPlayerInGame(int client) stock bool IsPlayerInGame(int client)
@ -380,40 +382,40 @@ stock bool IsPlayerInGame(int client)
/** /**
* Returns if a certain player has been authenticated. * Returns if a certain player has been authenticated.
* *
* @param client Player index. * @param client Player index.
* @return True if player has been authenticated, false otherwise. * @return True if player has been authenticated, false otherwise.
*/ */
native bool IsClientAuthorized(int client); native bool IsClientAuthorized(int client);
/** /**
* Returns if a certain player is a fake client. * Returns if a certain player is a fake client.
* *
* @param client Player index. * @param client Player index.
* @return True if player is a fake client, false otherwise. * @return True if player is a fake client, false otherwise.
*/ */
native bool IsFakeClient(int client); native bool IsFakeClient(int client);
/** /**
* Returns if a certain player is the SourceTV bot. * Returns if a certain player is the SourceTV bot.
* *
* @param client Player index. * @param client Player index.
* @return True if player is the SourceTV bot, false otherwise. * @return True if player is the SourceTV bot, false otherwise.
*/ */
native bool IsClientSourceTV(int client); native bool IsClientSourceTV(int client);
/** /**
* Returns if a certain player is the Replay bot. * Returns if a certain player is the Replay bot.
* *
* @param client Player index. * @param client Player index.
* @return True if player is the Replay bot, false otherwise. * @return True if player is the Replay bot, false otherwise.
*/ */
native bool IsClientReplay(int client); native bool IsClientReplay(int client);
/** /**
* Returns if a certain player is an observer/spectator. * Returns if a certain player is an observer/spectator.
* *
* @param client Player index. * @param client Player index.
* @return True if player is an observer, false otherwise. * @return True if player is an observer, false otherwise.
*/ */
native bool IsClientObserver(int client); native bool IsClientObserver(int client);
@ -422,49 +424,49 @@ native bool IsClientObserver(int client);
* *
* Note: This function was originally in SDKTools and was moved to core. * Note: This function was originally in SDKTools and was moved to core.
* *
* @param client Player's index. * @param client Player's index.
* @return True if the client is alive, false otherwise. * @return True if the client is alive, false otherwise.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native bool IsPlayerAlive(int client); native bool IsPlayerAlive(int client);
/** /**
* Retrieves values from client replicated keys. * Retrieves values from client replicated keys.
* *
* @param client Player's index. * @param client Player's index.
* @param key Key string. * @param key Key string.
* @param value Buffer to store value. * @param value Buffer to store value.
* @param maxlen Maximum length of valve (UTF-8 safe). * @param maxlen Maximum length of valve (UTF-8 safe).
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native bool GetClientInfo(int client, const char[] key, char[] value, int maxlen); native bool GetClientInfo(int client, const char[] key, char[] value, int maxlen);
/** /**
* Retrieves a client's team index. * Retrieves a client's team index.
* *
* @param client Player's index. * @param client Player's index.
* @return Team index the client is on (mod specific). * @return Team index the client is on (mod specific).
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native int GetClientTeam(int client); native int GetClientTeam(int client);
/** /**
* Sets a client's AdminId. * Sets a client's AdminId.
* *
* @param client Player's index. * @param client Player's index.
* @param id AdminId to set. INVALID_ADMIN_ID removes admin permissions. * @param id AdminId to set. INVALID_ADMIN_ID removes admin permissions.
* @param temp True if the id should be freed on disconnect. * @param temp True if the id should be freed on disconnect.
* @error Invalid client index, client not connected, or bogus AdminId. * @error Invalid client index, client not connected, or bogus AdminId.
*/ */
native void SetUserAdmin(int client, AdminId id, bool temp=false); native void SetUserAdmin(int client, AdminId id, bool temp=false);
/** /**
* Retrieves a client's AdminId. * Retrieves a client's AdminId.
* *
* @param client Player's index. * @param client Player's index.
* @return AdminId of the client, or INVALID_ADMIN_ID if none. * @return AdminId of the client, or INVALID_ADMIN_ID if none.
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native AdminId GetUserAdmin(int client); native AdminId GetUserAdmin(int client);
@ -472,9 +474,9 @@ native AdminId GetUserAdmin(int client);
* Sets access flags on a client. If the client is not an admin, * Sets access flags on a client. If the client is not an admin,
* a temporary, anonymous AdminId is given. * a temporary, anonymous AdminId is given.
* *
* @param client Player's index. * @param client Player's index.
* @param ... Flags to set on the client. * @param ... Flags to set on the client.
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native void AddUserFlags(int client, AdminFlag ...); native void AddUserFlags(int client, AdminFlag ...);
@ -482,9 +484,9 @@ native void AddUserFlags(int client, AdminFlag ...);
* Removes flags from a client. If the client is not an admin, * Removes flags from a client. If the client is not an admin,
* this has no effect. * this has no effect.
* *
* @param client Player's index. * @param client Player's index.
* @param ... Flags to remove from the client. * @param ... Flags to remove from the client.
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native void RemoveUserFlags(int client, AdminFlag ...); native void RemoveUserFlags(int client, AdminFlag ...);
@ -492,8 +494,8 @@ native void RemoveUserFlags(int client, AdminFlag ...);
* Sets access flags on a client using bits instead of flags. If the * Sets access flags on a client using bits instead of flags. If the
* client is not an admin, and flags not 0, a temporary, anonymous AdminId is given. * client is not an admin, and flags not 0, a temporary, anonymous AdminId is given.
* *
* @param client Player's index. * @param client Player's index.
* @param flags Bitstring of flags to set on client. * @param flags Bitstring of flags to set on client.
*/ */
native void SetUserFlagBits(int client, int flags); native void SetUserFlagBits(int client, int flags);
@ -501,9 +503,9 @@ native void SetUserFlagBits(int client, int flags);
* Returns client access flags. If the client is not an admin, * Returns client access flags. If the client is not an admin,
* the result is always 0. * the result is always 0.
* *
* @param client Player's index. * @param client Player's index.
* @return Flags * @return Flags
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native int GetUserFlagBits(int client); native int GetUserFlagBits(int client);
@ -511,10 +513,10 @@ native int GetUserFlagBits(int client);
* Returns whether a user can target another user. * Returns whether a user can target another user.
* This is a helper function for CanAdminTarget. * This is a helper function for CanAdminTarget.
* *
* @param client Player's index. * @param client Player's index.
* @param target Target player's index. * @param target Target player's index.
* @return True if target is targettable by the player, false otherwise. * @return True if target is targettable by the player, false otherwise.
* @error Invalid or unconnected player indexers. * @error Invalid or unconnected player indexers.
*/ */
native bool CanUserTarget(int client, int target); native bool CanUserTarget(int client, int target);
@ -524,9 +526,9 @@ native bool CanUserTarget(int client, int target);
* *
* Note: This function is based on the internal cache only. * Note: This function is based on the internal cache only.
* *
* @param client Client index. * @param client Client index.
* @return True if access was changed, false if it did not. * @return True if access was changed, false if it did not.
* @error Invalid client index or client not in-game AND authorized. * @error Invalid client index or client not in-game AND authorized.
*/ */
native bool RunAdminCacheChecks(int client); native bool RunAdminCacheChecks(int client);
@ -536,215 +538,215 @@ native bool RunAdminCacheChecks(int client);
* *
* Note: This must be sent even if no admin id was assigned. * Note: This must be sent even if no admin id was assigned.
* *
* @param client Client index. * @param client Client index.
* @error Invalid client index or client not in-game AND authorized. * @error Invalid client index or client not in-game AND authorized.
*/ */
native void NotifyPostAdminCheck(int client); native void NotifyPostAdminCheck(int client);
/** /**
* Creates a fake client. * Creates a fake client.
* *
* @param name Name to use. * @param name Name to use.
* @return Client index on success, 0 otherwise. * @return Client index on success, 0 otherwise.
*/ */
native int CreateFakeClient(const char[] name); native int CreateFakeClient(const char[] name);
/** /**
* Sets a convar value on a fake client. * Sets a convar value on a fake client.
* *
* @param client Client index. * @param client Client index.
* @param cvar ConVar name. * @param cvar ConVar name.
* @param value ConVar value. * @param value ConVar value.
* @error Invalid client index, client not connected, * @error Invalid client index, client not connected,
* or client not a fake client. * or client not a fake client.
*/ */
native void SetFakeClientConVar(int client, const char[] cvar, const char[] value); native void SetFakeClientConVar(int client, const char[] cvar, const char[] value);
/** /**
* Returns the client's health. * Returns the client's health.
* *
* @param client Player's index. * @param client Player's index.
* @return Health value. * @return Health value.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native int GetClientHealth(int client); native int GetClientHealth(int client);
/** /**
* Returns the client's model name. * Returns the client's model name.
* *
* @param client Player's index. * @param client Player's index.
* @param model Buffer to store the client's model name. * @param model Buffer to store the client's model name.
* @param maxlen Maximum length of string buffer (includes NULL terminator). * @param maxlen Maximum length of string buffer (includes NULL terminator).
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void GetClientModel(int client, char[] model, int maxlen); native void GetClientModel(int client, char[] model, int maxlen);
/** /**
* Returns the client's weapon name. * Returns the client's weapon name.
* *
* @param client Player's index. * @param client Player's index.
* @param weapon Buffer to store the client's weapon name. * @param weapon Buffer to store the client's weapon name.
* @param maxlen Maximum length of string buffer (includes NULL terminator). * @param maxlen Maximum length of string buffer (includes NULL terminator).
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void GetClientWeapon(int client, char[] weapon, int maxlen); native void GetClientWeapon(int client, char[] weapon, int maxlen);
/** /**
* Returns the client's max size vector. * Returns the client's max size vector.
* *
* @param client Player's index. * @param client Player's index.
* @param vec Destination vector to store the client's max size. * @param vec Destination vector to store the client's max size.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void GetClientMaxs(int client, float vec[3]); native void GetClientMaxs(int client, float vec[3]);
/** /**
* Returns the client's min size vector. * Returns the client's min size vector.
* *
* @param client Player's index. * @param client Player's index.
* @param vec Destination vector to store the client's min size. * @param vec Destination vector to store the client's min size.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void GetClientMins(int client, float vec[3]); native void GetClientMins(int client, float vec[3]);
/** /**
* Returns the client's position angle. * Returns the client's position angle.
* *
* @param client Player's index. * @param client Player's index.
* @param ang Destination vector to store the client's position angle. * @param ang Destination vector to store the client's position angle.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void GetClientAbsAngles(int client, float ang[3]); native void GetClientAbsAngles(int client, float ang[3]);
/** /**
* Returns the client's origin vector. * Returns the client's origin vector.
* *
* @param client Player's index. * @param client Player's index.
* @param vec Destination vector to store the client's origin vector. * @param vec Destination vector to store the client's origin vector.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void GetClientAbsOrigin(int client, float vec[3]); native void GetClientAbsOrigin(int client, float vec[3]);
/** /**
* Returns the client's armor. * Returns the client's armor.
* *
* @param client Player's index. * @param client Player's index.
* @return Armor value. * @return Armor value.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native int GetClientArmor(int client); native int GetClientArmor(int client);
/** /**
* Returns the client's death count. * Returns the client's death count.
* *
* @param client Player's index. * @param client Player's index.
* @return Death count. * @return Death count.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native int GetClientDeaths(int client); native int GetClientDeaths(int client);
/** /**
* Returns the client's frag count. * Returns the client's frag count.
* *
* @param client Player's index. * @param client Player's index.
* @return Frag count. * @return Frag count.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native int GetClientFrags(int client); native int GetClientFrags(int client);
/** /**
* Returns the client's send data rate in bytes/sec. * Returns the client's send data rate in bytes/sec.
* *
* @param client Player's index. * @param client Player's index.
* @return Data rate. * @return Data rate.
* @error Invalid client index, client not connected, or fake client. * @error Invalid client index, client not connected, or fake client.
*/ */
native int GetClientDataRate(int client); native int GetClientDataRate(int client);
/** /**
* Returns if a client is timing out * Returns if a client is timing out
* *
* @param client Player's index. * @param client Player's index.
* @return True if client is timing out, false otherwise. * @return True if client is timing out, false otherwise.
* @error Invalid client index, client not connected, or fake client. * @error Invalid client index, client not connected, or fake client.
*/ */
native bool IsClientTimingOut(int client); native bool IsClientTimingOut(int client);
/** /**
* Returns the client's connection time in seconds. * Returns the client's connection time in seconds.
* *
* @param client Player's index. * @param client Player's index.
* @return Connection time. * @return Connection time.
* @error Invalid client index, client not connected, or fake client. * @error Invalid client index, client not connected, or fake client.
*/ */
native float GetClientTime(int client); native float GetClientTime(int client);
/** /**
* Returns the client's current latency (RTT), more accurate than GetAvgLatency but jittering. * Returns the client's current latency (RTT), more accurate than GetAvgLatency but jittering.
* *
* @param client Player's index. * @param client Player's index.
* @param flow Traffic flowing direction. * @param flow Traffic flowing direction.
* @return Latency, or -1 if network info is not available. * @return Latency, or -1 if network info is not available.
* @error Invalid client index, client not connected, or fake client. * @error Invalid client index, client not connected, or fake client.
*/ */
native float GetClientLatency(int client, NetFlow flow); native float GetClientLatency(int client, NetFlow flow);
/** /**
* Returns the client's average packet latency in seconds. * Returns the client's average packet latency in seconds.
* *
* @param client Player's index. * @param client Player's index.
* @param flow Traffic flowing direction. * @param flow Traffic flowing direction.
* @return Latency, or -1 if network info is not available. * @return Latency, or -1 if network info is not available.
* @error Invalid client index, client not connected, or fake client. * @error Invalid client index, client not connected, or fake client.
*/ */
native float GetClientAvgLatency(int client, NetFlow flow); native float GetClientAvgLatency(int client, NetFlow flow);
/** /**
* Returns the client's average packet loss, values go from 0 to 1 (for percentages). * Returns the client's average packet loss, values go from 0 to 1 (for percentages).
* *
* @param client Player's index. * @param client Player's index.
* @param flow Traffic flowing direction. * @param flow Traffic flowing direction.
* @return Average packet loss, or -1 if network info is not available. * @return Average packet loss, or -1 if network info is not available.
* @error Invalid client index, client not connected, or fake client. * @error Invalid client index, client not connected, or fake client.
*/ */
native float GetClientAvgLoss(int client, NetFlow flow); native float GetClientAvgLoss(int client, NetFlow flow);
/** /**
* Returns the client's average packet choke, values go from 0 to 1 (for percentages). * Returns the client's average packet choke, values go from 0 to 1 (for percentages).
* *
* @param client Player's index. * @param client Player's index.
* @param flow Traffic flowing direction. * @param flow Traffic flowing direction.
* @return Average packet loss, or -1 if network info is not available. * @return Average packet loss, or -1 if network info is not available.
* @error Invalid client index, client not connected, or fake client. * @error Invalid client index, client not connected, or fake client.
*/ */
native float GetClientAvgChoke(int client, NetFlow flow); native float GetClientAvgChoke(int client, NetFlow flow);
/** /**
* Returns the client's data flow in bytes/sec. * Returns the client's data flow in bytes/sec.
* *
* @param client Player's index. * @param client Player's index.
* @param flow Traffic flowing direction. * @param flow Traffic flowing direction.
* @return Data flow. * @return Data flow.
* @error Invalid client index, client not connected, or fake client. * @error Invalid client index, client not connected, or fake client.
*/ */
native float GetClientAvgData(int client, NetFlow flow); native float GetClientAvgData(int client, NetFlow flow);
/** /**
* Returns the client's average packet frequency in packets/sec. * Returns the client's average packet frequency in packets/sec.
* *
* @param client Player's index. * @param client Player's index.
* @param flow Traffic flowing direction. * @param flow Traffic flowing direction.
* @return Packet frequency. * @return Packet frequency.
* @error Invalid client index, client not connected, or fake client. * @error Invalid client index, client not connected, or fake client.
*/ */
native float GetClientAvgPackets(int client, NetFlow flow); native float GetClientAvgPackets(int client, NetFlow flow);
/** /**
* Translates an userid index to the real player index. * Translates an userid index to the real player index.
* *
* @param userid Userid value. * @param userid Userid value.
* @return Client value. * @return Client value.
* @error Returns 0 if invalid userid. * @error Returns 0 if invalid userid.
*/ */
native int GetClientOfUserId(int userid); native int GetClientOfUserId(int userid);
@ -760,11 +762,11 @@ native int GetClientOfUserId(int userid);
* *
* Note: IsClientInKickQueue() will return true before the kick occurs. * Note: IsClientInKickQueue() will return true before the kick occurs.
* *
* @param client Client index. * @param client Client index.
* @param format Optional formatting rules for disconnect reason. * @param format Optional formatting rules for disconnect reason.
* Note that a period is automatically appended to the string by the engine. * Note that a period is automatically appended to the string by the engine.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native void KickClient(int client, const char[] format="", any ...); native void KickClient(int client, const char[] format="", any ...);
@ -775,11 +777,11 @@ native void KickClient(int client, const char[] format="", any ...);
* doubt, create a short (0.1 second) timer to kick the client in the next * doubt, create a short (0.1 second) timer to kick the client in the next
* available frame. * available frame.
* *
* @param client Client index. * @param client Client index.
* @param format Optional formatting rules for disconnect reason. * @param format Optional formatting rules for disconnect reason.
* Note that a period is automatically appended to the string by the engine. * Note that a period is automatically appended to the string by the engine.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native void KickClientEx(int client, const char[] format="", any ...); native void KickClientEx(int client, const char[] format="", any ...);
@ -787,26 +789,26 @@ native void KickClientEx(int client, const char[] format="", any ...);
* Changes a client's team through the mod's generic team changing function. * Changes a client's team through the mod's generic team changing function.
* On CS:S, this will kill the player. * On CS:S, this will kill the player.
* *
* @param client Client index. * @param client Client index.
* @param team Mod-specific team index. * @param team Mod-specific team index.
* @error Invalid client index, client not connected, or lack of * @error Invalid client index, client not connected, or lack of
* mod support. * mod support.
*/ */
native void ChangeClientTeam(int client, int team); native void ChangeClientTeam(int client, int team);
/** /**
* Returns the clients unique serial identifier. * Returns the clients unique serial identifier.
* *
* @param client Client index. * @param client Client index.
* @return Serial number. * @return Serial number.
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native int GetClientSerial(int client); native int GetClientSerial(int client);
/** /**
* Returns the client index by its serial number. * Returns the client index by its serial number.
* *
* @param serial Serial number. * @param serial Serial number.
* @return Client index, or 0 for invalid serial. * @return Client index, or 0 for invalid serial.
*/ */
native int GetClientFromSerial(int serial); native int GetClientFromSerial(int serial);

View File

@ -35,23 +35,23 @@
#endif #endif
#define _commandfilters_included #define _commandfilters_included
#define MAX_TARGET_LENGTH 64 #define MAX_TARGET_LENGTH 64
#define COMMAND_FILTER_ALIVE (1<<0) /**< Only allow alive players */ #define COMMAND_FILTER_ALIVE (1<<0) /**< Only allow alive players */
#define COMMAND_FILTER_DEAD (1<<1) /**< Only filter dead players */ #define COMMAND_FILTER_DEAD (1<<1) /**< Only filter dead players */
#define COMMAND_FILTER_CONNECTED (1<<2) /**< Allow players not fully in-game */ #define COMMAND_FILTER_CONNECTED (1<<2) /**< Allow players not fully in-game */
#define COMMAND_FILTER_NO_IMMUNITY (1<<3) /**< Ignore immunity rules */ #define COMMAND_FILTER_NO_IMMUNITY (1<<3) /**< Ignore immunity rules */
#define COMMAND_FILTER_NO_MULTI (1<<4) /**< Do not allow multiple target patterns */ #define COMMAND_FILTER_NO_MULTI (1<<4) /**< Do not allow multiple target patterns */
#define COMMAND_FILTER_NO_BOTS (1<<5) /**< Do not allow bots to be targetted */ #define COMMAND_FILTER_NO_BOTS (1<<5) /**< Do not allow bots to be targetted */
#define COMMAND_TARGET_NONE 0 /**< No target was found */ #define COMMAND_TARGET_NONE 0 /**< No target was found */
#define COMMAND_TARGET_NOT_ALIVE -1 /**< Single client is not alive */ #define COMMAND_TARGET_NOT_ALIVE -1 /**< Single client is not alive */
#define COMMAND_TARGET_NOT_DEAD -2 /**< Single client is not dead */ #define COMMAND_TARGET_NOT_DEAD -2 /**< Single client is not dead */
#define COMMAND_TARGET_NOT_IN_GAME -3 /**< Single client is not in game */ #define COMMAND_TARGET_NOT_IN_GAME -3 /**< Single client is not in game */
#define COMMAND_TARGET_IMMUNE -4 /**< Single client is immune */ #define COMMAND_TARGET_IMMUNE -4 /**< Single client is immune */
#define COMMAND_TARGET_EMPTY_FILTER -5 /**< A multi-filter (such as @all) had no targets */ #define COMMAND_TARGET_EMPTY_FILTER -5 /**< A multi-filter (such as @all) had no targets */
#define COMMAND_TARGET_NOT_HUMAN -6 /**< Target was not human */ #define COMMAND_TARGET_NOT_HUMAN -6 /**< Target was not human */
#define COMMAND_TARGET_AMBIGUOUS -7 /**< Partial name had too many targets */ #define COMMAND_TARGET_AMBIGUOUS -7 /**< Partial name had too many targets */
/** /**
* Processes a generic command target string, and resolves it to a list * Processes a generic command target string, and resolves it to a list
@ -61,28 +61,28 @@
* as that file is guaranteed to contain all of the translatable phrases that * as that file is guaranteed to contain all of the translatable phrases that
* ProcessTargetString() will return. * ProcessTargetString() will return.
* *
* @param pattern Pattern to find clients against. * @param pattern Pattern to find clients against.
* @param admin Admin performing the action, or 0 if the server. * @param admin Admin performing the action, or 0 if the server.
* @param targets Array to hold targets. * @param targets Array to hold targets.
* @param max_targets Maximum size of the targets array. * @param max_targets Maximum size of the targets array.
* @param filter_flags Filter flags. * @param filter_flags Filter flags.
* @param target_name Buffer to store the target name. * @param target_name Buffer to store the target name.
* @param tn_maxlength Maximum length of the target name buffer. * @param tn_maxlength Maximum length of the target name buffer.
* @param tn_is_ml OUTPUT: Will be true if the target name buffer is an ML phrase, * @param tn_is_ml OUTPUT: Will be true if the target name buffer is an ML phrase,
* false if it is a normal string. * false if it is a normal string.
* @return If a multi-target pattern was used, the number of clients found * @return If a multi-target pattern was used, the number of clients found
* is returned. If a single-target pattern was used, 1 is returned * is returned. If a single-target pattern was used, 1 is returned
* if one valid client is found. Otherwise, a COMMAND_TARGET reason * if one valid client is found. Otherwise, a COMMAND_TARGET reason
* for failure is returned. * for failure is returned.
*/ */
native int ProcessTargetString(const char[] pattern, native int ProcessTargetString(const char[] pattern,
int admin, int admin,
int[] targets, int[] targets,
int max_targets, int max_targets,
int filter_flags, int filter_flags,
char[] target_name, char[] target_name,
int tn_maxlength, int tn_maxlength,
bool &tn_is_ml); bool &tn_is_ml);
/** /**
* Replies to a client with a given message describing a targetting * Replies to a client with a given message describing a targetting
@ -90,8 +90,8 @@ native int ProcessTargetString(const char[] pattern,
* *
* Note: The translation phrases are found in common.phrases.txt. * Note: The translation phrases are found in common.phrases.txt.
* *
* @param client Client index, or 0 for server. * @param client Client index, or 0 for server.
* @param reason COMMAND_TARGET reason. * @param reason COMMAND_TARGET reason.
*/ */
stock void ReplyToTargetError(int client, int reason) stock void ReplyToTargetError(int client, int reason)
{ {

View File

@ -31,56 +31,56 @@
*/ */
#if defined _commandline_included_ #if defined _commandline_included_
#endinput #endinput
#endif #endif
#define _commandline_included_ #define _commandline_included_
/** /**
* Gets the full command line the server was launched with. * Gets the full command line the server was launched with.
* *
* @param commandLine Buffer to store the command line in. * @param commandLine Buffer to store the command line in.
* @param maxlen Maximum length of the command line buffer. * @param maxlen Maximum length of the command line buffer.
* @return True if the command line is valid; otherwise, false. * @return True if the command line is valid; otherwise, false.
* @error No command line available, or no mod support. * @error No command line available, or no mod support.
*/ */
native bool GetCommandLine(char[] commandLine, int maxlen); native bool GetCommandLine(char[] commandLine, int maxlen);
/** /**
* Gets the value of a command line parameter the server was launched with. * Gets the value of a command line parameter the server was launched with.
* *
* @param param The command line parameter to get the value of. * @param param The command line parameter to get the value of.
* @param value Buffer to store the parameter value in. * @param value Buffer to store the parameter value in.
* @param maxlen Maximum length of the value buffer. * @param maxlen Maximum length of the value buffer.
* @param defValue The default value to return if the parameter wasn't specified. * @param defValue The default value to return if the parameter wasn't specified.
* @error No command line available, or no mod support. * @error No command line available, or no mod support.
*/ */
native void GetCommandLineParam(const char[] param, char[] value, int maxlen, const char[] defValue=""); native void GetCommandLineParam(const char[] param, char[] value, int maxlen, const char[] defValue="");
/** /**
* Gets the value of a command line parameter the server was launched with. * Gets the value of a command line parameter the server was launched with.
* *
* @param param The command line parameter to get the value of. * @param param The command line parameter to get the value of.
* @param defValue The default value to return if the parameter wasn't specified. * @param defValue The default value to return if the parameter wasn't specified.
* @return The integer value of the command line parameter value. * @return The integer value of the command line parameter value.
* @error No command line available, or no mod support. * @error No command line available, or no mod support.
*/ */
native int GetCommandLineParamInt(const char[] param, int defValue=0); native int GetCommandLineParamInt(const char[] param, int defValue=0);
/** /**
* Gets the value of a command line parameter the server was launched with. * Gets the value of a command line parameter the server was launched with.
* *
* @param param The command line parameter to get the value of. * @param param The command line parameter to get the value of.
* @param defValue The default value to return if the parameter wasn't specified. * @param defValue The default value to return if the parameter wasn't specified.
* @return The floating point value of the command line parameter value. * @return The floating point value of the command line parameter value.
* @error No command line available, or no mod support. * @error No command line available, or no mod support.
*/ */
native float GetCommandLineParamFloat(const char[] param, float defValue=0.0); native float GetCommandLineParamFloat(const char[] param, float defValue=0.0);
/** /**
* Determines if a specific command line parameter is present. * Determines if a specific command line parameter is present.
* *
* @param param The command line parameter to test. * @param param The command line parameter to test.
* @return True if the command line parameter is specified; otherwise, false. * @return True if the command line parameter is specified; otherwise, false.
* @error No command line available, or no mod support. * @error No command line available, or no mod support.
*/ */
native bool FindCommandLineParam(const char[] param); native bool FindCommandLineParam(const char[] param);

View File

@ -35,14 +35,14 @@
#endif #endif
#define _console_included #define _console_included
#define INVALID_FCVAR_FLAGS (-1) #define INVALID_FCVAR_FLAGS (-1)
/** /**
* Console variable query helper values. * Console variable query helper values.
*/ */
enum QueryCookie enum QueryCookie
{ {
QUERYCOOKIE_FAILED = 0, QUERYCOOKIE_FAILED = 0
}; };
/** /**
@ -51,7 +51,7 @@ enum QueryCookie
enum ReplySource enum ReplySource
{ {
SM_REPLY_TO_CONSOLE = 0, SM_REPLY_TO_CONSOLE = 0,
SM_REPLY_TO_CHAT = 1, SM_REPLY_TO_CHAT = 1
}; };
/** /**
@ -65,25 +65,25 @@ enum ReplySource
#define FCVAR_LAUNCHER (1<<1) // Same value as FCVAR_DEVELOPMENTONLY, which is what most usages of this were intending to use. #define FCVAR_LAUNCHER (1<<1) // Same value as FCVAR_DEVELOPMENTONLY, which is what most usages of this were intending to use.
#define FCVAR_NONE 0 // The default, no flags at all #define FCVAR_NONE 0 // The default, no flags at all
#define FCVAR_UNREGISTERED (1<<0) // If this is set, don't add to linked list, etc. #define FCVAR_UNREGISTERED (1<<0) // If this is set, don't add to linked list, etc.
#define FCVAR_DEVELOPMENTONLY (1<<1) // Hidden in released products. Flag is removed automatically if ALLOW_DEVELOPMENT_CVARS is defined. (OB+) #define FCVAR_DEVELOPMENTONLY (1<<1) // Hidden in released products. Flag is removed automatically if ALLOW_DEVELOPMENT_CVARS is defined. (OB+)
#define FCVAR_GAMEDLL (1<<2) // Defined by the game DLL. #define FCVAR_GAMEDLL (1<<2) // Defined by the game DLL.
#define FCVAR_CLIENTDLL (1<<3) // Defined by the client DLL. #define FCVAR_CLIENTDLL (1<<3) // Defined by the client DLL.
#define FCVAR_MATERIAL_SYSTEM (1<<4) // Defined by the material system. (EP1-only) #define FCVAR_MATERIAL_SYSTEM (1<<4) // Defined by the material system. (EP1-only)
#define FCVAR_HIDDEN (1<<4) // Hidden. Doesn't appear in find or autocomplete. Like DEVELOPMENTONLY, but can't be compiled out.1 (OB+) #define FCVAR_HIDDEN (1<<4) // Hidden. Doesn't appear in find or autocomplete. Like DEVELOPMENTONLY, but can't be compiled out.1 (OB+)
#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. #define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc.
// Sends 1 if it's not bland/zero, 0 otherwise as value. // Sends 1 if it's not bland/zero, 0 otherwise as value.
#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server. #define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server.
#define FCVAR_ARCHIVE (1<<7) // Set to cause it to be saved to vars.rc #define FCVAR_ARCHIVE (1<<7) // Set to cause it to be saved to vars.rc
#define FCVAR_NOTIFY (1<<8) // Notifies players when changed. #define FCVAR_NOTIFY (1<<8) // Notifies players when changed.
#define FCVAR_USERINFO (1<<9) // Changes the client's info string. #define FCVAR_USERINFO (1<<9) // Changes the client's info string.
#define FCVAR_PRINTABLEONLY (1<<10) // This cvar's string cannot contain unprintable characters (e.g., used for player name, etc.) #define FCVAR_PRINTABLEONLY (1<<10) // This cvar's string cannot contain unprintable characters (e.g., used for player name, etc.)
#define FCVAR_UNLOGGED (1<<11) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log #define FCVAR_UNLOGGED (1<<11) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
#define FCVAR_NEVER_AS_STRING (1<<12) // Never try to print that cvar. #define FCVAR_NEVER_AS_STRING (1<<12) // Never try to print that cvar.
#define FCVAR_REPLICATED (1<<13) // Server setting enforced on clients. #define FCVAR_REPLICATED (1<<13) // Server setting enforced on clients.
#define FCVAR_CHEAT (1<<14) // Only useable in singleplayer / debug / multiplayer & sv_cheats #define FCVAR_CHEAT (1<<14) // Only useable in singleplayer / debug / multiplayer & sv_cheats
#define FCVAR_SS (1<<15) // causes varnameN where N 2 through max splitscreen slots for mod to be autogenerated (L4D+) #define FCVAR_SS (1<<15) // causes varnameN where N 2 through max splitscreen slots for mod to be autogenerated (L4D+)
#define FCVAR_DEMO (1<<16) // Record this cvar when starting a demo file. #define FCVAR_DEMO (1<<16) // Record this cvar when starting a demo file.
#define FCVAR_DONTRECORD (1<<17) // Don't record these command in demo files. #define FCVAR_DONTRECORD (1<<17) // Don't record these command in demo files.
#define FCVAR_SS_ADDED (1<<18) // This is one of the "added" FCVAR_SS variables for the splitscreen players (L4D+) #define FCVAR_SS_ADDED (1<<18) // This is one of the "added" FCVAR_SS variables for the splitscreen players (L4D+)
@ -109,8 +109,8 @@ enum ReplySource
/** /**
* Executes a server command as if it were on the server console (or RCON) * Executes a server command as if it were on the server console (or RCON)
* *
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
*/ */
native void ServerCommand(const char[] format, any ...); native void ServerCommand(const char[] format, any ...);
@ -123,18 +123,18 @@ native void ServerCommand(const char[] format, any ...);
* the response. * the response.
* Also, on L4D2 this will not print the command output to the server console. * Also, on L4D2 this will not print the command output to the server console.
* *
* @param buffer String to store command result into. * @param buffer String to store command result into.
* @param maxlen Length of buffer. * @param maxlen Length of buffer.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
*/ */
native void ServerCommandEx(char[] buffer, int maxlen, const char[] format, any ...); native void ServerCommandEx(char[] buffer, int maxlen, const char[] format, any ...);
/** /**
* Inserts a server command at the beginning of the server command buffer. * Inserts a server command at the beginning of the server command buffer.
* *
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
*/ */
native void InsertServerCommand(const char[] format, any ...); native void InsertServerCommand(const char[] format, any ...);
@ -147,10 +147,10 @@ native void ServerExecute();
* Executes a client command. Note that this will not work on clients unless * Executes a client command. Note that this will not work on clients unless
* they have cl_restrict_server_commands set to 0. * they have cl_restrict_server_commands set to 0.
* *
* @param client Index of the client. * @param client Index of the client.
* @param fmt Format of the client command. * @param fmt Format of the client command.
* @param ... Format parameters * @param ... Format parameters
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native void ClientCommand(int client, const char[] fmt, any ...); native void ClientCommand(int client, const char[] fmt, any ...);
@ -163,10 +163,10 @@ native void ClientCommand(int client, const char[] fmt, any ...);
* a hook where this matters (for example, a "say" hook), you should use * a hook where this matters (for example, a "say" hook), you should use
* FakeClientCommandEx() instead. * FakeClientCommandEx() instead.
* *
* @param client Index of the client. * @param client Index of the client.
* @param fmt Format of the client command. * @param fmt Format of the client command.
* @param ... Format parameters * @param ... Format parameters
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native void FakeClientCommand(int client, const char[] fmt, any ...); native void FakeClientCommand(int client, const char[] fmt, any ...);
@ -175,38 +175,38 @@ native void FakeClientCommand(int client, const char[] fmt, any ...);
* execution of the client command is delayed by one frame to prevent any * execution of the client command is delayed by one frame to prevent any
* re-entrancy issues that might surface with FakeClientCommand(). * re-entrancy issues that might surface with FakeClientCommand().
* *
* @param client Index of the client. * @param client Index of the client.
* @param fmt Format of the client command. * @param fmt Format of the client command.
* @param ... Format parameters * @param ... Format parameters
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native void FakeClientCommandEx(int client, const char[] fmt, any ...); native void FakeClientCommandEx(int client, const char[] fmt, any ...);
/** /**
* Executes a KeyValues client command on the server without being networked. * Executes a KeyValues client command on the server without being networked.
* *
* @param client Index of the client. * @param client Index of the client.
* @param kv KeyValues data to be sent. * @param kv KeyValues data to be sent.
* @error Invalid client index, client not connected, * @error Invalid client index, client not connected,
* or unsupported on current game. * or unsupported on current game.
*/ */
native void FakeClientCommandKeyValues(int client, KeyValues kv); native void FakeClientCommandKeyValues(int client, KeyValues kv);
/** /**
* Sends a message to the server console. * Sends a message to the server console.
* *
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
*/ */
native void PrintToServer(const char[] format, any ...); native void PrintToServer(const char[] format, any ...);
/** /**
* Sends a message to a client's console. * Sends a message to a client's console.
* *
* @param client Client index. * @param client Client index.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @error If the client is not connected an error will be thrown. * @error If the client is not connected an error will be thrown.
*/ */
native void PrintToConsole(int client, const char[] format, any ...); native void PrintToConsole(int client, const char[] format, any ...);
@ -214,8 +214,8 @@ native void PrintToConsole(int client, const char[] format, any ...);
/** /**
* Sends a message to every client's console. * Sends a message to every client's console.
* *
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
*/ */
stock void PrintToConsoleAll(const char[] format, any ...) stock void PrintToConsoleAll(const char[] format, any ...)
{ {
@ -239,17 +239,17 @@ stock void PrintToConsoleAll(const char[] format, any ...)
* If the command was from the console, PrintToConsole() is used. * If the command was from the console, PrintToConsole() is used.
* If the command was from chat, PrintToChat() is used. * If the command was from chat, PrintToChat() is used.
* *
* @param client Client index, or 0 for server. * @param client Client index, or 0 for server.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @error If the client is not connected or invalid. * @error If the client is not connected or invalid.
*/ */
native void ReplyToCommand(int client, const char[] format, any ...); native void ReplyToCommand(int client, const char[] format, any ...);
/** /**
* Returns the current reply source of a command. * Returns the current reply source of a command.
* *
* @return ReplySource value. * @return ReplySource value.
*/ */
native ReplySource GetCmdReplySource(); native ReplySource GetCmdReplySource();
@ -259,8 +259,8 @@ native ReplySource GetCmdReplySource();
* Only use this if you know what you are doing. You should save the old value * Only use this if you know what you are doing. You should save the old value
* and restore it once you are done. * and restore it once you are done.
* *
* @param source New ReplySource value. * @param source New ReplySource value.
* @return Old ReplySource value. * @return Old ReplySource value.
*/ */
native ReplySource SetCmdReplySource(ReplySource source); native ReplySource SetCmdReplySource(ReplySource source);
@ -269,7 +269,7 @@ native ReplySource SetCmdReplySource(ReplySource source);
* *
* This function is only meaningful inside say or say_team hooks. * This function is only meaningful inside say or say_team hooks.
* *
* @return True if a chat trigger, false otherwise. * @return True if a chat trigger, false otherwise.
*/ */
native bool IsChatTrigger(); native bool IsChatTrigger();
@ -279,10 +279,10 @@ native bool IsChatTrigger();
* in their chat text, except for the originating client, who receives * in their chat text, except for the originating client, who receives
* the message based on the current ReplySource. * the message based on the current ReplySource.
* *
* @param client Client index doing the action, or 0 for server. * @param client Client index doing the action, or 0 for server.
* @param tag Tag to prepend to the message. * @param tag Tag to prepend to the message.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @error * @error
*/ */
native void ShowActivity2(int client, const char[] tag, const char[] format, any ...); native void ShowActivity2(int client, const char[] tag, const char[] format, any ...);
@ -296,9 +296,9 @@ native void ShowActivity2(int client, const char[] tag, const char[] format, any
* for these cases, then this function will suffice. Otherwise, * for these cases, then this function will suffice. Otherwise,
* ShowActivity2() is slightly more useful. * ShowActivity2() is slightly more useful.
* *
* @param client Client index doing the action, or 0 for server. * @param client Client index doing the action, or 0 for server.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @error * @error
*/ */
native void ShowActivity(int client, const char[] format, any ...); native void ShowActivity(int client, const char[] format, any ...);
@ -307,10 +307,10 @@ native void ShowActivity(int client, const char[] format, any ...);
* Same as ShowActivity(), except the tag parameter is used instead of * Same as ShowActivity(), except the tag parameter is used instead of
* "[SM] " (note that you must supply any spacing). * "[SM] " (note that you must supply any spacing).
* *
* @param client Client index doing the action, or 0 for server. * @param client Client index doing the action, or 0 for server.
* @param tag Tag to display with. * @param tag Tag to display with.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @error * @error
*/ */
native void ShowActivityEx(int client, const char[] tag, const char[] format, any ...); native void ShowActivityEx(int client, const char[] tag, const char[] format, any ...);
@ -336,9 +336,9 @@ native bool FormatActivitySource(int client, int target, const char[] namebuf, i
/** /**
* Called when a server-only command is invoked. * Called when a server-only command is invoked.
* *
* @param args Number of arguments that were in the argument string. * @param args Number of arguments that were in the argument string.
* @return An Action value. Not handling the command * @return An Action value. Not handling the command
* means that Source will report it as "not found." * means that Source will report it as "not found."
*/ */
typedef SrvCmd = function Action (int args); typedef SrvCmd = function Action (int args);
@ -347,21 +347,21 @@ typedef SrvCmd = function Action (int args);
* *
* Server commands are case sensitive. * Server commands are case sensitive.
* *
* @param cmd Name of the command to hook or create. * @param cmd Name of the command to hook or create.
* @param callback A function to use as a callback for when the command is invoked. * @param callback A function to use as a callback for when the command is invoked.
* @param description Optional description to use for command creation. * @param description Optional description to use for command creation.
* @param flags Optional flags to use for command creation. * @param flags Optional flags to use for command creation.
* @error Command name is the same as an existing convar. * @error Command name is the same as an existing convar.
*/ */
native void RegServerCmd(const char[] cmd, SrvCmd callback, const char[] description="", int flags=0); native void RegServerCmd(const char[] cmd, SrvCmd callback, const char[] description="", int flags=0);
/** /**
* Called when a generic console command is invoked. * Called when a generic console command is invoked.
* *
* @param client Index of the client, or 0 from the server. * @param client Index of the client, or 0 from the server.
* @param args Number of arguments that were in the argument string. * @param args Number of arguments that were in the argument string.
* @return An Action value. Not handling the command * @return An Action value. Not handling the command
* means that Source will report it as "not found." * means that Source will report it as "not found."
*/ */
typedef ConCmd = function Action (int client, int args); typedef ConCmd = function Action (int client, int args);
@ -372,11 +372,11 @@ typedef ConCmd = function Action (int client, int args);
* a client may enter the command in any case. SourceMod corrects for this automatically, * a client may enter the command in any case. SourceMod corrects for this automatically,
* and you should only hook the "real" version of the command. * and you should only hook the "real" version of the command.
* *
* @param cmd Name of the command to hook or create. * @param cmd Name of the command to hook or create.
* @param callback A function to use as a callback for when the command is invoked. * @param callback A function to use as a callback for when the command is invoked.
* @param description Optional description to use for command creation. * @param description Optional description to use for command creation.
* @param flags Optional flags to use for command creation. * @param flags Optional flags to use for command creation.
* @error Command name is the same as an existing convar. * @error Command name is the same as an existing convar.
*/ */
native void RegConsoleCmd(const char[] cmd, ConCmd callback, const char[] description="", int flags=0); native void RegConsoleCmd(const char[] cmd, ConCmd callback, const char[] description="", int flags=0);
@ -387,14 +387,14 @@ native void RegConsoleCmd(const char[] cmd, ConCmd callback, const char[] descri
* *
* Admin commands are case sensitive from both the client and server. * Admin commands are case sensitive from both the client and server.
* *
* @param cmd String containing command to register. * @param cmd String containing command to register.
* @param callback A function to use as a callback for when the command is invoked. * @param callback A function to use as a callback for when the command is invoked.
* @param adminflags Administrative flags (bitstring) to use for permissions. * @param adminflags Administrative flags (bitstring) to use for permissions.
* @param description Optional description to use for help. * @param description Optional description to use for help.
* @param group String containing the command group to use. If empty, * @param group String containing the command group to use. If empty,
* the plugin's filename will be used instead. * the plugin's filename will be used instead.
* @param flags Optional console flags. * @param flags Optional console flags.
* @error Command name is the same as an existing convar. * @error Command name is the same as an existing convar.
*/ */
native void RegAdminCmd(const char[] cmd, native void RegAdminCmd(const char[] cmd,
ConCmd callback, ConCmd callback,
@ -407,7 +407,7 @@ native void RegAdminCmd(const char[] cmd,
* Returns the number of arguments from the current console or server command. * Returns the number of arguments from the current console or server command.
* @note Unlike the HL2 engine call, this does not include the command itself. * @note Unlike the HL2 engine call, this does not include the command itself.
* *
* @return Number of arguments to the current command. * @return Number of arguments to the current command.
*/ */
native int GetCmdArgs(); native int GetCmdArgs();
@ -416,10 +416,10 @@ native int GetCmdArgs();
* server command. * server command.
* @note Argument indexes start at 1; 0 retrieves the command name. * @note Argument indexes start at 1; 0 retrieves the command name.
* *
* @param argnum Argument number to retrieve. * @param argnum Argument number to retrieve.
* @param buffer Buffer to use for storing the string. * @param buffer Buffer to use for storing the string.
* @param maxlength Maximum length of the buffer. * @param maxlength Maximum length of the buffer.
* @return Length of string written to buffer. * @return Length of string written to buffer.
*/ */
native int GetCmdArg(int argnum, char[] buffer, int maxlength); native int GetCmdArg(int argnum, char[] buffer, int maxlength);
@ -427,9 +427,9 @@ native int GetCmdArg(int argnum, char[] buffer, int maxlength);
* Retrieves the entire command argument string in one lump from the current * Retrieves the entire command argument string in one lump from the current
* console or server command. * console or server command.
* *
* @param buffer Buffer to use for storing the string. * @param buffer Buffer to use for storing the string.
* @param maxlength Maximum length of the buffer. * @param maxlength Maximum length of the buffer.
* @return Length of string written to buffer. * @return Length of string written to buffer.
*/ */
native int GetCmdArgString(char[] buffer, int maxlength); native int GetCmdArgString(char[] buffer, int maxlength);
@ -441,39 +441,39 @@ methodmap CommandIterator < Handle {
// SourceMod plugins and allows inspection of properties associated // SourceMod plugins and allows inspection of properties associated
// with the command. // with the command.
// //
// @return New CommandIterator Handle. // @return New CommandIterator Handle.
public native CommandIterator(); public native CommandIterator();
// Determines if there is a next command. If one is found, the // Determines if there is a next command. If one is found, the
// iterator is advanced to it. // iterator is advanced to it.
// //
// @return true if found and iterator is advanced. // @return true if found and iterator is advanced.
public native bool Next(); public native bool Next();
// Retrieves the command's description. // Retrieves the command's description.
// //
// @param buffer Buffer to copy to. // @param buffer Buffer to copy to.
// @param maxlen Maximum size of the buffer. // @param maxlen Maximum size of the buffer.
// @error Invalid iterator position. // @error Invalid iterator position.
public native void GetDescription(char[] buffer, int maxlen); public native void GetDescription(char[] buffer, int maxlen);
// Retrieves the command's name. // Retrieves the command's name.
// //
// @param buffer Buffer to copy to. // @param buffer Buffer to copy to.
// @param maxlen Maximum size of the buffer. // @param maxlen Maximum size of the buffer.
// @error Invalid iterator position. // @error Invalid iterator position.
public native void GetName(char[] buffer, int maxlen); public native void GetName(char[] buffer, int maxlen);
// Retrieves the plugin handle of the command's creator // Retrieves the plugin handle of the command's creator
// //
// @error Invalid iterator position. // @error Invalid iterator position.
property Handle Plugin { property Handle Plugin {
public native get(); public native get();
} }
// Retrieves the command's default flags // Retrieves the command's default flags
// //
// @error Invalid iterator position. // @error Invalid iterator position.
property int Flags { property int Flags {
public native get(); public native get();
} }
@ -482,7 +482,7 @@ methodmap CommandIterator < Handle {
/** /**
* Gets a command iterator. Must be freed with CloseHandle(). * Gets a command iterator. Must be freed with CloseHandle().
* *
* @return A new command iterator. * @return A new command iterator.
*/ */
native Handle GetCommandIterator(); native Handle GetCommandIterator();
@ -490,13 +490,13 @@ native Handle GetCommandIterator();
* Reads a command iterator, then advances to the next command if any. * Reads a command iterator, then advances to the next command if any.
* Only SourceMod specific commands are returned. * Only SourceMod specific commands are returned.
* *
* @param iter Command iterator Handle. * @param iter Command iterator Handle.
* @param name Name buffer. * @param name Name buffer.
* @param nameLen Name buffer size. * @param nameLen Name buffer size.
* @param eflags Effective default flags of a command. * @param eflags Effective default flags of a command.
* @param desc Command description buffer. * @param desc Command description buffer.
* @param descLen Command description buffer size. * @param descLen Command description buffer size.
* @return True on success, false if there are no more commands. * @return True on success, false if there are no more commands.
*/ */
native bool ReadCommandIterator(Handle iter, native bool ReadCommandIterator(Handle iter,
char[] name, char[] name,
@ -511,16 +511,16 @@ native bool ReadCommandIterator(Handle iter,
* commands. This feature essentially allows you to create custom * commands. This feature essentially allows you to create custom
* flags using the override system. * flags using the override system.
* *
* @param client Client index. * @param client Client index.
* @param command Command name. If the command is not found, the default * @param command Command name. If the command is not found, the default
* flags are used. * flags are used.
* @param flags Flag string to use as a default, if the command or override * @param flags Flag string to use as a default, if the command or override
* is not found. * is not found.
* @param override_only If true, SourceMod will not attempt to find a matching * @param override_only If true, SourceMod will not attempt to find a matching
* command, and it will only use the default flags specified. * command, and it will only use the default flags specified.
* Otherwise, SourceMod will ignore the default flags if * Otherwise, SourceMod will ignore the default flags if
* there is a matching admin command. * there is a matching admin command.
* @return True if the client has access, false otherwise. * @return True if the client has access, false otherwise.
*/ */
native bool CheckCommandAccess(int client, native bool CheckCommandAccess(int client,
const char[] command, const char[] command,
@ -533,16 +533,16 @@ native bool CheckCommandAccess(int client,
* commands. This feature essentially allows you to create custom flags * commands. This feature essentially allows you to create custom flags
* using the override system. * using the override system.
* *
* @param id AdminId of the admin. * @param id AdminId of the admin.
* @param command Command name. If the command is not found, the default * @param command Command name. If the command is not found, the default
* flags are used. * flags are used.
* @param flags Flag string to use as a default, if the command or override * @param flags Flag string to use as a default, if the command or override
* is not found. * is not found.
* @param override_only If true, SourceMod will not attempt to find a matching * @param override_only If true, SourceMod will not attempt to find a matching
* command, and it will only use the default flags specified. * command, and it will only use the default flags specified.
* Otherwise, SourceMod will ignore the default flags if * Otherwise, SourceMod will ignore the default flags if
* there is a matching admin command. * there is a matching admin command.
* @return True if the admin has access, false otherwise. * @return True if the admin has access, false otherwise.
*/ */
native bool CheckAccess(AdminId id, native bool CheckAccess(AdminId id,
const char[] command, const char[] command,
@ -552,18 +552,18 @@ native bool CheckAccess(AdminId id,
/** /**
* Returns the bitstring of flags of a command. * Returns the bitstring of flags of a command.
* *
* @param name Name of the command. * @param name Name of the command.
* @return A bitstring containing the FCVAR_* flags that are enabled * @return A bitstring containing the FCVAR_* flags that are enabled
* or INVALID_FCVAR_FLAGS if command not found. * or INVALID_FCVAR_FLAGS if command not found.
*/ */
native int GetCommandFlags(const char[] name); native int GetCommandFlags(const char[] name);
/** /**
* Sets the bitstring of flags of a command. * Sets the bitstring of flags of a command.
* *
* @param name Name of the command. * @param name Name of the command.
* @param flags A bitstring containing the FCVAR_* flags to enable. * @param flags A bitstring containing the FCVAR_* flags to enable.
* @return True on success, otherwise false. * @return True on success, otherwise false.
*/ */
native bool SetCommandFlags(const char[] name, int flags); native bool SetCommandFlags(const char[] name, int flags);
@ -572,38 +572,38 @@ native bool SetCommandFlags(const char[] name, int flags);
* ConCommands. If a Handle is returned, the next entry must be read * ConCommands. If a Handle is returned, the next entry must be read
* via FindNextConCommand(). The order of the list is undefined. * via FindNextConCommand(). The order of the list is undefined.
* *
* @param buffer Buffer to store entry name. * @param buffer Buffer to store entry name.
* @param max_size Maximum size of the buffer. * @param max_size Maximum size of the buffer.
* @param isCommand Variable to store whether the entry is a command. * @param isCommand Variable to store whether the entry is a command.
* If it is not a command, it is a ConVar. * If it is not a command, it is a ConVar.
* @param flags Variable to store entry flags. * @param flags Variable to store entry flags.
* @param description Buffer to store the description, empty if no description present. * @param description Buffer to store the description, empty if no description present.
* @param descrmax_size Maximum size of the description buffer. * @param descrmax_size Maximum size of the description buffer.
* @return On success, a ConCmdIter Handle is returned, which * @return On success, a ConCmdIter Handle is returned, which
* can be read via FindNextConCommand(), and must be can be read via FindNextConCommand(), and must be
* closed via CloseHandle(). Additionally, the output closed via CloseHandle(). Additionally, the output
* parameters will be filled with information of the parameters will be filled with information of the
* first ConCommandBase entry. first ConCommandBase entry.
* On failure, INVALID_HANDLE is returned, and the On failure, INVALID_HANDLE is returned, and the
* contents of outputs is undefined. contents of outputs is undefined.
*/ */
native Handle FindFirstConCommand(char[] buffer, int max_size, bool &isCommand, int &flags=0, char[] description="", int descrmax_size=0); native Handle FindFirstConCommand(char[] buffer, int max_size, bool &isCommand, int &flags=0, char[] description="", int descrmax_size=0);
/** /**
* Reads the next entry in a ConCommandBase iterator. * Reads the next entry in a ConCommandBase iterator.
* *
* @param search ConCmdIter Handle to search. * @param search ConCmdIter Handle to search.
* @param buffer Buffer to store entry name. * @param buffer Buffer to store entry name.
* @param max_size Maximum size of the buffer. * @param max_size Maximum size of the buffer.
* @param isCommand Variable to store whether the entry is a command. * @param isCommand Variable to store whether the entry is a command.
* If it is not a command, it is a ConVar. If it is not a command, it is a ConVar.
* @param flags Variable to store entry flags. * @param flags Variable to store entry flags.
* @param description Buffer to store the description, empty if no description present. * @param description Buffer to store the description, empty if no description present.
* @param descrmax_size Maximum size of the description buffer. * @param descrmax_size Maximum size of the description buffer.
* @return On success, the outputs are filled, the iterator is * @return On success, the outputs are filled, the iterator is
* advanced to the next entry, and true is returned. advanced to the next entry, and true is returned.
* If no more entries exist, false is returned, and the If no more entries exist, false is returned, and the
* contents of outputs is undefined. contents of outputs is undefined.
*/ */
native bool FindNextConCommand(Handle search, char[] buffer, int max_size, bool &isCommand, int &flags=0, char[] description="", int descrmax_size=0); native bool FindNextConCommand(Handle search, char[] buffer, int max_size, bool &isCommand, int &flags=0, char[] description="", int descrmax_size=0);
@ -614,14 +614,14 @@ native bool FindNextConCommand(Handle search, char[] buffer, int max_size, bool
* Note: Tags are automatically removed when a plugin unloads. * Note: Tags are automatically removed when a plugin unloads.
* Note: Currently, this function does nothing because of bugs in the Valve master. * Note: Currently, this function does nothing because of bugs in the Valve master.
* *
* @param tag Tag string to append. * @param tag Tag string to append.
*/ */
native void AddServerTag(const char[] tag); native void AddServerTag(const char[] tag);
/** /**
* Removes a tag previously added by the calling plugin. * Removes a tag previously added by the calling plugin.
* *
* @param tag Tag string to remove. * @param tag Tag string to remove.
*/ */
native void RemoveServerTag(const char[] tag); native void RemoveServerTag(const char[] tag);
@ -647,7 +647,7 @@ native void RemoveServerTag(const char[] tag);
* @param command Command name, lower case. To get name as typed, use * @param command Command name, lower case. To get name as typed, use
* GetCmdArg() and specify argument 0. * GetCmdArg() and specify argument 0.
* @param argc Argument count. * @param argc Argument count.
* @return Action to take (see extended notes above). * @return Action to take (see extended notes above).
*/ */
typedef CommandListener = function Action (int client, const char[] command, int argc); typedef CommandListener = function Action (int client, const char[] command, int argc);
@ -665,7 +665,7 @@ typedef CommandListener = function Action (int client, const char[] command, int
* FEATURECAP_COMMANDLISTENER. * FEATURECAP_COMMANDLISTENER.
* *
* @param callback Callback. * @param callback Callback.
* @param command Command, or if not specified, a global listener. * @param command Command, or if not specified, a global listener.
* The command is case insensitive. * The command is case insensitive.
* @return True if this feature is available on the current game, * @return True if this feature is available on the current game,
* false otherwise. * false otherwise.
@ -675,18 +675,18 @@ native bool AddCommandListener(CommandListener callback, const char[] command=""
/** /**
* Removes a previously added command listener, in reverse order of being added. * Removes a previously added command listener, in reverse order of being added.
* *
* @param callback Callback. * @param callback Callback.
* @param command Command, or if not specified, a global listener. * @param command Command, or if not specified, a global listener.
* The command is case insensitive. * The command is case insensitive.
* @error Callback has no active listeners. * @error Callback has no active listeners.
*/ */
native void RemoveCommandListener(CommandListener callback, const char[] command=""); native void RemoveCommandListener(CommandListener callback, const char[] command="");
/** /**
* Returns true if the supplied command exists. * Returns true if the supplied command exists.
* *
* @param command Command to find. * @param command Command to find.
* @return True if command is found, false otherwise. * @return True if command is found, false otherwise.
*/ */
stock bool CommandExists(const char[] command) stock bool CommandExists(const char[] command)
{ {
@ -695,20 +695,20 @@ stock bool CommandExists(const char[] command)
/** /**
* Global listener for the chat commands. * Global listener for the chat commands.
* *
* @param client Client index. * @param client Client index.
* @param command Command name. * @param command Command name.
* @param sArgs Chat argument string. * @param sArgs Chat argument string.
* *
* @return An Action value. Returning Plugin_Handled bypasses the game function call. * @return An Action value. Returning Plugin_Handled bypasses the game function call.
Returning Plugin_Stop bypasses the post hook as well as the game function. * Returning Plugin_Stop bypasses the post hook as well as the game function.
*/ */
forward Action OnClientSayCommand(int client, const char[] command, const char[] sArgs); forward Action OnClientSayCommand(int client, const char[] command, const char[] sArgs);
/** /**
* Global post listener for the chat commands. * Global post listener for the chat commands.
* *
* @param client Client index. * @param client Client index.
* @param command Command name. * @param command Command name.
* @param sArgs Chat argument string. * @param sArgs Chat argument string.
*/ */
forward void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs); forward void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs);

View File

@ -31,7 +31,7 @@
*/ */
#if defined _convars_included #if defined _convars_included
#endinput #endinput
#endif #endif
#define _convars_included #define _convars_included
@ -49,31 +49,35 @@ enum ConVarBounds
*/ */
enum ConVarQueryResult enum ConVarQueryResult
{ {
ConVarQuery_Okay = 0, //< Retrieval of client convar value was successful. */ ConVarQuery_Okay = 0, //< Retrieval of client convar value was successful. */
ConVarQuery_NotFound, //< Client convar was not found. */ ConVarQuery_NotFound, //< Client convar was not found. */
ConVarQuery_NotValid, //< A console command with the same name was found, but there is no convar. */ ConVarQuery_NotValid, //< A console command with the same name was found, but there is no convar. */
ConVarQuery_Protected //< Client convar was found, but it is protected. The server cannot retrieve its value. */ ConVarQuery_Protected //< Client convar was found, but it is protected. The server cannot retrieve its value. */
}; };
// Called when a console variable's value is changed. /**
// * Called when a console variable's value is changed.
// @param convar Handle to the convar that was changed. *
// @param oldValue String containing the value of the convar before it was changed. * @param convar Handle to the convar that was changed.
// @param newValue String containing the new value of the convar. * @param oldValue String containing the value of the convar before it was changed.
* @param newValue String containing the new value of the convar.
*/
typedef ConVarChanged = function void (ConVar convar, const char[] oldValue, const char[] newValue); typedef ConVarChanged = function void (ConVar convar, const char[] oldValue, const char[] newValue);
// Creates a new console variable. /**
// * Creates a new console variable.
// @param name Name of new convar. *
// @param defaultValue String containing the default value of new convar. * @param name Name of new convar.
// @param description Optional description of the convar. * @param defaultValue String containing the default value of new convar.
// @param flags Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details. * @param description Optional description of the convar.
// @param hasMin Optional boolean that determines if the convar has a minimum value. * @param flags Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details.
// @param min Minimum floating point value that the convar can have if hasMin is true. * @param hasMin Optional boolean that determines if the convar has a minimum value.
// @param hasMax Optional boolean that determines if the convar has a maximum value. * @param min Minimum floating point value that the convar can have if hasMin is true.
// @param max Maximum floating point value that the convar can have if hasMax is true. * @param hasMax Optional boolean that determines if the convar has a maximum value.
// @return A handle to the newly created convar. If the convar already exists, a handle to it will still be returned. * @param max Maximum floating point value that the convar can have if hasMax is true.
// @error Convar name is blank or is the same as an existing console command. * @return A handle to the newly created convar. If the convar already exists, a handle to it will still be returned.
* @error Convar name is blank or is the same as an existing console command.
*/
native ConVar CreateConVar( native ConVar CreateConVar(
const char[] name, const char[] name,
const char[] defaultValue, const char[] defaultValue,
@ -82,10 +86,12 @@ native ConVar CreateConVar(
bool hasMin=false, float min=0.0, bool hasMin=false, float min=0.0,
bool hasMax=false, float max=0.0); bool hasMax=false, float max=0.0);
// Searches for a console variable. /**
// * Searches for a console variable.
// @param name Name of convar to find. *
// @return A ConVar object if found; null otherwise. * @param name Name of convar to find.
* @return A ConVar object if found; null otherwise.
*/
native ConVar FindConVar(const char[] name); native ConVar FindConVar(const char[] name);
// A ConVar is a configurable, named setting in the srcds console. // A ConVar is a configurable, named setting in the srcds console.
@ -242,27 +248,27 @@ methodmap ConVar < Handle
/** /**
* Creates a hook for when a console variable's value is changed. * Creates a hook for when a console variable's value is changed.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param callback An OnConVarChanged function pointer. * @param callback An OnConVarChanged function pointer.
* @error Invalid or corrupt Handle or invalid callback function. * @error Invalid or corrupt Handle or invalid callback function.
*/ */
native void HookConVarChange(Handle convar, ConVarChanged callback); native void HookConVarChange(Handle convar, ConVarChanged callback);
/** /**
* Removes a hook for when a console variable's value is changed. * Removes a hook for when a console variable's value is changed.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param callback An OnConVarChanged function pointer. * @param callback An OnConVarChanged function pointer.
* @error Invalid or corrupt Handle, invalid callback function, or no active hook on convar. * @error Invalid or corrupt Handle, invalid callback function, or no active hook on convar.
*/ */
native void UnhookConVarChange(Handle convar, ConVarChanged callback); native void UnhookConVarChange(Handle convar, ConVarChanged callback);
/** /**
* Returns the boolean value of a console variable. * Returns the boolean value of a console variable.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @return The boolean value of the convar. * @return The boolean value of the convar.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native bool GetConVarBool(Handle convar); native bool GetConVarBool(Handle convar);
@ -272,23 +278,23 @@ native bool GetConVarBool(Handle convar);
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and * Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed. * Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param value New boolean value. * @param value New boolean value.
* @param replicate If set to true, the new convar value will be set on all clients. * @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag * This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients. * and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed. * @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag. * This will only work if the convar has the FCVAR_NOTIFY flag.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void SetConVarBool(Handle convar, bool value, bool replicate=false, bool notify=false); native void SetConVarBool(Handle convar, bool value, bool replicate=false, bool notify=false);
/** /**
* Returns the integer value of a console variable. * Returns the integer value of a console variable.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @return The integer value of the convar. * @return The integer value of the convar.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native int GetConVarInt(Handle convar); native int GetConVarInt(Handle convar);
@ -298,23 +304,23 @@ native int GetConVarInt(Handle convar);
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and * Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed. * Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param value New integer value. * @param value New integer value.
* @param replicate If set to true, the new convar value will be set on all clients. * @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag * This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients. * and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed. * @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag. * This will only work if the convar has the FCVAR_NOTIFY flag.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void SetConVarInt(Handle convar, int value, bool replicate=false, bool notify=false); native void SetConVarInt(Handle convar, int value, bool replicate=false, bool notify=false);
/** /**
* Returns the floating point value of a console variable. * Returns the floating point value of a console variable.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @return The floating point value of the convar. * @return The floating point value of the convar.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native float GetConVarFloat(Handle convar); native float GetConVarFloat(Handle convar);
@ -324,24 +330,24 @@ native float GetConVarFloat(Handle convar);
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and * Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed. * Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param value New floating point value. * @param value New floating point value.
* @param replicate If set to true, the new convar value will be set on all clients. * @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag * This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients. * and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed. * @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag. * This will only work if the convar has the FCVAR_NOTIFY flag.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void SetConVarFloat(Handle convar, float value, bool replicate=false, bool notify=false); native void SetConVarFloat(Handle convar, float value, bool replicate=false, bool notify=false);
/** /**
* Retrieves the string value of a console variable. * Retrieves the string value of a console variable.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param value Buffer to store the value of the convar. * @param value Buffer to store the value of the convar.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void GetConVarString(Handle convar, char[] value, int maxlength); native void GetConVarString(Handle convar, char[] value, int maxlength);
@ -351,14 +357,14 @@ native void GetConVarString(Handle convar, char[] value, int maxlength);
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and * Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed. * Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param value New string value. * @param value New string value.
* @param replicate If set to true, the new convar value will be set on all clients. * @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag * This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients. * and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed. * @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag. * This will only work if the convar has the FCVAR_NOTIFY flag.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void SetConVarString(Handle convar, const char[] value, bool replicate=false, bool notify=false); native void SetConVarString(Handle convar, const char[] value, bool replicate=false, bool notify=false);
@ -368,85 +374,85 @@ native void SetConVarString(Handle convar, const char[] value, bool replicate=fa
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and * Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed. * Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param replicate If set to true, the new convar value will be set on all clients. * @param replicate If set to true, the new convar value will be set on all clients.
* This will only work if the convar has the FCVAR_REPLICATED flag * This will only work if the convar has the FCVAR_REPLICATED flag
* and actually exists on clients. * and actually exists on clients.
* @param notify If set to true, clients will be notified that the convar has changed. * @param notify If set to true, clients will be notified that the convar has changed.
* This will only work if the convar has the FCVAR_NOTIFY flag. * This will only work if the convar has the FCVAR_NOTIFY flag.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void ResetConVar(Handle convar, bool replicate=false, bool notify=false); native void ResetConVar(Handle convar, bool replicate=false, bool notify=false);
/** /**
* Retrieves the default string value of a console variable. * Retrieves the default string value of a console variable.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param value Buffer to store the default value of the convar. * @param value Buffer to store the default value of the convar.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @return Number of bytes written to the buffer (UTF-8 safe). * @return Number of bytes written to the buffer (UTF-8 safe).
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native int GetConVarDefault(Handle convar, char[] value, int maxlength); native int GetConVarDefault(Handle convar, char[] value, int maxlength);
/** /**
* Returns the bitstring of flags on a console variable. * Returns the bitstring of flags on a console variable.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @return A bitstring containing the FCVAR_* flags that are enabled. * @return A bitstring containing the FCVAR_* flags that are enabled.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native int GetConVarFlags(Handle convar); native int GetConVarFlags(Handle convar);
/** /**
* Sets the bitstring of flags on a console variable. * Sets the bitstring of flags on a console variable.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param flags A bitstring containing the FCVAR_* flags to enable. * @param flags A bitstring containing the FCVAR_* flags to enable.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void SetConVarFlags(Handle convar, int flags); native void SetConVarFlags(Handle convar, int flags);
/** /**
* Retrieves the specified bound of a console variable. * Retrieves the specified bound of a console variable.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param type Type of bound to retrieve, ConVarBound_Lower or ConVarBound_Upper. * @param type Type of bound to retrieve, ConVarBound_Lower or ConVarBound_Upper.
* @param value By-reference cell to store the specified floating point bound value. * @param value By-reference cell to store the specified floating point bound value.
* @return True if the convar has the specified bound set, false otherwise. * @return True if the convar has the specified bound set, false otherwise.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native bool GetConVarBounds(Handle convar, ConVarBounds type, float &value); native bool GetConVarBounds(Handle convar, ConVarBounds type, float &value);
/** /**
* Sets the specified bound of a console variable. * Sets the specified bound of a console variable.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param type Type of bound to set, ConVarBound_Lower or ConVarBound_Upper * @param type Type of bound to set, ConVarBound_Lower or ConVarBound_Upper
* @param set If set to true, convar will use specified bound. If false, bound will be removed. * @param set If set to true, convar will use specified bound. If false, bound will be removed.
* @param value Floating point value to use as the specified bound. * @param value Floating point value to use as the specified bound.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void SetConVarBounds(Handle convar, ConVarBounds type, bool set, float value=0.0); native void SetConVarBounds(Handle convar, ConVarBounds type, bool set, float value=0.0);
/** /**
* Retrieves the name of a console variable. * Retrieves the name of a console variable.
* *
* @param convar Handle to the convar. * @param convar Handle to the convar.
* @param name Buffer to store the name of the convar. * @param name Buffer to store the name of the convar.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void GetConVarName(Handle convar, char[] name, int maxlength); native void GetConVarName(Handle convar, char[] name, int maxlength);
/** /**
* Replicates a convar value to a specific client. This does not change the actual convar value. * Replicates a convar value to a specific client. This does not change the actual convar value.
* *
* @param client Client index * @param client Client index
* @param convar ConVar handle * @param convar ConVar handle
* @param value String value to send * @param value String value to send
* @return True on success, false on failure * @return True on success, false on failure
* @error Invalid client index, client not in game, or client is fake * @error Invalid client index, client not in game, or client is fake
*/ */
native bool SendConVarValue(int client, Handle convar, const char[] value); native bool SendConVarValue(int client, Handle convar, const char[] value);
@ -454,43 +460,43 @@ typeset ConVarQueryFinished
{ {
// Called when a query to retrieve a client's console variable has finished. // Called when a query to retrieve a client's console variable has finished.
// //
// @param cookie Unique identifier of query. // @param cookie Unique identifier of query.
// @param client Player index. // @param client Player index.
// @param result Result of query that tells one whether or not query was successful. // @param result Result of query that tells one whether or not query was successful.
// See ConVarQueryResult enum for more details. // See ConVarQueryResult enum for more details.
// @param convarName Name of client convar that was queried. // @param convarName Name of client convar that was queried.
// @param convarValue Value of client convar that was queried if successful. This will be "" if it was not. // @param convarValue Value of client convar that was queried if successful. This will be "" if it was not.
// @param value Value that was passed when query was started. // @param value Value that was passed when query was started.
function void (QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue, any value); function void (QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue, any value);
// Called when a query to retrieve a client's console variable has finished. // Called when a query to retrieve a client's console variable has finished.
// //
// @param cookie Unique identifier of query. // @param cookie Unique identifier of query.
// @param client Player index. // @param client Player index.
// @param result Result of query that tells one whether or not query was successful. // @param result Result of query that tells one whether or not query was successful.
// See ConVarQueryResult enum for more details. // See ConVarQueryResult enum for more details.
// @param convarName Name of client convar that was queried. // @param convarName Name of client convar that was queried.
// @param convarValue Value of client convar that was queried if successful. This will be "" if it was not. // @param convarValue Value of client convar that was queried if successful. This will be "" if it was not.
function void (QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue); function void (QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue);
}; };
/** /**
* Starts a query to retrieve the value of a client's console variable. * Starts a query to retrieve the value of a client's console variable.
* *
* @param client Player index. * @param client Player index.
* @param cvarName Name of client convar to query. * @param cvarName Name of client convar to query.
* @param callback A function to use as a callback when the query has finished. * @param callback A function to use as a callback when the query has finished.
* @param value Optional value to pass to the callback function. * @param value Optional value to pass to the callback function.
* @return A cookie that uniquely identifies the query. * @return A cookie that uniquely identifies the query.
* Returns QUERYCOOKIE_FAILED on failure, such as when used on a bot. * Returns QUERYCOOKIE_FAILED on failure, such as when used on a bot.
*/ */
native QueryCookie QueryClientConVar(int client, const char[] cvarName, ConVarQueryFinished callback, any value=0); native QueryCookie QueryClientConVar(int client, const char[] cvarName, ConVarQueryFinished callback, any value=0);
/** /**
* Returns true if the supplied character is valid in a ConVar name. * Returns true if the supplied character is valid in a ConVar name.
* *
* @param c Character to validate. * @param c Character to validate.
* @return True is valid for ConVars, false otherwise * @return True is valid for ConVars, false otherwise
*/ */
stock bool IsValidConVarChar(int c) stock bool IsValidConVarChar(int c)
{ {

View File

@ -38,7 +38,7 @@
#include <version> #include <version>
/** If this gets changed, you need to update Core's check. */ /** If this gets changed, you need to update Core's check. */
#define SOURCEMOD_PLUGINAPI_VERSION 5 #define SOURCEMOD_PLUGINAPI_VERSION 5
struct PlVers struct PlVers
{ {
@ -53,10 +53,10 @@ struct PlVers
*/ */
enum Action enum Action
{ {
Plugin_Continue = 0, /**< Continue with the original action */ Plugin_Continue = 0, /**< Continue with the original action */
Plugin_Changed = 1, /**< Inputs or outputs have been overridden with new values */ Plugin_Changed = 1, /**< Inputs or outputs have been overridden with new values */
Plugin_Handled = 3, /**< Handle the action at the end (don't call it) */ Plugin_Handled = 3, /**< Handle the action at the end (don't call it) */
Plugin_Stop = 4, /**< Immediately stop the hook chain and handle the original */ Plugin_Stop = 4 /**< Immediately stop the hook chain and handle the original */
}; };
/** /**
@ -82,17 +82,17 @@ public PlVers __version =
*/ */
enum PluginStatus enum PluginStatus
{ {
Plugin_Running=0, /**< Plugin is running */ Plugin_Running=0, /**< Plugin is running */
/* All states below are "temporarily" unexecutable */ /* All states below are "temporarily" unexecutable */
Plugin_Paused, /**< Plugin is loaded but paused */ Plugin_Paused, /**< Plugin is loaded but paused */
Plugin_Error, /**< Plugin is loaded but errored/locked */ Plugin_Error, /**< Plugin is loaded but errored/locked */
/* All states below do not have all natives */ /* All states below do not have all natives */
Plugin_Loaded, /**< Plugin has passed loading and can be finalized */ Plugin_Loaded, /**< Plugin has passed loading and can be finalized */
Plugin_Failed, /**< Plugin has a fatal failure */ Plugin_Failed, /**< Plugin has a fatal failure */
Plugin_Created, /**< Plugin is created but not initialized */ Plugin_Created, /**< Plugin is created but not initialized */
Plugin_Uncompiled, /**< Plugin is not yet compiled by the JIT */ Plugin_Uncompiled, /**< Plugin is not yet compiled by the JIT */
Plugin_BadLoad, /**< Plugin failed to load */ Plugin_BadLoad, /**< Plugin failed to load */
Plugin_Evicted /**< Plugin was unloaded due to an error */ Plugin_Evicted /**< Plugin was unloaded due to an error */
}; };
/** /**
@ -112,11 +112,11 @@ enum PluginStatus
*/ */
enum PluginInfo enum PluginInfo
{ {
PlInfo_Name, /**< Plugin name */ PlInfo_Name, /**< Plugin name */
PlInfo_Author, /**< Plugin author */ PlInfo_Author, /**< Plugin author */
PlInfo_Description, /**< Plugin description */ PlInfo_Description, /**< Plugin description */
PlInfo_Version, /**< Plugin version */ PlInfo_Version, /**< Plugin version */
PlInfo_URL, /**< Plugin URL */ PlInfo_URL /**< Plugin URL */
}; };
/** /**
@ -124,10 +124,10 @@ enum PluginInfo
*/ */
struct Extension struct Extension
{ {
public const char[] name; /**< Short name */ public const char[] name; /**< Short name */
public const char[] file; /**< Default file name */ public const char[] file; /**< Default file name */
public bool autoload; /**< Whether or not to auto-load */ public bool autoload; /**< Whether or not to auto-load */
public bool required; /**< Whether or not to require */ public bool required; /**< Whether or not to require */
}; };
/** /**
@ -135,13 +135,13 @@ struct Extension
*/ */
struct SharedPlugin struct SharedPlugin
{ {
public const char[] name; /**< Short name */ public const char[] name; /**< Short name */
public const char[] file; /**< File name */ public const char[] file; /**< File name */
public bool required; /**< Whether or not to require */ public bool required; /**< Whether or not to require */
}; };
public float NULL_VECTOR[3]; /**< Pass this into certain functions to act as a C++ NULL */ public float NULL_VECTOR[3]; /**< Pass this into certain functions to act as a C++ NULL */
public const char NULL_STRING[1]; /**< pass this into certain functions to act as a C++ NULL */ public const char NULL_STRING[1]; /**< pass this into certain functions to act as a C++ NULL */
/** /**
* Check if the given vector is the NULL_VECTOR. * Check if the given vector is the NULL_VECTOR.
@ -177,7 +177,7 @@ native int VerifyCoreVersion();
* or otherwise non-existent, the plugin will still work. Calling * or otherwise non-existent, the plugin will still work. Calling
* removed natives results in a run-time error. * removed natives results in a run-time error.
* *
* @param name Native name. * @param name Native name.
*/ */
native void MarkNativeAsOptional(const char[] name); native void MarkNativeAsOptional(const char[] name);

View File

@ -31,22 +31,22 @@
*/ */
#if defined _cstrike_included #if defined _cstrike_included
#endinput #endinput
#endif #endif
#define _cstrike_included #define _cstrike_included
#define CS_TEAM_NONE 0 /**< No team yet. */ #define CS_TEAM_NONE 0 /**< No team yet. */
#define CS_TEAM_SPECTATOR 1 /**< Spectators. */ #define CS_TEAM_SPECTATOR 1 /**< Spectators. */
#define CS_TEAM_T 2 /**< Terrorists. */ #define CS_TEAM_T 2 /**< Terrorists. */
#define CS_TEAM_CT 3 /**< Counter-Terrorists. */ #define CS_TEAM_CT 3 /**< Counter-Terrorists. */
#define CS_SLOT_PRIMARY 0 /**< Primary weapon slot. */ #define CS_SLOT_PRIMARY 0 /**< Primary weapon slot. */
#define CS_SLOT_SECONDARY 1 /**< Secondary weapon slot. */ #define CS_SLOT_SECONDARY 1 /**< Secondary weapon slot. */
#define CS_SLOT_KNIFE 2 /**< Knife slot. */ #define CS_SLOT_KNIFE 2 /**< Knife slot. */
#define CS_SLOT_GRENADE 3 /**< Grenade slot (will only return one grenade). */ #define CS_SLOT_GRENADE 3 /**< Grenade slot (will only return one grenade). */
#define CS_SLOT_C4 4 /**< C4 slot. */ #define CS_SLOT_C4 4 /**< C4 slot. */
#define CS_DMG_HEADSHOT (1 << 30) /**< Headshot */ #define CS_DMG_HEADSHOT (1 << 30) /**< Headshot */
enum CSRoundEndReason enum CSRoundEndReason
{ {
@ -70,8 +70,8 @@ enum CSRoundEndReason
// The below only exist on CS:GO // The below only exist on CS:GO
CSRoundEnd_TerroristsSurrender, /**< Terrorists Surrender */ CSRoundEnd_TerroristsSurrender, /**< Terrorists Surrender */
CSRoundEnd_CTSurrender, /**< CTs Surrender */ CSRoundEnd_CTSurrender, /**< CTs Surrender */
CSRoundEnd_TerroristsPlanted, /**< Terrorists Planted the bomb */ CSRoundEnd_TerroristsPlanted, /**< Terrorists Planted the bomb */
CSRoundEnd_CTsReachedHostage, /**< CTs Reached the hostage */ CSRoundEnd_CTsReachedHostage /**< CTs Reached the hostage */
}; };
enum CSWeaponID enum CSWeaponID
@ -177,8 +177,8 @@ enum CSWeaponID
* Return Plugin_Continue to allow the purchase or return a * Return Plugin_Continue to allow the purchase or return a
* higher action to deny. * higher action to deny.
* *
* @param client Client index * @param client Client index
* @param weapon User input for weapon name * @param weapon User input for weapon name
*/ */
forward Action CS_OnBuyCommand(int client, const char[] weapon); forward Action CS_OnBuyCommand(int client, const char[] weapon);
@ -187,8 +187,8 @@ forward Action CS_OnBuyCommand(int client, const char[] weapon);
* Return Plugin_Continue to allow the call or return a * Return Plugin_Continue to allow the call or return a
* higher action to block. * higher action to block.
* *
* @param client Client index * @param client Client index
* @param weaponIndex Weapon index * @param weaponIndex Weapon index
*/ */
forward Action CS_OnCSWeaponDrop(int client, int weaponIndex); forward Action CS_OnCSWeaponDrop(int client, int weaponIndex);
@ -199,11 +199,11 @@ forward Action CS_OnCSWeaponDrop(int client, int weaponIndex);
* *
* @note This can be called multiple times per weapon purchase * @note This can be called multiple times per weapon purchase
* *
* @param client Client index * @param client Client index
* @param weapon Weapon classname * @param weapon Weapon classname
* @param price Buffer param for the price of the weapon * @param price Buffer param for the price of the weapon
* *
* @note Not all "weapons" call GetWeaponPrice. Example: c4, knife, vest, vest helmet, night vision. * @note Not all "weapons" call GetWeaponPrice. Example: c4, knife, vest, vest helmet, night vision.
*/ */
forward Action CS_OnGetWeaponPrice(int client, const char[] weapon, int &price); forward Action CS_OnGetWeaponPrice(int client, const char[] weapon, int &price);
@ -213,171 +213,173 @@ forward Action CS_OnGetWeaponPrice(int client, const char[] weapon, int &price);
* using the given delay and reason, or return Plugin_Handled or a higher * using the given delay and reason, or return Plugin_Handled or a higher
* action to block TerminateRound from firing. * action to block TerminateRound from firing.
* *
* @param delay Time (in seconds) until new round starts * @param delay Time (in seconds) until new round starts
* @param reason Reason for round end * @param reason Reason for round end
*/ */
forward Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason); forward Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason);
/** /**
* Respawns a player. * Respawns a player.
* *
* @param client Player's index. * @param client Player's index.
* @error Invalid client index, client not in game. * @error Invalid client index, client not in game.
*/ */
native void CS_RespawnPlayer(int client); native void CS_RespawnPlayer(int client);
/** /**
* Switches the player's team. * Switches the player's team.
* *
* @param client Player's index. * @param client Player's index.
* @param team Team index. * @param team Team index.
* @error Invalid client index, client not in game. * @error Invalid client index, client not in game.
*/ */
native void CS_SwitchTeam(int client, int team); native void CS_SwitchTeam(int client, int team);
/** /**
* Forces a player to drop or toss their weapon * Forces a player to drop or toss their weapon
* *
* @param client Player's index. * @param client Player's index.
* @param weaponIndex Index of weapon to drop. * @param weaponIndex Index of weapon to drop.
* @param toss True to toss weapon (with velocity) or false to just drop weapon * @param toss True to toss weapon (with velocity) or false to just drop weapon
* @param blockhook Set to true to stop the corresponding CS_OnCSWeaponDrop * @param blockhook Set to true to stop the corresponding CS_OnCSWeaponDrop
* * @error Invalid client index, client not in game, or invalid weapon index.
* @error Invalid client index, client not in game, or invalid weapon index.
*/ */
native void CS_DropWeapon(int client, int weaponIndex, bool toss, bool blockhook = false); native void CS_DropWeapon(int client, int weaponIndex, bool toss, bool blockhook = false);
/** /**
* Forces round to end with a reason * Forces round to end with a reason
* *
* @param delay Time (in seconds) to delay before new round starts * @param delay Time (in seconds) to delay before new round starts
* @param reason Reason for the round ending * @param reason Reason for the round ending
* @param blockhook Set to true to stop the corresponding CS_OnTerminateRound * @param blockhook Set to true to stop the corresponding CS_OnTerminateRound
* forward from being called. * forward from being called.
*/ */
native void CS_TerminateRound(float delay, CSRoundEndReason reason, bool blockhook = false); native void CS_TerminateRound(float delay, CSRoundEndReason reason, bool blockhook = false);
/** /**
* Gets a weapon name from a weapon alias * Gets a weapon name from a weapon alias
* *
* @param alias Weapons alias to get weapon name for. * @param alias Weapons alias to get weapon name for.
* @param weapon Buffer to store weapons name * @param weapon Buffer to store weapons name
* @param size Size of buffer to store the weapons name. * @param size Size of buffer to store the weapons name.
* *
* @note Will set the buffer to the original alias if it is not an alias to a weapon. * @note Will set the buffer to the original alias if it is not an alias to a weapon.
*/ */
native void CS_GetTranslatedWeaponAlias(const char[] alias, char[] weapon, int size); native void CS_GetTranslatedWeaponAlias(const char[] alias, char[] weapon, int size);
/** /**
* Gets a weapon's price * Gets a weapon's price
* *
* @param client Client to check weapon price for. * @param client Client to check weapon price for.
* @param id Weapon id for the weapon to check * @param id Weapon id for the weapon to check
* @param defaultprice Set to true to get defaultprice. * @param defaultprice Set to true to get defaultprice.
* @return Returns price of the weapon (even if modified) * @return Returns price of the weapon (even if modified)
* @error Invalid client, failing to get weapon info, or failing to get price offset.
* *
* @error Invalid client, failing to get weapon info, or failing to get price offset. * @note c4, knife and shield will always return 0. vest, vest helmet and night vision will always return default price.
* @note c4, knife and shield will always return 0. vest, vest helmet and night vision will always return default price.
*/ */
native int CS_GetWeaponPrice(int client, CSWeaponID id, bool defaultprice = false); native int CS_GetWeaponPrice(int client, CSWeaponID id, bool defaultprice = false);
/** /**
* Gets a clients clan tag * Gets a clients clan tag
* @param client Client index to get clan tag for.
* @param buffer Buffer to store clients clan tag in.
* @param size Size of the buffer.
* @return Number of non-null bytes written.
* *
* @error Invalid client. * @param client Client index to get clan tag for.
* @param buffer Buffer to store clients clan tag in.
* @param size Size of the buffer.
* @return Number of non-null bytes written.
* @error Invalid client.
*/ */
native int CS_GetClientClanTag(int client, char[] buffer, int size); native int CS_GetClientClanTag(int client, char[] buffer, int size);
/** /**
* Sets a clients clan tag * Sets a clients clan tag
* @param client Client index to set clan tag for.
* @param tag Tag to set clients clan tag as.
* *
* @error Invalid client. * @param client Client index to set clan tag for.
* @param tag Tag to set clients clan tag as.
* @error Invalid client.
*/ */
native void CS_SetClientClanTag(int client, const char[] tag); native void CS_SetClientClanTag(int client, const char[] tag);
/** /**
* Gets a team's score * Gets a team's score
* @param team Team index to get score for.
* @return Returns the internal team score.
* *
* @error Invalid team index. * @param team Team index to get score for.
* @return Returns the internal team score.
* @error Invalid team index.
*/ */
native int CS_GetTeamScore(int team); native int CS_GetTeamScore(int team);
/** /**
* Sets a team's score * Sets a team's score
* @param team Team index to set score for.
* @param value Value to set teams score as.
* *
* @error Invalid team index. * @param team Team index to set score for.
* @note This will update the scoreboard only after the scoreboard update function is called. Use SetTeamScore plus this to update the scoreboard instantly and save values correctly. * @param value Value to set teams score as.
* @error Invalid team index.
*
* @note This will update the scoreboard only after the scoreboard update function is called.
* Use SetTeamScore plus this to update the scoreboard instantly and save values correctly.
*/ */
native void CS_SetTeamScore(int team, int value); native void CS_SetTeamScore(int team, int value);
/** /**
* Gets a client's mvp count * Gets a client's mvp count
* @param client Client index to get mvp count of.
* @return Returns the client's internal MVP count.
* *
* @error Invalid client. * @param client Client index to get mvp count of.
* @return Returns the client's internal MVP count.
* @error Invalid client.
*/ */
native int CS_GetMVPCount(int client); native int CS_GetMVPCount(int client);
/** /**
* Sets a client's mvp count * Sets a client's mvp count
* @param client Client index to set mvp count for.
* @param value Value to set client's mvp count as.
* *
* @error Invalid client. * @param client Client index to set mvp count for.
* @param value Value to set client's mvp count as.
* @error Invalid client.
*/ */
native void CS_SetMVPCount(int client, int value); native void CS_SetMVPCount(int client, int value);
/** /**
* Gets a client's contribution score (CS:GO only) * Gets a client's contribution score (CS:GO only)
* @param client Client index to get score of.
* @return Returns the client's score.
* *
* @error Invalid client. * @param client Client index to get score of.
* @return Returns the client's score.
* @error Invalid client.
*/ */
native int CS_GetClientContributionScore(int client); native int CS_GetClientContributionScore(int client);
/** /**
* Sets a client's contribution score (CS:GO only) * Sets a client's contribution score (CS:GO only)
* @param client Client index to set score for.
* @param value Value to set client's score as.
* *
* @error Invalid client. * @param client Client index to set score for.
* @param value Value to set client's score as.
* @error Invalid client.
*/ */
native void CS_SetClientContributionScore(int client, int value); native void CS_SetClientContributionScore(int client, int value);
/** /**
* Gets a client's assists (CS:GO only) * Gets a client's assists (CS:GO only)
* @param client Client index to get assists of.
* @return Returns the client's assists.
* *
* @error Invalid client. * @param client Client index to get assists of.
* @return Returns the client's assists.
* @error Invalid client.
*/ */
native int CS_GetClientAssists(int client); native int CS_GetClientAssists(int client);
/** /**
* Sets a client's assists (CS:GO only) * Sets a client's assists (CS:GO only)
* @param client Client index to set assists for.
* @param value Value to set client's assists as.
* *
* @error Invalid client. * @param client Client index to set assists for.
* @param value Value to set client's assists as.
* @error Invalid client.
*/ */
native void CS_SetClientAssists(int client, int value); native void CS_SetClientAssists(int client, int value);
/** /**
* Gets a weaponID from a alias * Gets a weaponID from a alias
* @param alias Weapon alias to attempt to get an id for. *
* @return Returns a weapon id or 0 if failed to find a match. * @param alias Weapon alias to attempt to get an id for.
* @return Returns a weapon id or 0 if failed to find a match.
* *
* @note For best results use CS_GetTranslatedWeaponAlias on the weapon name before passing it. * @note For best results use CS_GetTranslatedWeaponAlias on the weapon name before passing it.
*/ */
@ -385,17 +387,19 @@ native CSWeaponID CS_AliasToWeaponID(const char[] alias);
/** /**
* Gets a alias from a weaponID * Gets a alias from a weaponID
* @param weaponID WeaponID to get alias for. *
* @param destination Destination string to hold the weapon alias. * @param weaponID WeaponID to get alias for.
* @param len Length of the destination array. * @param destination Destination string to hold the weapon alias.
* @return Returns number of cells written. * @param len Length of the destination array.
* @return Returns number of cells written.
*/ */
native int CS_WeaponIDToAlias(CSWeaponID weaponID, char[] destination, int len); native int CS_WeaponIDToAlias(CSWeaponID weaponID, char[] destination, int len);
/** /**
* Returns weather a WeaponID is valid on the current mod (css or csgo) * Returns weather a WeaponID is valid on the current mod (css or csgo)
* @param weaponID WeaponID to check *
* @return Returns true if its a valid WeaponID false otherwise. * @param weaponID WeaponID to check
* @return Returns true if its a valid WeaponID false otherwise.
* *
* @note This will return false always for CSWeapon_NONE. Should only be called after OnMapStart since weapon info isnt intialized before. * @note This will return false always for CSWeapon_NONE. Should only be called after OnMapStart since weapon info isnt intialized before.
*/ */
@ -404,30 +408,30 @@ native bool CS_IsValidWeaponID(CSWeaponID id);
/** /**
* Sets a player's model based on their current class * Sets a player's model based on their current class
* *
* @param client Player's index. * @param client Player's index.
* @error Invalid client index, client not in game. * @error Invalid client index, client not in game.
*/ */
native void CS_UpdateClientModel(int client); native void CS_UpdateClientModel(int client);
/** /**
* Returns a CSWeaponID equivalent based on the item definition index. * Returns a CSWeaponID equivalent based on the item definition index.
* *
* @param iDefIndex Definition index to get the CSWeaponID value for. * @param iDefIndex Definition index to get the CSWeaponID value for.
* @return Returns CSWeaponID value for the definition index. * @return Returns CSWeaponID value for the definition index.
* @error Invalid definition index.
* *
* @error Invalid definition index. * @note In most cases the id will be the item definition index. Works for CS:GO ONLY.
* @note In most cases the id will be the item definition index. Works for CS:GO ONLY.
*/ */
native CSWeaponID CS_ItemDefIndexToID(int iDefIndex); native CSWeaponID CS_ItemDefIndexToID(int iDefIndex);
/** /**
* Returns a item definition index equivalent based on the CSWeaponID. * Returns a item definition index equivalent based on the CSWeaponID.
* *
* @param id CSWeaponID to get the item definition for. * @param id CSWeaponID to get the item definition for.
* @return Returns item definition index value for the weapon id. * @return Returns item definition index value for the weapon id.
* @error Invalid weapon id.
* *
* @error Invalid weapon id. * @note In most cases the item deinition index will be the id. Works for CS:GO ONLY.
* @note In most cases the item deinition index will be the id. Works for CS:GO ONLY.
*/ */
native int CS_WeaponIDToItemDefIndex(CSWeaponID id); native int CS_WeaponIDToItemDefIndex(CSWeaponID id);

View File

@ -39,7 +39,7 @@
/** /**
* Opaque handle to a datapack position. * Opaque handle to a datapack position.
*/ */
enum DataPackPos: {}; enum DataPackPos: {};
// A DataPack allows serializing multiple variables into a single stream. // A DataPack allows serializing multiple variables into a single stream.
methodmap DataPack < Handle methodmap DataPack < Handle
@ -49,58 +49,58 @@ methodmap DataPack < Handle
// Packs a normal cell into a data pack. // Packs a normal cell into a data pack.
// //
// @param cell Cell to add. // @param cell Cell to add.
// @param insert Determines whether mid-pack writes will insert instead of overwrite. // @param insert Determines whether mid-pack writes will insert instead of overwrite.
public native void WriteCell(any cell, bool insert = false); public native void WriteCell(any cell, bool insert = false);
// Packs a float into a data pack. // Packs a float into a data pack.
// //
// @param val Float to add. // @param val Float to add.
// @param insert Determines whether mid-pack writes will insert instead of overwrite. // @param insert Determines whether mid-pack writes will insert instead of overwrite.
public native void WriteFloat(float val, bool insert = false); public native void WriteFloat(float val, bool insert = false);
// Packs a string into a data pack. // Packs a string into a data pack.
// //
// @param str String to add. // @param str String to add.
// @param insert Determines whether mid-pack writes will insert instead of overwrite. // @param insert Determines whether mid-pack writes will insert instead of overwrite.
public native void WriteString(const char[] str, bool insert = false); public native void WriteString(const char[] str, bool insert = false);
// Packs a function pointer into a data pack. // Packs a function pointer into a data pack.
// //
// @param fktptr Function pointer to add. // @param fktptr Function pointer to add.
// @param insert Determines whether mid-pack writes will insert instead of overwrite. // @param insert Determines whether mid-pack writes will insert instead of overwrite.
public native void WriteFunction(Function fktptr, bool insert = false); public native void WriteFunction(Function fktptr, bool insert = false);
// Reads a cell from a data pack. // Reads a cell from a data pack.
// //
// @param pack Handle to the data pack. // @param pack Handle to the data pack.
public native any ReadCell(); public native any ReadCell();
// Reads a float from a data pack. // Reads a float from a data pack.
// //
// @param pack Handle to the data pack. // @param pack Handle to the data pack.
public native float ReadFloat(); public native float ReadFloat();
// Reads a string from a data pack. // Reads a string from a data pack.
// //
// @param buffer Destination string buffer. // @param buffer Destination string buffer.
// @param maxlen Maximum length of output string buffer. // @param maxlen Maximum length of output string buffer.
public native void ReadString(char[] buffer, int maxlen); public native void ReadString(char[] buffer, int maxlen);
// Reads a function pointer from a data pack. // Reads a function pointer from a data pack.
// //
// @return Function pointer. // @return Function pointer.
public native Function ReadFunction(); public native Function ReadFunction();
// Resets the position in a data pack. // Resets the position in a data pack.
// //
// @param clear If true, clears the contained data. // @param clear If true, clears the contained data.
public native void Reset(bool clear=false); public native void Reset(bool clear=false);
// Returns whether or not a specified number of bytes from the data pack // Returns whether or not a specified number of bytes from the data pack
// position to the end can be read. // position to the end can be read.
// //
// @param unused Unused variable. Exists for backwards compatability. // @param unused Unused variable. Exists for backwards compatability.
public native bool IsReadable(int unused = 0); public native bool IsReadable(int unused = 0);
// The read or write position in a data pack. // The read or write position in a data pack.
@ -113,117 +113,117 @@ methodmap DataPack < Handle
/** /**
* Creates a new data pack. * Creates a new data pack.
* *
* @return A Handle to the data pack. Must be closed with CloseHandle(). * @return A Handle to the data pack. Must be closed with CloseHandle().
*/ */
native DataPack CreateDataPack(); native DataPack CreateDataPack();
/** /**
* Packs a normal cell into a data pack. * Packs a normal cell into a data pack.
* *
* @param pack Handle to the data pack. * @param pack Handle to the data pack.
* @param cell Cell to add. * @param cell Cell to add.
* @error Invalid handle. * @error Invalid handle.
*/ */
native void WritePackCell(Handle pack, any cell); native void WritePackCell(Handle pack, any cell);
/** /**
* Packs a float into a data pack. * Packs a float into a data pack.
* *
* @param pack Handle to the data pack. * @param pack Handle to the data pack.
* @param val Float to add. * @param val Float to add.
* @error Invalid handle. * @error Invalid handle.
*/ */
native void WritePackFloat(Handle pack, float val); native void WritePackFloat(Handle pack, float val);
/** /**
* Packs a string into a data pack. * Packs a string into a data pack.
* *
* @param pack Handle to the data pack. * @param pack Handle to the data pack.
* @param str String to add. * @param str String to add.
* @error Invalid handle. * @error Invalid handle.
*/ */
native void WritePackString(Handle pack, const char[] str); native void WritePackString(Handle pack, const char[] str);
/** /**
* Packs a function pointer into a data pack. * Packs a function pointer into a data pack.
* *
* @param pack Handle to the data pack. * @param pack Handle to the data pack.
* @param fktptr Function pointer to add. * @param fktptr Function pointer to add.
* @error Invalid handle. * @error Invalid handle.
*/ */
native void WritePackFunction(Handle pack, Function fktptr); native void WritePackFunction(Handle pack, Function fktptr);
/** /**
* Reads a cell from a data pack. * Reads a cell from a data pack.
* *
* @param pack Handle to the data pack. * @param pack Handle to the data pack.
* @return Cell value. * @return Cell value.
* @error Invalid handle, or bounds error. * @error Invalid handle, or bounds error.
*/ */
native any ReadPackCell(Handle pack); native any ReadPackCell(Handle pack);
/** /**
* Reads a float from a data pack. * Reads a float from a data pack.
* *
* @param pack Handle to the data pack. * @param pack Handle to the data pack.
* @return Float value. * @return Float value.
* @error Invalid handle, or bounds error. * @error Invalid handle, or bounds error.
*/ */
native float ReadPackFloat(Handle pack); native float ReadPackFloat(Handle pack);
/** /**
* Reads a string from a data pack. * Reads a string from a data pack.
* *
* @param pack Handle to the data pack. * @param pack Handle to the data pack.
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlen Maximum length of output string buffer. * @param maxlen Maximum length of output string buffer.
* @error Invalid handle, or bounds error. * @error Invalid handle, or bounds error.
*/ */
native void ReadPackString(Handle pack, char[] buffer, int maxlen); native void ReadPackString(Handle pack, char[] buffer, int maxlen);
/** /**
* Reads a function pointer from a data pack. * Reads a function pointer from a data pack.
* *
* @param pack Handle to the data pack. * @param pack Handle to the data pack.
* @return Function pointer. * @return Function pointer.
* @error Invalid handle, or bounds error. * @error Invalid handle, or bounds error.
*/ */
native Function ReadPackFunction(Handle pack); native Function ReadPackFunction(Handle pack);
/** /**
* Resets the position in a data pack. * Resets the position in a data pack.
* *
* @param pack Handle to the data pack. * @param pack Handle to the data pack.
* @param clear If true, clears the contained data. * @param clear If true, clears the contained data.
* @error Invalid handle. * @error Invalid handle.
*/ */
native void ResetPack(Handle pack, bool clear=false); native void ResetPack(Handle pack, bool clear=false);
/** /**
* Returns the read or write position in a data pack. * Returns the read or write position in a data pack.
* *
* @param pack Handle to the data pack. * @param pack Handle to the data pack.
* @return Position in the data pack, only usable with calls to SetPackPosition. * @return Position in the data pack, only usable with calls to SetPackPosition.
* @error Invalid handle. * @error Invalid handle.
*/ */
native DataPackPos GetPackPosition(Handle pack); native DataPackPos GetPackPosition(Handle pack);
/** /**
* Sets the read/write position in a data pack. * Sets the read/write position in a data pack.
* *
* @param pack Handle to the data pack. * @param pack Handle to the data pack.
* @param position New position to set. Must have been previously retrieved from a call to GetPackPosition. * @param position New position to set. Must have been previously retrieved from a call to GetPackPosition.
* @error Invalid handle, or position is beyond the pack bounds. * @error Invalid handle, or position is beyond the pack bounds.
*/ */
native void SetPackPosition(Handle pack, DataPackPos position); native void SetPackPosition(Handle pack, DataPackPos position);
/** /**
* Returns whether or not a specified number of bytes from the data pack * Returns whether or not a specified number of bytes from the data pack
* position to the end can be read. * position to the end can be read.
* *
* @param pack Handle to the data pack. * @param pack Handle to the data pack.
* @param bytes Number of bytes to simulate reading. * @param bytes Number of bytes to simulate reading.
* @return True if can be read, false otherwise. * @return True if can be read, false otherwise.
* @error Invalid handle. * @error Invalid handle.
*/ */
native bool IsPackReadable(Handle pack, int bytes); native bool IsPackReadable(Handle pack, int bytes);

View File

@ -40,10 +40,10 @@
*/ */
enum DBResult enum DBResult
{ {
DBVal_Error = 0, /**< Column number/field is invalid. */ DBVal_Error = 0, /**< Column number/field is invalid. */
DBVal_TypeMismatch = 1, /**< You cannot retrieve this data with this type. */ DBVal_TypeMismatch = 1, /**< You cannot retrieve this data with this type. */
DBVal_Null = 2, /**< Field has no data (NULL) */ DBVal_Null = 2, /**< Field has no data (NULL) */
DBVal_Data = 3, /**< Field has data */ DBVal_Data = 3 /**< Field has data */
}; };
/** /**
@ -51,9 +51,9 @@ enum DBResult
*/ */
enum DBBindType enum DBBindType
{ {
DBBind_Int = 0, /**< Bind an integer. */ DBBind_Int = 0, /**< Bind an integer. */
DBBind_Float = 1, /**< Bind a float. */ DBBind_Float = 1, /**< Bind a float. */
DBBind_String = 2, /**< Bind a string. */ DBBind_String = 2 /**< Bind a string. */
}; };
/** /**
@ -61,9 +61,9 @@ enum DBBindType
*/ */
enum DBPriority enum DBPriority
{ {
DBPrio_High = 0, /**< High priority. */ DBPrio_High = 0, /**< High priority. */
DBPrio_Normal = 1, /**< Normal priority. */ DBPrio_Normal = 1, /**< Normal priority. */
DBPrio_Low = 2, /**< Low priority. */ DBPrio_Low = 2 /**< Low priority. */
}; };
// A Driver represents a database backend, currently MySQL or SQLite. // A Driver represents a database backend, currently MySQL or SQLite.
@ -192,8 +192,7 @@ methodmap DBResultSet < Handle
// @return Number of bytes written. // @return Number of bytes written.
// @error Invalid field index, invalid type conversion requested // @error Invalid field index, invalid type conversion requested
// from the database, or no current result set. // from the database, or no current result set.
public native int FetchString(int field, char[] buffer, int maxlength, public native int FetchString(int field, char[] buffer, int maxlength, DBResult &result=DBVal_Error);
DBResult &result=DBVal_Error);
// Fetches a float from a field in the current row of a result set. // Fetches a float from a field in the current row of a result set.
// If the result is NULL, a value of 0.0 will be returned. A NULL // If the result is NULL, a value of 0.0 will be returned. A NULL
@ -257,14 +256,16 @@ typeset SQLTxnSuccess
function void (Database db, any data, int numQueries, DBResultSet[] results, any[] queryData); function void (Database db, any data, int numQueries, DBResultSet[] results, any[] queryData);
} }
// Callback for a failed transaction. /**
// * Callback for a failed transaction.
// @param db Database handle. *
// @param data Data value passed to SQL_ExecuteTransaction(). * @param db Database handle.
// @param numQueries Number of queries executed in the transaction. * @param data Data value passed to SQL_ExecuteTransaction().
// @param error Error message. * @param numQueries Number of queries executed in the transaction.
// @param failIndex Index of the query that failed, or -1 if something else. * @param error Error message.
// @param queryData An array of each data value passed to SQL_AddQuery(). * @param failIndex Index of the query that failed, or -1 if something else.
* @param queryData An array of each data value passed to SQL_AddQuery().
*/
typedef SQLTxnFailure = function void (Database db, any data, int numQueries, const char[] error, int failIndex, any[] queryData); typedef SQLTxnFailure = function void (Database db, any data, int numQueries, const char[] error, int failIndex, any[] queryData);
// A Transaction is a collection of SQL statements that must all execute // A Transaction is a collection of SQL statements that must all execute
@ -315,23 +316,27 @@ methodmap DBStatement < Handle
public native void BindString(int param, const char[] value, bool copy); public native void BindString(int param, const char[] value, bool copy);
}; };
// Callback for receiving asynchronous database connections. /**
// * Callback for receiving asynchronous database connections.
// @param db Handle to the database connection. *
// @param error Error string if there was an error. The error could be * @param db Handle to the database connection.
// empty even if an error condition exists, so it is important * @param error Error string if there was an error. The error could be
// to check the actual Handle value instead. * empty even if an error condition exists, so it is important
// @param data Data passed in via the original threaded invocation. * to check the actual Handle value instead.
* @param data Data passed in via the original threaded invocation.
*/
typedef SQLConnectCallback = function void (Database db, const char[] error, any data); typedef SQLConnectCallback = function void (Database db, const char[] error, any data);
// Callback for receiving asynchronous database query results. /**
// * Callback for receiving asynchronous database query results.
// @param db Cloned handle to the database connection. *
// @param results Result object, or null on failure. * @param db Cloned handle to the database connection.
// @param error Error string if there was an error. The error could be * @param results Result object, or null on failure.
// empty even if an error condition exists, so it is important * @param error Error string if there was an error. The error could be
// to check the actual results value instead. * empty even if an error condition exists, so it is important
// @param data Data passed in via the original threaded invocation. * to check the actual results value instead.
* @param data Data passed in via the original threaded invocation.
*/
typedef SQLQueryCallback = function void (Database db, DBResultSet results, const char[] error, any data); typedef SQLQueryCallback = function void (Database db, DBResultSet results, const char[] error, any data);
// A Database represents a live connection to a database, either over the // A Database represents a live connection to a database, either over the
@ -340,9 +345,9 @@ methodmap Database < Handle
{ {
// Connects to a database asynchronously, so the game thread is not blocked. // Connects to a database asynchronously, so the game thread is not blocked.
// //
// @param callback Callback. If no driver was found, the owner is null. // @param callback Callback. If no driver was found, the owner is null.
// @param name Database configuration name. // @param name Database configuration name.
// @param data Extra data value to pass to the callback. // @param data Extra data value to pass to the callback.
public static native void Connect(SQLConnectCallback callback, const char[] name="default", any data=0); public static native void Connect(SQLConnectCallback callback, const char[] name="default", any data=0);
// Returns the driver for this database connection. // Returns the driver for this database connection.
@ -372,22 +377,22 @@ methodmap Database < Handle
// encloses the string in ''. While drivers tend to allow " instead, the string // encloses the string in ''. While drivers tend to allow " instead, the string
// may be not be escaped (for example, on SQLite)! // may be not be escaped (for example, on SQLite)!
// //
// @param string String to quote. // @param string String to quote.
// @param buffer Buffer to store quoted string in. // @param buffer Buffer to store quoted string in.
// @param maxlength Maximum length of the buffer. // @param maxlength Maximum length of the buffer.
// @param written Optionally returns the number of bytes written. // @param written Optionally returns the number of bytes written.
// @return True on success, false if buffer is not big enough. // @return True on success, false if buffer is not big enough.
// The buffer must be at least 2*strlen(string)+1. // The buffer must be at least 2*strlen(string)+1.
public native bool Escape(const char[] string, char[] buffer, int maxlength, int &written=0); public native bool Escape(const char[] string, char[] buffer, int maxlength, int &written=0);
// Formats a string according to the SourceMod format rules (see documentation). // Formats a string according to the SourceMod format rules (see documentation).
// All format specifiers are escaped (see SQL_EscapeString) unless the '!' flag is used. // All format specifiers are escaped (see SQL_EscapeString) unless the '!' flag is used.
// //
// @param buffer Destination string buffer. // @param buffer Destination string buffer.
// @param maxlength Maximum length of output string buffer. // @param maxlength Maximum length of output string buffer.
// @param format Formatting rules. // @param format Formatting rules.
// @param ... Variable number of format parameters. // @param ... Variable number of format parameters.
// @return Number of cells written. // @return Number of cells written.
public native int Format(const char[] buffer, int maxlength, const char[] format, any ...); public native int Format(const char[] buffer, int maxlength, const char[] format, any ...);
// Returns whether a database is the same connection as another database. // Returns whether a database is the same connection as another database.
@ -415,11 +420,11 @@ methodmap Database < Handle
// automatically closed. When the transaction completes, the optional // automatically closed. When the transaction completes, the optional
// callback is invoked. // callback is invoked.
// //
// @param txn A transaction handle. // @param txn A transaction handle.
// @param onSuccess An optional callback to receive a successful transaction. // @param onSuccess An optional callback to receive a successful transaction.
// @param onError An optional callback to receive an error message. // @param onError An optional callback to receive an error message.
// @param data An optional value to pass to callbacks. // @param data An optional value to pass to callbacks.
// @param prio Priority queue to use. // @param prio Priority queue to use.
public native void Execute(Transaction txn, public native void Execute(Transaction txn,
SQLTxnSuccess onSuccess = INVALID_FUNCTION, SQLTxnSuccess onSuccess = INVALID_FUNCTION,
SQLTxnFailure onError = INVALID_FUNCTION, SQLTxnFailure onError = INVALID_FUNCTION,
@ -430,24 +435,24 @@ methodmap Database < Handle
/** /**
* Creates an SQL connection from a named configuration. * Creates an SQL connection from a named configuration.
* *
* @param confname Named configuration. * @param confname Named configuration.
* @param persistent True to re-use a previous persistent connection if * @param persistent True to re-use a previous persistent connection if
* possible, false otherwise. * possible, false otherwise.
* @param error Error buffer. * @param error Error buffer.
* @param maxlength Maximum length of the error buffer. * @param maxlength Maximum length of the error buffer.
* @return A database connection Handle, or INVALID_HANDLE on failure. * @return A database connection Handle, or INVALID_HANDLE on failure.
*/ */
native Database SQL_Connect(const char[] confname, bool persistent, char[] error, int maxlength); native Database SQL_Connect(const char[] confname, bool persistent, char[] error, int maxlength);
/** /**
* Creates a default SQL connection. * Creates a default SQL connection.
* *
* @param error Error buffer. * @param error Error buffer.
* @param maxlength Maximum length of the error buffer. * @param maxlength Maximum length of the error buffer.
* @param persistent True to re-use a previous persistent connection * @param persistent True to re-use a previous persistent connection
* if possible, false otherwise. * if possible, false otherwise.
* @return A database connection Handle, or INVALID_HANDLE on failure. * @return A database connection Handle, or INVALID_HANDLE on failure.
* On failure the error buffer will be filled with a message. * On failure the error buffer will be filled with a message.
*/ */
stock Database SQL_DefConnect(char[] error, int maxlength, bool persistent=true) stock Database SQL_DefConnect(char[] error, int maxlength, bool persistent=true)
{ {
@ -466,19 +471,19 @@ stock Database SQL_DefConnect(char[] error, int maxlength, bool persistent=true)
* In general it is discouraged to use this function. Connections should go through * In general it is discouraged to use this function. Connections should go through
* databases.cfg for greatest flexibility on behalf of users. * databases.cfg for greatest flexibility on behalf of users.
* *
* @param keyvalues Key/value pairs from a KeyValues handle, describing the connection. * @param keyvalues Key/value pairs from a KeyValues handle, describing the connection.
* @param error Error buffer. * @param error Error buffer.
* @param maxlength Maximum length of the error buffer. * @param maxlength Maximum length of the error buffer.
* @param persistent True to re-use a previous persistent connection if * @param persistent True to re-use a previous persistent connection if
* possible, false otherwise. * possible, false otherwise.
* @return A database connection Handle, or INVALID_HANDLE on failure. * @return A database connection Handle, or INVALID_HANDLE on failure.
* On failure the error buffer will be filled with a message. * On failure the error buffer will be filled with a message.
* @error Invalid KeyValues handle. * @error Invalid KeyValues handle.
*/ */
native Database SQL_ConnectCustom(Handle keyvalues, native Database SQL_ConnectCustom(Handle keyvalues,
char[] error, char[] error,
int maxlength, int maxlength,
bool persistent); bool persistent);
/** /**
* Grabs a handle to an SQLite database, creating one if it does not exist. * Grabs a handle to an SQLite database, creating one if it does not exist.
@ -489,15 +494,13 @@ native Database SQL_ConnectCustom(Handle keyvalues,
* As a precaution, you should always create some sort of unique prefix to your table names so * As a precaution, you should always create some sort of unique prefix to your table names so
* there are no conflicts, and you should never drop or modify tables that you do not own. * there are no conflicts, and you should never drop or modify tables that you do not own.
* *
* @param database Database name. * @param database Database name.
* @param error Error buffer. * @param error Error buffer.
* @param maxlength Maximum length of the error buffer. * @param maxlength Maximum length of the error buffer.
* @return A database connection Handle, or INVALID_HANDLE on failure. * @return A database connection Handle, or INVALID_HANDLE on failure.
* On failure the error buffer will be filled with a message. * On failure the error buffer will be filled with a message.
*/ */
stock Database SQLite_UseDatabase(const char[] database, stock Database SQLite_UseDatabase(const char[] database, char[] error, int maxlength)
char[] error,
int maxlength)
{ {
KeyValues kv = new KeyValues(""); KeyValues kv = new KeyValues("");
kv.SetString("driver", "sqlite"); kv.SetString("driver", "sqlite");
@ -512,6 +515,7 @@ stock Database SQLite_UseDatabase(const char[] database,
/** /**
* This function is deprecated. Use SQL_ConnectCustom or SQLite_UseDatabase instead. * This function is deprecated. Use SQL_ConnectCustom or SQLite_UseDatabase instead.
* @deprecated
*/ */
#pragma deprecated Use SQL_ConnectCustom instead. #pragma deprecated Use SQL_ConnectCustom instead.
native Handle SQL_ConnectEx(Handle driver, native Handle SQL_ConnectEx(Handle driver,
@ -528,8 +532,8 @@ native Handle SQL_ConnectEx(Handle driver,
/** /**
* Returns if a named configuration is present in databases.cfg. * Returns if a named configuration is present in databases.cfg.
* *
* @param name Configuration name. * @param name Configuration name.
* @return True if it exists, false otherwise. * @return True if it exists, false otherwise.
*/ */
native bool SQL_CheckConfig(const char[] name); native bool SQL_CheckConfig(const char[] name);
@ -539,19 +543,19 @@ native bool SQL_CheckConfig(const char[] name);
* If the driver is not found, SourceMod will attempt * If the driver is not found, SourceMod will attempt
* to load an extension named dbi.<name>.ext.[dll|so]. * to load an extension named dbi.<name>.ext.[dll|so].
* *
* @param name Driver identification string, or an empty * @param name Driver identification string, or an empty
* string to return the default driver. * string to return the default driver.
* @return Driver Handle, or INVALID_HANDLE on failure. * @return Driver Handle, or INVALID_HANDLE on failure.
*/ */
native Handle SQL_GetDriver(const char[] name=""); native Handle SQL_GetDriver(const char[] name="");
/** /**
* Reads the driver of an opened database. * Reads the driver of an opened database.
* *
* @param database Database Handle. * @param database Database Handle.
* @param ident Option buffer to store the identification string. * @param ident Option buffer to store the identification string.
* @param ident_length Maximum length of the buffer. * @param ident_length Maximum length of the buffer.
* @return Driver Handle. * @return Driver Handle.
*/ */
native Handle SQL_ReadDriver(Handle database, char[] ident="", int ident_length=0); native Handle SQL_ReadDriver(Handle database, char[] ident="", int ident_length=0);
@ -560,10 +564,10 @@ native Handle SQL_ReadDriver(Handle database, char[] ident="", int ident_length=
* *
* Example: "mysql", "sqlite" * Example: "mysql", "sqlite"
* *
* @param driver Driver Handle, or INVALID_HANDLE for the default driver. * @param driver Driver Handle, or INVALID_HANDLE for the default driver.
* @param ident Identification string buffer. * @param ident Identification string buffer.
* @param maxlength Maximum length of the buffer. * @param maxlength Maximum length of the buffer.
* @error Invalid Handle other than INVALID_HANDLE. * @error Invalid Handle other than INVALID_HANDLE.
*/ */
native void SQL_GetDriverIdent(Handle driver, char[] ident, int maxlength); native void SQL_GetDriverIdent(Handle driver, char[] ident, int maxlength);
@ -572,10 +576,10 @@ native void SQL_GetDriverIdent(Handle driver, char[] ident, int maxlength);
* *
* Example: "MySQL", "SQLite" * Example: "MySQL", "SQLite"
* *
* @param driver Driver Handle, or INVALID_HANDLE for the default driver. * @param driver Driver Handle, or INVALID_HANDLE for the default driver.
* @param product Product string buffer. * @param product Product string buffer.
* @param maxlength Maximum length of the buffer. * @param maxlength Maximum length of the buffer.
* @error Invalid Handle other than INVALID_HANDLE. * @error Invalid Handle other than INVALID_HANDLE.
*/ */
native void SQL_GetDriverProduct(Handle driver, char[] product, int maxlength); native void SQL_GetDriverProduct(Handle driver, char[] product, int maxlength);
@ -594,29 +598,29 @@ native bool SQL_SetCharset(Handle database, const char[] charset);
/** /**
* Returns the number of affected rows from the last query. * Returns the number of affected rows from the last query.
* *
* @param hndl A database OR statement Handle. * @param hndl A database OR statement Handle.
* @return Number of rows affected by the last query. * @return Number of rows affected by the last query.
* @error Invalid database or statement Handle. * @error Invalid database or statement Handle.
*/ */
native int SQL_GetAffectedRows(Handle hndl); native int SQL_GetAffectedRows(Handle hndl);
/** /**
* Returns the last query's insertion id. * Returns the last query's insertion id.
* *
* @param hndl A database, query, OR statement Handle. * @param hndl A database, query, OR statement Handle.
* @return Last query's insertion id. * @return Last query's insertion id.
* @error Invalid database, query, or statement Handle. * @error Invalid database, query, or statement Handle.
*/ */
native int SQL_GetInsertId(Handle hndl); native int SQL_GetInsertId(Handle hndl);
/** /**
* Returns the error reported by the last query. * Returns the error reported by the last query.
* *
* @param hndl A database, query, OR statement Handle. * @param hndl A database, query, OR statement Handle.
* @param error Error buffer. * @param error Error buffer.
* @param maxlength Maximum length of the buffer. * @param maxlength Maximum length of the buffer.
* @return True if there was an error, false otherwise. * @return True if there was an error, false otherwise.
* @error Invalid database, query, or statement Handle. * @error Invalid database, query, or statement Handle.
*/ */
native bool SQL_GetError(Handle hndl, char[] error, int maxlength); native bool SQL_GetError(Handle hndl, char[] error, int maxlength);
@ -634,14 +638,14 @@ native bool SQL_GetError(Handle hndl, char[] error, int maxlength);
* encloses the string in ''. While drivers tend to allow " instead, the string * encloses the string in ''. While drivers tend to allow " instead, the string
* may be not be escaped (for example, on SQLite)! * may be not be escaped (for example, on SQLite)!
* *
* @param database A database Handle. * @param database A database Handle.
* @param string String to quote. * @param string String to quote.
* @param buffer Buffer to store quoted string in. * @param buffer Buffer to store quoted string in.
* @param maxlength Maximum length of the buffer. * @param maxlength Maximum length of the buffer.
* @param written Optionally returns the number of bytes written. * @param written Optionally returns the number of bytes written.
* @return True on success, false if buffer is not big enough. * @return True on success, false if buffer is not big enough.
* The buffer must be at least 2*strlen(string)+1. * The buffer must be at least 2*strlen(string)+1.
* @error Invalid database or statement Handle. * @error Invalid database or statement Handle.
*/ */
native bool SQL_EscapeString(Handle database, native bool SQL_EscapeString(Handle database,
const char[] string, const char[] string,
@ -653,17 +657,18 @@ native bool SQL_EscapeString(Handle database,
* Formats a string according to the SourceMod format rules (see documentation). * Formats a string according to the SourceMod format rules (see documentation).
* All format specifiers are escaped (see SQL_EscapeString) unless the '!' flag is used. * All format specifiers are escaped (see SQL_EscapeString) unless the '!' flag is used.
* *
* @param database A database Handle. * @param database A database Handle.
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer. * @param maxlength Maximum length of output string buffer.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @return Number of cells written. * @return Number of cells written.
*/ */
native int SQL_FormatQuery(Handle database, const char[] buffer, int maxlength, const char[] format, any ...); native int SQL_FormatQuery(Handle database, const char[] buffer, int maxlength, const char[] format, any ...);
/** /**
* This function is deprecated. Use SQL_EscapeString instead. * This function is deprecated. Use SQL_EscapeString instead.
* @deprecated
*/ */
#pragma deprecated Use SQL_EscapeString instead. #pragma deprecated Use SQL_EscapeString instead.
stock bool SQL_QuoteString(Handle database, stock bool SQL_QuoteString(Handle database,
@ -678,14 +683,14 @@ stock bool SQL_QuoteString(Handle database,
/** /**
* Executes a query and ignores the result set. * Executes a query and ignores the result set.
* *
* @param database A database Handle. * @param database A database Handle.
* @param query Query string. * @param query Query string.
* @param len Optional parameter to specify the query length, in * @param len Optional parameter to specify the query length, in
* bytes. This can be used to send binary queries that * bytes. This can be used to send binary queries that
* have a premature terminator. * have a premature terminator.
* @return True if query succeeded, false otherwise. Use * @return True if query succeeded, false otherwise. Use
* SQL_GetError to find the last error. * SQL_GetError to find the last error.
* @error Invalid database Handle. * @error Invalid database Handle.
*/ */
native bool SQL_FastQuery(Handle database, const char[] query, int len=-1); native bool SQL_FastQuery(Handle database, const char[] query, int len=-1);
@ -693,14 +698,14 @@ native bool SQL_FastQuery(Handle database, const char[] query, int len=-1);
* Executes a simple query and returns a new query Handle for * Executes a simple query and returns a new query Handle for
* receiving the results. * receiving the results.
* *
* @param database A database Handle. * @param database A database Handle.
* @param query Query string. * @param query Query string.
* @param len Optional parameter to specify the query length, in * @param len Optional parameter to specify the query length, in
* bytes. This can be used to send binary queries that * bytes. This can be used to send binary queries that
* have a premature terminator. * have a premature terminator.
* @return A new Query Handle on success, INVALID_HANDLE * @return A new Query Handle on success, INVALID_HANDLE
* otherwise. The Handle must be freed with CloseHandle(). * otherwise. The Handle must be freed with CloseHandle().
* @error Invalid database Handle. * @error Invalid database Handle.
*/ */
native DBResultSet SQL_Query(Handle database, const char[] query, int len=-1); native DBResultSet SQL_Query(Handle database, const char[] query, int len=-1);
@ -712,13 +717,13 @@ native DBResultSet SQL_Query(Handle database, const char[] query, int len=-1);
* *
* Statement handles will work in any function that accepts a Query handle. * Statement handles will work in any function that accepts a Query handle.
* *
* @param database A database Handle. * @param database A database Handle.
* @param query Query string. * @param query Query string.
* @param error Error buffer. * @param error Error buffer.
* @param maxlength Maximum size of the error buffer. * @param maxlength Maximum size of the error buffer.
* @return A new statement Handle on success, INVALID_HANDLE * @return A new statement Handle on success, INVALID_HANDLE
* otherwise. The Handle must be freed with CloseHandle(). * otherwise. The Handle must be freed with CloseHandle().
* @error Invalid database Handle. * @error Invalid database Handle.
*/ */
native DBStatement SQL_PrepareQuery(Handle database, const char[] query, char[] error, int maxlength); native DBStatement SQL_PrepareQuery(Handle database, const char[] query, char[] error, int maxlength);
@ -730,9 +735,9 @@ native DBStatement SQL_PrepareQuery(Handle database, const char[] query, char[]
* query. If this is the case, all result sets must be processed before * query. If this is the case, all result sets must be processed before
* another query is made. * another query is made.
* *
* @param query A query Handle. * @param query A query Handle.
* @return True if there was another result set, false otherwise. * @return True if there was another result set, false otherwise.
* @error Invalid query Handle. * @error Invalid query Handle.
*/ */
native bool SQL_FetchMoreResults(Handle query); native bool SQL_FetchMoreResults(Handle query);
@ -741,50 +746,50 @@ native bool SQL_FetchMoreResults(Handle query);
* return true even if 0 results were returned, but false * return true even if 0 results were returned, but false
* on queries like UPDATE, INSERT, or DELETE. * on queries like UPDATE, INSERT, or DELETE.
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @return True if there is a result set, false otherwise. * @return True if there is a result set, false otherwise.
* @error Invalid query Handle. * @error Invalid query Handle.
*/ */
native bool SQL_HasResultSet(Handle query); native bool SQL_HasResultSet(Handle query);
/** /**
* Retrieves the number of rows in the last result set. * Retrieves the number of rows in the last result set.
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @return Number of rows in the current result set. * @return Number of rows in the current result set.
* @error Invalid query Handle. * @error Invalid query Handle.
*/ */
native int SQL_GetRowCount(Handle query); native int SQL_GetRowCount(Handle query);
/** /**
* Retrieves the number of fields in the last result set. * Retrieves the number of fields in the last result set.
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @return Number of fields in the current result set. * @return Number of fields in the current result set.
* @error Invalid query Handle. * @error Invalid query Handle.
*/ */
native int SQL_GetFieldCount(Handle query); native int SQL_GetFieldCount(Handle query);
/** /**
* Retrieves the name of a field by index. * Retrieves the name of a field by index.
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @param field Field number (starting from 0). * @param field Field number (starting from 0).
* @param name Name buffer. * @param name Name buffer.
* @param maxlength Maximum length of the name buffer. * @param maxlength Maximum length of the name buffer.
* @error Invalid query Handle, invalid field index, or * @error Invalid query Handle, invalid field index, or
* no current result set. * no current result set.
*/ */
native void SQL_FieldNumToName(Handle query, int field, char[] name, int maxlength); native void SQL_FieldNumToName(Handle query, int field, char[] name, int maxlength);
/** /**
* Retrieves a field index by name. * Retrieves a field index by name.
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @param name Name of the field (case sensitive). * @param name Name of the field (case sensitive).
* @param field Variable to store field index in. * @param field Variable to store field index in.
* @return True if found, false if not found. * @return True if found, false if not found.
* @error Invalid query Handle or no current result set. * @error Invalid query Handle or no current result set.
*/ */
native bool SQL_FieldNameToNum(Handle query, const char[] name, int &field); native bool SQL_FieldNameToNum(Handle query, const char[] name, int &field);
@ -795,27 +800,27 @@ native bool SQL_FieldNameToNum(Handle query, const char[] name, int &field);
* If this function fails, SQL_MoreResults() can be used to * If this function fails, SQL_MoreResults() can be used to
* tell if there was an error or the result set is finished. * tell if there was an error or the result set is finished.
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @return True if a row was fetched, false otherwise. * @return True if a row was fetched, false otherwise.
* @error Invalid query Handle. * @error Invalid query Handle.
*/ */
native bool SQL_FetchRow(Handle query); native bool SQL_FetchRow(Handle query);
/** /**
* Returns if there are more rows. * Returns if there are more rows.
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @return True if there are more rows, false otherwise. * @return True if there are more rows, false otherwise.
* @error Invalid query Handle. * @error Invalid query Handle.
*/ */
native bool SQL_MoreRows(Handle query); native bool SQL_MoreRows(Handle query);
/** /**
* Rewinds a result set back to the first result. * Rewinds a result set back to the first result.
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid query Handle or no current result set. * @error Invalid query Handle or no current result set.
*/ */
native bool SQL_Rewind(Handle query); native bool SQL_Rewind(Handle query);
@ -824,15 +829,15 @@ native bool SQL_Rewind(Handle query);
* If the result is NULL, an empty string will be returned. A NULL * If the result is NULL, an empty string will be returned. A NULL
* check can be done with the result parameter, or SQL_IsFieldNull(). * check can be done with the result parameter, or SQL_IsFieldNull().
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @param field The field index (starting from 0). * @param field The field index (starting from 0).
* @param buffer String buffer. * @param buffer String buffer.
* @param maxlength Maximum size of the string buffer. * @param maxlength Maximum size of the string buffer.
* @param result Optional variable to store the status of the return value. * @param result Optional variable to store the status of the return value.
* @return Number of bytes written. * @return Number of bytes written.
* @error Invalid query Handle or field index, invalid * @error Invalid query Handle or field index, invalid
* type conversion requested from the database, * type conversion requested from the database,
* or no current result set. * or no current result set.
*/ */
native int SQL_FetchString(Handle query, int field, char[] buffer, int maxlength, DBResult &result=DBVal_Error); native int SQL_FetchString(Handle query, int field, char[] buffer, int maxlength, DBResult &result=DBVal_Error);
@ -841,13 +846,13 @@ native int SQL_FetchString(Handle query, int field, char[] buffer, int maxlength
* If the result is NULL, a value of 0.0 will be returned. A NULL * If the result is NULL, a value of 0.0 will be returned. A NULL
* check can be done with the result parameter, or SQL_IsFieldNull(). * check can be done with the result parameter, or SQL_IsFieldNull().
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @param field The field index (starting from 0). * @param field The field index (starting from 0).
* @param result Optional variable to store the status of the return value. * @param result Optional variable to store the status of the return value.
* @return A float value. * @return A float value.
* @error Invalid query Handle or field index, invalid * @error Invalid query Handle or field index, invalid
* type conversion requested from the database, * type conversion requested from the database,
* or no current result set. * or no current result set.
*/ */
native float SQL_FetchFloat(Handle query, int field, DBResult &result=DBVal_Error); native float SQL_FetchFloat(Handle query, int field, DBResult &result=DBVal_Error);
@ -856,13 +861,13 @@ native float SQL_FetchFloat(Handle query, int field, DBResult &result=DBVal_Erro
* If the result is NULL, a value of 0 will be returned. A NULL * If the result is NULL, a value of 0 will be returned. A NULL
* check can be done with the result parameter, or SQL_IsFieldNull(). * check can be done with the result parameter, or SQL_IsFieldNull().
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @param field The field index (starting from 0). * @param field The field index (starting from 0).
* @param result Optional variable to store the status of the return value. * @param result Optional variable to store the status of the return value.
* @return An integer value. * @return An integer value.
* @error Invalid query Handle or field index, invalid * @error Invalid query Handle or field index, invalid
* type conversion requested from the database, * type conversion requested from the database,
* or no current result set. * or no current result set.
*/ */
native int SQL_FetchInt(Handle query, int field, DBResult &result=DBVal_Error); native int SQL_FetchInt(Handle query, int field, DBResult &result=DBVal_Error);
@ -870,11 +875,11 @@ native int SQL_FetchInt(Handle query, int field, DBResult &result=DBVal_Error);
* Returns whether a field's data in the current row of a result set is * Returns whether a field's data in the current row of a result set is
* NULL or not. NULL is an SQL type which means "no data." * NULL or not. NULL is an SQL type which means "no data."
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @param field The field index (starting from 0). * @param field The field index (starting from 0).
* @return True if data is NULL, false otherwise. * @return True if data is NULL, false otherwise.
* @error Invalid query Handle or field index, or no * @error Invalid query Handle or field index, or no
* current result set. * current result set.
*/ */
native bool SQL_IsFieldNull(Handle query, int field); native bool SQL_IsFieldNull(Handle query, int field);
@ -884,59 +889,59 @@ native bool SQL_IsFieldNull(Handle query, int field);
* bytes to use. Note that the return value does not include the null * bytes to use. Note that the return value does not include the null
* terminator. * terminator.
* *
* @param query A query (or statement) Handle. * @param query A query (or statement) Handle.
* @param field The field index (starting from 0). * @param field The field index (starting from 0).
* @return Number of bytes for the field's data size. * @return Number of bytes for the field's data size.
* @error Invalid query Handle or field index or no * @error Invalid query Handle or field index or no
* current result set. * current result set.
*/ */
native int SQL_FetchSize(Handle query, int field); native int SQL_FetchSize(Handle query, int field);
/** /**
* Binds a parameter in a prepared statement to a given integer value. * Binds a parameter in a prepared statement to a given integer value.
* *
* @param statement A statement (prepared query) Handle. * @param statement A statement (prepared query) Handle.
* @param param The parameter index (starting from 0). * @param param The parameter index (starting from 0).
* @param number The number to bind. * @param number The number to bind.
* @param signed True to bind the number as signed, false to * @param signed True to bind the number as signed, false to
* bind it as unsigned. * bind it as unsigned.
* @error Invalid statement Handle or parameter index, or * @error Invalid statement Handle or parameter index, or
* SQL error. * SQL error.
*/ */
native void SQL_BindParamInt(Handle statement, int param, int number, bool signed=true); native void SQL_BindParamInt(Handle statement, int param, int number, bool signed=true);
/** /**
* Binds a parameter in a prepared statement to a given float value. * Binds a parameter in a prepared statement to a given float value.
* *
* @param statement A statement (prepared query) Handle. * @param statement A statement (prepared query) Handle.
* @param param The parameter index (starting from 0). * @param param The parameter index (starting from 0).
* @param value The float number to bind. * @param value The float number to bind.
* @error Invalid statement Handle or parameter index, or * @error Invalid statement Handle or parameter index, or
* SQL error. * SQL error.
*/ */
native void SQL_BindParamFloat(Handle statement, int param, float value); native void SQL_BindParamFloat(Handle statement, int param, float value);
/** /**
* Binds a parameter in a prepared statement to a given string value. * Binds a parameter in a prepared statement to a given string value.
* *
* @param statement A statement (prepared query) Handle. * @param statement A statement (prepared query) Handle.
* @param param The parameter index (starting from 0). * @param param The parameter index (starting from 0).
* @param value The string to bind. * @param value The string to bind.
* @param copy Whether or not SourceMod should copy the value * @param copy Whether or not SourceMod should copy the value
* locally if necessary. If the string contents * locally if necessary. If the string contents
* won't change before calling SQL_Execute(), this * won't change before calling SQL_Execute(), this
* can be set to false for optimization. * can be set to false for optimization.
* @error Invalid statement Handle or parameter index, or * @error Invalid statement Handle or parameter index, or
* SQL error. * SQL error.
*/ */
native void SQL_BindParamString(Handle statement, int param, const char[] value, bool copy); native void SQL_BindParamString(Handle statement, int param, const char[] value, bool copy);
/** /**
* Executes a prepared statement. All parameters must be bound beforehand. * Executes a prepared statement. All parameters must be bound beforehand.
* *
* @param statement A statement (prepared query) Handle. * @param statement A statement (prepared query) Handle.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid statement Handle. * @error Invalid statement Handle.
*/ */
native bool SQL_Execute(Handle statement); native bool SQL_Execute(Handle statement);
@ -954,38 +959,40 @@ native bool SQL_Execute(Handle statement);
* If the lock cannot be acquired, the main thread will pause until the * If the lock cannot be acquired, the main thread will pause until the
* threaded operation has concluded. * threaded operation has concluded.
* *
* @param database A database Handle. * @param database A database Handle.
* @error Invalid database Handle. * @error Invalid database Handle.
*/ */
native void SQL_LockDatabase(Handle database); native void SQL_LockDatabase(Handle database);
/** /**
* Unlocks a database so threading operations may continue. * Unlocks a database so threading operations may continue.
* *
* @param database A database Handle. * @param database A database Handle.
* @error Invalid database Handle. * @error Invalid database Handle.
*/ */
native void SQL_UnlockDatabase(Handle database); native void SQL_UnlockDatabase(Handle database);
// General callback for threaded SQL stuff. /**
// * General callback for threaded SQL stuff.
// @param owner Parent object of the Handle (or INVALID_HANDLE if none). *
// @param hndl Handle to the child object (or INVALID_HANDLE if none). * @param owner Parent object of the Handle (or INVALID_HANDLE if none).
// @param error Error string if there was an error. The error could be * @param hndl Handle to the child object (or INVALID_HANDLE if none).
// empty even if an error condition exists, so it is important * @param error Error string if there was an error. The error could be
// to check the actual Handle value instead. * empty even if an error condition exists, so it is important
// @param data Data passed in via the original threaded invocation. * to check the actual Handle value instead.
* @param data Data passed in via the original threaded invocation.
*/
typedef SQLTCallback = function void (Handle owner, Handle hndl, const char[] error, any data); typedef SQLTCallback = function void (Handle owner, Handle hndl, const char[] error, any data);
/** /**
* Tells whether two database handles both point to the same database * Tells whether two database handles both point to the same database
* connection. * connection.
* *
* @param hndl1 First database Handle. * @param hndl1 First database Handle.
* @param hndl2 Second database Handle. * @param hndl2 Second database Handle.
* @return True if the Handles point to the same * @return True if the Handles point to the same
* connection, false otherwise. * connection, false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool SQL_IsSameConnection(Handle hndl1, Handle hndl2); native bool SQL_IsSameConnection(Handle hndl1, Handle hndl2);
@ -997,10 +1004,10 @@ native bool SQL_IsSameConnection(Handle hndl1, Handle hndl2);
* don't (or you mix threaded/non-threaded queries), you should see * don't (or you mix threaded/non-threaded queries), you should see
* SQL_LockDatabase(). * SQL_LockDatabase().
* *
* @param callback Callback; new Handle will be in hndl, owner is the driver. * @param callback Callback; new Handle will be in hndl, owner is the driver.
* If no driver was found, the owner is INVALID_HANDLE. * If no driver was found, the owner is INVALID_HANDLE.
* @param name Database name. * @param name Database name.
* @param data Extra data value to pass to the callback. * @param data Extra data value to pass to the callback.
*/ */
native void SQL_TConnect(SQLTCallback callback, const char[] name="default", any data=0); native void SQL_TConnect(SQLTCallback callback, const char[] name="default", any data=0);
@ -1015,13 +1022,13 @@ native void SQL_TConnect(SQLTCallback callback, const char[] name="default", any
* The query Handle returned through the callback is temporary and destroyed * The query Handle returned through the callback is temporary and destroyed
* at the end of the callback. If you need to hold onto it, use CloneHandle(). * at the end of the callback. If you need to hold onto it, use CloneHandle().
* *
* @param database A database Handle. * @param database A database Handle.
* @param callback Callback; database is in "owner" and the query Handle * @param callback Callback; database is in "owner" and the query Handle
* is passed in "hndl". * is passed in "hndl".
* @param query Query string. * @param query Query string.
* @param data Extra data value to pass to the callback. * @param data Extra data value to pass to the callback.
* @param prio Priority queue to use. * @param prio Priority queue to use.
* @error Invalid database Handle. * @error Invalid database Handle.
*/ */
native void SQL_TQuery(Handle database, SQLTCallback callback, const char[] query, any data=0, DBPriority prio=DBPrio_Normal); native void SQL_TQuery(Handle database, SQLTCallback callback, const char[] query, any data=0, DBPriority prio=DBPrio_Normal);
@ -1038,7 +1045,7 @@ native Transaction SQL_CreateTransaction();
* *
* @param txn A transaction handle. * @param txn A transaction handle.
* @param query Query string. * @param query Query string.
* @param data Extra data value to pass to the final callback. * @param data Extra data value to pass to the final callback.
* @return The index of the query in the transaction's query list. * @return The index of the query in the transaction's query list.
* @error Invalid transaction handle. * @error Invalid transaction handle.
*/ */

View File

@ -40,40 +40,39 @@
*/ */
enum PropType enum PropType
{ {
Prop_Send = 0, /**< This property is networked. */ Prop_Send = 0, /**< This property is networked. */
Prop_Data = 1, /**< This property is for save game data fields. */ Prop_Data = 1 /**< This property is for save game data fields. */
}; };
/** /**
* @section For more information on these, see the HL2SDK (public/edict.h) * @section For more information on these, see the HL2SDK (public/edict.h)
*/ */
#define FL_EDICT_CHANGED (1<<0) /**< Game DLL sets this when the entity state changes #define FL_EDICT_CHANGED (1<<0) /**< Game DLL sets this when the entity state changes
Mutually exclusive with FL_EDICT_PARTIAL_CHANGE. */ Mutually exclusive with FL_EDICT_PARTIAL_CHANGE. */
#define FL_EDICT_FREE (1<<1) /**< this edict if free for reuse */ #define FL_EDICT_FREE (1<<1) /**< this edict if free for reuse */
#define FL_EDICT_FULL (1<<2) /**< this is a full server entity */ #define FL_EDICT_FULL (1<<2) /**< this is a full server entity */
#define FL_EDICT_FULLCHECK (0<<0) /**< call ShouldTransmit() each time, this is a fake flag */ #define FL_EDICT_FULLCHECK (0<<0) /**< call ShouldTransmit() each time, this is a fake flag */
#define FL_EDICT_ALWAYS (1<<3) /**< always transmit this entity */ #define FL_EDICT_ALWAYS (1<<3) /**< always transmit this entity */
#define FL_EDICT_DONTSEND (1<<4) /**< don't transmit this entity */ #define FL_EDICT_DONTSEND (1<<4) /**< don't transmit this entity */
#define FL_EDICT_PVSCHECK (1<<5) /**< always transmit entity, but cull against PVS */ #define FL_EDICT_PVSCHECK (1<<5) /**< always transmit entity, but cull against PVS */
#define FL_EDICT_PENDING_DORMANT_CHECK (1<<6) #define FL_EDICT_PENDING_DORMANT_CHECK (1<<6)
#define FL_EDICT_DIRTY_PVS_INFORMATION (1<<7) #define FL_EDICT_DIRTY_PVS_INFORMATION (1<<7)
#define FL_FULL_EDICT_CHANGED (1<<8) #define FL_FULL_EDICT_CHANGED (1<<8)
enum PropFieldType enum PropFieldType
{ {
PropField_Unsupported, /**< The type is unsupported. */ PropField_Unsupported, /**< The type is unsupported. */
PropField_Integer, /**< Valid for SendProp and Data fields */ PropField_Integer, /**< Valid for SendProp and Data fields */
PropField_Float, /**< Valid for SendProp and Data fields */ PropField_Float, /**< Valid for SendProp and Data fields */
PropField_Entity, /**< Valid for Data fields only (SendProp shows as int) */ PropField_Entity, /**< Valid for Data fields only (SendProp shows as int) */
PropField_Vector, /**< Valid for SendProp and Data fields */ PropField_Vector, /**< Valid for SendProp and Data fields */
PropField_String, /**< Valid for SendProp and Data fields */ PropField_String, /**< Valid for SendProp and Data fields */
PropField_String_T, /**< Valid for Data fields. Read only. PropField_String_T, /**< Valid for Data fields. Read only.
Note that the size of a string_t is dynamic, and Note that the size of a string_t is dynamic, and
thus FindDataMapOffs() will return the constant size thus FindDataMapOffs() will return the constant size
of the string_t container (which is 32 bits right now). of the string_t container (which is 32 bits right now). */
*/ PropField_Variant /**< Valid for Data fields only Type is not known at the field level,
PropField_Variant, /**< Valid for Data fields only Type is not known at the field level, (for this call), but dependent on current field value. */
(for this call), but dependent on current field value. */
}; };
/** /**
@ -87,7 +86,7 @@ enum PropFieldType
* networked entities (maximum edicts), rather than total * networked entities (maximum edicts), rather than total
* maximum entities. * maximum entities.
* *
* @return Maximum number of networked entities. * @return Maximum number of networked entities.
*/ */
native int GetMaxEntities(); native int GetMaxEntities();
@ -98,7 +97,7 @@ native int GetMaxEntities();
* of networked entities (current edicts), rather than total * of networked entities (current edicts), rather than total
* count of current entities. * count of current entities.
* *
* @return Number of entities in the server. * @return Number of entities in the server.
*/ */
native int GetEntityCount(); native int GetEntityCount();
@ -106,75 +105,75 @@ native int GetEntityCount();
* Returns whether or not an entity is valid. Returns false * Returns whether or not an entity is valid. Returns false
* if there is no matching CBaseEntity for this entity index. * if there is no matching CBaseEntity for this entity index.
* *
* @param entity Index of the entity. * @param entity Index of the entity.
* @return True if valid, false otherwise. * @return True if valid, false otherwise.
*/ */
native bool IsValidEntity(int entity); native bool IsValidEntity(int entity);
/** /**
* Returns whether or not an edict index is valid. * Returns whether or not an edict index is valid.
* *
* @param edict Index of the edict. * @param edict Index of the edict.
* @return True if valid, false otherwise. * @return True if valid, false otherwise.
*/ */
native bool IsValidEdict(int edict); native bool IsValidEdict(int edict);
/** /**
* Returns whether or not an entity has a valid networkable edict. * Returns whether or not an entity has a valid networkable edict.
* *
* @param entity Index of the entity. * @param entity Index of the entity.
* @return True if networkable, false if invalid or not networkable. * @return True if networkable, false if invalid or not networkable.
*/ */
native bool IsEntNetworkable(int entity); native bool IsEntNetworkable(int entity);
/** /**
* Creates a new edict (the basis of a networkable entity) * Creates a new edict (the basis of a networkable entity)
* *
* @return Index of the edict, 0 on failure. * @return Index of the edict, 0 on failure.
*/ */
native int CreateEdict(); native int CreateEdict();
/** /**
* Removes an edict from the world. * Removes an edict from the world.
* *
* @param edict Index of the edict. * @param edict Index of the edict.
* @error Invalid edict index. * @error Invalid edict index.
*/ */
native void RemoveEdict(int edict); native void RemoveEdict(int edict);
/** /**
* Marks an entity for deletion. * Marks an entity for deletion.
* *
* @param entity Index of the entity. * @param entity Index of the entity.
* @error Invalid entity index. * @error Invalid entity index.
*/ */
native void RemoveEntity(int entity); native void RemoveEntity(int entity);
/** /**
* Returns the flags on an edict. These are not the same as entity flags. * Returns the flags on an edict. These are not the same as entity flags.
* *
* @param edict Index of the entity. * @param edict Index of the entity.
* @return Edict flags. * @return Edict flags.
* @error Invalid edict index. * @error Invalid edict index.
*/ */
native int GetEdictFlags(int edict); native int GetEdictFlags(int edict);
/** /**
* Sets the flags on an edict. These are not the same as entity flags. * Sets the flags on an edict. These are not the same as entity flags.
* *
* @param edict Index of the entity. * @param edict Index of the entity.
* @param flags Flags to set. * @param flags Flags to set.
* @error Invalid edict index. * @error Invalid edict index.
*/ */
native void SetEdictFlags(int edict, int flags); native void SetEdictFlags(int edict, int flags);
/** /**
* Retrieves an edict classname. * Retrieves an edict classname.
* *
* @param edict Index of the entity. * @param edict Index of the entity.
* @param clsname Buffer to store the classname. * @param clsname Buffer to store the classname.
* @param maxlength Maximum length of the buffer. * @param maxlength Maximum length of the buffer.
* @return True on success, false if there is no classname set. * @return True on success, false if there is no classname set.
*/ */
native bool GetEdictClassname(int edict, char[] clsname, int maxlength); native bool GetEdictClassname(int edict, char[] clsname, int maxlength);
@ -182,11 +181,11 @@ native bool GetEdictClassname(int edict, char[] clsname, int maxlength);
* Retrieves an entity's networkable serverclass name. * Retrieves an entity's networkable serverclass name.
* This is not the same as the classname and is used for networkable state changes. * This is not the same as the classname and is used for networkable state changes.
* *
* @param edict Index of the entity. * @param edict Index of the entity.
* @param clsname Buffer to store the serverclass name. * @param clsname Buffer to store the serverclass name.
* @param maxlength Maximum length of the buffer. * @param maxlength Maximum length of the buffer.
* @return True on success, false if the edict is not networkable. * @return True on success, false if the edict is not networkable.
* @error Invalid edict index. * @error Invalid edict index.
*/ */
native bool GetEntityNetClass(int edict, char[] clsname, int maxlength); native bool GetEntityNetClass(int edict, char[] clsname, int maxlength);
@ -216,10 +215,10 @@ native bool GetEntityNetClass(int edict, char[] clsname, int maxlength);
* and wish for it to be immediately changed over the network. By default this * and wish for it to be immediately changed over the network. By default this
* is not done for offset setting functions. * is not done for offset setting functions.
* *
* @param edict Index to the edict. * @param edict Index to the edict.
* @param offset Offset to mark as changed. If 0, * @param offset Offset to mark as changed. If 0,
* the entire edict is marked as changed. * the entire edict is marked as changed.
* @error Invalid entity or offset out of bounds. * @error Invalid entity or offset out of bounds.
*/ */
native void ChangeEdictState(int edict, int offset = 0); native void ChangeEdictState(int edict, int offset = 0);
@ -227,11 +226,11 @@ native void ChangeEdictState(int edict, int offset = 0);
* Peeks into an entity's object data and retrieves the integer value at * Peeks into an entity's object data and retrieves the integer value at
* the given offset. * the given offset.
* *
* @param entity Edict index. * @param entity Edict index.
* @param offset Offset to use. * @param offset Offset to use.
* @param size Number of bytes to read (valid values are 1, 2, or 4). * @param size Number of bytes to read (valid values are 1, 2, or 4).
* @return Value at the given memory location. * @return Value at the given memory location.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native int GetEntData(int entity, int offset, int size=4); native int GetEntData(int entity, int offset, int size=4);
@ -239,12 +238,12 @@ native int GetEntData(int entity, int offset, int size=4);
* Peeks into an entity's object data and sets the integer value at * Peeks into an entity's object data and sets the integer value at
* the given offset. * the given offset.
* *
* @param entity Edict index. * @param entity Edict index.
* @param offset Offset to use. * @param offset Offset to use.
* @param value Value to set. * @param value Value to set.
* @param size Number of bytes to write (valid values are 1, 2, or 4). * @param size Number of bytes to write (valid values are 1, 2, or 4).
* @param changeState If true, change will be sent over the network. * @param changeState If true, change will be sent over the network.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native void SetEntData(int entity, int offset, any value, int size=4, bool changeState=false); native void SetEntData(int entity, int offset, any value, int size=4, bool changeState=false);
@ -252,10 +251,10 @@ native void SetEntData(int entity, int offset, any value, int size=4, bool chang
* Peeks into an entity's object data and retrieves the float value at * Peeks into an entity's object data and retrieves the float value at
* the given offset. * the given offset.
* *
* @param entity Edict index. * @param entity Edict index.
* @param offset Offset to use. * @param offset Offset to use.
* @return Value at the given memory location. * @return Value at the given memory location.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native float GetEntDataFloat(int entity, int offset); native float GetEntDataFloat(int entity, int offset);
@ -263,11 +262,11 @@ native float GetEntDataFloat(int entity, int offset);
* Peeks into an entity's object data and sets the float value at * Peeks into an entity's object data and sets the float value at
* the given offset. * the given offset.
* *
* @param entity Edict index. * @param entity Edict index.
* @param offset Offset to use. * @param offset Offset to use.
* @param value Value to set. * @param value Value to set.
* @param changeState If true, change will be sent over the network. * @param changeState If true, change will be sent over the network.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native void SetEntDataFloat(int entity, int offset, float value, bool changeState=false); native void SetEntDataFloat(int entity, int offset, float value, bool changeState=false);
@ -281,10 +280,11 @@ native void SetEntDataFloat(int entity, int offset, float value, bool changeStat
* Note: This function makes no attempt to validate the returned * Note: This function makes no attempt to validate the returned
* entity, and in fact, it could be garbage or completely unexpected. * entity, and in fact, it could be garbage or completely unexpected.
* *
* @param entity Edict index. * @param entity Edict index.
* @param offset Offset to use. * @param offset Offset to use.
* @return Entity index at the given location, or 0 if none. * @return Entity index at the given location, or 0 if none.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
* @deprecated Use GetEntDataEnt2() instead.
*/ */
#pragma deprecated Use GetEntDataEnt2() instead. #pragma deprecated Use GetEntDataEnt2() instead.
native int GetEntDataEnt(int entity, int offset); native int GetEntDataEnt(int entity, int offset);
@ -297,11 +297,12 @@ native int GetEntDataEnt(int entity, int offset);
* 0 is also the world entity index. Thus, a property cannot * 0 is also the world entity index. Thus, a property cannot
* be set to the world entity using this native. * be set to the world entity using this native.
* *
* @param entity Edict index. * @param entity Edict index.
* @param offset Offset to use. * @param offset Offset to use.
* @param other Entity index to set, or 0 to clear. * @param other Entity index to set, or 0 to clear.
* @param changeState If true, change will be sent over the network. * @param changeState If true, change will be sent over the network.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
* @deprecated Use SetEntDataEnt2() instead.
*/ */
#pragma deprecated Use SetEntDataEnt2() instead. #pragma deprecated Use SetEntDataEnt2() instead.
native void SetEntDataEnt(int entity, int offset, int other, bool changeState=false); native void SetEntDataEnt(int entity, int offset, int other, bool changeState=false);
@ -314,11 +315,11 @@ native void SetEntDataEnt(int entity, int offset, int other, bool changeState=fa
* handles" (which usually looks like m_h* in properties). These * handles" (which usually looks like m_h* in properties). These
* are not SourceMod Handles, but internal Source structures. * are not SourceMod Handles, but internal Source structures.
* *
* @param entity Edict index. * @param entity Edict index.
* @param offset Offset to use. * @param offset Offset to use.
* @return Entity index at the given location. If there is no entity, * @return Entity index at the given location. If there is no entity,
* or the stored entity is invalid, then -1 is returned. * or the stored entity is invalid, then -1 is returned.
* @error Invalid input entity, or offset out of reasonable bounds. * @error Invalid input entity, or offset out of reasonable bounds.
*/ */
native int GetEntDataEnt2(int entity, int offset); native int GetEntDataEnt2(int entity, int offset);
@ -330,11 +331,11 @@ native int GetEntDataEnt2(int entity, int offset);
* handles" (which usually looks like m_h* in properties). These * handles" (which usually looks like m_h* in properties). These
* are not SourceMod Handles, but internal Source structures. * are not SourceMod Handles, but internal Source structures.
* *
* @param entity Edict index. * @param entity Edict index.
* @param offset Offset to use. * @param offset Offset to use.
* @param other Entity index to set, or -1 to clear. * @param other Entity index to set, or -1 to clear.
* @param changeState If true, change will be sent over the network. * @param changeState If true, change will be sent over the network.
* @error Invalid input entity, or offset out of reasonable bounds. * @error Invalid input entity, or offset out of reasonable bounds.
*/ */
native void SetEntDataEnt2(int entity, int offset, int other, bool changeState=false); native void SetEntDataEnt2(int entity, int offset, int other, bool changeState=false);
@ -342,12 +343,12 @@ native void SetEntDataEnt2(int entity, int offset, int other, bool changeState=f
* Peeks into an entity's object data and retrieves the vector at the * Peeks into an entity's object data and retrieves the vector at the
* given offset. * given offset.
* @note Both a Vector and a QAngle are three floats. This is a * @note Both a Vector and a QAngle are three floats. This is a
* convenience function and will work with both types. * convenience function and will work with both types.
* *
* @param entity Edict index. * @param entity Edict index.
* @param offset Offset to use. * @param offset Offset to use.
* @param vec Vector buffer to store data in. * @param vec Vector buffer to store data in.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native void GetEntDataVector(int entity, int offset, float vec[3]); native void GetEntDataVector(int entity, int offset, float vec[3]);
@ -355,13 +356,13 @@ native void GetEntDataVector(int entity, int offset, float vec[3]);
* Peeks into an entity's object data and sets the vector at the given * Peeks into an entity's object data and sets the vector at the given
* offset. * offset.
* @note Both a Vector and a QAngle are three floats. This is a * @note Both a Vector and a QAngle are three floats. This is a
* convenience function and will work with both types. * convenience function and will work with both types.
* *
* @param entity Edict index. * @param entity Edict index.
* @param offset Offset to use. * @param offset Offset to use.
* @param vec Vector to set. * @param vec Vector to set.
* @param changeState If true, change will be sent over the network. * @param changeState If true, change will be sent over the network.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native void SetEntDataVector(int entity, int offset, const float vec[3], bool changeState=false); native void SetEntDataVector(int entity, int offset, const float vec[3], bool changeState=false);
@ -369,12 +370,12 @@ native void SetEntDataVector(int entity, int offset, const float vec[3], bool ch
* Peeks into an entity's object data and retrieves the string at * Peeks into an entity's object data and retrieves the string at
* the given offset. * the given offset.
* *
* @param entity Edict index. * @param entity Edict index.
* @param offset Offset to use. * @param offset Offset to use.
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlen Maximum length of output string buffer. * @param maxlen Maximum length of output string buffer.
* @return Number of non-null bytes written. * @return Number of non-null bytes written.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native int GetEntDataString(int entity, int offset, char[] buffer, int maxlen); native int GetEntDataString(int entity, int offset, char[] buffer, int maxlen);
@ -382,13 +383,13 @@ native int GetEntDataString(int entity, int offset, char[] buffer, int maxlen);
* Peeks into an entity's object data and sets the string at * Peeks into an entity's object data and sets the string at
* the given offset. * the given offset.
* *
* @param entity Edict index. * @param entity Edict index.
* @param offset Offset to use. * @param offset Offset to use.
* @param buffer String to set. * @param buffer String to set.
* @param maxlen Maximum length of bytes to write. * @param maxlen Maximum length of bytes to write.
* @param changeState If true, change will be sent over the network. * @param changeState If true, change will be sent over the network.
* @return Number of non-null bytes written. * @return Number of non-null bytes written.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native int SetEntDataString(int entity, int offset, const char[] buffer, int maxlen, bool changeState=false); native int SetEntDataString(int entity, int offset, const char[] buffer, int maxlen, bool changeState=false);
@ -406,9 +407,10 @@ native int SetEntDataString(int entity, int offset, const char[] buffer, int max
* should use FindSendPropInfo() instead. An example of such a property is * should use FindSendPropInfo() instead. An example of such a property is
* CTFPlayer::DT_LocalPlayer.m_nDisguiseClass on Team Fortress. * CTFPlayer::DT_LocalPlayer.m_nDisguiseClass on Team Fortress.
* *
* @param cls Classname. * @param cls Classname.
* @param prop Property name. * @param prop Property name.
* @return An offset, or -1 on failure. * @return An offset, or -1 on failure.
* @deprecated Use FindSendPropInfo instead, or HasEntProp if you just want to check for existence.
*/ */
#pragma deprecated Use FindSendPropInfo instead, or HasEntProp if you just want to check for existence. #pragma deprecated Use FindSendPropInfo instead, or HasEntProp if you just want to check for existence.
native int FindSendPropOffs(const char[] cls, const char[] prop); native int FindSendPropOffs(const char[] cls, const char[] prop);
@ -417,18 +419,18 @@ native int FindSendPropOffs(const char[] cls, const char[] prop);
* Given a ServerClass name, finds a networkable send property offset. * Given a ServerClass name, finds a networkable send property offset.
* This information is cached for future calls. * This information is cached for future calls.
* *
* @param cls Classname. * @param cls Classname.
* @param prop Property name. * @param prop Property name.
* @param type Optional parameter to store the type. * @param type Optional parameter to store the type.
* @param num_bits Optional parameter to store the number of bits the field * @param num_bits Optional parameter to store the number of bits the field
* uses, if applicable (otherwise 0 is stored). The number * uses, if applicable (otherwise 0 is stored). The number
* of bits varies for integers and floats, and is always 0 * of bits varies for integers and floats, and is always 0
* for strings. * for strings.
* @param local_offset Optional parameter to store the local offset, as * @param local_offset Optional parameter to store the local offset, as
* FindSendPropOffs() would return. * FindSendPropOffs() would return.
* @return On success, returns an absolutely computed offset. * @return On success, returns an absolutely computed offset.
* If no offset is available, 0 is returned. * If no offset is available, 0 is returned.
* If the property is not found, -1 is returned. * If the property is not found, -1 is returned.
*/ */
native int FindSendPropInfo(const char[] cls, native int FindSendPropInfo(const char[] cls,
const char[] prop, const char[] prop,
@ -440,13 +442,14 @@ native int FindSendPropInfo(const char[] cls,
* Given an entity, finds a datamap property offset. * Given an entity, finds a datamap property offset.
* This information is cached for future calls. * This information is cached for future calls.
* *
* @param entity Entity index. * @param entity Entity index.
* @param prop Property name. * @param prop Property name.
* @param type Optional parameter to store the type. * @param type Optional parameter to store the type.
* @param num_bits Optional parameter to store the number of bits the field * @param num_bits Optional parameter to store the number of bits the field
* uses. The bit count will either be 1 (for boolean) or * uses. The bit count will either be 1 (for boolean) or
* divisible by 8 (including 0 if unknown). * divisible by 8 (including 0 if unknown).
* @return An offset, or -1 on failure. * @return An offset, or -1 on failure.
* @deprecated Use FindDataMapInfo instead, or HasEntProp if you just want to check for existence.
*/ */
#pragma deprecated Use FindDataMapInfo instead, or HasEntProp if you just want to check for existence. #pragma deprecated Use FindDataMapInfo instead, or HasEntProp if you just want to check for existence.
native int FindDataMapOffs(int entity, native int FindDataMapOffs(int entity,
@ -458,15 +461,15 @@ native int FindDataMapOffs(int entity,
* Given an entity, finds a nested datamap property offset. * Given an entity, finds a nested datamap property offset.
* This information is cached for future calls. * This information is cached for future calls.
* *
* @param entity Entity index. * @param entity Entity index.
* @param prop Property name. * @param prop Property name.
* @param type Optional parameter to store the type. * @param type Optional parameter to store the type.
* @param num_bits Optional parameter to store the number of bits the field * @param num_bits Optional parameter to store the number of bits the field
* uses. The bit count will either be 1 (for boolean) or * uses. The bit count will either be 1 (for boolean) or
* divisible by 8 (including 0 if unknown). * divisible by 8 (including 0 if unknown).
* @param local_offset Optional parameter to store the local offset, as * @param local_offset Optional parameter to store the local offset, as
* FindDataMapOffs() would return. * FindDataMapOffs() would return.
* @return An offset, or -1 on failure. * @return An offset, or -1 on failure.
*/ */
native int FindDataMapInfo(int entity, native int FindDataMapInfo(int entity,
const char[] prop, const char[] prop,
@ -477,12 +480,12 @@ native int FindDataMapInfo(int entity,
/** /**
* Wrapper function for finding a send property for a particular entity. * Wrapper function for finding a send property for a particular entity.
* *
* @param ent Entity index. * @param ent Entity index.
* @param prop Property name. * @param prop Property name.
* @param actual Defaults to false for backwards compatibility. * @param actual Defaults to false for backwards compatibility.
* If true, the newer FindSendPropInfo() function * If true, the newer FindSendPropInfo() function
* is used instead. * is used instead.
* @return An offset, or -1 on failure. * @return An offset, or -1 on failure.
*/ */
stock int GetEntSendPropOffs(int ent, const char[] prop, bool actual=false) stock int GetEntSendPropOffs(int ent, const char[] prop, bool actual=false)
{ {
@ -499,32 +502,35 @@ stock int GetEntSendPropOffs(int ent, const char[] prop, bool actual=false)
if (actual) if (actual)
{ {
return offset; return offset;
} else {
return local;
} }
return local;
} }
/** /**
* Checks if an entity property exists on an entity. * Checks if an entity property exists on an entity.
* *
* @param entity Entity/edict index. * @param entity Entity/edict index.
* @param type Property type. * @param type Property type.
* @param prop Property name. * @param prop Property name.
* @return Whether the property exists on the entity. * @return Whether the property exists on the entity.
* @error Invalid entity. * @error Invalid entity.
*/ */
stock bool HasEntProp(int entity, PropType type, const char[] prop) stock bool HasEntProp(int entity, PropType type, const char[] prop)
{ {
if (type == Prop_Data) { if (type == Prop_Data)
{
return (FindDataMapInfo(entity, prop) != -1); return (FindDataMapInfo(entity, prop) != -1);
} }
if (type != Prop_Send) { if (type != Prop_Send)
{
return false; return false;
} }
char cls[64]; char cls[64];
if (!GetEntityNetClass(entity, cls, sizeof(cls))) { if (!GetEntityNetClass(entity, cls, sizeof(cls)))
{
return false; return false;
} }
@ -537,15 +543,15 @@ stock bool HasEntProp(int entity, PropType type, const char[] prop)
* This function is considered safer and more robust over GetEntData, * This function is considered safer and more robust over GetEntData,
* because it performs strict offset checking and typing rules. * because it performs strict offset checking and typing rules.
* *
* @param entity Entity/edict index. * @param entity Entity/edict index.
* @param type Property type. * @param type Property type.
* @param prop Property name. * @param prop Property name.
* @param size Number of bytes to write (valid values are 1, 2, or 4). * @param size Number of bytes to write (valid values are 1, 2, or 4).
* This value is auto-detected, and the size parameter is * This value is auto-detected, and the size parameter is
* only used as a fallback in case detection fails. * only used as a fallback in case detection fails.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @return Value at the given property offset. * @return Value at the given property offset.
* @error Invalid entity or property not found. * @error Invalid entity or property not found.
*/ */
native int GetEntProp(int entity, PropType type, const char[] prop, int size=4, int element=0); native int GetEntProp(int entity, PropType type, const char[] prop, int size=4, int element=0);
@ -555,15 +561,15 @@ native int GetEntProp(int entity, PropType type, const char[] prop, int size=4,
* This function is considered safer and more robust over SetEntData, * This function is considered safer and more robust over SetEntData,
* because it performs strict offset checking and typing rules. * because it performs strict offset checking and typing rules.
* *
* @param entity Entity/edict index. * @param entity Entity/edict index.
* @param type Property type. * @param type Property type.
* @param prop Property name. * @param prop Property name.
* @param value Value to set. * @param value Value to set.
* @param size Number of bytes to write (valid values are 1, 2, or 4). * @param size Number of bytes to write (valid values are 1, 2, or 4).
* This value is auto-detected, and the size parameter is * This value is auto-detected, and the size parameter is
* only used as a fallback in case detection fails. * only used as a fallback in case detection fails.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native void SetEntProp(int entity, PropType type, const char[] prop, any value, int size=4, int element=0); native void SetEntProp(int entity, PropType type, const char[] prop, any value, int size=4, int element=0);
@ -573,12 +579,12 @@ native void SetEntProp(int entity, PropType type, const char[] prop, any value,
* This function is considered safer and more robust over GetEntDataFloat, * This function is considered safer and more robust over GetEntDataFloat,
* because it performs strict offset checking and typing rules. * because it performs strict offset checking and typing rules.
* *
* @param entity Entity/edict index. * @param entity Entity/edict index.
* @param type Property type. * @param type Property type.
* @param prop Property name. * @param prop Property name.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @return Value at the given property offset. * @return Value at the given property offset.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native float GetEntPropFloat(int entity, PropType type, const char[] prop, int element=0); native float GetEntPropFloat(int entity, PropType type, const char[] prop, int element=0);
@ -588,12 +594,12 @@ native float GetEntPropFloat(int entity, PropType type, const char[] prop, int e
* This function is considered safer and more robust over SetEntDataFloat, * This function is considered safer and more robust over SetEntDataFloat,
* because it performs strict offset checking and typing rules. * because it performs strict offset checking and typing rules.
* *
* @param entity Entity/edict index. * @param entity Entity/edict index.
* @param type Property type. * @param type Property type.
* @param prop Property name. * @param prop Property name.
* @param value Value to set. * @param value Value to set.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native void SetEntPropFloat(int entity, PropType type, const char[] prop, float value, int element=0); native void SetEntPropFloat(int entity, PropType type, const char[] prop, float value, int element=0);
@ -603,14 +609,14 @@ native void SetEntPropFloat(int entity, PropType type, const char[] prop, float
* This function is considered safer and more robust over GetEntDataEnt*, * This function is considered safer and more robust over GetEntDataEnt*,
* because it performs strict offset checking and typing rules. * because it performs strict offset checking and typing rules.
* *
* @param entity Entity/edict index. * @param entity Entity/edict index.
* @param type Property type. * @param type Property type.
* @param prop Property name. * @param prop Property name.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @return Entity index at the given property. * @return Entity index at the given property.
* If there is no entity, or the entity is not valid, * If there is no entity, or the entity is not valid,
* then -1 is returned. * then -1 is returned.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native int GetEntPropEnt(int entity, PropType type, const char[] prop, int element=0); native int GetEntPropEnt(int entity, PropType type, const char[] prop, int element=0);
@ -620,12 +626,12 @@ native int GetEntPropEnt(int entity, PropType type, const char[] prop, int eleme
* This function is considered safer and more robust over SetEntDataEnt*, * This function is considered safer and more robust over SetEntDataEnt*,
* because it performs strict offset checking and typing rules. * because it performs strict offset checking and typing rules.
* *
* @param entity Entity/edict index. * @param entity Entity/edict index.
* @param type Property type. * @param type Property type.
* @param prop Property name. * @param prop Property name.
* @param other Entity index to set, or -1 to unset. * @param other Entity index to set, or -1 to unset.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
native void SetEntPropEnt(int entity, PropType type, const char[] prop, int other, int element=0); native void SetEntPropEnt(int entity, PropType type, const char[] prop, int other, int element=0);
@ -635,13 +641,13 @@ native void SetEntPropEnt(int entity, PropType type, const char[] prop, int othe
* This function is considered safer and more robust over GetEntDataVector, * This function is considered safer and more robust over GetEntDataVector,
* because it performs strict offset checking and typing rules. * because it performs strict offset checking and typing rules.
* *
* @param entity Entity/edict index. * @param entity Entity/edict index.
* @param type Property type. * @param type Property type.
* @param prop Property name. * @param prop Property name.
* @param vec Vector buffer to store data in. * @param vec Vector buffer to store data in.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @error Invalid entity, property not found, or property not * @error Invalid entity, property not found, or property not
* actually a vector data type. * actually a vector data type.
*/ */
native void GetEntPropVector(int entity, PropType type, const char[] prop, float vec[3], int element=0); native void GetEntPropVector(int entity, PropType type, const char[] prop, float vec[3], int element=0);
@ -651,84 +657,86 @@ native void GetEntPropVector(int entity, PropType type, const char[] prop, float
* This function is considered safer and more robust over SetEntDataVector, * This function is considered safer and more robust over SetEntDataVector,
* because it performs strict offset checking and typing rules. * because it performs strict offset checking and typing rules.
* *
* @param entity Entity/edict index. * @param entity Entity/edict index.
* @param type Property type. * @param type Property type.
* @param prop Property name. * @param prop Property name.
* @param vec Vector to set. * @param vec Vector to set.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @error Invalid entity, property not found, or property not * @error Invalid entity, property not found, or property not
* actually a vector data type. * actually a vector data type.
*/ */
native void SetEntPropVector(int entity, PropType type, const char[] prop, const float vec[3], int element=0); native void SetEntPropVector(int entity, PropType type, const char[] prop, const float vec[3], int element=0);
/** /**
* Gets a network property as a string. * Gets a network property as a string.
* *
* @param entity Edict index. * @param entity Edict index.
* @param type Property type. * @param type Property type.
* @param prop Property to use. * @param prop Property to use.
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlen Maximum length of output string buffer. * @param maxlen Maximum length of output string buffer.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @return Number of non-null bytes written. * @return Number of non-null bytes written.
* @error Invalid entity, offset out of reasonable bounds, or property is not a valid string. * @error Invalid entity, offset out of reasonable bounds, or property is not a valid string.
*/ */
native int GetEntPropString(int entity, PropType type, const char[] prop, char[] buffer, int maxlen, int element=0); native int GetEntPropString(int entity, PropType type, const char[] prop, char[] buffer, int maxlen, int element=0);
/** /**
* Sets a network property as a string. * Sets a network property as a string.
* *
* @param entity Edict index. * @param entity Edict index.
* @param type Property type. * @param type Property type.
* @param prop Property to use. * @param prop Property to use.
* @param buffer String to set. * @param buffer String to set.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @return Number of non-null bytes written. * @return Number of non-null bytes written.
* @error Invalid entity, offset out of reasonable bounds, or property is not a valid string. * @error Invalid entity, offset out of reasonable bounds, or property is not a valid string.
*/ */
native int SetEntPropString(int entity, PropType type, const char[] prop, const char[] buffer, int element=0); native int SetEntPropString(int entity, PropType type, const char[] prop, const char[] buffer, int element=0);
/** /**
* Retrieves the count of values that an entity property's array can store. * Retrieves the count of values that an entity property's array can store.
* *
* @param entity Entity/edict index. * @param entity Entity/edict index.
* @param type Property type. * @param type Property type.
* @param prop Property name. * @param prop Property name.
* @return Size of array (in elements) or 1 if property is not an array. * @return Size of array (in elements) or 1 if property is not an array.
* @error Invalid entity or property not found. * @error Invalid entity or property not found.
*/ */
native int GetEntPropArraySize(int entity, PropType type, const char[] prop); native int GetEntPropArraySize(int entity, PropType type, const char[] prop);
/** /**
* Copies an array of cells from an entity at a given offset. * Copies an array of cells from an entity at a given offset.
* *
* @param entity Entity index. * @param entity Entity index.
* @param offset Offset to use. * @param offset Offset to use.
* @param array Array to read into. * @param array Array to read into.
* @param arraySize Number of values to read. * @param arraySize Number of values to read.
* @param dataSize Size of each value in bytes (1, 2, or 4). * @param dataSize Size of each value in bytes (1, 2, or 4).
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
stock void GetEntDataArray(int entity, int offset, int[] array, int arraySize, int dataSize=4) stock void GetEntDataArray(int entity, int offset, int[] array, int arraySize, int dataSize=4)
{ {
for (int i=0; i<arraySize; i++) for (int i = 0; i < arraySize; i++)
{
array[i] = GetEntData(entity, offset + i*dataSize, dataSize); array[i] = GetEntData(entity, offset + i*dataSize, dataSize);
}
} }
/** /**
* Copies an array of cells to an entity at a given offset. * Copies an array of cells to an entity at a given offset.
* *
* @param entity Entity index. * @param entity Entity index.
* @param offset Offset to use. * @param offset Offset to use.
* @param array Array of values to copy. * @param array Array of values to copy.
* @param arraySize Number of values to copy. * @param arraySize Number of values to copy.
* @param dataSize Size of each value in bytes (1, 2, or 4). * @param dataSize Size of each value in bytes (1, 2, or 4).
* @param changeState True to set the network state as changed; false otherwise. * @param changeState True to set the network state as changed; false otherwise.
* @error Invalid entity or offset out of reasonable bounds. * @error Invalid entity or offset out of reasonable bounds.
*/ */
stock void SetEntDataArray(int entity, int offset, const int[] array, int arraySize, int dataSize=4, bool changeState=false) stock void SetEntDataArray(int entity, int offset, const int[] array, int arraySize, int dataSize=4, bool changeState=false)
{ {
for (int i=0; i<arraySize; i++) for (int i = 0; i < arraySize; i++)
{ {
SetEntData(entity, offset + i*dataSize, array[i], dataSize, changeState); SetEntData(entity, offset + i*dataSize, array[i], dataSize, changeState);
} }
@ -737,9 +745,9 @@ stock void SetEntDataArray(int entity, int offset, const int[] array, int arrayS
/** /**
* Gets the memory address of an entity. * Gets the memory address of an entity.
* *
* @param entity Entity index. * @param entity Entity index.
* @return Address of the entity. * @return Address of the entity.
* @error Invalid entity. * @error Invalid entity.
*/ */
native Address GetEntityAddress(int entity); native Address GetEntityAddress(int entity);
@ -748,10 +756,10 @@ native Address GetEntityAddress(int entity);
* This is like GetEdictClassname(), except it works for ALL * This is like GetEdictClassname(), except it works for ALL
* entities, not just edicts. * entities, not just edicts.
* *
* @param entity Index of the entity. * @param entity Index of the entity.
* @param clsname Buffer to store the classname. * @param clsname Buffer to store the classname.
* @param maxlength Maximum length of the buffer. * @param maxlength Maximum length of the buffer.
* @return True on success, false if there is no classname set. * @return True on success, false if there is no classname set.
*/ */
stock bool GetEntityClassname(int entity, char[] clsname, int maxlength) stock bool GetEntityClassname(int entity, char[] clsname, int maxlength)
{ {

View File

@ -37,33 +37,33 @@
enum MoveType enum MoveType
{ {
MOVETYPE_NONE = 0, /**< never moves */ MOVETYPE_NONE = 0, /**< never moves */
MOVETYPE_ISOMETRIC, /**< For players */ MOVETYPE_ISOMETRIC, /**< For players */
MOVETYPE_WALK, /**< Player only - moving on the ground */ MOVETYPE_WALK, /**< Player only - moving on the ground */
MOVETYPE_STEP, /**< gravity, special edge handling -- monsters use this */ MOVETYPE_STEP, /**< gravity, special edge handling -- monsters use this */
MOVETYPE_FLY, /**< No gravity, but still collides with stuff */ MOVETYPE_FLY, /**< No gravity, but still collides with stuff */
MOVETYPE_FLYGRAVITY, /**< flies through the air + is affected by gravity */ MOVETYPE_FLYGRAVITY, /**< flies through the air + is affected by gravity */
MOVETYPE_VPHYSICS, /**< uses VPHYSICS for simulation */ MOVETYPE_VPHYSICS, /**< uses VPHYSICS for simulation */
MOVETYPE_PUSH, /**< no clip to world, push and crush */ MOVETYPE_PUSH, /**< no clip to world, push and crush */
MOVETYPE_NOCLIP, /**< No gravity, no collisions, still do velocity/avelocity */ MOVETYPE_NOCLIP, /**< No gravity, no collisions, still do velocity/avelocity */
MOVETYPE_LADDER, /**< Used by players only when going onto a ladder */ MOVETYPE_LADDER, /**< Used by players only when going onto a ladder */
MOVETYPE_OBSERVER, /**< Observer movement, depends on player's observer mode */ MOVETYPE_OBSERVER, /**< Observer movement, depends on player's observer mode */
MOVETYPE_CUSTOM, /**< Allows the entity to describe its own physics */ MOVETYPE_CUSTOM /**< Allows the entity to describe its own physics */
}; };
enum RenderMode enum RenderMode
{ {
RENDER_NORMAL, /**< src */ RENDER_NORMAL, /**< src */
RENDER_TRANSCOLOR, /**< c*a+dest*(1-a) */ RENDER_TRANSCOLOR, /**< c*a+dest*(1-a) */
RENDER_TRANSTEXTURE, /**< src*a+dest*(1-a) */ RENDER_TRANSTEXTURE, /**< src*a+dest*(1-a) */
RENDER_GLOW, /**< src*a+dest -- No Z buffer checks -- Fixed size in screen space */ RENDER_GLOW, /**< src*a+dest -- No Z buffer checks -- Fixed size in screen space */
RENDER_TRANSALPHA, /**< src*srca+dest*(1-srca) */ RENDER_TRANSALPHA, /**< src*srca+dest*(1-srca) */
RENDER_TRANSADD, /**< src*a+dest */ RENDER_TRANSADD, /**< src*a+dest */
RENDER_ENVIRONMENTAL, /**< not drawn, used for environmental effects */ RENDER_ENVIRONMENTAL, /**< not drawn, used for environmental effects */
RENDER_TRANSADDFRAMEBLEND, /**< use a fractional frame value to blend between animation frames */ RENDER_TRANSADDFRAMEBLEND, /**< use a fractional frame value to blend between animation frames */
RENDER_TRANSALPHAADD, /**< src + dest*(1-a) */ RENDER_TRANSALPHAADD, /**< src + dest*(1-a) */
RENDER_WORLDGLOW, /**< Same as kRenderGlow but not fixed size in screen space */ RENDER_WORLDGLOW, /**< Same as kRenderGlow but not fixed size in screen space */
RENDER_NONE, /**< Don't render. */ RENDER_NONE /**< Don't render. */
}; };
enum RenderFx enum RenderFx
@ -83,86 +83,86 @@ enum RenderFx
RENDERFX_FLICKER_SLOW, RENDERFX_FLICKER_SLOW,
RENDERFX_FLICKER_FAST, RENDERFX_FLICKER_FAST,
RENDERFX_NO_DISSIPATION, RENDERFX_NO_DISSIPATION,
RENDERFX_DISTORT, /**< Distort/scale/translate flicker */ RENDERFX_DISTORT, /**< Distort/scale/translate flicker */
RENDERFX_HOLOGRAM, /**< kRenderFxDistort + distance fade */ RENDERFX_HOLOGRAM, /**< kRenderFxDistort + distance fade */
RENDERFX_EXPLODE, /**< Scale up really big! */ RENDERFX_EXPLODE, /**< Scale up really big! */
RENDERFX_GLOWSHELL, /**< Glowing Shell */ RENDERFX_GLOWSHELL, /**< Glowing Shell */
RENDERFX_CLAMP_MIN_SCALE, /**< Keep this sprite from getting very small (SPRITES only!) */ RENDERFX_CLAMP_MIN_SCALE, /**< Keep this sprite from getting very small (SPRITES only!) */
RENDERFX_ENV_RAIN, /**< for environmental rendermode, make rain */ RENDERFX_ENV_RAIN, /**< for environmental rendermode, make rain */
RENDERFX_ENV_SNOW, /**< " " " , make snow */ RENDERFX_ENV_SNOW, /**< " " " , make snow */
RENDERFX_SPOTLIGHT, /**< TEST CODE for experimental spotlight */ RENDERFX_SPOTLIGHT, /**< TEST CODE for experimental spotlight */
RENDERFX_RAGDOLL, /**< HACKHACK: TEST CODE for signalling death of a ragdoll character */ RENDERFX_RAGDOLL, /**< HACKHACK: TEST CODE for signalling death of a ragdoll character */
RENDERFX_PULSE_FAST_WIDER, RENDERFX_PULSE_FAST_WIDER,
RENDERFX_MAX RENDERFX_MAX
}; };
// These defines are for client button presses. // These defines are for client button presses.
#define IN_ATTACK (1 << 0) #define IN_ATTACK (1 << 0)
#define IN_JUMP (1 << 1) #define IN_JUMP (1 << 1)
#define IN_DUCK (1 << 2) #define IN_DUCK (1 << 2)
#define IN_FORWARD (1 << 3) #define IN_FORWARD (1 << 3)
#define IN_BACK (1 << 4) #define IN_BACK (1 << 4)
#define IN_USE (1 << 5) #define IN_USE (1 << 5)
#define IN_CANCEL (1 << 6) #define IN_CANCEL (1 << 6)
#define IN_LEFT (1 << 7) #define IN_LEFT (1 << 7)
#define IN_RIGHT (1 << 8) #define IN_RIGHT (1 << 8)
#define IN_MOVELEFT (1 << 9) #define IN_MOVELEFT (1 << 9)
#define IN_MOVERIGHT (1 << 10) #define IN_MOVERIGHT (1 << 10)
#define IN_ATTACK2 (1 << 11) #define IN_ATTACK2 (1 << 11)
#define IN_RUN (1 << 12) #define IN_RUN (1 << 12)
#define IN_RELOAD (1 << 13) #define IN_RELOAD (1 << 13)
#define IN_ALT1 (1 << 14) #define IN_ALT1 (1 << 14)
#define IN_ALT2 (1 << 15) #define IN_ALT2 (1 << 15)
#define IN_SCORE (1 << 16) /**< Used by client.dll for when scoreboard is held down */ #define IN_SCORE (1 << 16) /**< Used by client.dll for when scoreboard is held down */
#define IN_SPEED (1 << 17) /**< Player is holding the speed key */ #define IN_SPEED (1 << 17) /**< Player is holding the speed key */
#define IN_WALK (1 << 18) /**< Player holding walk key */ #define IN_WALK (1 << 18) /**< Player holding walk key */
#define IN_ZOOM (1 << 19) /**< Zoom key for HUD zoom */ #define IN_ZOOM (1 << 19) /**< Zoom key for HUD zoom */
#define IN_WEAPON1 (1 << 20) /**< weapon defines these bits */ #define IN_WEAPON1 (1 << 20) /**< weapon defines these bits */
#define IN_WEAPON2 (1 << 21) /**< weapon defines these bits */ #define IN_WEAPON2 (1 << 21) /**< weapon defines these bits */
#define IN_BULLRUSH (1 << 22) #define IN_BULLRUSH (1 << 22)
#define IN_GRENADE1 (1 << 23) /**< grenade 1 */ #define IN_GRENADE1 (1 << 23) /**< grenade 1 */
#define IN_GRENADE2 (1 << 24) /**< grenade 2 */ #define IN_GRENADE2 (1 << 24) /**< grenade 2 */
#define IN_ATTACK3 (1 << 25) #define IN_ATTACK3 (1 << 25)
// Note: these are only for use with GetEntityFlags and SetEntityFlags // Note: these are only for use with GetEntityFlags and SetEntityFlags
// and may not match the game's actual, internal m_fFlags values. // and may not match the game's actual, internal m_fFlags values.
// PLAYER SPECIFIC FLAGS FIRST BECAUSE WE USE ONLY A FEW BITS OF NETWORK PRECISION // PLAYER SPECIFIC FLAGS FIRST BECAUSE WE USE ONLY A FEW BITS OF NETWORK PRECISION
#define FL_ONGROUND (1 << 0) /**< At rest / on the ground */ #define FL_ONGROUND (1 << 0) /**< At rest / on the ground */
#define FL_DUCKING (1 << 1) /**< Player flag -- Player is fully crouched */ #define FL_DUCKING (1 << 1) /**< Player flag -- Player is fully crouched */
#define FL_WATERJUMP (1 << 2) /**< player jumping out of water */ #define FL_WATERJUMP (1 << 2) /**< player jumping out of water */
#define FL_ONTRAIN (1 << 3) /**< Player is _controlling_ a train, so movement commands should be ignored on client during prediction. */ #define FL_ONTRAIN (1 << 3) /**< Player is _controlling_ a train, so movement commands should be ignored on client during prediction. */
#define FL_INRAIN (1 << 4) /**< Indicates the entity is standing in rain */ #define FL_INRAIN (1 << 4) /**< Indicates the entity is standing in rain */
#define FL_FROZEN (1 << 5) /**< Player is frozen for 3rd person camera */ #define FL_FROZEN (1 << 5) /**< Player is frozen for 3rd person camera */
#define FL_ATCONTROLS (1 << 6) /**< Player can't move, but keeps key inputs for controlling another entity */ #define FL_ATCONTROLS (1 << 6) /**< Player can't move, but keeps key inputs for controlling another entity */
#define FL_CLIENT (1 << 7) /**< Is a player */ #define FL_CLIENT (1 << 7) /**< Is a player */
#define FL_FAKECLIENT (1 << 8) /**< Fake client, simulated server side; don't send network messages to them */ #define FL_FAKECLIENT (1 << 8) /**< Fake client, simulated server side; don't send network messages to them */
// NOTE if you move things up, make sure to change this value // NOTE if you move things up, make sure to change this value
#define PLAYER_FLAG_BITS 9 #define PLAYER_FLAG_BITS 9
// NON-PLAYER SPECIFIC (i.e., not used by GameMovement or the client .dll ) -- Can still be applied to players, though // NON-PLAYER SPECIFIC (i.e., not used by GameMovement or the client .dll ) -- Can still be applied to players, though
#define FL_INWATER (1 << 9) /**< In water */ #define FL_INWATER (1 << 9) /**< In water */
#define FL_FLY (1 << 10) /**< Changes the SV_Movestep() behavior to not need to be on ground */ #define FL_FLY (1 << 10) /**< Changes the SV_Movestep() behavior to not need to be on ground */
#define FL_SWIM (1 << 11) /**< Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) */ #define FL_SWIM (1 << 11) /**< Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) */
#define FL_CONVEYOR (1 << 12) #define FL_CONVEYOR (1 << 12)
#define FL_NPC (1 << 13) #define FL_NPC (1 << 13)
#define FL_GODMODE (1 << 14) #define FL_GODMODE (1 << 14)
#define FL_NOTARGET (1 << 15) #define FL_NOTARGET (1 << 15)
#define FL_AIMTARGET (1 << 16) /**< set if the crosshair needs to aim onto the entity */ #define FL_AIMTARGET (1 << 16) /**< set if the crosshair needs to aim onto the entity */
#define FL_PARTIALGROUND (1 << 17) /**< not all corners are valid */ #define FL_PARTIALGROUND (1 << 17) /**< not all corners are valid */
#define FL_STATICPROP (1 << 18) /**< Eetsa static prop! */ #define FL_STATICPROP (1 << 18) /**< Eetsa static prop! */
#define FL_GRAPHED (1 << 19) /**< worldgraph has this ent listed as something that blocks a connection */ #define FL_GRAPHED (1 << 19) /**< worldgraph has this ent listed as something that blocks a connection */
#define FL_GRENADE (1 << 20) #define FL_GRENADE (1 << 20)
#define FL_STEPMOVEMENT (1 << 21) /**< Changes the SV_Movestep() behavior to not do any processing */ #define FL_STEPMOVEMENT (1 << 21) /**< Changes the SV_Movestep() behavior to not do any processing */
#define FL_DONTTOUCH (1 << 22) /**< Doesn't generate touch functions, generates Untouch() for anything it was touching when this flag was set */ #define FL_DONTTOUCH (1 << 22) /**< Doesn't generate touch functions, generates Untouch() for anything it was touching when this flag was set */
#define FL_BASEVELOCITY (1 << 23) /**< Base velocity has been applied this frame (used to convert base velocity into momentum) */ #define FL_BASEVELOCITY (1 << 23) /**< Base velocity has been applied this frame (used to convert base velocity into momentum) */
#define FL_WORLDBRUSH (1 << 24) /**< Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something) */ #define FL_WORLDBRUSH (1 << 24) /**< Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something) */
#define FL_OBJECT (1 << 25) /**< Terrible name. This is an object that NPCs should see. Missiles, for example. */ #define FL_OBJECT (1 << 25) /**< Terrible name. This is an object that NPCs should see. Missiles, for example. */
#define FL_KILLME (1 << 26) /**< This entity is marked for death -- will be freed by game DLL */ #define FL_KILLME (1 << 26) /**< This entity is marked for death -- will be freed by game DLL */
#define FL_ONFIRE (1 << 27) /**< You know... */ #define FL_ONFIRE (1 << 27) /**< You know... */
#define FL_DISSOLVING (1 << 28) /**< We're dissolving! */ #define FL_DISSOLVING (1 << 28) /**< We're dissolving! */
#define FL_TRANSRAGDOLL (1 << 29) /**< In the process of turning into a client side ragdoll. */ #define FL_TRANSRAGDOLL (1 << 29) /**< In the process of turning into a client side ragdoll. */
#define FL_UNBLOCKABLE_BY_PLAYER (1 << 30) /**< pusher that can't be blocked by the player */ #define FL_UNBLOCKABLE_BY_PLAYER (1 << 30) /**< pusher that can't be blocked by the player */
#define FL_FREEZING (1 << 31) /**< We're becoming frozen! */ #define FL_FREEZING (1 << 31) /**< We're becoming frozen! */
#define FL_EP2V_UNKNOWN1 (1 << 31) /**< Unknown */ #define FL_EP2V_UNKNOWN1 (1 << 31) /**< Unknown */
// END entity flag #defines // END entity flag #defines
/** /**
@ -172,9 +172,9 @@ enum RenderFx
* to match the entity flags defined above as the actual values * to match the entity flags defined above as the actual values
* can differ per engine. * can differ per engine.
* *
* @param entity Entity index. * @param entity Entity index.
* @return Entity's flags, see entity flag defines above. * @return Entity's flags, see entity flag defines above.
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
native int GetEntityFlags(int entity); native int GetEntityFlags(int entity);
@ -185,9 +185,9 @@ native int GetEntityFlags(int entity);
* to match the current game's expected value for the flags as * to match the current game's expected value for the flags as
* the actual values can differ per engine. * the actual values can differ per engine.
* *
* @param entity Entity index. * @param entity Entity index.
* @param flags Entity flags, see entity flag defines above. * @param flags Entity flags, see entity flag defines above.
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
native void SetEntityFlags(int entity, int flags); native void SetEntityFlags(int entity, int flags);
@ -195,9 +195,9 @@ native void SetEntityFlags(int entity, int flags);
/** /**
* Gets an entity's movetype. * Gets an entity's movetype.
* *
* @param entity Entity index. * @param entity Entity index.
* @return Movetype, see enum above. * @return Movetype, see enum above.
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
stock MoveType GetEntityMoveType(int entity) stock MoveType GetEntityMoveType(int entity)
{ {
@ -224,9 +224,9 @@ stock MoveType GetEntityMoveType(int entity)
/** /**
* Sets an entity's movetype. * Sets an entity's movetype.
* *
* @param entity Entity index. * @param entity Entity index.
* @param mt Movetype, see enum above. * @param mt Movetype, see enum above.
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
stock void SetEntityMoveType(int entity, MoveType mt) stock void SetEntityMoveType(int entity, MoveType mt)
{ {
@ -253,9 +253,9 @@ stock void SetEntityMoveType(int entity, MoveType mt)
/** /**
* Gets an entity's render mode. * Gets an entity's render mode.
* *
* @param entity Entity index. * @param entity Entity index.
* @return RenderMode value. * @return RenderMode value.
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
stock RenderMode GetEntityRenderMode(int entity) stock RenderMode GetEntityRenderMode(int entity)
{ {
@ -282,9 +282,9 @@ stock RenderMode GetEntityRenderMode(int entity)
/** /**
* Sets an entity's render mode. * Sets an entity's render mode.
* *
* @param entity Entity index. * @param entity Entity index.
* @param mode RenderMode value. * @param mode RenderMode value.
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
stock void SetEntityRenderMode(int entity, RenderMode mode) stock void SetEntityRenderMode(int entity, RenderMode mode)
{ {
@ -311,9 +311,9 @@ stock void SetEntityRenderMode(int entity, RenderMode mode)
/** /**
* Gets an entity's render Fx. * Gets an entity's render Fx.
* *
* @param entity Entity index. * @param entity Entity index.
* @return RenderFx value. * @return RenderFx value.
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
stock RenderFx GetEntityRenderFx(int entity) stock RenderFx GetEntityRenderFx(int entity)
{ {
@ -340,9 +340,9 @@ stock RenderFx GetEntityRenderFx(int entity)
/** /**
* Sets an entity's render Fx. * Sets an entity's render Fx.
* *
* @param entity Entity index. * @param entity Entity index.
* @param fx RenderFx value. * @param fx RenderFx value.
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
stock void SetEntityRenderFx(int entity, RenderFx fx) stock void SetEntityRenderFx(int entity, RenderFx fx)
{ {
@ -369,12 +369,12 @@ stock void SetEntityRenderFx(int entity, RenderFx fx)
/** /**
* Gets an entity's color. * Gets an entity's color.
* *
* @param entity Entity index. * @param entity Entity index.
* @param r Amount of red (0-255) * @param r Amount of red (0-255)
* @param g Amount of green (0-255) * @param g Amount of green (0-255)
* @param b Amount of blue (0-255) * @param b Amount of blue (0-255)
* @param a Amount of alpha (0-255) * @param a Amount of alpha (0-255)
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
stock void GetEntityRenderColor(int entity, int &r, int &g, int &b, int &a) stock void GetEntityRenderColor(int entity, int &r, int &g, int &b, int &a)
{ {
@ -411,12 +411,12 @@ stock void GetEntityRenderColor(int entity, int &r, int &g, int &b, int &a)
/** /**
* Sets an entity's color. * Sets an entity's color.
* *
* @param entity Entity index * @param entity Entity index
* @param r Amount of red (0-255) * @param r Amount of red (0-255)
* @param g Amount of green (0-255) * @param g Amount of green (0-255)
* @param b Amount of blue (0-255) * @param b Amount of blue (0-255)
* @param a Amount of alpha (0-255) * @param a Amount of alpha (0-255)
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
stock void SetEntityRenderColor(int entity, int r=255, int g=255, int b=255, int a=255) stock void SetEntityRenderColor(int entity, int r=255, int g=255, int b=255, int a=255)
{ {
@ -454,8 +454,8 @@ stock void SetEntityRenderColor(int entity, int r=255, int g=255, int b=255, int
* Gets an entity's gravity. * Gets an entity's gravity.
* *
* @param entity Entity index. * @param entity Entity index.
* @return Entity's m_flGravity value. * @return Entity's m_flGravity value.
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
stock float GetEntityGravity(int entity) stock float GetEntityGravity(int entity)
{ {
@ -482,9 +482,9 @@ stock float GetEntityGravity(int entity)
/** /**
* Sets an entity's gravity. * Sets an entity's gravity.
* *
* @param entity Entity index. * @param entity Entity index.
* @param amount Gravity to set (default = 1.0, half = 0.5, double = 2.0). * @param amount Gravity to set (default = 1.0, half = 0.5, double = 2.0).
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
stock void SetEntityGravity(int entity, float amount) stock void SetEntityGravity(int entity, float amount)
{ {
@ -511,9 +511,9 @@ stock void SetEntityGravity(int entity, float amount)
/** /**
* Sets an entity's health * Sets an entity's health
* *
* @param entity Entity index. * @param entity Entity index.
* @param amount Health amount. * @param amount Health amount.
* @error Invalid entity index, or lack of mod compliance. * @error Invalid entity index, or lack of mod compliance.
*/ */
stock void SetEntityHealth(int entity, int amount) stock void SetEntityHealth(int entity, int amount)
{ {
@ -566,10 +566,10 @@ stock void SetEntityHealth(int entity, int amount)
/** /**
* Get's a users current pressed buttons * Get's a users current pressed buttons
* *
* @param client Client index * @param client Client index
* @return Bitsum of buttons * @return Bitsum of buttons
* @error Invalid client index, client not in game, * @error Invalid client index, client not in game,
* or lack of mod compliance. * or lack of mod compliance.
*/ */
stock int GetClientButtons(int client) stock int GetClientButtons(int client)
{ {

View File

@ -40,9 +40,9 @@
*/ */
enum EventHookMode enum EventHookMode
{ {
EventHookMode_Pre, //< Hook callback fired before event is fired */ EventHookMode_Pre, //< Hook callback fired before event is fired */
EventHookMode_Post, //< Hook callback fired after event is fired */ EventHookMode_Post, //< Hook callback fired after event is fired */
EventHookMode_PostNoCopy //< Hook callback fired after event is fired, but event data won't be copied */ EventHookMode_PostNoCopy //< Hook callback fired after event is fired, but event data won't be copied */
}; };
/** /**
@ -52,21 +52,22 @@ typeset EventHook
{ {
// Called when a game event is fired. // Called when a game event is fired.
// //
// @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking // @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking
// this event has set the hook mode EventHookMode_PostNoCopy. // this event has set the hook mode EventHookMode_PostNoCopy.
// @param name String containing the name of the event. // @param name String containing the name of the event.
// @param dontBroadcast True if event was not broadcast to clients, false otherwise. // @param dontBroadcast True if event was not broadcast to clients, false otherwise.
// May not correspond to the real value. Use the property BroadcastDisabled. // May not correspond to the real value. Use the property BroadcastDisabled.
// @return Ignored for post hooks. Plugin_Handled will block event if hooked as pre. // @return Ignored for post hooks. Plugin_Handled will block event if hooked as pre.
/// ///
function Action (Event event, const char[] name, bool dontBroadcast); function Action (Event event, const char[] name, bool dontBroadcast);
// //
// Called when a game event is fired. // Called when a game event is fired.
// //
// @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking // @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking
// this event has set the hook mode EventHookMode_PostNoCopy. // this event has set the hook mode EventHookMode_PostNoCopy.
// @param name String containing the name of the event. // @param name String containing the name of the event.
// @param dontBroadcast True if event was not broadcast to clients, false otherwise. // @param dontBroadcast True if event was not broadcast to clients, false otherwise.
/// ///
function void (Event event, const char[] name, bool dontBroadcast); function void (Event event, const char[] name, bool dontBroadcast);
}; };
@ -84,7 +85,7 @@ methodmap Event < Handle
// //
// Unlike Fire, this function DOES NOT close the event Handle. // Unlike Fire, this function DOES NOT close the event Handle.
// //
// @param client Index of client to receive the event.. // @param client Index of client to receive the event..
public native void FireToClient(int client); public native void FireToClient(int client);
// Cancels a previously created game event that has not been fired. This // Cancels a previously created game event that has not been fired. This
@ -168,31 +169,31 @@ methodmap Event < Handle
/** /**
* Creates a hook for when a game event is fired. * Creates a hook for when a game event is fired.
* *
* @param name Name of event. * @param name Name of event.
* @param callback An EventHook function pointer. * @param callback An EventHook function pointer.
* @param mode Optional EventHookMode determining the type of hook. * @param mode Optional EventHookMode determining the type of hook.
* @error Invalid event name or invalid callback function. * @error Invalid event name or invalid callback function.
*/ */
native void HookEvent(const char[] name, EventHook callback, EventHookMode mode=EventHookMode_Post); native void HookEvent(const char[] name, EventHook callback, EventHookMode mode=EventHookMode_Post);
/** /**
* Creates a hook for when a game event is fired. * Creates a hook for when a game event is fired.
* *
* @param name Name of event. * @param name Name of event.
* @param callback An EventHook function pointer. * @param callback An EventHook function pointer.
* @param mode Optional EventHookMode determining the type of hook. * @param mode Optional EventHookMode determining the type of hook.
* @return True if event exists and was hooked successfully, false otherwise. * @return True if event exists and was hooked successfully, false otherwise.
* @error Invalid callback function. * @error Invalid callback function.
*/ */
native bool HookEventEx(const char[] name, EventHook callback, EventHookMode mode=EventHookMode_Post); native bool HookEventEx(const char[] name, EventHook callback, EventHookMode mode=EventHookMode_Post);
/** /**
* Removes a hook for when a game event is fired. * Removes a hook for when a game event is fired.
* *
* @param name Name of event. * @param name Name of event.
* @param callback An EventHook function pointer. * @param callback An EventHook function pointer.
* @param mode Optional EventHookMode determining the type of hook. * @param mode Optional EventHookMode determining the type of hook.
* @error Invalid callback function or no active hook for specified event. * @error Invalid callback function or no active hook for specified event.
*/ */
native void UnhookEvent(const char[] name, EventHook callback, EventHookMode mode=EventHookMode_Post); native void UnhookEvent(const char[] name, EventHook callback, EventHookMode mode=EventHookMode_Post);
@ -202,11 +203,11 @@ native void UnhookEvent(const char[] name, EventHook callback, EventHookMode mod
* The Handle should not be closed via CloseHandle(). It must be closed via * The Handle should not be closed via CloseHandle(). It must be closed via
* event.Fire() or event.Cancel(). * event.Fire() or event.Cancel().
* *
* @param name Name of event. * @param name Name of event.
* @param force If set to true, this forces the event to be created even if it's not being hooked. * @param force If set to true, this forces the event to be created even if it's not being hooked.
* Note that this will not force it if the event doesn't exist at all. * Note that this will not force it if the event doesn't exist at all.
* @return Handle to event. INVALID_HANDLE is returned if the event doesn't exist or isn't * @return Handle to event. INVALID_HANDLE is returned if the event doesn't exist or isn't
being hooked (unless force is true). * being hooked (unless force is true).
*/ */
native Event CreateEvent(const char[] name, bool force=false); native Event CreateEvent(const char[] name, bool force=false);
@ -215,49 +216,49 @@ native Event CreateEvent(const char[] name, bool force=false);
* *
* This function closes the event Handle after completing. * This function closes the event Handle after completing.
* *
* @param event Handle to the event. * @param event Handle to the event.
* @param dontBroadcast Optional boolean that determines if event should be broadcast to clients. * @param dontBroadcast Optional boolean that determines if event should be broadcast to clients.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void FireEvent(Handle event, bool dontBroadcast=false); native void FireEvent(Handle event, bool dontBroadcast=false);
/** /**
* Cancels a previously created game event that has not been fired. * Cancels a previously created game event that has not been fired.
* *
* @param event Handled to the event. * @param event Handled to the event.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void CancelCreatedEvent(Handle event); native void CancelCreatedEvent(Handle event);
/** /**
* Returns the boolean value of a game event's key. * Returns the boolean value of a game event's key.
* *
* @param event Handle to the event. * @param event Handle to the event.
* @param key Name of event key. * @param key Name of event key.
* @param defValue Optional default value to use if the key is not found. * @param defValue Optional default value to use if the key is not found.
* @return The boolean value of the specified event key. * @return The boolean value of the specified event key.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native bool GetEventBool(Handle event, const char[] key, bool defValue=false); native bool GetEventBool(Handle event, const char[] key, bool defValue=false);
/** /**
* Sets the boolean value of a game event's key. * Sets the boolean value of a game event's key.
* *
* @param event Handle to the event. * @param event Handle to the event.
* @param key Name of event key. * @param key Name of event key.
* @param value New boolean value. * @param value New boolean value.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void SetEventBool(Handle event, const char[] key, bool value); native void SetEventBool(Handle event, const char[] key, bool value);
/** /**
* Returns the integer value of a game event's key. * Returns the integer value of a game event's key.
* *
* @param event Handle to the event. * @param event Handle to the event.
* @param key Name of event key. * @param key Name of event key.
* @param defValue Optional default value to use if the key is not found. * @param defValue Optional default value to use if the key is not found.
* @return The integer value of the specified event key. * @return The integer value of the specified event key.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native int GetEventInt(Handle event, const char[] key, int defValue=0); native int GetEventInt(Handle event, const char[] key, int defValue=0);
@ -269,63 +270,63 @@ native int GetEventInt(Handle event, const char[] key, int defValue=0);
* integers, and only refer to how much data will actually be sent * integers, and only refer to how much data will actually be sent
* over the network (if applicable). * over the network (if applicable).
* *
* @param event Handle to the event. * @param event Handle to the event.
* @param key Name of event key. * @param key Name of event key.
* @param value New integer value. * @param value New integer value.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void SetEventInt(Handle event, const char[] key, int value); native void SetEventInt(Handle event, const char[] key, int value);
/** /**
* Returns the floating point value of a game event's key. * Returns the floating point value of a game event's key.
* *
* @param event Handle to the event. * @param event Handle to the event.
* @param key Name of event key. * @param key Name of event key.
* @param defValue Optional default value to use if the key is not found. * @param defValue Optional default value to use if the key is not found.
* @return The floating point value of the specified event key. * @return The floating point value of the specified event key.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native float GetEventFloat(Handle event, const char[] key, float defValue=0.0); native float GetEventFloat(Handle event, const char[] key, float defValue=0.0);
/** /**
* Sets the floating point value of a game event's key. * Sets the floating point value of a game event's key.
* *
* @param event Handle to the event. * @param event Handle to the event.
* @param key Name of event key. * @param key Name of event key.
* @param value New floating point value. * @param value New floating point value.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void SetEventFloat(Handle event, const char[] key, float value); native void SetEventFloat(Handle event, const char[] key, float value);
/** /**
* Retrieves the string value of a game event's key. * Retrieves the string value of a game event's key.
* *
* @param event Handle to the event. * @param event Handle to the event.
* @param key Name of event key. * @param key Name of event key.
* @param value Buffer to store the value of the specified event key. * @param value Buffer to store the value of the specified event key.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @param defValue Optional default value to use if the key is not found. * @param defValue Optional default value to use if the key is not found.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void GetEventString(Handle event, const char[] key, char[] value, int maxlength, const char[] defvalue=""); native void GetEventString(Handle event, const char[] key, char[] value, int maxlength, const char[] defvalue="");
/** /**
* Sets the string value of a game event's key. * Sets the string value of a game event's key.
* *
* @param event Handle to the event. * @param event Handle to the event.
* @param key Name of event key. * @param key Name of event key.
* @param value New string value. * @param value New string value.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void SetEventString(Handle event, const char[] key, const char[] value); native void SetEventString(Handle event, const char[] key, const char[] value);
/** /**
* Retrieves the name of a game event. * Retrieves the name of a game event.
* *
* @param event Handle to the event. * @param event Handle to the event.
* @param name Buffer to store the name of the event. * @param name Buffer to store the name of the event.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void GetEventName(Handle event, char[] name, int maxlength); native void GetEventName(Handle event, char[] name, int maxlength);

View File

@ -57,9 +57,9 @@
*/ */
enum FileType enum FileType
{ {
FileType_Unknown = 0, /* Unknown file type (device/socket) */ FileType_Unknown = 0, /* Unknown file type (device/socket) */
FileType_Directory = 1, /* File is a directory */ FileType_Directory = 1, /* File is a directory */
FileType_File = 2, /* File is a file */ FileType_File = 2 /* File is a file */
}; };
/** /**
@ -67,23 +67,23 @@ enum FileType
*/ */
enum FileTimeMode enum FileTimeMode
{ {
FileTime_LastAccess = 0, /* Last access (does not work on FAT) */ FileTime_LastAccess = 0, /* Last access (does not work on FAT) */
FileTime_Created = 1, /* Creation (does not work on FAT) */ FileTime_Created = 1, /* Creation (does not work on FAT) */
FileTime_LastChange = 2, /* Last modification */ FileTime_LastChange = 2 /* Last modification */
}; };
#define PLATFORM_MAX_PATH 256 /**< Maximum path length. */ #define PLATFORM_MAX_PATH 256 /**< Maximum path length. */
#define SEEK_SET 0 /**< Seek from start. */ #define SEEK_SET 0 /**< Seek from start. */
#define SEEK_CUR 1 /**< Seek from current position. */ #define SEEK_CUR 1 /**< Seek from current position. */
#define SEEK_END 2 /**< Seek from end position. */ #define SEEK_END 2 /**< Seek from end position. */
/** /**
* Path types. * Path types.
*/ */
enum PathType enum PathType
{ {
Path_SM, /**< SourceMod root folder */ Path_SM, /**< SourceMod root folder */
}; };
// A DirectoryListing iterates over the contents of a directory. To obtain a // A DirectoryListing iterates over the contents of a directory. To obtain a
@ -244,12 +244,12 @@ methodmap File < Handle
* directly referencing addons/sourcemod, in case users change the name of their * directly referencing addons/sourcemod, in case users change the name of their
* folder layout. * folder layout.
* *
* @param type Type of path to build as the base. * @param type Type of path to build as the base.
* @param buffer Buffer to store the path. * @param buffer Buffer to store the path.
* @param maxlength Maximum length of buffer. * @param maxlength Maximum length of buffer.
* @param fmt Format string. * @param fmt Format string.
* @param ... Format arguments. * @param ... Format arguments.
* @return Number of bytes written to buffer (not including null terminator). * @return Number of bytes written to buffer (not including null terminator).
*/ */
native int BuildPath(PathType type, char[] buffer, int maxlength, const char[] fmt, any ...); native int BuildPath(PathType type, char[] buffer, int maxlength, const char[] fmt, any ...);
@ -260,13 +260,13 @@ native int BuildPath(PathType type, char[] buffer, int maxlength, const char[] f
* @note Directories Handles can be cloned. * @note Directories Handles can be cloned.
* @note OpenDirectory() supports the "file://" notation. * @note OpenDirectory() supports the "file://" notation.
* *
* @param path Path to open. * @param path Path to open.
* @param use_valve_fs If true, the Valve file system will be used instead. * @param use_valve_fs If true, the Valve file system will be used instead.
* This can be used to find files existing in any of * This can be used to find files existing in any of
* the Valve search paths, rather than solely files * the Valve search paths, rather than solely files
* existing directly in the gamedir. * existing directly in the gamedir.
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
* @return A Handle to the directory, null on error. * @return A Handle to the directory, null on error.
*/ */
native DirectoryListing OpenDirectory(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME"); native DirectoryListing OpenDirectory(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME");
@ -276,12 +276,12 @@ native DirectoryListing OpenDirectory(const char[] path, bool use_valve_fs=false
* @note Contents of buffers are undefined when returning false. * @note Contents of buffers are undefined when returning false.
* @note Both the '.' and '..' automatic directory entries will be retrieved for Windows and Linux. * @note Both the '.' and '..' automatic directory entries will be retrieved for Windows and Linux.
* *
* @param dir Handle to a directory. * @param dir Handle to a directory.
* @param buffer String buffer to hold directory name. * @param buffer String buffer to hold directory name.
* @param maxlength Maximum size of string buffer. * @param maxlength Maximum size of string buffer.
* @param type Optional variable to store the file type. * @param type Optional variable to store the file type.
* @return True on success, false if there are no more files to read. * @return True on success, false if there are no more files to read.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native bool ReadDirEntry(Handle dir, char[] buffer, int maxlength, FileType &type=FileType_Unknown); native bool ReadDirEntry(Handle dir, char[] buffer, int maxlength, FileType &type=FileType_Unknown);
@ -310,116 +310,116 @@ native bool ReadDirEntry(Handle dir, char[] buffer, int maxlength, FileType &typ
* Example: "rb" opens a binary file for writing; "at" opens a text file for * Example: "rb" opens a binary file for writing; "at" opens a text file for
* appending. * appending.
* *
* @param file File to open. * @param file File to open.
* @param mode Open mode. * @param mode Open mode.
* @param use_valve_fs If true, the Valve file system will be used instead. * @param use_valve_fs If true, the Valve file system will be used instead.
* This can be used to find files existing in valve * This can be used to find files existing in valve
* search paths, rather than solely files existing directly * search paths, rather than solely files existing directly
* in the gamedir. * in the gamedir.
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
* @return A File handle, or null if the file could not be opened. * @return A File handle, or null if the file could not be opened.
*/ */
native File OpenFile(const char[] file, const char[] mode, bool use_valve_fs=false, const char[] valve_path_id="GAME"); native File OpenFile(const char[] file, const char[] mode, bool use_valve_fs=false, const char[] valve_path_id="GAME");
/** /**
* Deletes a file. * Deletes a file.
* *
* @param path Path of the file to delete. * @param path Path of the file to delete.
* @param use_valve_fs If true, the Valve file system will be used instead. * @param use_valve_fs If true, the Valve file system will be used instead.
* This can be used to delete files existing in the Valve * This can be used to delete files existing in the Valve
* search path, rather than solely files existing directly * search path, rather than solely files existing directly
* in the gamedir. * in the gamedir.
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
* @return True on success, false on failure or if file not immediately removed. * @return True on success, false on failure or if file not immediately removed.
*/ */
native bool DeleteFile(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH"); native bool DeleteFile(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH");
/** /**
* Reads a line from a text file. * Reads a line from a text file.
* *
* @param hndl Handle to the file. * @param hndl Handle to the file.
* @param buffer String buffer to hold the line. * @param buffer String buffer to hold the line.
* @param maxlength Maximum size of string buffer. * @param maxlength Maximum size of string buffer.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
native bool ReadFileLine(Handle hndl, char[] buffer, int maxlength); native bool ReadFileLine(Handle hndl, char[] buffer, int maxlength);
/** /**
* Reads binary data from a file. * Reads binary data from a file.
* *
* @param hndl Handle to the file. * @param hndl Handle to the file.
* @param items Array to store each item read. * @param items Array to store each item read.
* @param num_items Number of items to read into the array. * @param num_items Number of items to read into the array.
* @param size Size of each element, in bytes, to be read. * @param size Size of each element, in bytes, to be read.
* Valid sizes are 1, 2, or 4. * Valid sizes are 1, 2, or 4.
* @return Number of elements read, or -1 on error. * @return Number of elements read, or -1 on error.
*/ */
native int ReadFile(Handle hndl, int[] items, int num_items, int size); native int ReadFile(Handle hndl, int[] items, int num_items, int size);
/** /**
* Reads a UTF8 or ANSI string from a file. * Reads a UTF8 or ANSI string from a file.
* *
* @param hndl Handle to the file. * @param hndl Handle to the file.
* @param buffer Buffer to store the string. * @param buffer Buffer to store the string.
* @param max_size Maximum size of the string buffer. * @param max_size Maximum size of the string buffer.
* @param read_count If -1, reads until a null terminator is encountered in * @param read_count If -1, reads until a null terminator is encountered in
* the file. Otherwise, read_count bytes are read * the file. Otherwise, read_count bytes are read
* into the buffer provided. In this case the buffer * into the buffer provided. In this case the buffer
* is not explicitly null terminated, and the buffer * is not explicitly null terminated, and the buffer
* will contain any null terminators read from the file. * will contain any null terminators read from the file.
* @return Number of characters written to the buffer, or -1 * @return Number of characters written to the buffer, or -1
* if an error was encountered. * if an error was encountered.
* @error Invalid Handle, or read_count > max_size. * @error Invalid Handle, or read_count > max_size.
*/ */
native int ReadFileString(Handle hndl, char[] buffer, int max_size, int read_count=-1); native int ReadFileString(Handle hndl, char[] buffer, int max_size, int read_count=-1);
/** /**
* Writes binary data to a file. * Writes binary data to a file.
* *
* @param hndl Handle to the file. * @param hndl Handle to the file.
* @param items Array of items to write. The data is read directly. * @param items Array of items to write. The data is read directly.
* That is, in 1 or 2-byte mode, the lower byte(s) in * That is, in 1 or 2-byte mode, the lower byte(s) in
* each cell are used directly, rather than performing * each cell are used directly, rather than performing
* any casts from a 4-byte number to a smaller number. * any casts from a 4-byte number to a smaller number.
* @param num_items Number of items in the array. * @param num_items Number of items in the array.
* @param size Size of each item in the array in bytes. * @param size Size of each item in the array in bytes.
* Valid sizes are 1, 2, or 4. * Valid sizes are 1, 2, or 4.
* @return True on success, false on error. * @return True on success, false on error.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool WriteFile(Handle hndl, const int[] items, int num_items, int size); native bool WriteFile(Handle hndl, const int[] items, int num_items, int size);
/** /**
* Writes a binary string to a file. * Writes a binary string to a file.
* *
* @param hndl Handle to the file. * @param hndl Handle to the file.
* @param buffer String to write. * @param buffer String to write.
* @param term True to append NUL terminator, false otherwise. * @param term True to append NUL terminator, false otherwise.
* @return True on success, false on error. * @return True on success, false on error.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool WriteFileString(Handle hndl, const char[] buffer, bool term); native bool WriteFileString(Handle hndl, const char[] buffer, bool term);
/** /**
* Writes a line of text to a text file. A newline is automatically appended. * Writes a line of text to a text file. A newline is automatically appended.
* *
* @param hndl Handle to the file. * @param hndl Handle to the file.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool WriteFileLine(Handle hndl, const char[] format, any ...); native bool WriteFileLine(Handle hndl, const char[] format, any ...);
/** /**
* Reads a single binary cell from a file. * Reads a single binary cell from a file.
* *
* @param hndl Handle to the file. * @param hndl Handle to the file.
* @param data Variable to store the data read. * @param data Variable to store the data read.
* @param size Size of the data to read in bytes. Valid * @param size Size of the data to read in bytes. Valid
* sizes are 1, 2, or 4 bytes. * sizes are 1, 2, or 4 bytes.
* @return Number of elements read (max 1), or -1 on error. * @return Number of elements read (max 1), or -1 on error.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
stock int ReadFileCell(Handle hndl, int &data, int size) stock int ReadFileCell(Handle hndl, int &data, int size)
{ {
@ -427,7 +427,9 @@ stock int ReadFileCell(Handle hndl, int &data, int size)
int array[1]; int array[1];
if ((ret = ReadFile(hndl, array, 1, size)) == 1) if ((ret = ReadFile(hndl, array, 1, size)) == 1)
{
data = array[0]; data = array[0];
}
return ret; return ret;
} }
@ -435,102 +437,102 @@ stock int ReadFileCell(Handle hndl, int &data, int size)
/** /**
* Writes a single binary cell to a file. * Writes a single binary cell to a file.
* *
* @param hndl Handle to the file. * @param hndl Handle to the file.
* @param data Cell to write to the file. * @param data Cell to write to the file.
* @param size Size of the data to read in bytes. Valid * @param size Size of the data to read in bytes. Valid
* sizes are 1, 2, or 4 bytes. If the size * sizes are 1, 2, or 4 bytes. If the size
* is less than 4 bytes, the data is truncated * is less than 4 bytes, the data is truncated
* rather than casted. That is, only the lower * rather than casted. That is, only the lower
* bits will be read. * bits will be read.
* @return True on success, false on error. * @return True on success, false on error.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
stock bool WriteFileCell(Handle hndl, int data, int size) stock bool WriteFileCell(Handle hndl, int data, int size)
{ {
int array[1]; int array[1];
array[0] = data; array[0] = data;
return WriteFile(hndl, array, 1, size); return WriteFile(hndl, array, 1, size);
} }
/** /**
* Tests if the end of file has been reached. * Tests if the end of file has been reached.
* *
* @param file Handle to the file. * @param file Handle to the file.
* @return True if end of file has been reached, false otherwise. * @return True if end of file has been reached, false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool IsEndOfFile(Handle file); native bool IsEndOfFile(Handle file);
/** /**
* Sets the file position indicator. * Sets the file position indicator.
* *
* @param file Handle to the file. * @param file Handle to the file.
* @param position Position relative to what is specified in whence. * @param position Position relative to what is specified in whence.
* @param where SEEK_ constant value of where to see from. * @param where SEEK_ constant value of where to see from.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool FileSeek(Handle file, int position, int where); native bool FileSeek(Handle file, int position, int where);
/** /**
* Get current position in the file. * Get current position in the file.
* *
* @param file Handle to the file. * @param file Handle to the file.
* @return Value for the file position indicator. * @return Value for the file position indicator.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int FilePosition(Handle file); native int FilePosition(Handle file);
/** /**
* Checks if a file exists. * Checks if a file exists.
* *
* @param path Path to the file. * @param path Path to the file.
* @param use_valve_fs If true, the Valve file system will be used instead. * @param use_valve_fs If true, the Valve file system will be used instead.
* This can be used to find files existing in any of * This can be used to find files existing in any of
* the Valve search paths, rather than solely files * the Valve search paths, rather than solely files
* existing directly in the gamedir. * existing directly in the gamedir.
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
* @return True if the file exists, false otherwise. * @return True if the file exists, false otherwise.
*/ */
native bool FileExists(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME"); native bool FileExists(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME");
/** /**
* Renames a file. * Renames a file.
* *
* @param newpath New path to the file. * @param newpath New path to the file.
* @param oldpath Path to the existing file. * @param oldpath Path to the existing file.
* @param use_valve_fs If true, the Valve file system will be used instead. * @param use_valve_fs If true, the Valve file system will be used instead.
* This can be used to rename files in the game's * This can be used to rename files in the game's
* Valve search paths, rather than directly in the gamedir. * Valve search paths, rather than directly in the gamedir.
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
* @return True on success or use_valve_fs specified, false otherwise. * @return True on success or use_valve_fs specified, false otherwise.
*/ */
native bool RenameFile(const char[] newpath, const char[] oldpath, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH"); native bool RenameFile(const char[] newpath, const char[] oldpath, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH");
/** /**
* Checks if a directory exists. * Checks if a directory exists.
* *
* @param path Path to the directory. * @param path Path to the directory.
* @param use_valve_fs If true, the Valve file system will be used instead. * @param use_valve_fs If true, the Valve file system will be used instead.
* This can be used to find files existing in any of * This can be used to find files existing in any of
* the Valve search paths, rather than solely files * the Valve search paths, rather than solely files
* existing directly in the gamedir. * existing directly in the gamedir.
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
* @return True if the directory exists, false otherwise. * @return True if the directory exists, false otherwise.
*/ */
native bool DirExists(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME"); native bool DirExists(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME");
/** /**
* Get the file size in bytes. * Get the file size in bytes.
* *
* @param path Path to the file. * @param path Path to the file.
* @param use_valve_fs If true, the Valve file system will be used instead. * @param use_valve_fs If true, the Valve file system will be used instead.
* This can be used to find files existing in any of * This can be used to find files existing in any of
* the Valve search paths, rather than solely files * the Valve search paths, rather than solely files
* existing directly in the gamedir. * existing directly in the gamedir.
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
* @return File size in bytes, -1 if file not found. * @return File size in bytes, -1 if file not found.
*/ */
native int FileSize(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME"); native int FileSize(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME");
@ -538,8 +540,8 @@ native int FileSize(const char[] path, bool use_valve_fs=false, const char[] val
* Flushes a file's buffered output; any buffered output * Flushes a file's buffered output; any buffered output
* is immediately written to the file. * is immediately written to the file.
* *
* @param file Handle to the file. * @param file Handle to the file.
* @return True on success or use_valve_fs specified with OpenFile, * @return True on success or use_valve_fs specified with OpenFile,
* otherwise false on failure. * otherwise false on failure.
*/ */
native bool FlushFile(Handle file); native bool FlushFile(Handle file);
@ -548,51 +550,51 @@ native bool FlushFile(Handle file);
* Removes a directory. * Removes a directory.
* @note On most Operating Systems you cannot remove a directory which has files inside it. * @note On most Operating Systems you cannot remove a directory which has files inside it.
* *
* @param path Path to the directory. * @param path Path to the directory.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
native bool RemoveDir(const char[] path); native bool RemoveDir(const char[] path);
#define FPERM_U_READ 0x0100 /* User can read. */ #define FPERM_U_READ 0x0100 /* User can read. */
#define FPERM_U_WRITE 0x0080 /* User can write. */ #define FPERM_U_WRITE 0x0080 /* User can write. */
#define FPERM_U_EXEC 0x0040 /* User can exec. */ #define FPERM_U_EXEC 0x0040 /* User can exec. */
#define FPERM_G_READ 0x0020 /* Group can read. */ #define FPERM_G_READ 0x0020 /* Group can read. */
#define FPERM_G_WRITE 0x0010 /* Group can write. */ #define FPERM_G_WRITE 0x0010 /* Group can write. */
#define FPERM_G_EXEC 0x0008 /* Group can exec. */ #define FPERM_G_EXEC 0x0008 /* Group can exec. */
#define FPERM_O_READ 0x0004 /* Anyone can read. */ #define FPERM_O_READ 0x0004 /* Anyone can read. */
#define FPERM_O_WRITE 0x0002 /* Anyone can write. */ #define FPERM_O_WRITE 0x0002 /* Anyone can write. */
#define FPERM_O_EXEC 0x0001 /* Anyone can exec. */ #define FPERM_O_EXEC 0x0001 /* Anyone can exec. */
/** /**
* Creates a directory. * Creates a directory.
* *
* @param path Path to create. * @param path Path to create.
* @param mode Permissions (default is o=rx,g=rx,u=rwx). Note that folders must have * @param mode Permissions (default is o=rx,g=rx,u=rwx). Note that folders must have
* the execute bit set on Linux. On Windows, the mode is ignored. * the execute bit set on Linux. On Windows, the mode is ignored.
* @param use_valve_fs If true, the Valve file system will be used instead. * @param use_valve_fs If true, the Valve file system will be used instead.
* This can be used to create folders in the game's * This can be used to create folders in the game's
* Valve search paths, rather than directly in the gamedir. * Valve search paths, rather than directly in the gamedir.
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for default. * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for default.
* In this case, mode is ignored. * In this case, mode is ignored.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
native bool CreateDirectory(const char[] path, int mode, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH"); native bool CreateDirectory(const char[] path, int mode, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH");
/** /**
* Changes a file or directories permissions. * Changes a file or directories permissions.
* *
* @param path Path to the file. * @param path Path to the file.
* @param mode Permissions to set. * @param mode Permissions to set.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
native bool SetFilePermissions(const char[] path, int mode); native bool SetFilePermissions(const char[] path, int mode);
/** /**
* Returns a file timestamp as a unix timestamp. * Returns a file timestamp as a unix timestamp.
* *
* @param file File name. * @param file File name.
* @param tmode Time mode. * @param tmode Time mode.
* @return Time value, or -1 on failure. * @return Time value, or -1 on failure.
*/ */
native int GetFileTime(const char[] file, FileTimeMode tmode); native int GetFileTime(const char[] file, FileTimeMode tmode);
@ -600,10 +602,10 @@ native int GetFileTime(const char[] file, FileTimeMode tmode);
* Same as LogToFile(), except uses an open file Handle. The file must * Same as LogToFile(), except uses an open file Handle. The file must
* be opened in text appending mode. * be opened in text appending mode.
* *
* @param hndl Handle to the file. * @param hndl Handle to the file.
* @param message Message format. * @param message Message format.
* @param ... Message format parameters. * @param ... Message format parameters.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void LogToOpenFile(Handle hndl, const char[] message, any ...); native void LogToOpenFile(Handle hndl, const char[] message, any ...);
@ -611,9 +613,9 @@ native void LogToOpenFile(Handle hndl, const char[] message, any ...);
* Same as LogToFileEx(), except uses an open file Handle. The file must * Same as LogToFileEx(), except uses an open file Handle. The file must
* be opened in text appending mode. * be opened in text appending mode.
* *
* @param hndl Handle to the file. * @param hndl Handle to the file.
* @param message Message format. * @param message Message format.
* @param ... Message format parameters. * @param ... Message format parameters.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void LogToOpenFileEx(Handle hndl, const char[] message, any ...); native void LogToOpenFileEx(Handle hndl, const char[] message, any ...);

View File

@ -39,8 +39,8 @@
/** /**
* Converts an integer into a floating point value. * Converts an integer into a floating point value.
* *
* @param value Integer to convert. * @param value Integer to convert.
* @return Floating point value. * @return Floating point value.
*/ */
native float float(int value); native float float(int value);
#endif #endif
@ -50,9 +50,10 @@ native float float(int value);
* *
* Note: This native is internal implementation. For multiplication use the '*' operator. * Note: This native is internal implementation. For multiplication use the '*' operator.
* *
* @param oper1 First value. * @param oper1 First value.
* @param oper2 Second value. * @param oper2 Second value.
* @return oper1*oper2. * @return oper1*oper2.
* @deprecated This native is internal implementation. For multiplication use the '*' operator.
*/ */
#pragma deprecated This native is internal implementation. For multiplication use the '*' operator. #pragma deprecated This native is internal implementation. For multiplication use the '*' operator.
native float FloatMul(float oper1, float oper2); native float FloatMul(float oper1, float oper2);
@ -62,9 +63,10 @@ native float FloatMul(float oper1, float oper2);
* *
* Note: This native is internal implementation. For division use the '/' operator. * Note: This native is internal implementation. For division use the '/' operator.
* *
* @param dividend First value. * @param dividend First value.
* @param divisor Second value. * @param divisor Second value.
* @return dividend/divisor. * @return dividend/divisor.
* @deprecated This native is internal implementation. For division use the '/' operator.
*/ */
#pragma deprecated This native is internal implementation. For division use the '/' operator. #pragma deprecated This native is internal implementation. For division use the '/' operator.
native float FloatDiv(float dividend, float divisor); native float FloatDiv(float dividend, float divisor);
@ -74,9 +76,10 @@ native float FloatDiv(float dividend, float divisor);
* *
* Note: This native is internal implementation. For addition use the '+' operator. * Note: This native is internal implementation. For addition use the '+' operator.
* *
* @param oper1 First value. * @param oper1 First value.
* @param oper2 Second value. * @param oper2 Second value.
* @return oper1+oper2. * @return oper1+oper2.
* @deprecated This native is internal implementation. For addition use the '+' operator.
*/ */
#pragma deprecated This native is internal implementation. For addition use the '+' operator. #pragma deprecated This native is internal implementation. For addition use the '+' operator.
native float FloatAdd(float oper1, float oper2); native float FloatAdd(float oper1, float oper2);
@ -86,9 +89,10 @@ native float FloatAdd(float oper1, float oper2);
* *
* Note: This native is internal implementation. For subtraction use the '-' operator. * Note: This native is internal implementation. For subtraction use the '-' operator.
* *
* @param oper1 First value. * @param oper1 First value.
* @param oper2 Second value. * @param oper2 Second value.
* @return oper1-oper2. * @return oper1-oper2.
* @deprecated This native is internal implementation. For subtraction use the '-' operator.
*/ */
#pragma deprecated This native is internal implementation. For subtraction use the '-' operator. #pragma deprecated This native is internal implementation. For subtraction use the '-' operator.
native float FloatSub(float oper1, float oper2); native float FloatSub(float oper1, float oper2);
@ -96,49 +100,49 @@ native float FloatSub(float oper1, float oper2);
/** /**
* Returns the decimal part of a float. * Returns the decimal part of a float.
* *
* @param value Input value. * @param value Input value.
* @return Decimal part. * @return Decimal part.
*/ */
native float FloatFraction(float value); native float FloatFraction(float value);
/** /**
* Rounds a float to the closest integer to zero. * Rounds a float to the closest integer to zero.
* *
* @param value Input value to be rounded. * @param value Input value to be rounded.
* @return Rounded value. * @return Rounded value.
*/ */
native int RoundToZero(float value); native int RoundToZero(float value);
/** /**
* Rounds a float to the next highest integer value. * Rounds a float to the next highest integer value.
* *
* @param value Input value to be rounded. * @param value Input value to be rounded.
* @return Rounded value. * @return Rounded value.
*/ */
native int RoundToCeil(float value); native int RoundToCeil(float value);
/** /**
* Rounds a float to the next lowest integer value. * Rounds a float to the next lowest integer value.
* *
* @param value Input value to be rounded. * @param value Input value to be rounded.
* @return Rounded value. * @return Rounded value.
*/ */
native int RoundToFloor(float value); native int RoundToFloor(float value);
/** /**
* Standard IEEE rounding. * Standard IEEE rounding.
* *
* @param value Input value to be rounded. * @param value Input value to be rounded.
* @return Rounded value. * @return Rounded value.
*/ */
native int RoundToNearest(float value); native int RoundToNearest(float value);
/** /**
* Compares two floats. * Compares two floats.
* *
* @param fOne First value. * @param fOne First value.
* @param fTwo Second value. * @param fTwo Second value.
* @return Returns 1 if the first argument is greater than the second argument. * @return Returns 1 if the first argument is greater than the second argument.
* Returns -1 if the first argument is smaller than the second argument. * Returns -1 if the first argument is smaller than the second argument.
* Returns 0 if both arguments are equal. * Returns 0 if both arguments are equal.
*/ */
@ -147,107 +151,107 @@ native int FloatCompare(float fOne, float fTwo);
/** /**
* Returns the square root of the input value, equivalent to floatpower(value, 0.5). * Returns the square root of the input value, equivalent to floatpower(value, 0.5).
* *
* @param value Input value. * @param value Input value.
* @return Square root of the value. * @return Square root of the value.
*/ */
native float SquareRoot(float value); native float SquareRoot(float value);
/** /**
* Returns the value raised to the power of the exponent. * Returns the value raised to the power of the exponent.
* *
* @param value Value to be raised. * @param value Value to be raised.
* @param exponent Value to raise the base. * @param exponent Value to raise the base.
* @return value^exponent. * @return value^exponent.
*/ */
native float Pow(float value, float exponent); native float Pow(float value, float exponent);
/** /**
* Returns the value of raising the input by e. * Returns the value of raising the input by e.
* *
* @param value Input value. * @param value Input value.
* @return exp(value). * @return exp(value).
*/ */
native float Exponential(float value); native float Exponential(float value);
/** /**
* Returns the logarithm of any base specified. * Returns the logarithm of any base specified.
* *
* @param value Input value. * @param value Input value.
* @param base Logarithm base to use, default is 10. * @param base Logarithm base to use, default is 10.
* @return log(value)/log(base). * @return log(value)/log(base).
*/ */
native float Logarithm(float value, float base=10.0); native float Logarithm(float value, float base=10.0);
/** /**
* Returns the sine of the argument. * Returns the sine of the argument.
* *
* @param value Input value in radians. * @param value Input value in radians.
* @return sin(value). * @return sin(value).
*/ */
native float Sine(float value); native float Sine(float value);
/** /**
* Returns the cosine of the argument. * Returns the cosine of the argument.
* *
* @param value Input value in radians. * @param value Input value in radians.
* @return cos(value). * @return cos(value).
*/ */
native float Cosine(float value); native float Cosine(float value);
/** /**
* Returns the tangent of the argument. * Returns the tangent of the argument.
* *
* @param value Input value in radians. * @param value Input value in radians.
* @return tan(value). * @return tan(value).
*/ */
native float Tangent(float value); native float Tangent(float value);
/** /**
* Returns an absolute value. * Returns an absolute value.
* *
* @param value Input value. * @param value Input value.
* @return Absolute value of the input. * @return Absolute value of the input.
*/ */
native float FloatAbs(float value); native float FloatAbs(float value);
/** /**
* Returns the arctangent of the input value. * Returns the arctangent of the input value.
* *
* @param angle Input value. * @param angle Input value.
* @return atan(value) in radians. * @return atan(value) in radians.
*/ */
native float ArcTangent(float angle); native float ArcTangent(float angle);
/** /**
* Returns the arccosine of the input value. * Returns the arccosine of the input value.
* *
* @param angle Input value. * @param angle Input value.
* @return acos(value) in radians. * @return acos(value) in radians.
*/ */
native float ArcCosine(float angle); native float ArcCosine(float angle);
/** /**
* Returns the arcsine of the input value. * Returns the arcsine of the input value.
* *
* @param angle Input value. * @param angle Input value.
* @return asin(value) in radians. * @return asin(value) in radians.
*/ */
native float ArcSine(float angle); native float ArcSine(float angle);
/** /**
* Returns the arctangent2 of the input values. * Returns the arctangent2 of the input values.
* *
* @param x Horizontal value. * @param x Horizontal value.
* @param y Vertical value. * @param y Vertical value.
* @return atan2(value) in radians. * @return atan2(value) in radians.
*/ */
native float ArcTangent2(float x, float y); native float ArcTangent2(float x, float y);
/** /**
* Rounds a floating point number using the "round to nearest" algorithm. * Rounds a floating point number using the "round to nearest" algorithm.
* *
* @param value Floating point value to round. * @param value Floating point value to round.
* @return The value rounded to the nearest integer. * @return The value rounded to the nearest integer.
*/ */
stock int RoundFloat(float value) stock int RoundFloat(float value)
{ {
@ -298,14 +302,14 @@ stock float operator--(float oper)
stock float operator-(float oper) stock float operator-(float oper)
{ {
return oper^view_as<float>(cellmin); /* IEEE values are sign/magnitude */ return oper^view_as<float>(cellmin); /* IEEE values are sign/magnitude */
} }
// The stocks below are int->float converting versions of the above natives. // The stocks below are int->float converting versions of the above natives.
stock float operator*(float oper1, int oper2) stock float operator*(float oper1, int oper2)
{ {
return __FLOAT_MUL__(oper1, float(oper2)); /* "*" is commutative */ return __FLOAT_MUL__(oper1, float(oper2)); /* "*" is commutative */
} }
stock float operator/(float oper1, int oper2) stock float operator/(float oper1, int oper2)
@ -320,7 +324,7 @@ stock float operator/(int oper1, float oper2)
stock float operator+(float oper1, int oper2) stock float operator+(float oper1, int oper2)
{ {
return __FLOAT_ADD__(oper1, float(oper2)); /* "+" is commutative */ return __FLOAT_ADD__(oper1, float(oper2)); /* "+" is commutative */
} }
stock float operator-(float oper1, int oper2) stock float operator-(float oper1, int oper2)
@ -396,8 +400,8 @@ forward operator%(int oper1, float oper2);
/** /**
* Converts degrees to radians. * Converts degrees to radians.
* *
* @param angle Degrees. * @param angle Degrees.
* @return Radians. * @return Radians.
*/ */
stock float DegToRad(float angle) stock float DegToRad(float angle)
{ {
@ -407,8 +411,8 @@ stock float DegToRad(float angle)
/** /**
* Converts radians to degrees. * Converts radians to degrees.
* *
* @param angle Radians. * @param angle Radians.
* @return Degrees. * @return Degrees.
*/ */
stock float RadToDeg(float angle) stock float RadToDeg(float angle)
{ {
@ -420,7 +424,7 @@ stock float RadToDeg(float angle)
* *
* Note: Uniform random number streams are seeded automatically per-plugin. * Note: Uniform random number streams are seeded automatically per-plugin.
* *
* @return Random integer. * @return Random integer.
*/ */
native int GetURandomInt(); native int GetURandomInt();
@ -429,7 +433,7 @@ native int GetURandomInt();
* *
* Note: Uniform random number streams are seeded automatically per-plugin. * Note: Uniform random number streams are seeded automatically per-plugin.
* *
* @return Uniform random floating-point number. * @return Uniform random floating-point number.
*/ */
native float GetURandomFloat(); native float GetURandomFloat();
@ -437,8 +441,8 @@ native float GetURandomFloat();
* Seeds a plugin's uniform random number stream. This is done automatically, * Seeds a plugin's uniform random number stream. This is done automatically,
* so normally it is totally unnecessary to call this. * so normally it is totally unnecessary to call this.
* *
* @param seeds Array of numbers to use as seeding data. * @param seeds Array of numbers to use as seeding data.
* @param numSeeds Number of seeds in the seeds array. * @param numSeeds Number of seeds in the seeds array.
*/ */
native void SetURandomSeed(const int[] seeds, int numSeeds); native void SetURandomSeed(const int[] seeds, int numSeeds);

View File

@ -35,21 +35,21 @@
#endif #endif
#define _functions_included #define _functions_included
#define SP_PARAMFLAG_BYREF (1<<0) /**< Internal use only. */ #define SP_PARAMFLAG_BYREF (1<<0) /**< Internal use only. */
/** /**
* Describes the various ways to pass parameters to functions or forwards. * Describes the various ways to pass parameters to functions or forwards.
*/ */
enum ParamType enum ParamType
{ {
Param_Any = 0, /**< Any data type can be pushed */ Param_Any = 0, /**< Any data type can be pushed */
Param_Cell = (1<<1), /**< Only basic cells can be pushed */ Param_Cell = (1<<1), /**< Only basic cells can be pushed */
Param_Float = (2<<1), /**< Only floats can be pushed */ Param_Float = (2<<1), /**< Only floats can be pushed */
Param_String = (3<<1)|SP_PARAMFLAG_BYREF, /**< Only strings can be pushed */ Param_String = (3<<1)|SP_PARAMFLAG_BYREF, /**< Only strings can be pushed */
Param_Array = (4<<1)|SP_PARAMFLAG_BYREF, /**< Only arrays can be pushed */ Param_Array = (4<<1)|SP_PARAMFLAG_BYREF, /**< Only arrays can be pushed */
Param_VarArgs = (5<<1), /**< Same as "..." in plugins, anything can be pushed, but it will always be byref */ Param_VarArgs = (5<<1), /**< Same as "..." in plugins, anything can be pushed, but it will always be byref */
Param_CellByRef = (1<<1)|SP_PARAMFLAG_BYREF, /**< Only a cell by reference can be pushed */ Param_CellByRef = (1<<1)|SP_PARAMFLAG_BYREF, /**< Only a cell by reference can be pushed */
Param_FloatByRef = (2<<1)|SP_PARAMFLAG_BYREF /**< Only a float by reference can be pushed */ Param_FloatByRef = (2<<1)|SP_PARAMFLAG_BYREF /**< Only a float by reference can be pushed */
}; };
/** /**
@ -57,21 +57,21 @@ enum ParamType
*/ */
enum ExecType enum ExecType
{ {
ET_Ignore = 0, /**< Ignore all return values, return 0 */ ET_Ignore = 0, /**< Ignore all return values, return 0 */
ET_Single = 1, /**< Only return the last exec, ignore all others */ ET_Single = 1, /**< Only return the last exec, ignore all others */
ET_Event = 2, /**< Acts as an event with the Actions defined in core.inc, no mid-Stops allowed, returns highest */ ET_Event = 2, /**< Acts as an event with the Actions defined in core.inc, no mid-Stops allowed, returns highest */
ET_Hook = 3 /**< Acts as a hook with the Actions defined in core.inc, mid-Stops allowed, returns highest */ ET_Hook = 3 /**< Acts as a hook with the Actions defined in core.inc, mid-Stops allowed, returns highest */
}; };
/** /**
* @section Flags that are used with Call_PushArrayEx() and Call_PushStringEx() * @section Flags that are used with Call_PushArrayEx() and Call_PushStringEx()
*/ */
#define SM_PARAM_COPYBACK (1<<0) /**< Copy an array/reference back after call */ #define SM_PARAM_COPYBACK (1<<0) /**< Copy an array/reference back after call */
#define SM_PARAM_STRING_UTF8 (1<<0) /**< String should be UTF-8 handled */ #define SM_PARAM_STRING_UTF8 (1<<0) /**< String should be UTF-8 handled */
#define SM_PARAM_STRING_COPY (1<<1) /**< String should be copied into the plugin */ #define SM_PARAM_STRING_COPY (1<<1) /**< String should be copied into the plugin */
#define SM_PARAM_STRING_BINARY (1<<2) /**< Treat the string as a binary string */ #define SM_PARAM_STRING_BINARY (1<<2) /**< Treat the string as a binary string */
/** /**
* @endsection * @endsection
@ -80,32 +80,32 @@ enum ExecType
/** /**
* @section Error codes * @section Error codes
*/ */
#define SP_ERROR_NONE 0 /**< No error occurred */ #define SP_ERROR_NONE 0 /**< No error occurred */
#define SP_ERROR_FILE_FORMAT 1 /**< File format unrecognized */ #define SP_ERROR_FILE_FORMAT 1 /**< File format unrecognized */
#define SP_ERROR_DECOMPRESSOR 2 /**< A decompressor was not found */ #define SP_ERROR_DECOMPRESSOR 2 /**< A decompressor was not found */
#define SP_ERROR_HEAPLOW 3 /**< Not enough space left on the heap */ #define SP_ERROR_HEAPLOW 3 /**< Not enough space left on the heap */
#define SP_ERROR_PARAM 4 /**< Invalid parameter or parameter type */ #define SP_ERROR_PARAM 4 /**< Invalid parameter or parameter type */
#define SP_ERROR_INVALID_ADDRESS 5 /**< A memory address was not valid */ #define SP_ERROR_INVALID_ADDRESS 5 /**< A memory address was not valid */
#define SP_ERROR_NOT_FOUND 6 /**< The object in question was not found */ #define SP_ERROR_NOT_FOUND 6 /**< The object in question was not found */
#define SP_ERROR_INDEX 7 /**< Invalid index parameter */ #define SP_ERROR_INDEX 7 /**< Invalid index parameter */
#define SP_ERROR_STACKLOW 8 /**< Not enough space left on the stack */ #define SP_ERROR_STACKLOW 8 /**< Not enough space left on the stack */
#define SP_ERROR_NOTDEBUGGING 9 /**< Debug mode was not on or debug section not found */ #define SP_ERROR_NOTDEBUGGING 9 /**< Debug mode was not on or debug section not found */
#define SP_ERROR_INVALID_INSTRUCTION 10 /**< Invalid instruction was encountered */ #define SP_ERROR_INVALID_INSTRUCTION 10 /**< Invalid instruction was encountered */
#define SP_ERROR_MEMACCESS 11 /**< Invalid memory access */ #define SP_ERROR_MEMACCESS 11 /**< Invalid memory access */
#define SP_ERROR_STACKMIN 12 /**< Stack went beyond its minimum value */ #define SP_ERROR_STACKMIN 12 /**< Stack went beyond its minimum value */
#define SP_ERROR_HEAPMIN 13 /**< Heap went beyond its minimum value */ #define SP_ERROR_HEAPMIN 13 /**< Heap went beyond its minimum value */
#define SP_ERROR_DIVIDE_BY_ZERO 14 /**< Division by zero */ #define SP_ERROR_DIVIDE_BY_ZERO 14 /**< Division by zero */
#define SP_ERROR_ARRAY_BOUNDS 15 /**< Array index is out of bounds */ #define SP_ERROR_ARRAY_BOUNDS 15 /**< Array index is out of bounds */
#define SP_ERROR_INSTRUCTION_PARAM 16 /**< Instruction had an invalid parameter */ #define SP_ERROR_INSTRUCTION_PARAM 16 /**< Instruction had an invalid parameter */
#define SP_ERROR_STACKLEAK 17 /**< A native leaked an item on the stack */ #define SP_ERROR_STACKLEAK 17 /**< A native leaked an item on the stack */
#define SP_ERROR_HEAPLEAK 18 /**< A native leaked an item on the heap */ #define SP_ERROR_HEAPLEAK 18 /**< A native leaked an item on the heap */
#define SP_ERROR_ARRAY_TOO_BIG 19 /**< A dynamic array is too big */ #define SP_ERROR_ARRAY_TOO_BIG 19 /**< A dynamic array is too big */
#define SP_ERROR_TRACKER_BOUNDS 20 /**< Tracker stack is out of bounds */ #define SP_ERROR_TRACKER_BOUNDS 20 /**< Tracker stack is out of bounds */
#define SP_ERROR_INVALID_NATIVE 21 /**< Native was pending or invalid */ #define SP_ERROR_INVALID_NATIVE 21 /**< Native was pending or invalid */
#define SP_ERROR_PARAMS_MAX 22 /**< Maximum number of parameters reached */ #define SP_ERROR_PARAMS_MAX 22 /**< Maximum number of parameters reached */
#define SP_ERROR_NATIVE 23 /**< Error originates from a native */ #define SP_ERROR_NATIVE 23 /**< Error originates from a native */
#define SP_ERROR_NOT_RUNNABLE 24 /**< Function or plugin is not runnable */ #define SP_ERROR_NOT_RUNNABLE 24 /**< Function or plugin is not runnable */
#define SP_ERROR_ABORTED 25 /**< Function call was aborted */ #define SP_ERROR_ABORTED 25 /**< Function call was aborted */
/** /**
* @endsection * @endsection
@ -114,11 +114,11 @@ enum ExecType
/** /**
* Gets a function id from a function name. * Gets a function id from a function name.
* *
* @param plugin Handle of the plugin that contains the function. * @param plugin Handle of the plugin that contains the function.
Pass INVALID_HANDLE to search in the calling plugin. * Pass INVALID_HANDLE to search in the calling plugin.
* @param name Name of the function. * @param name Name of the function.
* @return Function id or INVALID_FUNCTION if not found. * @return Function id or INVALID_FUNCTION if not found.
* @error Invalid or corrupt plugin handle. * @error Invalid or corrupt plugin handle.
*/ */
native Function GetFunctionByName(Handle plugin, const char[] name); native Function GetFunctionByName(Handle plugin, const char[] name);
@ -130,11 +130,11 @@ native Function GetFunctionByName(Handle plugin, const char[] name);
* @note Global forwards cannot be cloned. * @note Global forwards cannot be cloned.
* @note Use CloseHandle() to destroy these. * @note Use CloseHandle() to destroy these.
* *
* @param name Name of public function to use in forward. * @param name Name of public function to use in forward.
* @param type Execution type to be used. * @param type Execution type to be used.
* @param ... Variable number of parameter types (up to 32). * @param ... Variable number of parameter types (up to 32).
* @return Handle to new global forward. * @return Handle to new global forward.
* @error More than 32 paramater types passed. * @error More than 32 paramater types passed.
*/ */
native Handle CreateGlobalForward(const char[] name, ExecType type, ParamType ...); native Handle CreateGlobalForward(const char[] name, ExecType type, ParamType ...);
@ -145,19 +145,19 @@ native Handle CreateGlobalForward(const char[] name, ExecType type, ParamType ..
* @note Private forwards can be cloned. * @note Private forwards can be cloned.
* @note Use CloseHandle() to destroy these. * @note Use CloseHandle() to destroy these.
* *
* @param type Execution type to be used. * @param type Execution type to be used.
* @param ... Variable number of parameter types (up to 32). * @param ... Variable number of parameter types (up to 32).
* @return Handle to new private forward. * @return Handle to new private forward.
* @error More than 32 paramater types passed. * @error More than 32 paramater types passed.
*/ */
native Handle CreateForward(ExecType type, ParamType ...); native Handle CreateForward(ExecType type, ParamType ...);
/** /**
* Returns the number of functions in a global or private forward's call list. * Returns the number of functions in a global or private forward's call list.
* *
* @param fwd Handle to global or private forward. * @param fwd Handle to global or private forward.
* @return Number of functions in forward. * @return Number of functions in forward.
* @error Invalid or corrupt forward handle. * @error Invalid or corrupt forward handle.
*/ */
native int GetForwardFunctionCount(Handle fwd); native int GetForwardFunctionCount(Handle fwd);
@ -166,12 +166,12 @@ native int GetForwardFunctionCount(Handle fwd);
* *
* @note Cannot be used during an incomplete call. * @note Cannot be used during an incomplete call.
* *
* @param fwd Handle to private forward. * @param fwd Handle to private forward.
* @param plugin Handle of the plugin that contains the function. * @param plugin Handle of the plugin that contains the function.
* Pass INVALID_HANDLE to specify the calling plugin. * Pass INVALID_HANDLE to specify the calling plugin.
* @param func Function to add to forward. * @param func Function to add to forward.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid or corrupt private forward handle, invalid or corrupt plugin handle, or invalid function. * @error Invalid or corrupt private forward handle, invalid or corrupt plugin handle, or invalid function.
*/ */
native bool AddToForward(Handle fwd, Handle plugin, Function func); native bool AddToForward(Handle fwd, Handle plugin, Function func);
@ -181,12 +181,12 @@ native bool AddToForward(Handle fwd, Handle plugin, Function func);
* @note Only removes one instance. * @note Only removes one instance.
* @note Functions will be removed automatically if their parent plugin is unloaded. * @note Functions will be removed automatically if their parent plugin is unloaded.
* *
* @param fwd Handle to private forward. * @param fwd Handle to private forward.
* @param plugin Handle of the plugin that contains the function. * @param plugin Handle of the plugin that contains the function.
* Pass INVALID_HANDLE to specify the calling plugin. * Pass INVALID_HANDLE to specify the calling plugin.
* @param func Function to remove from forward. * @param func Function to remove from forward.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid or corrupt private forward handle, invalid or corrupt plugin handle, or invalid function. * @error Invalid or corrupt private forward handle, invalid or corrupt plugin handle, or invalid function.
*/ */
native bool RemoveFromForward(Handle fwd, Handle plugin, Function func); native bool RemoveFromForward(Handle fwd, Handle plugin, Function func);
@ -195,11 +195,11 @@ native bool RemoveFromForward(Handle fwd, Handle plugin, Function func);
* *
* @note Functions will be removed automatically if their parent plugin is unloaded. * @note Functions will be removed automatically if their parent plugin is unloaded.
* *
* @param fwd Handle to private forward. * @param fwd Handle to private forward.
* @param plugin Handle of the plugin to remove instances of. * @param plugin Handle of the plugin to remove instances of.
* Pass INVALID_HANDLE to specify the calling plugin. * Pass INVALID_HANDLE to specify the calling plugin.
* @return Number of functions removed from forward. * @return Number of functions removed from forward.
* @error Invalid or corrupt private forward handle or invalid or corrupt plugin handle. * @error Invalid or corrupt private forward handle or invalid or corrupt plugin handle.
*/ */
native int RemoveAllFromForward(Handle fwd, Handle plugin); native int RemoveAllFromForward(Handle fwd, Handle plugin);
@ -208,8 +208,8 @@ native int RemoveAllFromForward(Handle fwd, Handle plugin);
* *
* @note Cannot be used during an incomplete call. * @note Cannot be used during an incomplete call.
* *
* @param fwd Handle to global or private forward. * @param fwd Handle to global or private forward.
* @error Invalid or corrupt forward handle or called before another call has completed. * @error Invalid or corrupt forward handle or called before another call has completed.
*/ */
native void Call_StartForward(Handle fwd); native void Call_StartForward(Handle fwd);
@ -218,10 +218,10 @@ native void Call_StartForward(Handle fwd);
* *
* @note Cannot be used during an incomplete call. * @note Cannot be used during an incomplete call.
* *
* @param plugin Handle of the plugin that contains the function. * @param plugin Handle of the plugin that contains the function.
* Pass INVALID_HANDLE to specify the calling plugin. * Pass INVALID_HANDLE to specify the calling plugin.
* @param func Function to call. * @param func Function to call.
* @error Invalid or corrupt plugin handle, invalid function, or called before another call has completed. * @error Invalid or corrupt plugin handle, invalid function, or called before another call has completed.
*/ */
native void Call_StartFunction(Handle plugin, Function func); native void Call_StartFunction(Handle plugin, Function func);
@ -230,8 +230,8 @@ native void Call_StartFunction(Handle plugin, Function func);
* *
* @note Cannot be used before a call has been started. * @note Cannot be used before a call has been started.
* *
* @param value Cell value to push. * @param value Cell value to push.
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native void Call_PushCell(any value); native void Call_PushCell(any value);
@ -240,8 +240,8 @@ native void Call_PushCell(any value);
* *
* @note Cannot be used before a call has been started. * @note Cannot be used before a call has been started.
* *
* @param value Cell reference to push. * @param value Cell reference to push.
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native void Call_PushCellRef(any &value); native void Call_PushCellRef(any &value);
@ -250,8 +250,8 @@ native void Call_PushCellRef(any &value);
* *
* @note Cannot be used before a call has been started. * @note Cannot be used before a call has been started.
* *
* @param value Floating point value to push. * @param value Floating point value to push.
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native void Call_PushFloat(float value); native void Call_PushFloat(float value);
@ -260,8 +260,8 @@ native void Call_PushFloat(float value);
* *
* @note Cannot be used before a call has been started. * @note Cannot be used before a call has been started.
* *
* @param value Floating point reference to push. * @param value Floating point reference to push.
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native void Call_PushFloatRef(float &value); native void Call_PushFloatRef(float &value);
@ -271,9 +271,9 @@ native void Call_PushFloatRef(float &value);
* @note Changes to array are not copied back to caller. Use PushArrayEx() to do this. * @note Changes to array are not copied back to caller. Use PushArrayEx() to do this.
* @note Cannot be used before a call has been started. * @note Cannot be used before a call has been started.
* *
* @param value Array to push. * @param value Array to push.
* @param size Size of array. * @param size Size of array.
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native void Call_PushArray(const any[] value, int size); native void Call_PushArray(const any[] value, int size);
@ -282,11 +282,11 @@ native void Call_PushArray(const any[] value, int size);
* *
* @note Cannot be used before a call has been started. * @note Cannot be used before a call has been started.
* *
* @param value Array to push. * @param value Array to push.
* @param size Size of array. * @param size Size of array.
* @param cpflags Whether or not changes should be copied back to the input array. * @param cpflags Whether or not changes should be copied back to the input array.
* See SP_PARAM_* constants for details. * See SP_PARAM_* constants for details.
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native void Call_PushArrayEx(any[] value, int size, int cpflags); native void Call_PushArrayEx(any[] value, int size, int cpflags);
@ -296,7 +296,7 @@ native void Call_PushArrayEx(any[] value, int size, int cpflags);
* *
* @note Cannot be used before a call has been started. * @note Cannot be used before a call has been started.
* *
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native void Call_PushNullVector(); native void Call_PushNullVector();
@ -306,8 +306,8 @@ native void Call_PushNullVector();
* @note Changes to string are not copied back to caller. Use PushStringEx() to do this. * @note Changes to string are not copied back to caller. Use PushStringEx() to do this.
* @note Cannot be used before a call has been started. * @note Cannot be used before a call has been started.
* *
* @param value String to push. * @param value String to push.
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native void Call_PushString(const char[] value); native void Call_PushString(const char[] value);
@ -316,14 +316,14 @@ native void Call_PushString(const char[] value);
* *
* @note Cannot be used before a call has been started. * @note Cannot be used before a call has been started.
* *
* @param value String to push. * @param value String to push.
* @param length Length of string buffer. * @param length Length of string buffer.
* @param szflags Flags determining how string should be handled. * @param szflags Flags determining how string should be handled.
* See SM_PARAM_STRING_* constants for details. * See SM_PARAM_STRING_* constants for details.
* The default (0) is to push ASCII. * The default (0) is to push ASCII.
* @param cpflags Whether or not changes should be copied back to the input array. * @param cpflags Whether or not changes should be copied back to the input array.
* See SM_PARAM_* constants for details. * See SM_PARAM_* constants for details.
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native void Call_PushStringEx(char[] value, int length, int szflags, int cpflags); native void Call_PushStringEx(char[] value, int length, int szflags, int cpflags);
@ -333,7 +333,7 @@ native void Call_PushStringEx(char[] value, int length, int szflags, int cpflags
* *
* @note Cannot be used before a call has been started. * @note Cannot be used before a call has been started.
* *
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native void Call_PushNullString(); native void Call_PushNullString();
@ -342,9 +342,9 @@ native void Call_PushNullString();
* *
* @note Cannot be used before a call has been started. * @note Cannot be used before a call has been started.
* *
* @param result Return value of function or forward's call list. * @param result Return value of function or forward's call list.
* @return SP_ERROR_NONE on success, any other integer on failure. * @return SP_ERROR_NONE on success, any other integer on failure.
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native int Call_Finish(any &result=0); native int Call_Finish(any &result=0);
@ -353,7 +353,7 @@ native int Call_Finish(any &result=0);
* *
* @note Cannot be used before a call has been started. * @note Cannot be used before a call has been started.
* *
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native void Call_Cancel(); native void Call_Cancel();
@ -364,9 +364,9 @@ typeset NativeCall
* *
* It is not necessary to validate the parameter count * It is not necessary to validate the parameter count
* *
* @param plugin Handle of the calling plugin. * @param plugin Handle of the calling plugin.
* @param numParams Number of parameters passed to the native. * @param numParams Number of parameters passed to the native.
* @return Value for the native call to return. * @return Value for the native call to return.
*/ */
function int (Handle plugin, int numParams); function int (Handle plugin, int numParams);
@ -375,9 +375,9 @@ typeset NativeCall
* *
* It is not necessary to validate the parameter count * It is not necessary to validate the parameter count
* *
* @param plugin Handle of the calling plugin. * @param plugin Handle of the calling plugin.
* @param numParams Number of parameters passed to the native. * @param numParams Number of parameters passed to the native.
* @return Value for the native call to return. * @return Value for the native call to return.
*/ */
function any (Handle plugin, int numParams); function any (Handle plugin, int numParams);
} }
@ -386,67 +386,70 @@ typeset NativeCall
* Creates a dynamic native. This should only be called in AskPluginLoad(), or * Creates a dynamic native. This should only be called in AskPluginLoad(), or
* else you risk not having your native shared with other plugins. * else you risk not having your native shared with other plugins.
* *
* @param name Name of the dynamic native; must be unique among * @param name Name of the dynamic native; must be unique among
* all other registered dynamic natives. * all other registered dynamic natives.
* @param func Function to use as the dynamic native. * @param func Function to use as the dynamic native.
*/ */
native void CreateNative(const char[] name, NativeCall func); native void CreateNative(const char[] name, NativeCall func);
/** /**
* Throws an error in the calling plugin of a native, instead of your own plugin. * Throws an error in the calling plugin of a native, instead of your own plugin.
* *
* @param error Error code to use. * @param error Error code to use.
* @param fmt Error message format. * @param fmt Error message format.
* @param ... Format arguments. * @param ... Format arguments.
*/ */
native int ThrowNativeError(int error, const char[] fmt, any ...); native int ThrowNativeError(int error, const char[] fmt, any ...);
/** /**
* Retrieves the string length from a native parameter string. This is useful * Retrieves the string length from a native parameter string. This is useful for
* fetching the entire string using dynamic arrays. * fetching the entire string using dynamic arrays.
*
* @note If this function succeeds, Get/SetNativeString will also succeed. * @note If this function succeeds, Get/SetNativeString will also succeed.
* *
* @param param Parameter number, starting from 1. * @param param Parameter number, starting from 1.
* @param length Stores the length of the string. * @param length Stores the length of the string.
* @return SP_ERROR_NONE on success, any other integer on failure. * @return SP_ERROR_NONE on success, any other integer on failure.
* @error Invalid parameter number or calling from a non-native function. * @error Invalid parameter number or calling from a non-native function.
*/ */
native int GetNativeStringLength(int param, int &length); native int GetNativeStringLength(int param, int &length);
/** /**
* Retrieves a string from a native parameter. * Retrieves a string from a native parameter.
*
* @note Output conditions are undefined on failure. * @note Output conditions are undefined on failure.
* *
* @param param Parameter number, starting from 1. * @param param Parameter number, starting from 1.
* @param buffer Buffer to store the string in. * @param buffer Buffer to store the string in.
* @param maxlength Maximum length of the buffer. * @param maxlength Maximum length of the buffer.
* @param bytes Optionally store the number of bytes written. * @param bytes Optionally store the number of bytes written.
* @return SP_ERROR_NONE on success, any other integer on failure. * @return SP_ERROR_NONE on success, any other integer on failure.
* @error Invalid parameter number or calling from a non-native function. * @error Invalid parameter number or calling from a non-native function.
*/ */
native int GetNativeString(int param, char[] buffer, int maxlength, int &bytes=0); native int GetNativeString(int param, char[] buffer, int maxlength, int &bytes=0);
/** /**
* Sets a string in a native parameter. * Sets a string in a native parameter.
*
* @note Output conditions are undefined on failure. * @note Output conditions are undefined on failure.
* *
* @param param Parameter number, starting from 1. * @param param Parameter number, starting from 1.
* @param source Source string to use. * @param source Source string to use.
* @param maxlength Maximum number of bytes to write. * @param maxlength Maximum number of bytes to write.
* @param utf8 If false, string will not be written * @param utf8 If false, string will not be written
* with UTF8 safety. * with UTF8 safety.
* @param bytes Optionally store the number of bytes written. * @param bytes Optionally store the number of bytes written.
* @return SP_ERROR_NONE on success, any other integer on failure. * @return SP_ERROR_NONE on success, any other integer on failure.
* @error Invalid parameter number or calling from a non-native function. * @error Invalid parameter number or calling from a non-native function.
*/ */
native int SetNativeString(int param, const char[] source, int maxlength, bool utf8=true, int &bytes=0); native int SetNativeString(int param, const char[] source, int maxlength, bool utf8=true, int &bytes=0);
/** /**
* Gets a cell from a native parameter. * Gets a cell from a native parameter.
* *
* @param param Parameter number, starting from 1. * @param param Parameter number, starting from 1.
* @return Cell value at the parameter number. * @return Cell value at the parameter number.
* @error Invalid parameter number or calling from a non-native function. * @error Invalid parameter number or calling from a non-native function.
*/ */
native any GetNativeCell(int param); native any GetNativeCell(int param);
@ -462,56 +465,56 @@ native Function GetNativeFunction(int param);
/** /**
* Gets a cell from a native parameter, by reference. * Gets a cell from a native parameter, by reference.
* *
* @param param Parameter number, starting from 1. * @param param Parameter number, starting from 1.
* @return Cell value at the parameter number. * @return Cell value at the parameter number.
* @error Invalid parameter number or calling from a non-native function. * @error Invalid parameter number or calling from a non-native function.
*/ */
native any GetNativeCellRef(int param); native any GetNativeCellRef(int param);
/** /**
* Sets a cell from a native parameter, by reference. * Sets a cell from a native parameter, by reference.
* *
* @param param Parameter number, starting from 1. * @param param Parameter number, starting from 1.
* @param value Cell value at the parameter number to set by reference. * @param value Cell value at the parameter number to set by reference.
* @error Invalid parameter number or calling from a non-native function. * @error Invalid parameter number or calling from a non-native function.
*/ */
native void SetNativeCellRef(int param, any value); native void SetNativeCellRef(int param, any value);
/** /**
* Gets an array from a native parameter (always by reference). * Gets an array from a native parameter (always by reference).
* *
* @param param Parameter number, starting from 1. * @param param Parameter number, starting from 1.
* @param local Local array to copy into. * @param local Local array to copy into.
* @param size Maximum size of local array. * @param size Maximum size of local array.
* @return SP_ERROR_NONE on success, anything else on failure. * @return SP_ERROR_NONE on success, anything else on failure.
* @error Invalid parameter number or calling from a non-native function. * @error Invalid parameter number or calling from a non-native function.
*/ */
native int GetNativeArray(int param, any[] local, int size); native int GetNativeArray(int param, any[] local, int size);
/** /**
* Copies a local array into a native parameter array (always by reference). * Copies a local array into a native parameter array (always by reference).
* *
* @param param Parameter number, starting from 1. * @param param Parameter number, starting from 1.
* @param local Local array to copy from. * @param local Local array to copy from.
* @param size Size of the local array to copy. * @param size Size of the local array to copy.
* @return SP_ERROR_NONE on success, anything else on failure. * @return SP_ERROR_NONE on success, anything else on failure.
* @error Invalid parameter number or calling from a non-native function. * @error Invalid parameter number or calling from a non-native function.
*/ */
native int SetNativeArray(int param, const any[] local, int size); native int SetNativeArray(int param, const any[] local, int size);
/** /**
* Check if the native parameter is the NULL_VECTOR. * Check if the native parameter is the NULL_VECTOR.
* *
* @param param Parameter number, starting from 1. * @param param Parameter number, starting from 1.
* @return True if NULL_VECTOR, false otherwise. * @return True if NULL_VECTOR, false otherwise.
*/ */
native bool IsNativeParamNullVector(int param); native bool IsNativeParamNullVector(int param);
/** /**
* Check if the native parameter is the NULL_STRING. * Check if the native parameter is the NULL_STRING.
* *
* @param param Parameter number, starting from 1. * @param param Parameter number, starting from 1.
* @return True if NULL_STRING, false otherwise. * @return True if NULL_STRING, false otherwise.
*/ */
native bool IsNativeParamNullString(int param); native bool IsNativeParamNullString(int param);
@ -520,16 +523,16 @@ native bool IsNativeParamNullString(int param);
* *
* @note All parameter indexes start at 1. * @note All parameter indexes start at 1.
* @note If the input and output buffers overlap, the contents * @note If the input and output buffers overlap, the contents
* of the output buffer at the end is undefined. * of the output buffer at the end is undefined.
* *
* @param out_param Output parameter number to write to. If 0, out_string is used. * @param out_param Output parameter number to write to. If 0, out_string is used.
* @param fmt_param Format parameter number. If 0, fmt_string is used. * @param fmt_param Format parameter number. If 0, fmt_string is used.
* @param vararg_param First variable parameter number. * @param vararg_param First variable parameter number.
* @param out_len Output string buffer maximum length (always required). * @param out_len Output string buffer maximum length (always required).
* @param written Optionally stores the number of bytes written. * @param written Optionally stores the number of bytes written.
* @param out_string Output string buffer to use if out_param is not used. * @param out_string Output string buffer to use if out_param is not used.
* @param fmt_string Format string to use if fmt_param is not used. * @param fmt_string Format string to use if fmt_param is not used.
* @return SP_ERROR_NONE on success, anything else on failure. * @return SP_ERROR_NONE on success, anything else on failure.
*/ */
native int FormatNativeString(int out_param, native int FormatNativeString(int out_param,
int fmt_param, int fmt_param,
@ -542,14 +545,14 @@ native int FormatNativeString(int out_param,
/** /**
* Defines a RequestFrame Callback. * Defines a RequestFrame Callback.
* *
* @param data Data passed to the RequestFrame native. * @param data Data passed to the RequestFrame native.
*/ */
typedef RequestFrameCallback = function void (any data); typedef RequestFrameCallback = function void (any data);
/** /**
* Creates a single use Next Frame hook. * Creates a single use Next Frame hook.
* *
* @param Function Function to call on the next frame. * @param Function Function to call on the next frame.
* @param data Value to be passed on the invocation of the Function. * @param data Value to be passed on the invocation of the Function.
*/ */
native void RequestFrame(RequestFrameCallback Function, any data=0); native void RequestFrame(RequestFrameCallback Function, any data=0);

View File

@ -31,7 +31,7 @@
*/ */
#if defined _geoip_included #if defined _geoip_included
#endinput #endinput
#endif #endif
#define _geoip_included #define _geoip_included
@ -44,28 +44,28 @@
/** /**
* Gets the two character country code from an IP address. (US, CA, etc) * Gets the two character country code from an IP address. (US, CA, etc)
* *
* @param ip Ip to determine the country code. * @param ip Ip to determine the country code.
* @param ccode Destination string buffer to store the code. * @param ccode Destination string buffer to store the code.
* @return True on success, false if no country found. * @return True on success, false if no country found.
*/ */
native bool GeoipCode2(const char[] ip, char ccode[3]); native bool GeoipCode2(const char[] ip, char ccode[3]);
/** /**
* Gets the three character country code from an IP address. (USA, CAN, etc) * Gets the three character country code from an IP address. (USA, CAN, etc)
* *
* @param ip Ip to determine the country code. * @param ip Ip to determine the country code.
* @param ccode Destination string buffer to store the code. * @param ccode Destination string buffer to store the code.
* @return True on success, false if no country found. * @return True on success, false if no country found.
*/ */
native bool GeoipCode3(const char[] ip, char ccode[4]); native bool GeoipCode3(const char[] ip, char ccode[4]);
/** /**
* Gets the full country name. (max length of output string is 45) * Gets the full country name. (max length of output string is 45)
* *
* @param ip Ip to determine the country code. * @param ip Ip to determine the country code.
* @param name Destination string buffer to store the country name. * @param name Destination string buffer to store the country name.
* @param maxlength Maximum length of output string buffer. * @param maxlength Maximum length of output string buffer.
* @return True on success, false if no country found. * @return True on success, false if no country found.
*/ */
native bool GeoipCountry(const char[] ip, char[] name, int maxlength); native bool GeoipCountry(const char[] ip, char[] name, int maxlength);

View File

@ -35,61 +35,61 @@
#endif #endif
#define _halflife_included #define _halflife_included
#define SOURCE_SDK_UNKNOWN 0 /**< Could not determine the engine version */ #define SOURCE_SDK_UNKNOWN 0 /**< Could not determine the engine version */
#define SOURCE_SDK_ORIGINAL 10 /**< Original Source engine (still used by "The Ship") */ #define SOURCE_SDK_ORIGINAL 10 /**< Original Source engine (still used by "The Ship") */
#define SOURCE_SDK_DARKMESSIAH 15 /**< Modified version of original engine used by Dark Messiah (no SDK) */ #define SOURCE_SDK_DARKMESSIAH 15 /**< Modified version of original engine used by Dark Messiah (no SDK) */
#define SOURCE_SDK_EPISODE1 20 /**< SDK+Engine released after Episode 1 */ #define SOURCE_SDK_EPISODE1 20 /**< SDK+Engine released after Episode 1 */
#define SOURCE_SDK_EPISODE2 30 /**< SDK+Engine released after Episode 2/Orange Box */ #define SOURCE_SDK_EPISODE2 30 /**< SDK+Engine released after Episode 2/Orange Box */
#define SOURCE_SDK_BLOODYGOODTIME 32 /**< Modified version of ep2 engine used by Bloody Good Time (no SDK) */ #define SOURCE_SDK_BLOODYGOODTIME 32 /**< Modified version of ep2 engine used by Bloody Good Time (no SDK) */
#define SOURCE_SDK_EYE 33 /**< Modified version of ep2 engine used by E.Y.E Divine Cybermancy (no SDK) */ #define SOURCE_SDK_EYE 33 /**< Modified version of ep2 engine used by E.Y.E Divine Cybermancy (no SDK) */
#define SOURCE_SDK_CSS 34 /**< Sometime-older version of Source 2009 SDK+Engine, used for Counter-Strike: Source */ #define SOURCE_SDK_CSS 34 /**< Sometime-older version of Source 2009 SDK+Engine, used for Counter-Strike: Source */
#define SOURCE_SDK_EPISODE2VALVE 35 /**< SDK+Engine released after Episode 2/Orange Box, "Source 2009" or "Source MP" */ #define SOURCE_SDK_EPISODE2VALVE 35 /**< SDK+Engine released after Episode 2/Orange Box, "Source 2009" or "Source MP" */
#define SOURCE_SDK_LEFT4DEAD 40 /**< Engine released after Left 4 Dead (no SDK yet) */ #define SOURCE_SDK_LEFT4DEAD 40 /**< Engine released after Left 4 Dead (no SDK yet) */
#define SOURCE_SDK_LEFT4DEAD2 50 /**< Engine released after Left 4 Dead 2 (no SDK yet) */ #define SOURCE_SDK_LEFT4DEAD2 50 /**< Engine released after Left 4 Dead 2 (no SDK yet) */
#define SOURCE_SDK_ALIENSWARM 60 /**< SDK+Engine released after Alien Swarm */ #define SOURCE_SDK_ALIENSWARM 60 /**< SDK+Engine released after Alien Swarm */
#define SOURCE_SDK_CSGO 80 /**< Engine released after CS:GO (no SDK yet) */ #define SOURCE_SDK_CSGO 80 /**< Engine released after CS:GO (no SDK yet) */
#define SOURCE_SDK_DOTA 90 /**< Engine released after Dota 2 (no SDK) */ #define SOURCE_SDK_DOTA 90 /**< Engine released after Dota 2 (no SDK) */
#define MOTDPANEL_TYPE_TEXT 0 /**< Treat msg as plain text */ #define MOTDPANEL_TYPE_TEXT 0 /**< Treat msg as plain text */
#define MOTDPANEL_TYPE_INDEX 1 /**< Msg is auto determined by the engine */ #define MOTDPANEL_TYPE_INDEX 1 /**< Msg is auto determined by the engine */
#define MOTDPANEL_TYPE_URL 2 /**< Treat msg as an URL link */ #define MOTDPANEL_TYPE_URL 2 /**< Treat msg as an URL link */
#define MOTDPANEL_TYPE_FILE 3 /**< Treat msg as a filename to be opened */ #define MOTDPANEL_TYPE_FILE 3 /**< Treat msg as a filename to be opened */
enum DialogType enum DialogType
{ {
DialogType_Msg = 0, /**< just an on screen message */ DialogType_Msg = 0, /**< just an on screen message */
DialogType_Menu, /**< an options menu */ DialogType_Menu, /**< an options menu */
DialogType_Text, /**< a richtext dialog */ DialogType_Text, /**< a richtext dialog */
DialogType_Entry, /**< an entry box */ DialogType_Entry, /**< an entry box */
DialogType_AskConnect /**< ask the client to connect to a specified IP */ DialogType_AskConnect /**< ask the client to connect to a specified IP */
}; };
enum EngineVersion enum EngineVersion
{ {
Engine_Unknown, /**< Could not determine the engine version */ Engine_Unknown, /**< Could not determine the engine version */
Engine_Original, /**< Original Source Engine (used by The Ship) */ Engine_Original, /**< Original Source Engine (used by The Ship) */
Engine_SourceSDK2006, /**< Episode 1 Source Engine (second major SDK) */ Engine_SourceSDK2006, /**< Episode 1 Source Engine (second major SDK) */
Engine_SourceSDK2007, /**< Orange Box Source Engine (third major SDK) */ Engine_SourceSDK2007, /**< Orange Box Source Engine (third major SDK) */
Engine_Left4Dead, /**< Left 4 Dead */ Engine_Left4Dead, /**< Left 4 Dead */
Engine_DarkMessiah, /**< Dark Messiah Multiplayer (based on original engine) */ Engine_DarkMessiah, /**< Dark Messiah Multiplayer (based on original engine) */
Engine_Left4Dead2 = 7, /**< Left 4 Dead 2 */ Engine_Left4Dead2 = 7, /**< Left 4 Dead 2 */
Engine_AlienSwarm, /**< Alien Swarm (and Alien Swarm SDK) */ Engine_AlienSwarm, /**< Alien Swarm (and Alien Swarm SDK) */
Engine_BloodyGoodTime, /**< Bloody Good Time */ Engine_BloodyGoodTime, /**< Bloody Good Time */
Engine_EYE, /**< E.Y.E Divine Cybermancy */ Engine_EYE, /**< E.Y.E Divine Cybermancy */
Engine_Portal2, /**< Portal 2 */ Engine_Portal2, /**< Portal 2 */
Engine_CSGO, /**< Counter-Strike: Global Offensive */ Engine_CSGO, /**< Counter-Strike: Global Offensive */
Engine_CSS, /**< Counter-Strike: Source */ Engine_CSS, /**< Counter-Strike: Source */
Engine_DOTA, /**< Dota 2 */ Engine_DOTA, /**< Dota 2 */
Engine_HL2DM, /**< Half-Life 2 Deathmatch */ Engine_HL2DM, /**< Half-Life 2 Deathmatch */
Engine_DODS, /**< Day of Defeat: Source */ Engine_DODS, /**< Day of Defeat: Source */
Engine_TF2, /**< Team Fortress 2 */ Engine_TF2, /**< Team Fortress 2 */
Engine_NuclearDawn, /**< Nuclear Dawn */ Engine_NuclearDawn, /**< Nuclear Dawn */
Engine_SDK2013, /**< Source SDK 2013 */ Engine_SDK2013, /**< Source SDK 2013 */
Engine_Blade, /**< Blade Symphony */ Engine_Blade, /**< Blade Symphony */
Engine_Insurgency, /**< Insurgency (2013 Retail version)*/ Engine_Insurgency, /**< Insurgency (2013 Retail version)*/
Engine_Contagion, /**< Contagion */ Engine_Contagion, /**< Contagion */
Engine_BlackMesa, /**< Black Mesa Multiplayer */ Engine_BlackMesa, /**< Black Mesa Multiplayer */
Engine_DOI, /**< Day of Infamy */ Engine_DOI /**< Day of Infamy */
}; };
enum FindMapResult enum FindMapResult
@ -116,53 +116,53 @@ enum FindMapResult
/** /**
* Logs a generic message to the HL2 logs. * Logs a generic message to the HL2 logs.
* *
* @param format String format. * @param format String format.
* @param ... Format arguments. * @param ... Format arguments.
*/ */
native void LogToGame(const char[] format, any ...); native void LogToGame(const char[] format, any ...);
/** /**
* Sets the seed value for the global Half-Life 2 Random Stream. * Sets the seed value for the global Half-Life 2 Random Stream.
* *
* @param seed Seed value. * @param seed Seed value.
*/ */
native void SetRandomSeed(int seed); native void SetRandomSeed(int seed);
/** /**
* Returns a random floating point number from the Half-Life 2 Random Stream. * Returns a random floating point number from the Half-Life 2 Random Stream.
* *
* @param fMin Minimum random bound. * @param fMin Minimum random bound.
* @param fMax Maximum random bound. * @param fMax Maximum random bound.
* @return A random number between (inclusive) fMin and fMax. * @return A random number between (inclusive) fMin and fMax.
*/ */
native float GetRandomFloat(float fMin=0.0, float fMax=1.0); native float GetRandomFloat(float fMin=0.0, float fMax=1.0);
/** /**
* Returns a random number from the Half-Life 2 Random Stream. * Returns a random number from the Half-Life 2 Random Stream.
* *
* @param nmin Minimum random bound. * @param nmin Minimum random bound.
* @param nmax Maximum random bound. * @param nmax Maximum random bound.
* @return A random number between (inclusive) nmin and nmax. * @return A random number between (inclusive) nmin and nmax.
*/ */
native int GetRandomInt(int nmin, int nmax); native int GetRandomInt(int nmin, int nmax);
/** /**
* Returns whether a map is valid or not. * Returns whether a map is valid or not.
* *
* @param map Map name, excluding .bsp extension. * @param map Map name, excluding .bsp extension.
* @return True if valid, false otherwise. * @return True if valid, false otherwise.
*/ */
native bool IsMapValid(const char[] map); native bool IsMapValid(const char[] map);
/** /**
* Returns whether a full or partial map name is found or can be resolved * Returns whether a full or partial map name is found or can be resolved
* *
* @param map Map name (usually same as map path relative to maps/ dir, * @param map Map name (usually same as map path relative to maps/ dir,
* excluding .bsp extension). * excluding .bsp extension).
* @param foundmap Resolved map name. If the return is FindMap_FuzzyMatch * @param foundmap Resolved map name. If the return is FindMap_FuzzyMatch
* or FindMap_NonCanonical the buffer will be the full path. * or FindMap_NonCanonical the buffer will be the full path.
* @param maxlen Maximum length to write to map var. * @param maxlen Maximum length to write to map var.
* @return Result of the find operation. Not all result types are supported on all games. * @return Result of the find operation. Not all result types are supported on all games.
*/ */
native FindMapResult FindMap(const char[] map, char[] foundmap, int maxlen); native FindMapResult FindMap(const char[] map, char[] foundmap, int maxlen);
@ -171,167 +171,167 @@ native FindMapResult FindMap(const char[] map, char[] foundmap, int maxlen);
* *
* Note: You do not need to call FindMap first. This native will call FindMap internally. * Note: You do not need to call FindMap first. This native will call FindMap internally.
* *
* @param map Map name (usually same as map path relative to maps/ dir, * @param map Map name (usually same as map path relative to maps/ dir,
* excluding .bsp extension). * excluding .bsp extension).
* @param displayName Map's display name, i.e. cp_mymapname or de_mymapname. * @param displayName Map's display name, i.e. cp_mymapname or de_mymapname.
* If FindMap returns FindMap_PossiblyAvailable or FindMap_NotFound, * If FindMap returns FindMap_PossiblyAvailable or FindMap_NotFound,
* the map cannot be resolved and this native will return false, * the map cannot be resolved and this native will return false,
* but displayName will be a copy of map. * but displayName will be a copy of map.
* @param maxlen Maximum length to write to displayName var. * @param maxlen Maximum length to write to displayName var.
* @return true if FindMap returns FindMap_Found, FindMap_FuzzyMatch, or * @return true if FindMap returns FindMap_Found, FindMap_FuzzyMatch, or
* FindMap_NonCanonical. * FindMap_NonCanonical.
* false if FindMap returns FindMap_PossiblyAvailable or FindMap_NotFound. * false if FindMap returns FindMap_PossiblyAvailable or FindMap_NotFound.
*/ */
native bool GetMapDisplayName(const char[] map, char[] displayName, int maxlen); native bool GetMapDisplayName(const char[] map, char[] displayName, int maxlen);
/** /**
* Returns whether the server is dedicated. * Returns whether the server is dedicated.
* *
* @return True if dedicated, false otherwise. * @return True if dedicated, false otherwise.
*/ */
native bool IsDedicatedServer(); native bool IsDedicatedServer();
/** /**
* Returns a high-precision time value for profiling the engine. * Returns a high-precision time value for profiling the engine.
* *
* @return A floating point time value. * @return A floating point time value.
*/ */
native float GetEngineTime(); native float GetEngineTime();
/** /**
* Returns the game time based on the game tick. * Returns the game time based on the game tick.
* *
* @return Game tick time. * @return Game tick time.
*/ */
native float GetGameTime(); native float GetGameTime();
/** /**
* Returns the game's internal tick count. * Returns the game's internal tick count.
* *
* @return Game tick count. * @return Game tick count.
*/ */
native int GetGameTickCount(); native int GetGameTickCount();
/** /**
* Returns the time the Game took processing the last frame. * Returns the time the Game took processing the last frame.
* *
* @return Game frame time. * @return Game frame time.
*/ */
native float GetGameFrameTime(); native float GetGameFrameTime();
/** /**
* Returns the game description from the mod. * Returns the game description from the mod.
* *
* @param buffer Buffer to store the description. * @param buffer Buffer to store the description.
* @param maxlength Maximum size of the buffer. * @param maxlength Maximum size of the buffer.
* @param original If true, retrieves the original game description, * @param original If true, retrieves the original game description,
* ignoring any potential hooks from plugins. * ignoring any potential hooks from plugins.
* @return Number of bytes written to the buffer (UTF-8 safe). * @return Number of bytes written to the buffer (UTF-8 safe).
*/ */
native int GetGameDescription(char[] buffer, int maxlength, bool original=false); native int GetGameDescription(char[] buffer, int maxlength, bool original=false);
/** /**
* Returns the name of the game's directory. * Returns the name of the game's directory.
* *
* @param buffer Buffer to store the directory name. * @param buffer Buffer to store the directory name.
* @param maxlength Maximum size of the buffer. * @param maxlength Maximum size of the buffer.
* @return Number of bytes written to the buffer (UTF-8 safe). * @return Number of bytes written to the buffer (UTF-8 safe).
*/ */
native int GetGameFolderName(char[] buffer, int maxlength); native int GetGameFolderName(char[] buffer, int maxlength);
/** /**
* Returns the current map name. * Returns the current map name.
* *
* @param buffer Buffer to store map name. * @param buffer Buffer to store map name.
* @param maxlength Maximum length of buffer. * @param maxlength Maximum length of buffer.
* @return Number of bytes written (UTF-8 safe). * @return Number of bytes written (UTF-8 safe).
*/ */
native int GetCurrentMap(char[] buffer, int maxlength); native int GetCurrentMap(char[] buffer, int maxlength);
/** /**
* Precaches a given model. * Precaches a given model.
* *
* @param model Name of the model to precache. * @param model Name of the model to precache.
* @param preload If preload is true the file will be precached before level startup. * @param preload If preload is true the file will be precached before level startup.
* @return Returns the model index, 0 for error. * @return Returns the model index, 0 for error.
*/ */
native int PrecacheModel(const char[] model, bool preload=false); native int PrecacheModel(const char[] model, bool preload=false);
/** /**
* Precaches a given sentence file. * Precaches a given sentence file.
* *
* @param file Name of the sentence file to precache. * @param file Name of the sentence file to precache.
* @param preload If preload is true the file will be precached before level startup. * @param preload If preload is true the file will be precached before level startup.
* @return Returns a sentence file index. * @return Returns a sentence file index.
*/ */
native int PrecacheSentenceFile(const char[] file, bool preload=false); native int PrecacheSentenceFile(const char[] file, bool preload=false);
/** /**
* Precaches a given decal. * Precaches a given decal.
* *
* @param decal Name of the decal to precache. * @param decal Name of the decal to precache.
* @param preload If preload is true the file will be precached before level startup. * @param preload If preload is true the file will be precached before level startup.
* @return Returns a decal index. * @return Returns a decal index.
*/ */
native int PrecacheDecal(const char[] decal, bool preload=false); native int PrecacheDecal(const char[] decal, bool preload=false);
/** /**
* Precaches a given generic file. * Precaches a given generic file.
* *
* @param generic Name of the generic file to precache. * @param generic Name of the generic file to precache.
* @param preload If preload is true the file will be precached before level startup. * @param preload If preload is true the file will be precached before level startup.
* @return Returns a generic file index. * @return Returns a generic file index.
*/ */
native int PrecacheGeneric(const char[] generic, bool preload=false); native int PrecacheGeneric(const char[] generic, bool preload=false);
/** /**
* Returns if a given model is precached. * Returns if a given model is precached.
* *
* @param model Name of the model to check. * @param model Name of the model to check.
* @return True if precached, false otherwise. * @return True if precached, false otherwise.
*/ */
native bool IsModelPrecached(const char[] model); native bool IsModelPrecached(const char[] model);
/** /**
* Returns if a given decal is precached. * Returns if a given decal is precached.
* *
* @param decal Name of the decal to check. * @param decal Name of the decal to check.
* @return True if precached, false otherwise. * @return True if precached, false otherwise.
*/ */
native bool IsDecalPrecached(const char[] decal); native bool IsDecalPrecached(const char[] decal);
/** /**
* Returns if a given generic file is precached. * Returns if a given generic file is precached.
* *
* @param generic Name of the generic file to check. * @param generic Name of the generic file to check.
* @return True if precached, false otherwise. * @return True if precached, false otherwise.
*/ */
native bool IsGenericPrecached(const char[] generic); native bool IsGenericPrecached(const char[] generic);
/** /**
* Precaches a given sound. * Precaches a given sound.
* *
* @param sound Name of the sound to precache. * @param sound Name of the sound to precache.
* @param preload If preload is true the file will be precached before level startup. * @param preload If preload is true the file will be precached before level startup.
* @return True if successfully precached, false otherwise. * @return True if successfully precached, false otherwise.
*/ */
native bool PrecacheSound(const char[] sound, bool preload=false); native bool PrecacheSound(const char[] sound, bool preload=false);
/** /**
* Returns if a given sound is precached. * Returns if a given sound is precached.
* *
* @param sound Name of the sound to check. * @param sound Name of the sound to check.
* @return True if precached, false otherwise. * @return True if precached, false otherwise.
*/ */
native bool IsSoundPrecached(const char[] sound); native bool IsSoundPrecached(const char[] sound);
/** /**
* Creates different types of ingame messages. * Creates different types of ingame messages.
* *
* @param client Index of the client. * @param client Index of the client.
* @param kv KeyValues handle to set the menu keys and options. (Check iserverplugin.h for more information). * @param kv KeyValues handle to set the menu keys and options. (Check iserverplugin.h for more information).
* @param type Message type to display ingame. * @param type Message type to display ingame.
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native void CreateDialog(int client, Handle kv, DialogType type); native void CreateDialog(int client, Handle kv, DialogType type);
@ -342,7 +342,8 @@ native void CreateDialog(int client, Handle kv, DialogType type);
* The return values are guaranteed to increase chronologically (that is, * The return values are guaranteed to increase chronologically (that is,
* a later release will have a higher value). * a later release will have a higher value).
* *
* @return SOURCE_SDK version code. * @return SOURCE_SDK version code.
* @deprecated See GetEngineVersion()
*/ */
#pragma deprecated See GetEngineVersion() #pragma deprecated See GetEngineVersion()
native int GuessSDKVersion(); native int GuessSDKVersion();
@ -353,25 +354,25 @@ native int GuessSDKVersion();
* The engine version values are not guaranteed to be in any particular order, * The engine version values are not guaranteed to be in any particular order,
* and should only be compared by (in)equality. * and should only be compared by (in)equality.
* *
* @return An EngineVersion value. * @return An EngineVersion value.
*/ */
native EngineVersion GetEngineVersion(); native EngineVersion GetEngineVersion();
/** /**
* Prints a message to a specific client in the chat area. * Prints a message to a specific client in the chat area.
* *
* @param client Client index. * @param client Client index.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @error If the client is not connected an error will be thrown. * @error If the client is not connected an error will be thrown.
*/ */
native void PrintToChat(int client, const char[] format, any ...); native void PrintToChat(int client, const char[] format, any ...);
/** /**
* Prints a message to all clients in the chat area. * Prints a message to all clients in the chat area.
* *
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
*/ */
stock void PrintToChatAll(const char[] format, any ...) stock void PrintToChatAll(const char[] format, any ...)
{ {
@ -391,18 +392,18 @@ stock void PrintToChatAll(const char[] format, any ...)
/** /**
* Prints a message to a specific client in the center of the screen. * Prints a message to a specific client in the center of the screen.
* *
* @param client Client index. * @param client Client index.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @error If the client is not connected an error will be thrown. * @error If the client is not connected an error will be thrown.
*/ */
native void PrintCenterText(int client, const char[] format, any ...); native void PrintCenterText(int client, const char[] format, any ...);
/** /**
* Prints a message to all clients in the center of the screen. * Prints a message to all clients in the center of the screen.
* *
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
*/ */
stock void PrintCenterTextAll(const char[] format, any ...) stock void PrintCenterTextAll(const char[] format, any ...)
{ {
@ -422,18 +423,18 @@ stock void PrintCenterTextAll(const char[] format, any ...)
/** /**
* Prints a message to a specific client with a hint box. * Prints a message to a specific client with a hint box.
* *
* @param client Client index. * @param client Client index.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @error If the client is not connected an error will be thrown. * @error If the client is not connected an error will be thrown.
*/ */
native void PrintHintText(int client, const char[] format, any ...); native void PrintHintText(int client, const char[] format, any ...);
/** /**
* Prints a message to all clients with a hint box. * Prints a message to all clients with a hint box.
* *
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
*/ */
stock void PrintHintTextToAll(const char[] format, any ...) stock void PrintHintTextToAll(const char[] format, any ...)
{ {
@ -453,13 +454,13 @@ stock void PrintHintTextToAll(const char[] format, any ...)
/** /**
* Shows a VGUI panel to a specific client. * Shows a VGUI panel to a specific client.
* *
* @param client Client index. * @param client Client index.
* @param name Panel type name (Check viewport_panel_names.h to see a list of * @param name Panel type name (Check viewport_panel_names.h to see a list of
* some panel names). * some panel names).
* @param Kv KeyValues handle with all the data for the panel setup (Depends * @param Kv KeyValues handle with all the data for the panel setup (Depends
* on the panel type and may be unused). * on the panel type and may be unused).
* @param show True to show the panel, or false to remove it from the client screen. * @param show True to show the panel, or false to remove it from the client screen.
* @error If the client is not connected an error will be thrown. * @error If the client is not connected an error will be thrown.
*/ */
native void ShowVGUIPanel(int client, const char[] name, Handle Kv=INVALID_HANDLE, bool show=true); native void ShowVGUIPanel(int client, const char[] name, Handle Kv=INVALID_HANDLE, bool show=true);
@ -491,10 +492,10 @@ native void ShowVGUIPanel(int client, const char[] name, Handle Kv=INVALID_HANDL
* center-say messages that may pop up randomly that you don't want to overlap each * center-say messages that may pop up randomly that you don't want to overlap each
* other). * other).
* *
* @return New HUD synchronization object. * @return New HUD synchronization object.
* The Handle can be closed with CloseHandle(). * The Handle can be closed with CloseHandle().
* If HUD text is not supported on this mod, then * If HUD text is not supported on this mod, then
* INVALID_HANDLE is returned. * INVALID_HANDLE is returned.
*/ */
native Handle CreateHudSynchronizer(); native Handle CreateHudSynchronizer();
@ -508,18 +509,18 @@ native Handle CreateHudSynchronizer();
* they won't be modified. However, as soon as you pass control back * they won't be modified. However, as soon as you pass control back
* to other plugins, you must reset the parameters next time you draw. * to other plugins, you must reset the parameters next time you draw.
* *
* @param x x coordinate, from 0 to 1. -1.0 is the center. * @param x x coordinate, from 0 to 1. -1.0 is the center.
* @param y y coordinate, from 0 to 1. -1.0 is the center. * @param y y coordinate, from 0 to 1. -1.0 is the center.
* @param holdTime Number of seconds to hold the text. * @param holdTime Number of seconds to hold the text.
* @param r Red color value. * @param r Red color value.
* @param g Green color value. * @param g Green color value.
* @param b Blue color value. * @param b Blue color value.
* @param a Alpha transparency value. * @param a Alpha transparency value.
* @param effect 0/1 causes the text to fade in and fade out. * @param effect 0/1 causes the text to fade in and fade out.
* 2 causes the text to flash[?]. * 2 causes the text to flash[?].
* @param fxTime Duration of chosen effect (may not apply to all effects). * @param fxTime Duration of chosen effect (may not apply to all effects).
* @param fadeIn Number of seconds to spend fading in. * @param fadeIn Number of seconds to spend fading in.
* @param fadeOut Number of seconds to spend fading out. * @param fadeOut Number of seconds to spend fading out.
*/ */
native void SetHudTextParams(float x, float y, float holdTime, int r, int g, int b, int a, int effect = 0, native void SetHudTextParams(float x, float y, float holdTime, int r, int g, int b, int a, int effect = 0,
float fxTime=6.0, float fadeIn=0.1, float fadeOut=0.2); float fxTime=6.0, float fadeIn=0.1, float fadeOut=0.2);
@ -532,16 +533,16 @@ native void SetHudTextParams(float x, float y, float holdTime, int r, int g, int
* This is the same as SetHudTextParams(), except it lets you set the alternate * This is the same as SetHudTextParams(), except it lets you set the alternate
* color for when effects require it. * color for when effects require it.
* *
* @param x x coordinate, from 0 to 1. -1.0 is the center. * @param x x coordinate, from 0 to 1. -1.0 is the center.
* @param y y coordinate, from 0 to 1. -1.0 is the center. * @param y y coordinate, from 0 to 1. -1.0 is the center.
* @param holdTime Number of seconds to hold the text. * @param holdTime Number of seconds to hold the text.
* @param color1 First color set, array values being [red, green, blue, alpha] * @param color1 First color set, array values being [red, green, blue, alpha]
* @param color2 Second color set, array values being [red, green, blue, alpha] * @param color2 Second color set, array values being [red, green, blue, alpha]
* @param effect 0/1 causes the text to fade in and fade out. * @param effect 0/1 causes the text to fade in and fade out.
* 2 causes the text to flash[?]. * 2 causes the text to flash[?].
* @param fxTime Duration of chosen effect (may not apply to all effects). * @param fxTime Duration of chosen effect (may not apply to all effects).
* @param fadeIn Number of seconds to spend fading in. * @param fadeIn Number of seconds to spend fading in.
* @param fadeOut Number of seconds to spend fading out. * @param fadeOut Number of seconds to spend fading out.
*/ */
native void SetHudTextParamsEx(float x, float y, float holdTime, int color1[4], native void SetHudTextParamsEx(float x, float y, float holdTime, int color1[4],
int color2[4]={255,255,255,0}, int effect = 0, float fxTime=6.0, int color2[4]={255,255,255,0}, int effect = 0, float fxTime=6.0,
@ -552,13 +553,13 @@ native void SetHudTextParamsEx(float x, float y, float holdTime, int color1[4],
* *
* As of this writing, only TF, HL2MP, and SourceForts support HUD Text. * As of this writing, only TF, HL2MP, and SourceForts support HUD Text.
* *
* @param client Client index to send the message to. * @param client Client index to send the message to.
* @param sync Synchronization object. * @param sync Synchronization object.
* @param message Message text or formatting rules. * @param message Message text or formatting rules.
* @param ... Message formatting parameters. * @param ... Message formatting parameters.
* @return -1 on failure, anything else on success. * @return -1 on failure, anything else on success.
* This function fails if the mod does not support it. * This function fails if the mod does not support it.
* @error Client not in-game, or sync object not valid. * @error Client not in-game, or sync object not valid.
*/ */
native int ShowSyncHudText(int client, Handle sync, const char[] message, any ...); native int ShowSyncHudText(int client, Handle sync, const char[] message, any ...);
@ -574,9 +575,9 @@ native int ShowSyncHudText(int client, Handle sync, const char[] message, any ..
* If you were to simply send "" on your synchronized message, * If you were to simply send "" on your synchronized message,
* then someone else's text could be overwritten. * then someone else's text could be overwritten.
* *
* @param client Client index to send the message to. * @param client Client index to send the message to.
* @param sync Synchronization object. * @param sync Synchronization object.
* @error Client not in-game, or sync object not valid. * @error Client not in-game, or sync object not valid.
*/ */
native void ClearSyncHud(int client, Handle sync); native void ClearSyncHud(int client, Handle sync);
@ -585,29 +586,29 @@ native void ClearSyncHud(int client, Handle sync);
* *
* As of this writing, only TF, HL2MP, and SourceForts support HUD Text. * As of this writing, only TF, HL2MP, and SourceForts support HUD Text.
* *
* @param client Client index to send the message to. * @param client Client index to send the message to.
* @param channel A channel number. * @param channel A channel number.
* If -1, then a channel will automatically be selected * If -1, then a channel will automatically be selected
* based on the least-recently-used channel. If the * based on the least-recently-used channel. If the
* channel is any other number, it will be modulo'd with * channel is any other number, it will be modulo'd with
* the channel count to get a final channel number. * the channel count to get a final channel number.
* @param message Message text or formatting rules. * @param message Message text or formatting rules.
* @param ... Message formatting parameters. * @param ... Message formatting parameters.
* @return -1 on failure (lack of mod support). * @return -1 on failure (lack of mod support).
* Any other return value is the channel number that was * Any other return value is the channel number that was
* used to render the text. * used to render the text.
*/ */
native int ShowHudText(int client, int channel, const char[] message, any ...); native int ShowHudText(int client, int channel, const char[] message, any ...);
/** /**
* Shows a MOTD panel to a specific client. * Shows a MOTD panel to a specific client.
* *
* @param client Client index. * @param client Client index.
* @param title Title of the panel (printed on the top border of the window). * @param title Title of the panel (printed on the top border of the window).
* @param msg Contents of the panel, it can be treated as an url, filename or plain text * @param msg Contents of the panel, it can be treated as an url, filename or plain text
* depending on the type parameter (WARNING: msg has to be 192 bytes maximum!) * depending on the type parameter (WARNING: msg has to be 192 bytes maximum!)
* @param type Determines the way to treat the message body of the panel. * @param type Determines the way to treat the message body of the panel.
* @error If the client is not connected an error will be thrown. * @error If the client is not connected an error will be thrown.
*/ */
stock void ShowMOTDPanel(int client, const char[] title, const char[] msg, int type=MOTDPANEL_TYPE_INDEX) stock void ShowMOTDPanel(int client, const char[] title, const char[] msg, int type=MOTDPANEL_TYPE_INDEX)
{ {
@ -625,10 +626,10 @@ stock void ShowMOTDPanel(int client, const char[] title, const char[] msg, int t
/** /**
* Displays a panel asking the client to connect to a specified IP. * Displays a panel asking the client to connect to a specified IP.
* *
* @param client Client index. * @param client Client index.
* @param time Duration to hold the panel on the client's screen. * @param time Duration to hold the panel on the client's screen.
* @param ip Destination IP. * @param ip Destination IP.
* @param password Password to connect to the destination IP. The client will be able to see this. * @param password Password to connect to the destination IP. The client will be able to see this.
*/ */
stock void DisplayAskConnectBox(int client, float time, const char[] ip, const char[] password = "") stock void DisplayAskConnectBox(int client, float time, const char[] ip, const char[] password = "")
{ {
@ -645,42 +646,41 @@ stock void DisplayAskConnectBox(int client, float time, const char[] ip, const c
/** /**
* Converts an entity index into a serial encoded entity reference. * Converts an entity index into a serial encoded entity reference.
* *
* @param entity Entity index. * @param entity Entity index.
* @return Entity reference. * @return Entity reference.
*/ */
native int EntIndexToEntRef(int entity); native int EntIndexToEntRef(int entity);
/** /**
* Retrieves the entity index from a reference. * Retrieves the entity index from a reference.
* *
* @param ref Entity reference. * @param ref Entity reference.
* @return Entity index. * @return Entity index.
*/ */
native int EntRefToEntIndex(int ref); native int EntRefToEntIndex(int ref);
/** /**
* Converts a reference into a backwards compatible version. * Converts a reference into a backwards compatible version.
* *
* @param ref Entity reference. * @param ref Entity reference.
* @return Bcompat reference. * @return Bcompat reference.
*/ */
native int MakeCompatEntRef(int ref); native int MakeCompatEntRef(int ref);
enum ClientRangeType enum ClientRangeType
{ {
RangeType_Visibility = 0, RangeType_Visibility = 0,
RangeType_Audibility, RangeType_Audibility
} }
/** /**
* Find clients that are potentially in range of a position. * Find clients that are potentially in range of a position.
* *
* @param origin Coordinates from which to test range. * @param origin Coordinates from which to test range.
* @param rangeType Range type to use for filtering clients. * @param rangeType Range type to use for filtering clients.
* @param clients Array to which found client indexes will be written. * @param clients Array to which found client indexes will be written.
* @param size Maximum size of clients array. * @param size Maximum size of clients array.
* @return Number of client indexes written to clients array. * @return Number of client indexes written to clients array.
*/ */
native int GetClientsInRange(float origin[3], ClientRangeType rangeType, int[] clients, int size); native int GetClientsInRange(float origin[3], ClientRangeType rangeType, int[] clients, int size);
@ -690,17 +690,17 @@ native int GetClientsInRange(float origin[3], ClientRangeType rangeType, int[] c
* Note: If called before server is connected to Steam, auth id * Note: If called before server is connected to Steam, auth id
* will be invalid ([I:0:1], 1, etc.) * will be invalid ([I:0:1], 1, etc.)
* *
* @param authType Auth id type and format to use. * @param authType Auth id type and format to use.
* (Only AuthId_Steam3 and AuthId_SteamID64 are supported) * (Only AuthId_Steam3 and AuthId_SteamID64 are supported)
* @param auth Buffer to store the server's auth id. * @param auth Buffer to store the server's auth id.
* @param maxlen Maximum length of string buffer (includes NULL terminator). * @param maxlen Maximum length of string buffer (includes NULL terminator).
* @error Invalid AuthIdType given. * @error Invalid AuthIdType given.
*/ */
native void GetServerAuthId(AuthIdType authType, char[] auth, int maxlen); native void GetServerAuthId(AuthIdType authType, char[] auth, int maxlen);
/** /**
* Returns the server's Steam account ID. * Returns the server's Steam account ID.
* *
* @return Steam account ID or 0 if not available. * @return Steam account ID or 0 if not available.
*/ */
native int GetServerSteamAccountId(); native int GetServerSteamAccountId();

View File

@ -40,7 +40,7 @@
*/ */
enum Handle // Tag disables introducing "Handle" as a symbol. enum Handle // Tag disables introducing "Handle" as a symbol.
{ {
INVALID_HANDLE = 0, INVALID_HANDLE = 0
}; };
@ -51,8 +51,8 @@ enum Handle // Tag disables introducing "Handle" as a symbol.
* @note Closing a Handle has a different meaning for each Handle type. Make * @note Closing a Handle has a different meaning for each Handle type. Make
* sure you read the documentation on whatever provided the Handle. * sure you read the documentation on whatever provided the Handle.
* *
* @param hndl Handle to close. * @param hndl Handle to close.
* @error Invalid handles will cause a run time error. * @error Invalid handles will cause a run time error.
*/ */
native void CloseHandle(Handle hndl); native void CloseHandle(Handle hndl);
@ -62,16 +62,16 @@ native void CloseHandle(Handle hndl);
* is unloaded from memory. To prevent this, the Handle may be "cloned" with a new owner. * is unloaded from memory. To prevent this, the Handle may be "cloned" with a new owner.
* *
* @note Usually, you will be cloning Handles for other plugins. This means that if you clone * @note Usually, you will be cloning Handles for other plugins. This means that if you clone
* the Handle without specifying the new owner, it will assume the identity of your original calling * the Handle without specifying the new owner, it will assume the identity of your original
* plugin, which is not very useful. You should either specify that the receiving plugin should * calling plugin, which is not very useful. You should either specify that the receiving
* clone the handle on its own, or you should explicitly clone the Handle using the receiving plugin's * plugin should clone the handle on its own, or you should explicitly clone the Handle
* identity Handle. * using the receiving plugin's identity Handle.
* *
* @param hndl Handle to clone/duplicate. * @param hndl Handle to clone/duplicate.
* @param plugin Optional Handle to another plugin to mark as the new owner. * @param plugin Optional Handle to another plugin to mark as the new owner.
* If no owner is passed, the owner becomes the calling plugin. * If no owner is passed, the owner becomes the calling plugin.
* @return Handle on success, INVALID_HANDLE if not cloneable. * @return Handle on success, INVALID_HANDLE if not cloneable.
* @error Invalid handles will cause a run time error. * @error Invalid handles will cause a run time error.
*/ */
native Handle CloneHandle(Handle hndl, Handle plugin=INVALID_HANDLE); native Handle CloneHandle(Handle hndl, Handle plugin=INVALID_HANDLE);
@ -90,8 +90,9 @@ using __intrinsics__.Handle;
* This function is for very specific usage and using it for general * This function is for very specific usage and using it for general
* purpose routines can and will hide very subtle bugs. * purpose routines can and will hide very subtle bugs.
* *
* @param hndl Handle to test for validity. * @param hndl Handle to test for validity.
* @return True if handle is valid, false otherwise. * @return True if handle is valid, false otherwise.
* @deprecated Do not use this function.
*/ */
#pragma deprecated Do not use this function. #pragma deprecated Do not use this function.
native bool IsValidHandle(Handle hndl); native bool IsValidHandle(Handle hndl);

View File

@ -40,9 +40,10 @@
* *
* Formats a user's info as log text. * Formats a user's info as log text.
* *
* @param client Client index. * @param client Client index.
* @param buffer Buffer for text. * @param buffer Buffer for text.
* @param maxlength Maximum length of text. * @param maxlength Maximum length of text.
* @deprecated Use the %L format specifier instead.
*/ */
#pragma deprecated Use the %L format specifier instead. #pragma deprecated Use the %L format specifier instead.
stock void FormatUserLogText(int client, char[] buffer, int maxlength) stock void FormatUserLogText(int client, char[] buffer, int maxlength)
@ -53,8 +54,8 @@ stock void FormatUserLogText(int client, char[] buffer, int maxlength)
/** /**
* Returns plugin handle from plugin filename. * Returns plugin handle from plugin filename.
* *
* @param filename Filename of the plugin to search for. * @param filename Filename of the plugin to search for.
* @return Handle to plugin if found, INVALID_HANDLE otherwise. * @return Handle to plugin if found, INVALID_HANDLE otherwise.
*/ */
stock Handle FindPluginByFile(const char[] filename) stock Handle FindPluginByFile(const char[] filename)
{ {
@ -81,7 +82,7 @@ stock Handle FindPluginByFile(const char[] filename)
} }
/** /**
* @deprecated Use FindTarget() or ProcessTargetString(). * @deprecated Use FindTarget() or ProcessTargetString().
*/ */
#pragma deprecated Use FindTarget() or ProcessTargetString() #pragma deprecated Use FindTarget() or ProcessTargetString()
stock int SearchForClients(const char[] pattern, int[] clients, int maxClients) stock int SearchForClients(const char[] pattern, int[] clients, int maxClients)
@ -89,24 +90,34 @@ stock int SearchForClients(const char[] pattern, int[] clients, int maxClients)
int total = 0; int total = 0;
if (maxClients == 0) if (maxClients == 0)
{
return 0; return 0;
}
if (pattern[0] == '#') { if (pattern[0] == '#')
{
int input = StringToInt(pattern[1]); int input = StringToInt(pattern[1]);
if (!input) { if (!input) {
char name[MAX_NAME_LENGTH]; char name[MAX_NAME_LENGTH];
for (int i=1; i<=MaxClients; i++) { for (int i=1; i<=MaxClients; i++)
{
if (!IsClientInGame(i)) if (!IsClientInGame(i))
{
continue; continue;
}
GetClientName(i, name, sizeof(name)); GetClientName(i, name, sizeof(name));
if (strcmp(name, pattern, false) == 0) { if (strcmp(name, pattern, false) == 0)
{
clients[0] = i; clients[0] = i;
return 1; return 1;
} }
} }
} else { }
else
{
int client = GetClientOfUserId(input); int client = GetClientOfUserId(input);
if (client) { if (client)
{
clients[0] = client; clients[0] = client;
return 1; return 1;
} }
@ -117,12 +128,18 @@ stock int SearchForClients(const char[] pattern, int[] clients, int maxClients)
for (int i=1; i<=MaxClients; i++) for (int i=1; i<=MaxClients; i++)
{ {
if (!IsClientInGame(i)) if (!IsClientInGame(i))
{
continue; continue;
}
GetClientName(i, name, sizeof(name)); GetClientName(i, name, sizeof(name));
if (StrContains(name, pattern, false) != -1) { if (StrContains(name, pattern, false) != -1)
{
clients[total++] = i; clients[total++] = i;
if (total >= maxClients) if (total >= maxClients)
{
break; break;
}
} }
} }
@ -133,11 +150,11 @@ stock int SearchForClients(const char[] pattern, int[] clients, int maxClients)
* Wraps ProcessTargetString() and handles producing error messages for * Wraps ProcessTargetString() and handles producing error messages for
* bad targets. * bad targets.
* *
* @param client Client who issued command * @param client Client who issued command
* @param target Client's target argument * @param target Client's target argument
* @param nobots Optional. Set to true if bots should NOT be targetted * @param nobots Optional. Set to true if bots should NOT be targetted
* @param immunity Optional. Set to false to ignore target immunity. * @param immunity Optional. Set to false to ignore target immunity.
* @return Index of target client, or -1 on error. * @return Index of target client, or -1 on error.
*/ */
stock int FindTarget(int client, const char[] target, bool nobots = false, bool immunity = true) stock int FindTarget(int client, const char[] target, bool nobots = false, bool immunity = true)
{ {
@ -150,6 +167,7 @@ stock int FindTarget(int client, const char[] target, bool nobots = false, bool
{ {
flags |= COMMAND_FILTER_NO_BOTS; flags |= COMMAND_FILTER_NO_BOTS;
} }
if (!immunity) if (!immunity)
{ {
flags |= COMMAND_FILTER_NO_IMMUNITY; flags |= COMMAND_FILTER_NO_IMMUNITY;
@ -167,11 +185,9 @@ stock int FindTarget(int client, const char[] target, bool nobots = false, bool
{ {
return target_list[0]; return target_list[0];
} }
else
{ ReplyToTargetError(client, target_count);
ReplyToTargetError(client, target_count); return -1;
return -1;
}
} }
/** /**
@ -184,83 +200,84 @@ stock int FindTarget(int client, const char[] target, bool nobots = false, bool
* parameter is used to store a timestamp of the file. If specified, the file will only be reloaded if it * parameter is used to store a timestamp of the file. If specified, the file will only be reloaded if it
* has changed. * has changed.
* *
* @param array Valid array handle, should be created with CreateArray(33) or larger. * @param array Valid array handle, should be created with CreateArray(33) or larger.
* @param fileTime Variable containing the "last changed" time of the file. Used to avoid needless reloading. * @param fileTime Variable containing the "last changed" time of the file. Used to avoid needless reloading.
* @param fileCvar CVAR set to the file to be loaded. Optional. * @param fileCvar CVAR set to the file to be loaded. Optional.
* @return Number of maps loaded or 0 if in error. * @return Number of maps loaded or 0 if in error.
* @deprecated Use ReadMapList() instead.
*/ */
#pragma deprecated Use ReadMapList() instead. #pragma deprecated Use ReadMapList() instead.
stock int LoadMaps(Handle array, int &fileTime = 0, Handle fileCvar = INVALID_HANDLE) stock int LoadMaps(Handle array, int &fileTime = 0, Handle fileCvar = INVALID_HANDLE)
{ {
char mapPath[256], mapFile[64]; char mapPath[256], mapFile[64];
bool fileFound = false; bool fileFound = false;
if (fileCvar != INVALID_HANDLE) if (fileCvar != INVALID_HANDLE)
{ {
GetConVarString(fileCvar, mapFile, 64); GetConVarString(fileCvar, mapFile, 64);
BuildPath(Path_SM, mapPath, sizeof(mapPath), mapFile); BuildPath(Path_SM, mapPath, sizeof(mapPath), mapFile);
fileFound = FileExists(mapPath); fileFound = FileExists(mapPath);
} }
if (!fileFound) if (!fileFound)
{ {
Handle mapCycleFile = FindConVar("mapcyclefile"); Handle mapCycleFile = FindConVar("mapcyclefile");
GetConVarString(mapCycleFile, mapPath, sizeof(mapPath)); GetConVarString(mapCycleFile, mapPath, sizeof(mapPath));
fileFound = FileExists(mapPath); fileFound = FileExists(mapPath);
} }
if (!fileFound) if (!fileFound)
{ {
LogError("Failed to find a file to load maps from. No maps loaded."); LogError("Failed to find a file to load maps from. No maps loaded.");
ClearArray(array); ClearArray(array);
return 0; return 0;
} }
// If the file hasn't changed, there's no reason to reload // If the file hasn't changed, there's no reason to reload
// all of the maps. // all of the maps.
int newTime = GetFileTime(mapPath, FileTime_LastChange); int newTime = GetFileTime(mapPath, FileTime_LastChange);
if (fileTime == newTime) if (fileTime == newTime)
{ {
return GetArraySize(array); return GetArraySize(array);
} }
fileTime = newTime; fileTime = newTime;
ClearArray(array); ClearArray(array);
File file = OpenFile(mapPath, "rt"); File file = OpenFile(mapPath, "rt");
if (!file) { if (!file) {
LogError("Could not open file: %s", mapPath); LogError("Could not open file: %s", mapPath);
return 0; return 0;
} }
LogMessage("Loading maps from file: %s", mapPath); LogMessage("Loading maps from file: %s", mapPath);
int len; int len;
char buffer[64]; char buffer[64];
while (!file.EndOfFile() && file.ReadLine(buffer, sizeof(buffer))) while (!file.EndOfFile() && file.ReadLine(buffer, sizeof(buffer)))
{ {
TrimString(buffer); TrimString(buffer);
if ((len = StrContains(buffer, ".bsp", false)) != -1) if ((len = StrContains(buffer, ".bsp", false)) != -1)
{ {
buffer[len] = '\0'; buffer[len] = '\0';
} }
if (buffer[0] == '\0' || !IsValidConVarChar(buffer[0]) || !IsMapValid(buffer)) if (buffer[0] == '\0' || !IsValidConVarChar(buffer[0]) || !IsMapValid(buffer))
{ {
continue; continue;
} }
if (FindStringInArray(array, buffer) != -1) if (FindStringInArray(array, buffer) != -1)
{ {
continue; continue;
} }
PushArrayString(array, buffer); PushArrayString(array, buffer);
} }
file.Close(); file.Close();
return GetArraySize(array); return GetArraySize(array);
} }

View File

@ -40,16 +40,16 @@
*/ */
enum KvDataTypes enum KvDataTypes
{ {
KvData_None = 0, /**< Type could not be identified, or no type */ KvData_None = 0, /**< Type could not be identified, or no type */
KvData_String, /**< String value */ KvData_String, /**< String value */
KvData_Int, /**< Integer value */ KvData_Int, /**< Integer value */
KvData_Float, /**< Floating point value */ KvData_Float, /**< Floating point value */
KvData_Ptr, /**< Pointer value (sometimes called "long") */ KvData_Ptr, /**< Pointer value (sometimes called "long") */
KvData_WString, /**< Wide string value */ KvData_WString, /**< Wide string value */
KvData_Color, /**< Color value */ KvData_Color, /**< Color value */
KvData_UInt64, /**< Large integer value */ KvData_UInt64, /**< Large integer value */
/* --- */ /* --- */
KvData_NUMTYPES, KvData_NUMTYPES
}; };
methodmap KeyValues < Handle methodmap KeyValues < Handle
@ -71,7 +71,7 @@ methodmap KeyValues < Handle
// Exports a KeyValues tree to a string. The string is dumped from the current position. // Exports a KeyValues tree to a string. The string is dumped from the current position.
// //
// @param buffer Buffer to write to. // @param buffer Buffer to write to.
// @param maxlength Max length of buffer. // @param maxlength Max length of buffer.
// @return Number of bytes that can be written to buffer. // @return Number of bytes that can be written to buffer.
public native int ExportToString(char[] buffer, int maxlength); public native int ExportToString(char[] buffer, int maxlength);
@ -336,161 +336,161 @@ methodmap KeyValues < Handle
/** /**
* Creates a new KeyValues structure. The Handle must always be closed. * Creates a new KeyValues structure. The Handle must always be closed.
* *
* @param name Name of the root section. * @param name Name of the root section.
* @param firstKey If non-empty, specifies the first key value. * @param firstKey If non-empty, specifies the first key value.
* @param firstValue If firstKey is non-empty, specifies the first key's value. * @param firstValue If firstKey is non-empty, specifies the first key's value.
* @return A Handle to a new KeyValues structure. * @return A Handle to a new KeyValues structure.
*/ */
native KeyValues CreateKeyValues(const char[] name, const char[] firstKey="", const char[] firstValue=""); native KeyValues CreateKeyValues(const char[] name, const char[] firstKey="", const char[] firstValue="");
/** /**
* Sets a string value of a KeyValues key. * Sets a string value of a KeyValues key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key, or NULL_STRING. * @param key Name of the key, or NULL_STRING.
* @param value String value. * @param value String value.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvSetString(Handle kv, const char[] key, const char[] value); native void KvSetString(Handle kv, const char[] key, const char[] value);
/** /**
* Sets an integer value of a KeyValues key. * Sets an integer value of a KeyValues key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key, or NULL_STRING. * @param key Name of the key, or NULL_STRING.
* @param value Value number. * @param value Value number.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvSetNum(Handle kv, const char[] key, int value); native void KvSetNum(Handle kv, const char[] key, int value);
/** /**
* Sets a large integer value of a KeyValues key. * Sets a large integer value of a KeyValues key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key, or NULL_STRING. * @param key Name of the key, or NULL_STRING.
* @param value Large integer value (0=High bits, 1=Low bits) * @param value Large integer value (0=High bits, 1=Low bits)
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvSetUInt64(Handle kv, const char[] key, const int value[2]); native void KvSetUInt64(Handle kv, const char[] key, const int value[2]);
/** /**
* Sets a floating point value of a KeyValues key. * Sets a floating point value of a KeyValues key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key, or NULL_STRING. * @param key Name of the key, or NULL_STRING.
* @param value Floating point value. * @param value Floating point value.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvSetFloat(Handle kv, const char[] key, float value); native void KvSetFloat(Handle kv, const char[] key, float value);
/** /**
* Sets a set of color values of a KeyValues key. * Sets a set of color values of a KeyValues key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key, or NULL_STRING. * @param key Name of the key, or NULL_STRING.
* @param r Red value. * @param r Red value.
* @param g Green value. * @param g Green value.
* @param b Blue value. * @param b Blue value.
* @param a Alpha value. * @param a Alpha value.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvSetColor(Handle kv, const char[] key, int r, int g, int b, int a=0); native void KvSetColor(Handle kv, const char[] key, int r, int g, int b, int a=0);
/** /**
* Sets a vector value of a KeyValues key. * Sets a vector value of a KeyValues key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key, or NULL_STRING. * @param key Name of the key, or NULL_STRING.
* @param vec Vector value. * @param vec Vector value.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvSetVector(Handle kv, const char[] key, const float vec[3]); native void KvSetVector(Handle kv, const char[] key, const float vec[3]);
/** /**
* Retrieves a string value from a KeyValues key. * Retrieves a string value from a KeyValues key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key, or NULL_STRING. * @param key Name of the key, or NULL_STRING.
* @param value Buffer to store key value in. * @param value Buffer to store key value in.
* @param maxlength Maximum length of the value buffer. * @param maxlength Maximum length of the value buffer.
* @param defvalue Optional default value to use if the key is not found. * @param defvalue Optional default value to use if the key is not found.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvGetString(Handle kv, const char[] key, char[] value, int maxlength, const char[] defvalue=""); native void KvGetString(Handle kv, const char[] key, char[] value, int maxlength, const char[] defvalue="");
/** /**
* Retrieves an integer value from a KeyValues key. * Retrieves an integer value from a KeyValues key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key, or NULL_STRING. * @param key Name of the key, or NULL_STRING.
* @param defvalue Optional default value to use if the key is not found. * @param defvalue Optional default value to use if the key is not found.
* @return Integer value of the key. * @return Integer value of the key.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int KvGetNum(Handle kv, const char[] key, int defvalue=0); native int KvGetNum(Handle kv, const char[] key, int defvalue=0);
/** /**
* Retrieves a floating point value from a KeyValues key. * Retrieves a floating point value from a KeyValues key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key, or NULL_STRING. * @param key Name of the key, or NULL_STRING.
* @param defvalue Optional default value to use if the key is not found. * @param defvalue Optional default value to use if the key is not found.
* @return Floating point value of the key. * @return Floating point value of the key.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native float KvGetFloat(Handle kv, const char[] key, float defvalue=0.0); native float KvGetFloat(Handle kv, const char[] key, float defvalue=0.0);
/** /**
* Retrieves a set of color values from a KeyValues key. * Retrieves a set of color values from a KeyValues key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key, or NULL_STRING. * @param key Name of the key, or NULL_STRING.
* @param r Red value, set by reference. * @param r Red value, set by reference.
* @param g Green value, set by reference. * @param g Green value, set by reference.
* @param b Blue value, set by reference. * @param b Blue value, set by reference.
* @param a Alpha value, set by reference. * @param a Alpha value, set by reference.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvGetColor(Handle kv, const char[] key, int &r, int &g, int &b, int &a); native void KvGetColor(Handle kv, const char[] key, int &r, int &g, int &b, int &a);
/** /**
* Retrieves a large integer value from a KeyValues key. * Retrieves a large integer value from a KeyValues key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key, or NULL_STRING. * @param key Name of the key, or NULL_STRING.
* @param value Array to represent the large integer. * @param value Array to represent the large integer.
* @param defvalue Optional default value to use if the key is not found. * @param defvalue Optional default value to use if the key is not found.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvGetUInt64(Handle kv, const char[] key, int value[2], int defvalue[2]={0,0}); native void KvGetUInt64(Handle kv, const char[] key, int value[2], int defvalue[2]={0,0});
/** /**
* Retrieves a vector value from a KeyValues key. * Retrieves a vector value from a KeyValues key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key, or NULL_STRING. * @param key Name of the key, or NULL_STRING.
* @param vec Destination vector to store the value in. * @param vec Destination vector to store the value in.
* @param defvalue Optional default value to use if the key is not found. * @param defvalue Optional default value to use if the key is not found.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvGetVector(Handle kv, const char[] key, float vec[3], const float defvalue[3]={0.0, 0.0, 0.0}); native void KvGetVector(Handle kv, const char[] key, float vec[3], const float defvalue[3]={0.0, 0.0, 0.0});
/** /**
* Sets the current position in the KeyValues tree to the given key. * Sets the current position in the KeyValues tree to the given key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key. * @param key Name of the key.
* @param create If true, and the key does not exist, it will be created. * @param create If true, and the key does not exist, it will be created.
* @return True if the key exists, false if it does not and was not created. * @return True if the key exists, false if it does not and was not created.
*/ */
native bool KvJumpToKey(Handle kv, const char[] key, bool create=false); native bool KvJumpToKey(Handle kv, const char[] key, bool create=false);
/** /**
* Sets the current position in the KeyValues tree to the given key. * Sets the current position in the KeyValues tree to the given key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param id KeyValues id. * @param id KeyValues id.
* @return True if the key exists, false if it does not. * @return True if the key exists, false if it does not.
*/ */
native bool KvJumpToKeySymbol(Handle kv, int id); native bool KvJumpToKeySymbol(Handle kv, int id);
@ -498,10 +498,10 @@ native bool KvJumpToKeySymbol(Handle kv, int id);
* Sets the current position in the KeyValues tree to the first sub key. * Sets the current position in the KeyValues tree to the first sub key.
* This native adds to the internal traversal stack. * This native adds to the internal traversal stack.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param keyOnly If false, non-keys will be traversed (values). * @param keyOnly If false, non-keys will be traversed (values).
* @return True on success, false if there was no first sub key. * @return True on success, false if there was no first sub key.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool KvGotoFirstSubKey(Handle kv, bool keyOnly=true); native bool KvGotoFirstSubKey(Handle kv, bool keyOnly=true);
@ -510,10 +510,10 @@ native bool KvGotoFirstSubKey(Handle kv, bool keyOnly=true);
* This native does NOT add to the internal traversal stack, and thus * This native does NOT add to the internal traversal stack, and thus
* KvGoBack() is not needed for each successive call to this function. * KvGoBack() is not needed for each successive call to this function.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param keyOnly If false, non-keys will be traversed (values). * @param keyOnly If false, non-keys will be traversed (values).
* @return True on success, false if there was no next sub key. * @return True on success, false if there was no next sub key.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool KvGotoNextKey(Handle kv, bool keyOnly=true); native bool KvGotoNextKey(Handle kv, bool keyOnly=true);
@ -522,18 +522,18 @@ native bool KvGotoNextKey(Handle kv, bool keyOnly=true);
* stack. This can be useful if you wish to use KvGotoNextKey() and * stack. This can be useful if you wish to use KvGotoNextKey() and
* have the previous key saved for backwards traversal. * have the previous key saved for backwards traversal.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvSavePosition(Handle kv); native void KvSavePosition(Handle kv);
/** /**
* Removes the given key from the current position. * Removes the given key from the current position.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Name of the key. * @param key Name of the key.
* @return True on success, false if key did not exist. * @return True on success, false if key did not exist.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool KvDeleteKey(Handle kv, const char[] key); native bool KvDeleteKey(Handle kv, const char[] key);
@ -544,13 +544,13 @@ native bool KvDeleteKey(Handle kv, const char[] key);
* Given the sub-key having position "N" in the traversal stack, the * Given the sub-key having position "N" in the traversal stack, the
* removal will always take place from position "N-1." * removal will always take place from position "N-1."
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @return 1 if removal succeeded and there was another key. * @return 1 if removal succeeded and there was another key.
* 0 if the current node was not contained in the * 0 if the current node was not contained in the
* previous node, or no previous node exists. * previous node, or no previous node exists.
* -1 if removal succeeded and there were no more keys, * -1 if removal succeeded and there were no more keys,
* thus the state is as if KvGoBack() was called. * thus the state is as if KvGoBack() was called.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int KvDeleteThis(Handle kv); native int KvDeleteThis(Handle kv);
@ -560,9 +560,9 @@ native int KvDeleteThis(Handle kv);
* once for each successful Jump call, in order to return to the top node. * once for each successful Jump call, in order to return to the top node.
* This function pops one node off the internal traversal stack. * This function pops one node off the internal traversal stack.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @return True on success, false if there is no higher node. * @return True on success, false if there is no higher node.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool KvGoBack(Handle kv); native bool KvGoBack(Handle kv);
@ -571,38 +571,38 @@ native bool KvGoBack(Handle kv);
* traversal history. This can be used instead of looping KvGoBack() * traversal history. This can be used instead of looping KvGoBack()
* if recursive iteration is not important. * if recursive iteration is not important.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvRewind(Handle kv); native void KvRewind(Handle kv);
/** /**
* Retrieves the current section name. * Retrieves the current section name.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param section Buffer to store the section name. * @param section Buffer to store the section name.
* @param maxlength Maximum length of the name buffer. * @param maxlength Maximum length of the name buffer.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool KvGetSectionName(Handle kv, char[] section, int maxlength); native bool KvGetSectionName(Handle kv, char[] section, int maxlength);
/** /**
* Sets the current section name. * Sets the current section name.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param section Section name. * @param section Section name.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvSetSectionName(Handle kv, const char[] section); native void KvSetSectionName(Handle kv, const char[] section);
/** /**
* Returns the data type at a key. * Returns the data type at a key.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Key name. * @param key Key name.
* @return KvDataType value of the key. * @return KvDataType value of the key.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native KvDataTypes KvGetDataType(Handle kv, const char[] key); native KvDataTypes KvGetDataType(Handle kv, const char[] key);
@ -610,10 +610,10 @@ native KvDataTypes KvGetDataType(Handle kv, const char[] key);
* Converts a KeyValues tree to a file. The tree is dumped * Converts a KeyValues tree to a file. The tree is dumped
* from the current position. * from the current position.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param file File to dump write to. * @param file File to dump write to.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool KeyValuesToFile(Handle kv, const char[] file); native bool KeyValuesToFile(Handle kv, const char[] file);
@ -621,10 +621,10 @@ native bool KeyValuesToFile(Handle kv, const char[] file);
* Converts a file to a KeyValues tree. The file is read into * Converts a file to a KeyValues tree. The file is read into
* the current position of the tree. * the current position of the tree.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param file File to read from. * @param file File to read from.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool FileToKeyValues(Handle kv, const char[] file); native bool FileToKeyValues(Handle kv, const char[] file);
@ -632,11 +632,11 @@ native bool FileToKeyValues(Handle kv, const char[] file);
* Converts a given string to a KeyValues tree. The string is read into * Converts a given string to a KeyValues tree. The string is read into
* the current postion of the tree. * the current postion of the tree.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param buffer String buffer to load into the KeyValues. * @param buffer String buffer to load into the KeyValues.
* @param resourceName The resource name of the KeyValues, used for error tracking purposes. * @param resourceName The resource name of the KeyValues, used for error tracking purposes.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool StringToKeyValues(Handle kv, const char[] buffer, const char[] resourceName="StringToKeyValues"); native bool StringToKeyValues(Handle kv, const char[] buffer, const char[] resourceName="StringToKeyValues");
@ -645,9 +645,9 @@ native bool StringToKeyValues(Handle kv, const char[] buffer, const char[] resou
* For example, \n would be read as a literal newline. This defaults * For example, \n would be read as a literal newline. This defaults
* to false for new KeyValues structures. * to false for new KeyValues structures.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param useEscapes Whether or not to read escape sequences. * @param useEscapes Whether or not to read escape sequences.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvSetEscapeSequences(Handle kv, bool useEscapes); native void KvSetEscapeSequences(Handle kv, bool useEscapes);
@ -656,9 +656,9 @@ native void KvSetEscapeSequences(Handle kv, bool useEscapes);
* required for KvGoBack to return to the root node. If at the root node, * required for KvGoBack to return to the root node. If at the root node,
* 0 is returned. * 0 is returned.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @return Number of non-root nodes in the jump stack. * @return Number of non-root nodes in the jump stack.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int KvNodesInStack(Handle kv); native int KvNodesInStack(Handle kv);
@ -667,41 +667,41 @@ native int KvNodesInStack(Handle kv);
* the destination KeyValues. * the destination KeyValues.
* NOTE: All KeyValues are processed from the current location not the root one. * NOTE: All KeyValues are processed from the current location not the root one.
* *
* @param origin Origin KeyValues Handle. * @param origin Origin KeyValues Handle.
* @param dest Destination KeyValues Handle. * @param dest Destination KeyValues Handle.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void KvCopySubkeys(Handle origin, Handle dest); native void KvCopySubkeys(Handle origin, Handle dest);
/** /**
* Finds a KeyValues name by id. * Finds a KeyValues name by id.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param id KeyValues id. * @param id KeyValues id.
* @param name Buffer to store the name. * @param name Buffer to store the name.
* @param maxlength Maximum length of the value buffer. * @param maxlength Maximum length of the value buffer.
* @return True on success, false if id not found. * @return True on success, false if id not found.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool KvFindKeyById(Handle kv, int id, char[] name, int maxlength); native bool KvFindKeyById(Handle kv, int id, char[] name, int maxlength);
/** /**
* Finds a KeyValues id inside a KeyValues tree. * Finds a KeyValues id inside a KeyValues tree.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param key Key name. * @param key Key name.
* @param id Id of the found KeyValue. * @param id Id of the found KeyValue.
* @return True on success, false if key not found. * @return True on success, false if key not found.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool KvGetNameSymbol(Handle kv, const char[] key, int &id); native bool KvGetNameSymbol(Handle kv, const char[] key, int &id);
/** /**
* Retrieves the current section id. * Retrieves the current section id.
* *
* @param kv KeyValues Handle. * @param kv KeyValues Handle.
* @param id Id of the current section. * @param id Id of the current section.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool KvGetSectionSymbol(Handle kv, int &id); native bool KvGetSectionSymbol(Handle kv, int &id);

View File

@ -35,13 +35,13 @@
#endif #endif
#define _lang_included #define _lang_included
#define LANG_SERVER 0 /**< Translate using the server's language */ #define LANG_SERVER 0 /**< Translate using the server's language */
/** /**
* Loads a translation file for the plugin calling this native. * Loads a translation file for the plugin calling this native.
* If no extension is specified, .txt is assumed. * If no extension is specified, .txt is assumed.
* *
* @param file Translation file. * @param file Translation file.
*/ */
native void LoadTranslations(const char[] file); native void LoadTranslations(const char[] file);
@ -51,67 +51,67 @@ native void LoadTranslations(const char[] file);
* indexes can be specified but the error will occur during translation, * indexes can be specified but the error will occur during translation,
* not during this function call. * not during this function call.
* *
* @param client Client index or LANG_SERVER. * @param client Client index or LANG_SERVER.
*/ */
native void SetGlobalTransTarget(int client); native void SetGlobalTransTarget(int client);
/** /**
* Retrieves the language number of a client. * Retrieves the language number of a client.
* *
* @param client Client index. * @param client Client index.
* @return Language number client is using. * @return Language number client is using.
* @error Invalid client index or client not connected. * @error Invalid client index or client not connected.
*/ */
native int GetClientLanguage(int client); native int GetClientLanguage(int client);
/** /**
* Retrieves the server's language. * Retrieves the server's language.
* *
* @return Language number server is using. * @return Language number server is using.
*/ */
native int GetServerLanguage(); native int GetServerLanguage();
/** /**
* Returns the number of languages known in languages.cfg. * Returns the number of languages known in languages.cfg.
* *
* @return Language count. * @return Language count.
*/ */
native int GetLanguageCount(); native int GetLanguageCount();
/** /**
* Retrieves info about a given language number. * Retrieves info about a given language number.
* *
* @param language Language number. * @param language Language number.
* @param code Language code buffer (2-3 characters usually). * @param code Language code buffer (2-3 characters usually).
* @param codeLen Maximum length of the language code buffer. * @param codeLen Maximum length of the language code buffer.
* @param name Language name buffer. * @param name Language name buffer.
* @param nameLen Maximum length of the language name buffer. * @param nameLen Maximum length of the language name buffer.
* @error Invalid language number. * @error Invalid language number.
*/ */
native void GetLanguageInfo(int language, char[] code="", int codeLen=0, char[] name="", int nameLen=0); native void GetLanguageInfo(int language, char[] code="", int codeLen=0, char[] name="", int nameLen=0);
/** /**
* Sets the language number of a client. * Sets the language number of a client.
* *
* @param client Client index. * @param client Client index.
* @param language Language number. * @param language Language number.
* @error Invalid client index or client not connected. * @error Invalid client index or client not connected.
*/ */
native void SetClientLanguage(int client, int language); native void SetClientLanguage(int client, int language);
/** /**
* Retrieves the language number from a language code. * Retrieves the language number from a language code.
* *
* @param code Language code (2-3 characters usually). * @param code Language code (2-3 characters usually).
* @return Language number. -1 if not found. * @return Language number. -1 if not found.
*/ */
native int GetLanguageByCode(const char[] code); native int GetLanguageByCode(const char[] code);
/** /**
* Retrieves the language number from a language name. * Retrieves the language number from a language name.
* *
* @param name Language name (case insensitive). * @param name Language name (case insensitive).
* @return Language number. -1 if not found. * @return Language number. -1 if not found.
*/ */
native int GetLanguageByName(const char[] name); native int GetLanguageByName(const char[] name);
@ -119,16 +119,16 @@ native int GetLanguageByName(const char[] name);
* Determines if the specified phrase exists within the plugin's * Determines if the specified phrase exists within the plugin's
* translation cache. * translation cache.
* *
* @param phrase Phrase to look for. * @param phrase Phrase to look for.
* @return True if phrase exists. * @return True if phrase exists.
*/ */
native bool TranslationPhraseExists(const char[] phrase); native bool TranslationPhraseExists(const char[] phrase);
/** /**
* Determines if there is a translation for the specified language. * Determines if there is a translation for the specified language.
* *
* @param phrase Phrase to check. * @param phrase Phrase to check.
* @param language Language number. * @param language Language number.
* @return True if translation exists. * @return True if translation exists.
*/ */
native bool IsTranslatedForLanguage(const char[] phrase, int language); native bool IsTranslatedForLanguage(const char[] phrase, int language);

View File

@ -39,8 +39,8 @@
* Logs a plugin message to the SourceMod logs. The log message will be * Logs a plugin message to the SourceMod logs. The log message will be
* prefixed by the plugin's logtag (filename). * prefixed by the plugin's logtag (filename).
* *
* @param format String format. * @param format String format.
* @param ... Format arguments. * @param ... Format arguments.
*/ */
native void LogMessage(const char[] format, any ...); native void LogMessage(const char[] format, any ...);
@ -48,20 +48,20 @@ native void LogMessage(const char[] format, any ...);
* Logs a message to any file. The log message will be in the normal * Logs a message to any file. The log message will be in the normal
* SourceMod format, with the plugin logtag prepended. * SourceMod format, with the plugin logtag prepended.
* *
* @param file File to write the log message in. * @param file File to write the log message in.
* @param format String format. * @param format String format.
* @param ... Format arguments. * @param ... Format arguments.
* @error File could not be opened/written. * @error File could not be opened/written.
*/ */
native void LogToFile(const char[] file, const char[] format, any ...); native void LogToFile(const char[] file, const char[] format, any ...);
/** /**
* Same as LogToFile(), except no plugin logtag is prepended. * Same as LogToFile(), except no plugin logtag is prepended.
* *
* @param file File to write the log message in. * @param file File to write the log message in.
* @param format String format. * @param format String format.
* @param ... Format arguments. * @param ... Format arguments.
* @error File could not be opened/written. * @error File could not be opened/written.
*/ */
native void LogToFileEx(const char[] file, const char[] format, any ...); native void LogToFileEx(const char[] file, const char[] format, any ...);
@ -69,35 +69,35 @@ native void LogToFileEx(const char[] file, const char[] format, any ...);
* Logs an action from a command or event whereby interception and routing may * Logs an action from a command or event whereby interception and routing may
* be important. This is intended to be a logging version of ShowActivity(). * be important. This is intended to be a logging version of ShowActivity().
* *
* @param client Client performing the action, 0 for server, or -1 if not * @param client Client performing the action, 0 for server, or -1 if not
* applicable. * applicable.
* @param target Client being targetted, or -1 if not applicable. * @param target Client being targetted, or -1 if not applicable.
* @param message Message format. * @param message Message format.
* @param ... Message formatting parameters. * @param ... Message formatting parameters.
*/ */
native void LogAction(int client, int target, const char[] message, any ...); native void LogAction(int client, int target, const char[] message, any ...);
/** /**
* Logs a plugin error message to the SourceMod logs. * Logs a plugin error message to the SourceMod logs.
* *
* @param format String format. * @param format String format.
* @param ... Format arguments. * @param ... Format arguments.
*/ */
native void LogError(const char[] format, any ...); native void LogError(const char[] format, any ...);
/** /**
* Called when an action is going to be logged. * Called when an action is going to be logged.
* *
* @param source Handle to the object logging the action, or INVALID_HANDLE * @param source Handle to the object logging the action, or INVALID_HANDLE
* if Core is logging the action. * if Core is logging the action.
* @param ident Type of object logging the action (plugin, ext, or core). * @param ident Type of object logging the action (plugin, ext, or core).
* @param client Client the action is from; 0 for server, -1 if not applicable. * @param client Client the action is from; 0 for server, -1 if not applicable.
* @param target Client the action is targetting, or -1 if not applicable. * @param target Client the action is targetting, or -1 if not applicable.
* @param message Message that is being logged. * @param message Message that is being logged.
* @return Plugin_Continue will perform the default logging behavior. * @return Plugin_Continue will perform the default logging behavior.
* Plugin_Handled will stop Core from logging the message. * Plugin_Handled will stop Core from logging the message.
* Plugin_Stop is the same as Handled, but prevents any other * Plugin_Stop is the same as Handled, but prevents any other
* plugins from handling the message. * plugins from handling the message.
*/ */
forward Action OnLogAction(Handle source, forward Action OnLogAction(Handle source,
Identity ident, Identity ident,
@ -114,22 +114,22 @@ forward Action OnLogAction(Handle source,
* Note that this does not capture log messages from the engine. It only * Note that this does not capture log messages from the engine. It only
* captures log messages being sent from the game/mod itself. * captures log messages being sent from the game/mod itself.
* *
* @param message Message contents. * @param message Message contents.
* @return Plugin_Handled or Plugin_Stop will prevent the message * @return Plugin_Handled or Plugin_Stop will prevent the message
* from being written to the log file. * from being written to the log file.
*/ */
typedef GameLogHook = function Action (const char[] message); typedef GameLogHook = function Action (const char[] message);
/** /**
* Adds a game log hook. * Adds a game log hook.
* *
* @param hook Hook function. * @param hook Hook function.
*/ */
native void AddGameLogHook(GameLogHook hook); native void AddGameLogHook(GameLogHook hook);
/** /**
* Removes a game log hook. * Removes a game log hook.
* *
* @param hook Hook function. * @param hook Hook function.
*/ */
native void RemoveGameLogHook(GameLogHook hook); native void RemoveGameLogHook(GameLogHook hook);

View File

@ -30,71 +30,72 @@
* Version: $Id$ * Version: $Id$
*/ */
#if defined _mapchooser_included_ #if defined _mapchooser_included_
#endinput #endinput
#endif #endif
#define _mapchooser_included_ #define _mapchooser_included_
enum NominateResult enum NominateResult
{ {
Nominate_Added, /** The map was added to the nominate list */ Nominate_Added, /** The map was added to the nominate list */
Nominate_Replaced, /** A clients existing nomination was replaced */ Nominate_Replaced, /** A clients existing nomination was replaced */
Nominate_AlreadyInVote, /** Specified map was already in the vote */ Nominate_AlreadyInVote, /** Specified map was already in the vote */
Nominate_InvalidMap, /** Mapname specified wasn't a valid map */ Nominate_InvalidMap, /** Mapname specified wasn't a valid map */
Nominate_VoteFull, /** This will only occur if force was set to false */ Nominate_VoteFull /** This will only occur if force was set to false */
}; };
enum MapChange enum MapChange
{ {
MapChange_Instant, /** Change map as soon as the voting results have come in */ MapChange_Instant, /** Change map as soon as the voting results have come in */
MapChange_RoundEnd, /** Change map at the end of the round */ MapChange_RoundEnd, /** Change map at the end of the round */
MapChange_MapEnd, /** Change the sm_nextmap cvar */ MapChange_MapEnd /** Change the sm_nextmap cvar */
}; };
/** /**
* Attempt to add a map to the mapchooser map list. * Attempt to add a map to the mapchooser map list.
* *
* @param map Map to add. * @param map Map to add.
* @param force Should we force the map in even if it requires overwriting an existing nomination? * @param force Should we force the map in even if it requires overwriting an existing nomination?
* @param owner Client index of the nominator. If the client disconnects the nomination will be removed. Use 0 for constant nominations * @param owner Client index of the nominator. If the client disconnects the nomination will be removed.
* @return Nominate Result of the outcome * Use 0 for constant nominations
* @return Nominate Result of the outcome
*/ */
native NominateResult NominateMap(const char[] map, bool force, int owner); native NominateResult NominateMap(const char[] map, bool force, int owner);
/** /**
* Attempt to remove a map from the mapchooser map list. * Attempt to remove a map from the mapchooser map list.
* *
* @param map Map to remove. * @param map Map to remove.
* @return True if the nomination was found and removed, or false if the nomination was not found. * @return True if the nomination was found and removed, or false if the nomination was not found.
*/ */
native bool RemoveNominationByMap(const char[] map); native bool RemoveNominationByMap(const char[] map);
/** /**
* Attempt to remove a map from the mapchooser map list. * Attempt to remove a map from the mapchooser map list.
* *
* @param owner Client index of the nominator. * @param owner Client index of the nominator.
* @return True if the nomination was found and removed, or false if the nomination was not found. * @return True if the nomination was found and removed, or false if the nomination was not found.
*/ */
native bool RemoveNominationByOwner(int owner); native bool RemoveNominationByOwner(int owner);
/** /**
* Gets the current list of excluded maps. * Gets the current list of excluded maps.
* *
* @param array An ADT array handle to add the map strings to. * @param array An ADT array handle to add the map strings to.
*/ */
native void GetExcludeMapList(ArrayList array); native void GetExcludeMapList(ArrayList array);
/** /**
* Gets the current list of nominated maps. * Gets the current list of nominated maps.
* *
* @param maparray An ADT array handle to add the map strings to. * @param maparray An ADT array handle to add the map strings to.
* @param ownerarray An optional ADT array handle to add the nominator client indexes to. * @param ownerarray An optional ADT array handle to add the nominator client indexes to.
*/ */
native void GetNominatedMapList(ArrayList maparray, ArrayList ownerarray = null); native void GetNominatedMapList(ArrayList maparray, ArrayList ownerarray = null);
/** /**
* Checks if MapChooser will allow a vote * Checks if MapChooser will allow a vote
* *
* @return True if a vote can be held, or false if mapchooser is already holding a vote. * @return True if a vote can be held, or false if mapchooser is already holding a vote.
*/ */
native bool CanMapChooserStartVote(); native bool CanMapChooserStartVote();
@ -104,22 +105,22 @@ native bool CanMapChooserStartVote();
* Note: If no input array is specified mapchooser will use its internal list. This includes * Note: If no input array is specified mapchooser will use its internal list. This includes
* any nominations and excluded maps (as per mapchoosers convars). * any nominations and excluded maps (as per mapchoosers convars).
* *
* @param when MapChange consant of when the resulting mapchange should occur. * @param when MapChange consant of when the resulting mapchange should occur.
* @param inputarray ADT array list of maps to add to the vote. * @param inputarray ADT array list of maps to add to the vote.
*/ */
native void InitiateMapChooserVote(MapChange when, ArrayList inputarray=null); native void InitiateMapChooserVote(MapChange when, ArrayList inputarray=null);
/** /**
* Checks if MapChooser's end of map vote has completed. * Checks if MapChooser's end of map vote has completed.
* *
* @return True if complete, false otherwise. * @return True if complete, false otherwise.
*/ */
native bool HasEndOfMapVoteFinished(); native bool HasEndOfMapVoteFinished();
/** /**
* Checks if MapChooser is set to run an end of map vote. * Checks if MapChooser is set to run an end of map vote.
* *
* @return True if enabled, false otherwise. * @return True if enabled, false otherwise.
*/ */
native bool EndOfMapVoteEnabled(); native bool EndOfMapVoteEnabled();

View File

@ -40,9 +40,9 @@
*/ */
enum MenuStyle enum MenuStyle
{ {
MenuStyle_Default = 0, /**< The "default" menu style for the mod */ MenuStyle_Default = 0, /**< The "default" menu style for the mod */
MenuStyle_Valve = 1, /**< The Valve provided menu style (Used on HL2DM) */ MenuStyle_Valve = 1, /**< The Valve provided menu style (Used on HL2DM) */
MenuStyle_Radio = 2, /**< The simpler menu style commonly used on CS:S */ MenuStyle_Radio = 2 /**< The simpler menu style commonly used on CS:S */
}; };
/** /**
@ -50,64 +50,62 @@ enum MenuStyle
*/ */
enum MenuAction enum MenuAction
{ {
MenuAction_Start = (1<<0), /**< A menu has been started (nothing passed) */ MenuAction_Start = (1<<0), /**< A menu has been started (nothing passed) */
MenuAction_Display = (1<<1), /**< A menu is about to be displayed (param1=client, param2=MenuPanel Handle) */ MenuAction_Display = (1<<1), /**< A menu is about to be displayed (param1=client, param2=MenuPanel Handle) */
MenuAction_Select = (1<<2), /**< An item was selected (param1=client, param2=item) */ MenuAction_Select = (1<<2), /**< An item was selected (param1=client, param2=item) */
MenuAction_Cancel = (1<<3), /**< The menu was cancelled (param1=client, param2=reason) */ MenuAction_Cancel = (1<<3), /**< The menu was cancelled (param1=client, param2=reason) */
MenuAction_End = (1<<4), /**< A menu display has fully ended. MenuAction_End = (1<<4), /**< A menu display has fully ended.
param1 is the MenuEnd reason, and if it's MenuEnd_Cancelled, then param1 is the MenuEnd reason, and if it's MenuEnd_Cancelled, then
param2 is the MenuCancel reason from MenuAction_Cancel. param2 is the MenuCancel reason from MenuAction_Cancel. */
*/ MenuAction_VoteEnd = (1<<5), /**< (VOTE ONLY): A vote sequence has succeeded (param1=chosen item)
MenuAction_VoteEnd = (1<<5), /**< (VOTE ONLY): A vote sequence has succeeded (param1=chosen item) This is not called if SetVoteResultCallback has been used on the menu. */
This is not called if SetVoteResultCallback has been used on the menu. */ MenuAction_VoteStart = (1<<6), /**< (VOTE ONLY): A vote sequence has started (nothing passed) */
MenuAction_VoteStart = (1<<6), /**< (VOTE ONLY): A vote sequence has started (nothing passed) */ MenuAction_VoteCancel = (1<<7), /**< (VOTE ONLY): A vote sequence has been cancelled (param1=reason) */
MenuAction_VoteCancel = (1<<7), /**< (VOTE ONLY): A vote sequence has been cancelled (param1=reason) */ MenuAction_DrawItem = (1<<8), /**< An item is being drawn; return the new style (param1=client, param2=item) */
MenuAction_DrawItem = (1<<8), /**< An item is being drawn; return the new style (param1=client, param2=item) */ MenuAction_DisplayItem = (1<<9) /**< Item text is being drawn to the display (param1=client, param2=item)
MenuAction_DisplayItem = (1<<9),/**< Item text is being drawn to the display (param1=client, param2=item) To change the text, use RedrawMenuItem().
To change the text, use RedrawMenuItem(). If you do so, return its return value. Otherwise, return 0. */
If you do so, return its return value. Otherwise, return 0.
*/
}; };
/** Default menu actions */ /** Default menu actions */
#define MENU_ACTIONS_DEFAULT MenuAction_Select|MenuAction_Cancel|MenuAction_End #define MENU_ACTIONS_DEFAULT MenuAction_Select|MenuAction_Cancel|MenuAction_End
/** All menu actions */ /** All menu actions */
#define MENU_ACTIONS_ALL view_as<MenuAction>(0xFFFFFFFF) #define MENU_ACTIONS_ALL view_as<MenuAction>(0xFFFFFFFF)
#define MENU_NO_PAGINATION 0 /**< Menu should not be paginated (10 items max) */ #define MENU_NO_PAGINATION 0 /**< Menu should not be paginated (10 items max) */
#define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */ #define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */
#define ITEMDRAW_DEFAULT (0) /**< Item should be drawn normally */ #define ITEMDRAW_DEFAULT (0) /**< Item should be drawn normally */
#define ITEMDRAW_DISABLED (1<<0) /**< Item is drawn but not selectable */ #define ITEMDRAW_DISABLED (1<<0) /**< Item is drawn but not selectable */
#define ITEMDRAW_RAWLINE (1<<1) /**< Item should be a raw line, without a slot */ #define ITEMDRAW_RAWLINE (1<<1) /**< Item should be a raw line, without a slot */
#define ITEMDRAW_NOTEXT (1<<2) /**< No text should be drawn */ #define ITEMDRAW_NOTEXT (1<<2) /**< No text should be drawn */
#define ITEMDRAW_SPACER (1<<3) /**< Item should be drawn as a spacer, if possible */ #define ITEMDRAW_SPACER (1<<3) /**< Item should be drawn as a spacer, if possible */
#define ITEMDRAW_IGNORE ((1<<1)|(1<<2)) /**< Item should be completely ignored (rawline + notext) */ #define ITEMDRAW_IGNORE ((1<<1)|(1<<2)) /**< Item should be completely ignored (rawline + notext) */
#define ITEMDRAW_CONTROL (1<<4) /**< Item is control text (back/next/exit) */ #define ITEMDRAW_CONTROL (1<<4) /**< Item is control text (back/next/exit) */
#define MENUFLAG_BUTTON_EXIT (1<<0) /**< Menu has an "exit" button (default if paginated) */ #define MENUFLAG_BUTTON_EXIT (1<<0) /**< Menu has an "exit" button (default if paginated) */
#define MENUFLAG_BUTTON_EXITBACK (1<<1) /**< Menu has an "exit back" button */ #define MENUFLAG_BUTTON_EXITBACK (1<<1) /**< Menu has an "exit back" button */
#define MENUFLAG_NO_SOUND (1<<2) /**< Menu will not have any select sounds */ #define MENUFLAG_NO_SOUND (1<<2) /**< Menu will not have any select sounds */
#define MENUFLAG_BUTTON_NOVOTE (1<<3) /**< Menu has a "No Vote" button at slot 1 */ #define MENUFLAG_BUTTON_NOVOTE (1<<3) /**< Menu has a "No Vote" button at slot 1 */
#define VOTEINFO_CLIENT_INDEX 0 /**< Client index */ #define VOTEINFO_CLIENT_INDEX 0 /**< Client index */
#define VOTEINFO_CLIENT_ITEM 1 /**< Item the client selected, or -1 for none */ #define VOTEINFO_CLIENT_ITEM 1 /**< Item the client selected, or -1 for none */
#define VOTEINFO_ITEM_INDEX 0 /**< Item index */ #define VOTEINFO_ITEM_INDEX 0 /**< Item index */
#define VOTEINFO_ITEM_VOTES 1 /**< Number of votes for the item */ #define VOTEINFO_ITEM_VOTES 1 /**< Number of votes for the item */
#define VOTEFLAG_NO_REVOTES (1<<0) /**< Players cannot change their votes */ #define VOTEFLAG_NO_REVOTES (1<<0) /**< Players cannot change their votes */
/** /**
* Reasons a menu can be cancelled (MenuAction_Cancel). * Reasons a menu can be cancelled (MenuAction_Cancel).
*/ */
enum enum
{ {
MenuCancel_Disconnected = -1, /**< Client dropped from the server */ MenuCancel_Disconnected = -1, /**< Client dropped from the server */
MenuCancel_Interrupted = -2, /**< Client was interrupted with another menu */ MenuCancel_Interrupted = -2, /**< Client was interrupted with another menu */
MenuCancel_Exit = -3, /**< Client exited via "exit" */ MenuCancel_Exit = -3, /**< Client exited via "exit" */
MenuCancel_NoDisplay = -4, /**< Menu could not be displayed to the client */ MenuCancel_NoDisplay = -4, /**< Menu could not be displayed to the client */
MenuCancel_Timeout = -5, /**< Menu timed out */ MenuCancel_Timeout = -5, /**< Menu timed out */
MenuCancel_ExitBack = -6, /**< Client selected "exit back" on a paginated menu */ MenuCancel_ExitBack = -6 /**< Client selected "exit back" on a paginated menu */
}; };
/** /**
@ -115,8 +113,8 @@ enum
*/ */
enum enum
{ {
VoteCancel_Generic = -1, /**< Vote was generically cancelled. */ VoteCancel_Generic = -1, /**< Vote was generically cancelled. */
VoteCancel_NoVotes = -2, /**< Vote did not receive any votes. */ VoteCancel_NoVotes = -2 /**< Vote did not receive any votes. */
}; };
/** /**
@ -124,12 +122,12 @@ enum
*/ */
enum enum
{ {
MenuEnd_Selected = 0, /**< Menu item was selected */ MenuEnd_Selected = 0, /**< Menu item was selected */
MenuEnd_VotingDone = -1, /**< Voting finished */ MenuEnd_VotingDone = -1, /**< Voting finished */
MenuEnd_VotingCancelled = -2, /**< Voting was cancelled */ MenuEnd_VotingCancelled = -2, /**< Voting was cancelled */
MenuEnd_Cancelled = -3, /**< Menu was cancelled (reason in param2) */ MenuEnd_Cancelled = -3, /**< Menu was cancelled (reason in param2) */
MenuEnd_Exit = -4, /**< Menu was cleanly exited via "exit" */ MenuEnd_Exit = -4, /**< Menu was cleanly exited via "exit" */
MenuEnd_ExitBack = -5, /**< Menu was cleanly exited via "back" */ MenuEnd_ExitBack = -5 /**< Menu was cleanly exited via "back" */
}; };
/** /**
@ -137,19 +135,19 @@ enum
*/ */
enum MenuSource enum MenuSource
{ {
MenuSource_None = 0, /**< No menu is being displayed */ MenuSource_None = 0, /**< No menu is being displayed */
MenuSource_External = 1, /**< External menu */ MenuSource_External = 1, /**< External menu */
MenuSource_Normal = 2, /**< A basic menu is being displayed */ MenuSource_Normal = 2, /**< A basic menu is being displayed */
MenuSource_RawPanel = 3, /**< A display is active, but it is not tied to a menu */ MenuSource_RawPanel = 3 /**< A display is active, but it is not tied to a menu */
}; };
/** /**
* Called when a menu action is completed. * Called when a menu action is completed.
* *
* @param menu The menu being acted upon. * @param menu The menu being acted upon.
* @param action The action of the menu. * @param action The action of the menu.
* @param param1 First action parameter (usually the client). * @param param1 First action parameter (usually the client).
* @param param2 Second action parameter (usually the item). * @param param2 Second action parameter (usually the item).
*/ */
typedef MenuHandler = function int (Menu menu, MenuAction action, int param1, int param2); typedef MenuHandler = function int (Menu menu, MenuAction action, int param1, int param2);
@ -159,7 +157,7 @@ methodmap Panel < Handle
{ {
// Constructor for a new Panel. // Constructor for a new Panel.
// //
// @param hStyle MenuStyle Handle, or null to use the default style. // @param hStyle MenuStyle Handle, or null to use the default style.
public native Panel(Handle hStyle = null); public native Panel(Handle hStyle = null);
// Sets the panel's title. // Sets the panel's title.
@ -369,7 +367,9 @@ methodmap Menu < Handle
int[] players = new int[MaxClients]; int[] players = new int[MaxClients];
for (int i = 1; i <= MaxClients; i++) { for (int i = 1; i <= MaxClients; i++) {
if (!IsClientInGame(i) || IsFakeClient(i)) if (!IsClientInGame(i) || IsFakeClient(i))
{
continue; continue;
}
players[total++] = i; players[total++] = i;
} }
return this.DisplayVote(players, total, time, flags); return this.DisplayVote(players, total, time, flags);
@ -442,48 +442,48 @@ methodmap Menu < Handle
/** /**
* Creates a new, empty menu using the default style. * Creates a new, empty menu using the default style.
* *
* @param handler Function which will receive menu actions. * @param handler Function which will receive menu actions.
* @param actions Optionally set which actions to receive. Select, * @param actions Optionally set which actions to receive. Select,
* Cancel, and End will always be received regardless * Cancel, and End will always be received regardless
* of whether they are set or not. They are also * of whether they are set or not. They are also
* the only default actions. * the only default actions.
* @return A new menu Handle. * @return A new menu Handle.
*/ */
native Menu CreateMenu(MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT); native Menu CreateMenu(MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT);
/** /**
* Displays a menu to a client. * Displays a menu to a client.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param client Client index. * @param client Client index.
* @param time Maximum time to leave menu on the screen. * @param time Maximum time to leave menu on the screen.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid Handle or client not in game. * @error Invalid Handle or client not in game.
*/ */
native bool DisplayMenu(Handle menu, int client, int time); native bool DisplayMenu(Handle menu, int client, int time);
/** /**
* Displays a menu to a client, starting from the given item. * Displays a menu to a client, starting from the given item.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param client Client index. * @param client Client index.
* @param first_item First item to begin drawing from. * @param first_item First item to begin drawing from.
* @param time Maximum time to leave menu on the screen. * @param time Maximum time to leave menu on the screen.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid Handle or client not in game. * @error Invalid Handle or client not in game.
*/ */
native bool DisplayMenuAtItem(Handle menu, int client, int first_item, int time); native bool DisplayMenuAtItem(Handle menu, int client, int first_item, int time);
/** /**
* Appends a new item to the end of a menu. * Appends a new item to the end of a menu.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param info Item information string. * @param info Item information string.
* @param display Default item display string. * @param display Default item display string.
* @param style Drawing style flags. Anything other than DEFAULT or * @param style Drawing style flags. Anything other than DEFAULT or
* DISABLED will be completely ignored when paginating. * DISABLED will be completely ignored when paginating.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid Handle or item limit reached. * @error Invalid Handle or item limit reached.
*/ */
native bool AddMenuItem(Handle menu, native bool AddMenuItem(Handle menu,
const char[] info, const char[] info,
@ -494,14 +494,14 @@ native bool AddMenuItem(Handle menu,
* Inserts an item into the menu before a certain position; the new item will * Inserts an item into the menu before a certain position; the new item will
* be at the given position and all next items pushed forward. * be at the given position and all next items pushed forward.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param position Position, starting from 0. * @param position Position, starting from 0.
* @param info Item information string. * @param info Item information string.
* @param display Default item display string. * @param display Default item display string.
* @param style Drawing style flags. Anything other than DEFAULT or * @param style Drawing style flags. Anything other than DEFAULT or
* DISABLED will be completely ignored when paginating. * DISABLED will be completely ignored when paginating.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid Handle or menu position. * @error Invalid Handle or menu position.
*/ */
native bool InsertMenuItem(Handle menu, native bool InsertMenuItem(Handle menu,
position, position,
@ -512,33 +512,33 @@ native bool InsertMenuItem(Handle menu,
/** /**
* Removes an item from the menu. * Removes an item from the menu.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param position Position, starting from 0. * @param position Position, starting from 0.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid Handle or menu position. * @error Invalid Handle or menu position.
*/ */
native bool RemoveMenuItem(Handle menu, int position); native bool RemoveMenuItem(Handle menu, int position);
/** /**
* Removes all items from a menu. * Removes all items from a menu.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @error Invalid Handle or menu position. * @error Invalid Handle or menu position.
*/ */
native void RemoveAllMenuItems(Handle menu); native void RemoveAllMenuItems(Handle menu);
/** /**
* Retrieves information about a menu item. * Retrieves information about a menu item.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param position Position, starting from 0. * @param position Position, starting from 0.
* @param infoBuf Info buffer. * @param infoBuf Info buffer.
* @param infoBufLen Maximum length of the info buffer. * @param infoBufLen Maximum length of the info buffer.
* @param style By-reference variable to store drawing flags. * @param style By-reference variable to store drawing flags.
* @param dispBuf Display buffer. * @param dispBuf Display buffer.
* @param dispBufLen Maximum length of the display buffer. * @param dispBufLen Maximum length of the display buffer.
* @return True on success, false if position is invalid. * @return True on success, false if position is invalid.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool GetMenuItem(Handle menu, native bool GetMenuItem(Handle menu,
int position, int position,
@ -553,20 +553,20 @@ native bool GetMenuItem(Handle menu,
* *
* This is only valid inside a MenuAction_Select callback. * This is only valid inside a MenuAction_Select callback.
* *
* @return First item number on the page the client was viewing * @return First item number on the page the client was viewing
* before selecting the item in the callback. This can * before selecting the item in the callback. This can
* be used to re-display the menu from the original * be used to re-display the menu from the original
* position. * position.
* @error Not called from inside a MenuAction_Select callback. * @error Not called from inside a MenuAction_Select callback.
*/ */
native int GetMenuSelectionPosition(); native int GetMenuSelectionPosition();
/** /**
* Returns the number of items in a menu. * Returns the number of items in a menu.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @return Number of items in the menu. * @return Number of items in the menu.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int GetMenuItemCount(Handle menu); native int GetMenuItemCount(Handle menu);
@ -576,20 +576,20 @@ native int GetMenuItemCount(Handle menu);
* If itemsPerPage is MENU_NO_PAGINATION, and the exit button flag is set, * If itemsPerPage is MENU_NO_PAGINATION, and the exit button flag is set,
* then the exit button flag is removed. It can be re-applied if desired. * then the exit button flag is removed. It can be re-applied if desired.
* *
* @param menu Handle to the menu. * @param menu Handle to the menu.
* @param itemsPerPage Number of items per page, or MENU_NO_PAGINATION. * @param itemsPerPage Number of items per page, or MENU_NO_PAGINATION.
* @return True on success, false if pagination is too high or * @return True on success, false if pagination is too high or
* low. * low.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool SetMenuPagination(Handle menu, int itemsPerPage); native bool SetMenuPagination(Handle menu, int itemsPerPage);
/** /**
* Returns a menu's pagination setting. * Returns a menu's pagination setting.
* *
* @param menu Handle to the menu. * @param menu Handle to the menu.
* @return Pagination setting. * @return Pagination setting.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int GetMenuPagination(Handle menu); native int GetMenuPagination(Handle menu);
@ -597,30 +597,30 @@ native int GetMenuPagination(Handle menu);
* Returns a menu's MenuStyle Handle. The Handle * Returns a menu's MenuStyle Handle. The Handle
* is global and cannot be freed. * is global and cannot be freed.
* *
* @param menu Handle to the menu. * @param menu Handle to the menu.
* @return Handle to the menu's draw style. * @return Handle to the menu's draw style.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native Handle GetMenuStyle(Handle menu); native Handle GetMenuStyle(Handle menu);
/** /**
* Sets the menu's default title/instruction message. * Sets the menu's default title/instruction message.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param fmt Message string format * @param fmt Message string format
* @param ... Message string arguments. * @param ... Message string arguments.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void SetMenuTitle(Handle menu, const char[] fmt, any ...); native void SetMenuTitle(Handle menu, const char[] fmt, any ...);
/** /**
* Returns the text of a menu's title. * Returns the text of a menu's title.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param buffer Buffer to store title. * @param buffer Buffer to store title.
* @param maxlength Maximum length of the buffer. * @param maxlength Maximum length of the buffer.
* @return Number of bytes written. * @return Number of bytes written.
* @error Invalid Handle/ * @error Invalid Handle/
*/ */
native int GetMenuTitle(Handle menu, char[] buffer, int maxlength); native int GetMenuTitle(Handle menu, char[] buffer, int maxlength);
@ -628,9 +628,9 @@ native int GetMenuTitle(Handle menu, char[] buffer, int maxlength);
* Creates a raw MenuPanel based off the menu's style. * Creates a raw MenuPanel based off the menu's style.
* The Handle must be freed with CloseHandle(). * The Handle must be freed with CloseHandle().
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @return A new MenuPanel Handle. * @return A new MenuPanel Handle.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native Panel CreatePanelFromMenu(Handle menu); native Panel CreatePanelFromMenu(Handle menu);
@ -638,9 +638,9 @@ native Panel CreatePanelFromMenu(Handle menu);
* Returns whether or not the menu has an exit button. * Returns whether or not the menu has an exit button.
* By default, menus have an exit button. * By default, menus have an exit button.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @return True if the menu has an exit button; false otherwise. * @return True if the menu has an exit button; false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool GetMenuExitButton(Handle menu); native bool GetMenuExitButton(Handle menu);
@ -655,10 +655,10 @@ native bool GetMenuExitButton(Handle menu);
* If a non-paginated menu has an exit button, then at most 9 items will be * If a non-paginated menu has an exit button, then at most 9 items will be
* displayed. * displayed.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param button True to enable the button, false to remove it. * @param button True to enable the button, false to remove it.
* @return True if allowed; false on failure. * @return True if allowed; false on failure.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool SetMenuExitButton(Handle menu, bool button); native bool SetMenuExitButton(Handle menu, bool button);
@ -669,9 +669,9 @@ native bool SetMenuExitButton(Handle menu, bool button);
* Exit Back buttons appear as "Back" on page 1 of paginated menus and have * Exit Back buttons appear as "Back" on page 1 of paginated menus and have
* functionality defined by the user in MenuEnd_ExitBack. * functionality defined by the user in MenuEnd_ExitBack.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @return True if the menu has an exit back button; false otherwise. * @return True if the menu has an exit back button; false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool GetMenuExitBackButton(Handle menu); native bool GetMenuExitBackButton(Handle menu);
@ -682,9 +682,9 @@ native bool GetMenuExitBackButton(Handle menu);
* Exit Back buttons appear as "Back" on page 1 of paginated menus and have * Exit Back buttons appear as "Back" on page 1 of paginated menus and have
* functionality defined by the user in MenuEnd_ExitBack. * functionality defined by the user in MenuEnd_ExitBack.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param button True to enable the button, false to remove it. * @param button True to enable the button, false to remove it.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void SetMenuExitBackButton(Handle menu, bool button); native void SetMenuExitBackButton(Handle menu, bool button);
@ -692,10 +692,10 @@ native void SetMenuExitBackButton(Handle menu, bool button);
* Sets whether or not the menu has a "no vote" button in slot 1. * Sets whether or not the menu has a "no vote" button in slot 1.
* By default, menus do not have a no vote button. * By default, menus do not have a no vote button.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param button True to enable the button, false to remove it. * @param button True to enable the button, false to remove it.
* @return True if allowed; false on failure. * @return True if allowed; false on failure.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool SetMenuNoVoteButton(Handle menu, bool button); native bool SetMenuNoVoteButton(Handle menu, bool button);
@ -709,17 +709,17 @@ native bool SetMenuNoVoteButton(Handle menu, bool button);
* *
* If any vote is in progress on a menu, it will be cancelled. * If any vote is in progress on a menu, it will be cancelled.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void CancelMenu(Handle menu); native void CancelMenu(Handle menu);
/** /**
* Retrieves a menu's option flags. * Retrieves a menu's option flags.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @return A bitstring of MENUFLAG bits. * @return A bitstring of MENUFLAG bits.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int GetMenuOptionFlags(Handle menu); native int GetMenuOptionFlags(Handle menu);
@ -730,24 +730,24 @@ native int GetMenuOptionFlags(Handle menu);
* See SetMenuExitButton() for information on Exit buttons. * See SetMenuExitButton() for information on Exit buttons.
* See SetMenuExitBackButton() for information on Exit Back buttons. * See SetMenuExitBackButton() for information on Exit Back buttons.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param flags A new bitstring of MENUFLAG bits. * @param flags A new bitstring of MENUFLAG bits.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void SetMenuOptionFlags(Handle menu, int flags); native void SetMenuOptionFlags(Handle menu, int flags);
/** /**
* Returns whether a vote is in progress. * Returns whether a vote is in progress.
* *
* @param menu Deprecated; no longer used. * @param menu Deprecated; no longer used.
* @return True if a vote is in progress, false otherwise. * @return True if a vote is in progress, false otherwise.
*/ */
native bool IsVoteInProgress(Handle menu=INVALID_HANDLE); native bool IsVoteInProgress(Handle menu=INVALID_HANDLE);
/** /**
* Cancels the vote in progress. * Cancels the vote in progress.
* *
* @error If no vote is in progress. * @error If no vote is in progress.
*/ */
native void CancelVote(); native void CancelVote();
@ -759,26 +759,26 @@ native void CancelVote();
* Note that MenuAction_VoteEnd and MenuAction_VoteStart are both * Note that MenuAction_VoteEnd and MenuAction_VoteStart are both
* default callbacks and do not need to be enabled. * default callbacks and do not need to be enabled.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param clients Array of clients to broadcast to. * @param clients Array of clients to broadcast to.
* @param numClients Number of clients in the array. * @param numClients Number of clients in the array.
* @param time Maximum time to leave menu on the screen. * @param time Maximum time to leave menu on the screen.
* @param flags Optional voting flags. * @param flags Optional voting flags.
* @return True on success, false if this menu already has a vote session * @return True on success, false if this menu already has a vote session
* in progress. * in progress.
* @error Invalid Handle, or a vote is already in progress. * @error Invalid Handle, or a vote is already in progress.
*/ */
native bool VoteMenu(Handle menu, int[] clients, int numClients, int time, int flags=0); native bool VoteMenu(Handle menu, int[] clients, int numClients, int time, int flags=0);
/** /**
* Sends a vote menu to all clients. See VoteMenu() for more information. * Sends a vote menu to all clients. See VoteMenu() for more information.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param time Maximum time to leave menu on the screen. * @param time Maximum time to leave menu on the screen.
* @param flags Optional voting flags. * @param flags Optional voting flags.
* @return True on success, false if this menu already has a vote session * @return True on success, false if this menu already has a vote session
* in progress. * in progress.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
stock bool VoteMenuToAll(Handle menu, int time, int flags=0) stock bool VoteMenuToAll(Handle menu, int time, int flags=0)
{ {
@ -800,13 +800,13 @@ stock bool VoteMenuToAll(Handle menu, int time, int flags=0)
/** /**
* Callback for when a vote has ended and results are available. * Callback for when a vote has ended and results are available.
* *
* @param menu The menu being voted on. * @param menu The menu being voted on.
* @param num_votes Number of votes tallied in total. * @param num_votes Number of votes tallied in total.
* @param num_clients Number of clients who could vote. * @param num_clients Number of clients who could vote.
* @param client_info Array of clients. Use VOTEINFO_CLIENT_ defines. * @param client_info Array of clients. Use VOTEINFO_CLIENT_ defines.
* @param num_items Number of unique items that were selected. * @param num_items Number of unique items that were selected.
* @param item_info Array of items, sorted by count. Use VOTEINFO_ITEM * @param item_info Array of items, sorted by count. Use VOTEINFO_ITEM
* defines. * defines.
*/ */
typeset VoteHandler typeset VoteHandler
{ {
@ -835,9 +835,9 @@ typeset VoteHandler
* Sets an advanced vote handling callback. If this callback is set, * Sets an advanced vote handling callback. If this callback is set,
* MenuAction_VoteEnd will not be called. * MenuAction_VoteEnd will not be called.
* *
* @param menu Menu Handle. * @param menu Menu Handle.
* @param callback Callback function. * @param callback Callback function.
* @error Invalid Handle or callback. * @error Invalid Handle or callback.
*/ */
native void SetVoteResultCallback(Handle menu, VoteHandler callback); native void SetVoteResultCallback(Handle menu, VoteHandler callback);
@ -846,7 +846,7 @@ native void SetVoteResultCallback(Handle menu, VoteHandler callback);
* a publicly invocable menu. This number is the time remaining until * a publicly invocable menu. This number is the time remaining until
* (last_vote + sm_vote_delay). * (last_vote + sm_vote_delay).
* *
* @return Number of seconds to wait, or 0 for none. * @return Number of seconds to wait, or 0 for none.
*/ */
native int CheckVoteDelay(); native int CheckVoteDelay();
@ -855,29 +855,29 @@ native int CheckVoteDelay();
* to participate in the current vote. This is determined by * to participate in the current vote. This is determined by
* the client list passed to VoteMenu(). * the client list passed to VoteMenu().
* *
* @param client Client index. * @param client Client index.
* @return True if client is allowed to vote, false otherwise. * @return True if client is allowed to vote, false otherwise.
* @error If no vote is in progress or client index is invalid. * @error If no vote is in progress or client index is invalid.
*/ */
native bool IsClientInVotePool(int client); native bool IsClientInVotePool(int client);
/** /**
* Redraws the current vote menu to a client in the voting pool. * Redraws the current vote menu to a client in the voting pool.
* *
* @param client Client index. * @param client Client index.
* @param revotes True to allow revotes, false otherwise. * @param revotes True to allow revotes, false otherwise.
* @return True on success, false if the client is in the vote pool * @return True on success, false if the client is in the vote pool
* but cannot vote again. * but cannot vote again.
* @error No vote in progress, int client is not in the voting pool, * @error No vote in progress, int client is not in the voting pool,
* or client index is invalid. * or client index is invalid.
*/ */
native bool RedrawClientVoteMenu(int client, bool revotes=true); native bool RedrawClientVoteMenu(int client, bool revotes=true);
/** /**
* Returns a style's global Handle. * Returns a style's global Handle.
* *
* @param style Menu Style. * @param style Menu Style.
* @return A Handle, or INVALID_HANDLE if not found or unusable. * @return A Handle, or INVALID_HANDLE if not found or unusable.
*/ */
native Handle GetMenuStyleHandle(MenuStyle style); native Handle GetMenuStyleHandle(MenuStyle style);
@ -886,9 +886,9 @@ native Handle GetMenuStyleHandle(MenuStyle style);
* menus without any extra helper functions. The Handle must be closed * menus without any extra helper functions. The Handle must be closed
* with CloseHandle(). * with CloseHandle().
* *
* @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style. * @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style.
* @return A new MenuPanel Handle. * @return A new MenuPanel Handle.
* @error Invalid Handle other than INVALID_HANDLE. * @error Invalid Handle other than INVALID_HANDLE.
*/ */
native Panel CreatePanel(Handle hStyle=INVALID_HANDLE); native Panel CreatePanel(Handle hStyle=INVALID_HANDLE);
@ -896,63 +896,63 @@ native Panel CreatePanel(Handle hStyle=INVALID_HANDLE);
* Creates a Menu from a MenuStyle. The Handle must be closed with * Creates a Menu from a MenuStyle. The Handle must be closed with
* CloseHandle(). * CloseHandle().
* *
* @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style. * @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style.
* @param handler Function which will receive menu actions. * @param handler Function which will receive menu actions.
* @param actions Optionally set which actions to receive. Select, * @param actions Optionally set which actions to receive. Select,
* Cancel, and End will always be received regardless * Cancel, and End will always be received regardless
* of whether they are set or not. They are also * of whether they are set or not. They are also
* the only default actions. * the only default actions.
* @return A new menu Handle. * @return A new menu Handle.
* @error Invalid Handle other than INVALID_HANDLE. * @error Invalid Handle other than INVALID_HANDLE.
*/ */
native Menu CreateMenuEx(Handle hStyle=INVALID_HANDLE, MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT); native Menu CreateMenuEx(Handle hStyle=INVALID_HANDLE, MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT);
/** /**
* Returns whether a client is viewing a menu. * Returns whether a client is viewing a menu.
* *
* @param client Client index. * @param client Client index.
* @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style. * @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style.
* @return A MenuSource value. * @return A MenuSource value.
* @error Invalid Handle other than null. * @error Invalid Handle other than null.
*/ */
native MenuSource GetClientMenu(int client, Handle hStyle=null); native MenuSource GetClientMenu(int client, Handle hStyle=null);
/** /**
* Cancels a menu on a client. This will only affect non-external menus. * Cancels a menu on a client. This will only affect non-external menus.
* *
* @param client Client index. * @param client Client index.
* @param autoIgnore If true, no menus can be re-drawn on the client during * @param autoIgnore If true, no menus can be re-drawn on the client during
* the cancellation process. * the cancellation process.
* @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style. * @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style.
* @return True if a menu was cancelled, false otherwise. * @return True if a menu was cancelled, false otherwise.
*/ */
native bool CancelClientMenu(int client, bool autoIgnore=false, Handle hStyle=INVALID_HANDLE); native bool CancelClientMenu(int client, bool autoIgnore=false, Handle hStyle=INVALID_HANDLE);
/** /**
* Returns a style's maximum items per page. * Returns a style's maximum items per page.
* *
* @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style. * @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style.
* @return Maximum items per page. * @return Maximum items per page.
* @error Invalid Handle other than INVALID_HANDLE. * @error Invalid Handle other than INVALID_HANDLE.
*/ */
native int GetMaxPageItems(Handle hStyle=INVALID_HANDLE); native int GetMaxPageItems(Handle hStyle=INVALID_HANDLE);
/** /**
* Returns a MenuPanel's parent style. * Returns a MenuPanel's parent style.
* *
* @param panel A MenuPanel Handle. * @param panel A MenuPanel Handle.
* @return The MenuStyle Handle that created the panel. * @return The MenuStyle Handle that created the panel.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native Handle GetPanelStyle(Handle panel); native Handle GetPanelStyle(Handle panel);
/** /**
* Sets the panel's title. * Sets the panel's title.
* *
* @param panel A MenuPanel Handle. * @param panel A MenuPanel Handle.
* @param text Text to set as the title. * @param text Text to set as the title.
* @param onlyIfEmpty If true, the title will only be set if no title is set. * @param onlyIfEmpty If true, the title will only be set if no title is set.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void SetPanelTitle(Handle panel, const char[] text, bool onlyIfEmpty=false); native void SetPanelTitle(Handle panel, const char[] text, bool onlyIfEmpty=false);
@ -960,24 +960,24 @@ native void SetPanelTitle(Handle panel, const char[] text, bool onlyIfEmpty=fals
* Draws an item on a panel. If the item takes up a slot, the position * Draws an item on a panel. If the item takes up a slot, the position
* is returned. * is returned.
* *
* @param panel A MenuPanel Handle. * @param panel A MenuPanel Handle.
* @param text Display text to use. If not a raw line, * @param text Display text to use. If not a raw line,
* the style may automatically add color markup. * the style may automatically add color markup.
* No numbering or newlines are needed. * No numbering or newlines are needed.
* @param style ITEMDRAW style flags. * @param style ITEMDRAW style flags.
* @return A slot position, or 0 if item was a rawline or could not be drawn. * @return A slot position, or 0 if item was a rawline or could not be drawn.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int DrawPanelItem(Handle panel, const char[] text, int style=ITEMDRAW_DEFAULT); native int DrawPanelItem(Handle panel, const char[] text, int style=ITEMDRAW_DEFAULT);
/** /**
* Draws a raw line of text on a panel, without any markup other than a newline. * Draws a raw line of text on a panel, without any markup other than a newline.
* *
* @param panel A MenuPanel Handle, or INVALID_HANDLE if inside a * @param panel A MenuPanel Handle, or INVALID_HANDLE if inside a
* MenuAction_DisplayItem callback. * MenuAction_DisplayItem callback.
* @param text Display text to use. * @param text Display text to use.
* @return True on success, false if raw lines are not supported. * @return True on success, false if raw lines are not supported.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool DrawPanelText(Handle panel, const char[] text); native bool DrawPanelText(Handle panel, const char[] text);
@ -985,10 +985,10 @@ native bool DrawPanelText(Handle panel, const char[] text);
* Returns whether or not the given drawing flags are supported by * Returns whether or not the given drawing flags are supported by
* the menu style. * the menu style.
* *
* @param panel A MenuPanel Handle. * @param panel A MenuPanel Handle.
* @param style ITEMDRAW style flags. * @param style ITEMDRAW style flags.
* @return True if item is drawable, false otherwise. * @return True if item is drawable, false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool CanPanelDrawFlags(Handle panel, int style); native bool CanPanelDrawFlags(Handle panel, int style);
@ -996,11 +996,11 @@ native bool CanPanelDrawFlags(Handle panel, int style);
* Sets the selectable key map of a panel. This is not supported by * Sets the selectable key map of a panel. This is not supported by
* all styles (only by Radio, as of this writing). * all styles (only by Radio, as of this writing).
* *
* @param panel A MenuPanel Handle. * @param panel A MenuPanel Handle.
* @param keys An integer where each bit N allows key * @param keys An integer where each bit N allows key
* N+1 to be selected. If no keys are selectable, * N+1 to be selected. If no keys are selectable,
* then key 0 (bit 9) is automatically set. * then key 0 (bit 9) is automatically set.
* @return True if supported, false otherwise. * @return True if supported, false otherwise.
*/ */
native bool SetPanelKeys(Handle panel, int keys); native bool SetPanelKeys(Handle panel, int keys);
@ -1015,12 +1015,12 @@ native bool SetPanelKeys(Handle panel, int keys);
* *
* Also, if the menu fails to display, no callbacks will be called. * Also, if the menu fails to display, no callbacks will be called.
* *
* @param panel A MenuPanel Handle. * @param panel A MenuPanel Handle.
* @param client A client to draw to. * @param client A client to draw to.
* @param handler The MenuHandler function to catch actions with. * @param handler The MenuHandler function to catch actions with.
* @param time Time to hold the menu for. * @param time Time to hold the menu for.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool SendPanelToClient(Handle panel, int client, MenuHandler handler, int time); native bool SendPanelToClient(Handle panel, int client, MenuHandler handler, int time);
@ -1031,19 +1031,19 @@ native bool SendPanelToClient(Handle panel, int client, MenuHandler handler, int
* Radio menus: Currently 511 characters (512 bytes). * Radio menus: Currently 511 characters (512 bytes).
* Valve menus: Currently -1 (no meaning). * Valve menus: Currently -1 (no meaning).
* *
* @param panel A MenuPanel Handle. * @param panel A MenuPanel Handle.
* @return Number of characters that the menu can still hold, * @return Number of characters that the menu can still hold,
* or -1 if there is no known limit. * or -1 if there is no known limit.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int GetPanelTextRemaining(Handle panel); native int GetPanelTextRemaining(Handle panel);
/** /**
* @brief Returns the current key position. * @brief Returns the current key position.
* *
* @param panel A MenuPanel Handle. * @param panel A MenuPanel Handle.
* @return Current key position starting at 1. * @return Current key position starting at 1.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int GetPanelCurrentKey(Handle panel); native int GetPanelCurrentKey(Handle panel);
@ -1051,19 +1051,19 @@ native int GetPanelCurrentKey(Handle panel);
* @brief Sets the next key position. This cannot be used * @brief Sets the next key position. This cannot be used
* to traverse backwards. * to traverse backwards.
* *
* @param panel A MenuPanel Handle. * @param panel A MenuPanel Handle.
* @param key Key that is greater or equal to * @param key Key that is greater or equal to
* GetPanelCurrentKey(). * GetPanelCurrentKey().
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool SetPanelCurrentKey(Handle panel, int key); native bool SetPanelCurrentKey(Handle panel, int key);
/** /**
* @brief Redraws menu text from inside a MenuAction_DisplayItem callback. * @brief Redraws menu text from inside a MenuAction_DisplayItem callback.
* *
* @param text Menu text to draw. * @param text Menu text to draw.
* @return Item position; must be returned via the callback. * @return Item position; must be returned via the callback.
*/ */
native int RedrawMenuItem(const char[] text); native int RedrawMenuItem(const char[] text);
@ -1076,23 +1076,23 @@ native int RedrawMenuItem(const char[] text);
* split up your menu into multiple packets; SourceMod will break the string * split up your menu into multiple packets; SourceMod will break the string
* up internally. * up internally.
* *
* @param client Client index. * @param client Client index.
* @param str Full menu string as would be passed over the network. * @param str Full menu string as would be passed over the network.
* @param time Time to hold the menu for. * @param time Time to hold the menu for.
* @param keys Selectable key bitstring. * @param keys Selectable key bitstring.
* @param handler Optional handler function, with the same rules as * @param handler Optional handler function, with the same rules as
* SendPanelToClient(). * SendPanelToClient().
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid client index, or radio menus not supported. * @error Invalid client index, or radio menus not supported.
*/ */
native bool InternalShowMenu(int client, const char[] str, int time, int keys=-1, MenuHandler handler=INVALID_FUNCTION); native bool InternalShowMenu(int client, const char[] str, int time, int keys=-1, MenuHandler handler=INVALID_FUNCTION);
/** /**
* Retrieves voting information from MenuAction_VoteEnd. * Retrieves voting information from MenuAction_VoteEnd.
* *
* @param param2 Second parameter of MenuAction_VoteEnd. * @param param2 Second parameter of MenuAction_VoteEnd.
* @param winningVotes Number of votes received by the winning option. * @param winningVotes Number of votes received by the winning option.
* @param totalVotes Number of total votes received. * @param totalVotes Number of total votes received.
*/ */
stock void GetMenuVoteInfo(int param2, int &winningVotes, int &totalVotes) stock void GetMenuVoteInfo(int param2, int &winningVotes, int &totalVotes)
{ {
@ -1105,8 +1105,8 @@ stock void GetMenuVoteInfo(int param2, int &winningVotes, int &totalVotes)
* fine-tune a reason for not voting, so it's not recommended for lazily * fine-tune a reason for not voting, so it's not recommended for lazily
* telling clients that voting isn't allowed. * telling clients that voting isn't allowed.
* *
* @return True if voting is allowed, false if voting is in progress * @return True if voting is allowed, false if voting is in progress
* or the cooldown is active. * or the cooldown is active.
*/ */
stock bool IsNewVoteAllowed() stock bool IsNewVoteAllowed()
{ {

View File

@ -31,7 +31,7 @@
*/ */
#if defined _nextmap_included_ #if defined _nextmap_included_
#endinput #endinput
#endif #endif
#define _nextmap_included_ #define _nextmap_included_
@ -39,44 +39,44 @@
* Sets SourceMod's internal nextmap. * Sets SourceMod's internal nextmap.
* Equivalent to changing sm_nextmap but with an added validity check. * Equivalent to changing sm_nextmap but with an added validity check.
* *
* @param map Next map to set. * @param map Next map to set.
* @return True if the nextmap was set, false if map was invalid. * @return True if the nextmap was set, false if map was invalid.
*/ */
native bool SetNextMap(const char[] map); native bool SetNextMap(const char[] map);
/** /**
* Returns SourceMod's internal nextmap. * Returns SourceMod's internal nextmap.
* *
* @param map Buffer to store the nextmap name. * @param map Buffer to store the nextmap name.
* @param maxlen Maximum length of the map buffer. * @param maxlen Maximum length of the map buffer.
* @return True if a Map was found and copied, false if no nextmap is set (map will be unchanged). * @return True if a Map was found and copied, false if no nextmap is set (map will be unchanged).
*/ */
native bool GetNextMap(char[] map, int maxlen); native bool GetNextMap(char[] map, int maxlen);
/** /**
* Changes the current map and records the reason for the change with maphistory * Changes the current map and records the reason for the change with maphistory
* *
* @param map Map to change to. * @param map Map to change to.
* @param reason Reason for change. * @param reason Reason for change.
*/ */
native void ForceChangeLevel(const char[] map, const char[] reason); native void ForceChangeLevel(const char[] map, const char[] reason);
/** /**
* Gets the current number of maps in the map history * Gets the current number of maps in the map history
* *
* @return Number of maps. * @return Number of maps.
*/ */
native int GetMapHistorySize(); native int GetMapHistorySize();
/** /**
* Retrieves a map from the map history list. * Retrieves a map from the map history list.
* *
* @param item Item number. Must be 0 or greater and less than GetMapHistorySize(). * @param item Item number. Must be 0 or greater and less than GetMapHistorySize().
* @param map Buffer to store the map name. * @param map Buffer to store the map name.
* @param mapLen Length of map buffer. * @param mapLen Length of map buffer.
* @param reason Buffer to store the change reason. * @param reason Buffer to store the change reason.
* @param reasonLen Length of the reason buffer. * @param reasonLen Length of the reason buffer.
* @param startTime Time the map started. * @param startTime Time the map started.
* @error Invalid item number. * @error Invalid item number.
*/ */
native void GetMapHistory(int item, char[] map, int mapLen, char[] reason, int reasonLen, int &startTime); native void GetMapHistory(int item, char[] map, int mapLen, char[] reason, int reasonLen, int &startTime);

View File

@ -44,7 +44,7 @@ methodmap Profiler < Handle
// Creates a new profile object. The Handle must be freed // Creates a new profile object. The Handle must be freed
// using delete or CloseHandle(). // using delete or CloseHandle().
// //
// @return A new Profiler Handle. // @return A new Profiler Handle.
public native Profiler(); public native Profiler();
// Starts a cycle for profiling. // Starts a cycle for profiling.
@ -52,14 +52,14 @@ methodmap Profiler < Handle
// Stops a cycle for profiling. // Stops a cycle for profiling.
// //
// @error Profiler was never started. // @error Profiler was never started.
public native void Stop(); public native void Stop();
// Returns the amount of high-precision time in seconds // Returns the amount of high-precision time in seconds
// that passed during the profiler's last start/stop // that passed during the profiler's last start/stop
// cycle. // cycle.
// //
// @return Time elapsed in seconds. // @return Time elapsed in seconds.
property float Time { property float Time {
public native get(); public native get();
} }
@ -69,23 +69,23 @@ methodmap Profiler < Handle
* Creates a new profile object. The Handle must be freed * Creates a new profile object. The Handle must be freed
* using delete or CloseHandle(). * using delete or CloseHandle().
* *
* @return Handle to the profiler object. * @return Handle to the profiler object.
*/ */
native Profiler CreateProfiler(); native Profiler CreateProfiler();
/** /**
* Starts profiling. * Starts profiling.
* *
* @param prof Profiling object. * @param prof Profiling object.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void StartProfiling(Handle prof); native void StartProfiling(Handle prof);
/** /**
* Stops profiling. * Stops profiling.
* *
* @param prof Profiling object. * @param prof Profiling object.
* @error Invalid Handle or profiling was never started. * @error Invalid Handle or profiling was never started.
*/ */
native void StopProfiling(Handle prof); native void StopProfiling(Handle prof);
@ -94,9 +94,9 @@ native void StopProfiling(Handle prof);
* that passed during the profiler's last start/stop * that passed during the profiler's last start/stop
* cycle. * cycle.
* *
* @param prof Profiling object. * @param prof Profiling object.
* @return Time elapsed in seconds. * @return Time elapsed in seconds.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native float GetProfilerTime(Handle prof); native float GetProfilerTime(Handle prof);

View File

@ -31,7 +31,7 @@
*/ */
#if defined _protobuf_included #if defined _protobuf_included
#endinput #endinput
#endif #endif
#define _protobuf_included #define _protobuf_included
@ -296,307 +296,307 @@ methodmap Protobuf < Handle
/** /**
* Reads an int32, uint32, sint32, fixed32, sfixed32, or enum value from a protobuf message. * Reads an int32, uint32, sint32, fixed32, sfixed32, or enum value from a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param index Index into repeated field. * @param index Index into repeated field.
* @return Integer value read. * @return Integer value read.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native int PbReadInt(Handle pb, const char[] field, int index = PB_FIELD_NOT_REPEATED); native int PbReadInt(Handle pb, const char[] field, int index = PB_FIELD_NOT_REPEATED);
/** /**
* Reads a float or downcasted double from a protobuf message. * Reads a float or downcasted double from a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param index Index into repeated field. * @param index Index into repeated field.
* @return Float value read. * @return Float value read.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native float PbReadFloat(Handle pb, const char[] field, int index = PB_FIELD_NOT_REPEATED); native float PbReadFloat(Handle pb, const char[] field, int index = PB_FIELD_NOT_REPEATED);
/** /**
* Reads a bool from a protobuf message. * Reads a bool from a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param index Index into repeated field. * @param index Index into repeated field.
* @return Boolean value read. * @return Boolean value read.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native bool PbReadBool(Handle pb, const char[] field, int index = PB_FIELD_NOT_REPEATED); native bool PbReadBool(Handle pb, const char[] field, int index = PB_FIELD_NOT_REPEATED);
/** /**
* Reads a string from a protobuf message. * Reads a string from a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer. * @param maxlength Maximum length of output string buffer.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbReadString(Handle pb, const char[] field, char[] buffer, int maxlength, int index = PB_FIELD_NOT_REPEATED); native void PbReadString(Handle pb, const char[] field, char[] buffer, int maxlength, int index = PB_FIELD_NOT_REPEATED);
/** /**
* Reads an RGBA color value from a protobuf message. * Reads an RGBA color value from a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param buffer Destination color buffer. * @param buffer Destination color buffer.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbReadColor(Handle pb, const char[] field, int buffer[4], int index = PB_FIELD_NOT_REPEATED); native void PbReadColor(Handle pb, const char[] field, int buffer[4], int index = PB_FIELD_NOT_REPEATED);
/** /**
* Reads an XYZ angle value from a protobuf message. * Reads an XYZ angle value from a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param buffer Destination angle buffer. * @param buffer Destination angle buffer.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbReadAngle(Handle pb, const char[] field, float buffer[3], int index = PB_FIELD_NOT_REPEATED); native void PbReadAngle(Handle pb, const char[] field, float buffer[3], int index = PB_FIELD_NOT_REPEATED);
/** /**
* Reads an XYZ vector value from a protobuf message. * Reads an XYZ vector value from a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param buffer Destination vector buffer. * @param buffer Destination vector buffer.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbReadVector(Handle pb, const char[] field, float buffer[3], int index = PB_FIELD_NOT_REPEATED); native void PbReadVector(Handle pb, const char[] field, float buffer[3], int index = PB_FIELD_NOT_REPEATED);
/** /**
* Reads an XY vector value from a protobuf message. * Reads an XY vector value from a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param buffer Destination vector buffer. * @param buffer Destination vector buffer.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbReadVector2D(Handle pb, const char[] field, float buffer[2], int index = PB_FIELD_NOT_REPEATED); native void PbReadVector2D(Handle pb, const char[] field, float buffer[2], int index = PB_FIELD_NOT_REPEATED);
/** /**
* Gets the number of elements in a repeated field of a protobuf message. * Gets the number of elements in a repeated field of a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @return Number of elements in the field. * @return Number of elements in the field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native int PbGetRepeatedFieldCount(Handle pb, const char[] field); native int PbGetRepeatedFieldCount(Handle pb, const char[] field);
/** /**
* Sets an int32, uint32, sint32, fixed32, sfixed32, or enum value on a protobuf message. * Sets an int32, uint32, sint32, fixed32, sfixed32, or enum value on a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param value Integer value to set. * @param value Integer value to set.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbSetInt(Handle pb, const char[] field, int value, int index = PB_FIELD_NOT_REPEATED); native void PbSetInt(Handle pb, const char[] field, int value, int index = PB_FIELD_NOT_REPEATED);
/** /**
* Sets a float or double on a protobuf message. * Sets a float or double on a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param value Float value to set. * @param value Float value to set.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbSetFloat(Handle pb, const char[] field, float value, int index = PB_FIELD_NOT_REPEATED); native void PbSetFloat(Handle pb, const char[] field, float value, int index = PB_FIELD_NOT_REPEATED);
/** /**
* Sets a bool on a protobuf message. * Sets a bool on a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param value Boolean value to set. * @param value Boolean value to set.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbSetBool(Handle pb, const char[] field, bool value, int index = PB_FIELD_NOT_REPEATED); native void PbSetBool(Handle pb, const char[] field, bool value, int index = PB_FIELD_NOT_REPEATED);
/** /**
* Sets a string on a protobuf message. * Sets a string on a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param value String value to set. * @param value String value to set.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbSetString(Handle pb, const char[] field, const char[] value, int index = PB_FIELD_NOT_REPEATED); native void PbSetString(Handle pb, const char[] field, const char[] value, int index = PB_FIELD_NOT_REPEATED);
/** /**
* Sets an RGBA color on a protobuf message. * Sets an RGBA color on a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param color Color value to set. * @param color Color value to set.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbSetColor(Handle pb, const char[] field, const int color[4], int index = PB_FIELD_NOT_REPEATED); native void PbSetColor(Handle pb, const char[] field, const int color[4], int index = PB_FIELD_NOT_REPEATED);
/** /**
* Sets an XYZ angle on a protobuf message. * Sets an XYZ angle on a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param angle Angle value to set. * @param angle Angle value to set.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbSetAngle(Handle pb, const char[] field, const float angle[3], int index = PB_FIELD_NOT_REPEATED); native void PbSetAngle(Handle pb, const char[] field, const float angle[3], int index = PB_FIELD_NOT_REPEATED);
/** /**
* Sets an XYZ vector on a protobuf message. * Sets an XYZ vector on a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param vec Vector value to set. * @param vec Vector value to set.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbSetVector(Handle pb, const char[] field, const float vec[3], int index = PB_FIELD_NOT_REPEATED); native void PbSetVector(Handle pb, const char[] field, const float vec[3], int index = PB_FIELD_NOT_REPEATED);
/** /**
* Sets an XY vector on a protobuf message. * Sets an XY vector on a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param vec Vector value to set. * @param vec Vector value to set.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbSetVector2D(Handle pb, const char[] field, const float vec[2], int index = PB_FIELD_NOT_REPEATED); native void PbSetVector2D(Handle pb, const char[] field, const float vec[2], int index = PB_FIELD_NOT_REPEATED);
/** /**
* Add an int32, uint32, sint32, fixed32, sfixed32, or enum value to a protobuf message repeated field. * Add an int32, uint32, sint32, fixed32, sfixed32, or enum value to a protobuf message repeated field.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param value Integer value to add. * @param value Integer value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbAddInt(Handle pb, const char[] field, int value); native void PbAddInt(Handle pb, const char[] field, int value);
/** /**
* Add a float or double to a protobuf message repeated field. * Add a float or double to a protobuf message repeated field.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param value Float value to add. * @param value Float value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbAddFloat(Handle pb, const char[] field, float value); native void PbAddFloat(Handle pb, const char[] field, float value);
/** /**
* Add a bool to a protobuf message repeated field. * Add a bool to a protobuf message repeated field.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param value Boolean value to add. * @param value Boolean value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbAddBool(Handle pb, const char[] field, bool value); native void PbAddBool(Handle pb, const char[] field, bool value);
/** /**
* Add a string to a protobuf message repeated field. * Add a string to a protobuf message repeated field.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param value String value to add. * @param value String value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbAddString(Handle pb, const char[] field, const char[] value); native void PbAddString(Handle pb, const char[] field, const char[] value);
/** /**
* Add an RGBA color to a protobuf message repeated field. * Add an RGBA color to a protobuf message repeated field.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param color Color value to add. * @param color Color value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbAddColor(Handle pb, const char[] field, const int color[4]); native void PbAddColor(Handle pb, const char[] field, const int color[4]);
/** /**
* Add an XYZ angle to a protobuf message repeated field. * Add an XYZ angle to a protobuf message repeated field.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param angle Angle value to add. * @param angle Angle value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbAddAngle(Handle pb, const char[] field, const float angle[3]); native void PbAddAngle(Handle pb, const char[] field, const float angle[3]);
/** /**
* Add an XYZ vector to a protobuf message repeated field. * Add an XYZ vector to a protobuf message repeated field.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param vec Vector value to add. * @param vec Vector value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbAddVector(Handle pb, const char[] field, const float vec[3]); native void PbAddVector(Handle pb, const char[] field, const float vec[3]);
/** /**
* Add an XY vector to a protobuf message repeated field. * Add an XY vector to a protobuf message repeated field.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param vec Vector value to add. * @param vec Vector value to add.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbAddVector2D(Handle pb, const char[] field, const float vec[2]); native void PbAddVector2D(Handle pb, const char[] field, const float vec[2]);
/** /**
* Removes a value by index from a protobuf message repeated field. * Removes a value by index from a protobuf message repeated field.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param index Index into repeated field. * @param index Index into repeated field.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native void PbRemoveRepeatedFieldValue(Handle pb, const char[] field, int index); native void PbRemoveRepeatedFieldValue(Handle pb, const char[] field, int index);
/** /**
* Retrieve a handle to an embedded protobuf message in a protobuf message. * Retrieve a handle to an embedded protobuf message in a protobuf message.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @return protobuf handle to embedded message. * @return protobuf handle to embedded message.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native Handle PbReadMessage(Handle pb, const char[] field); native Handle PbReadMessage(Handle pb, const char[] field);
/** /**
* Retrieve a handle to an embedded protobuf message in a protobuf message repeated field. * Retrieve a handle to an embedded protobuf message in a protobuf message repeated field.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @param index Index in the repeated field. * @param index Index in the repeated field.
* @return protobuf handle to embedded message. * @return protobuf handle to embedded message.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native Handle PbReadRepeatedMessage(Handle pb, const char[] field, int index); native Handle PbReadRepeatedMessage(Handle pb, const char[] field, int index);
/** /**
* Adds an embedded protobuf message to a protobuf message repeated field. * Adds an embedded protobuf message to a protobuf message repeated field.
* *
* @param pb protobuf handle. * @param pb protobuf handle.
* @param field Field name. * @param field Field name.
* @return protobuf handle to added, embedded message. * @return protobuf handle to added, embedded message.
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type. * @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
*/ */
native Handle PbAddMessage(Handle pb, const char[] field); native Handle PbAddMessage(Handle pb, const char[] field);

View File

@ -31,12 +31,12 @@
*/ */
#if defined _regex_included #if defined _regex_included
#endinput #endinput
#endif #endif
#define _regex_included #define _regex_included
/** /**
* @section Flags for compiling regex expressions. These come directly from the * @section Flags for compiling regex expressions. These come directly from the
* pcre library and can be used in MatchRegex and CompileRegex. * pcre library and can be used in MatchRegex and CompileRegex.
*/ */
#define PCRE_CASELESS 0x00000001 /* Ignore Case */ #define PCRE_CASELESS 0x00000001 /* Ignore Case */
@ -44,12 +44,12 @@
#define PCRE_DOTALL 0x00000004 /* Single line (affects . so that it matches any character, even new line characters). */ #define PCRE_DOTALL 0x00000004 /* Single line (affects . so that it matches any character, even new line characters). */
#define PCRE_EXTENDED 0x00000008 /* Pattern extension (ignore whitespace and # comments). */ #define PCRE_EXTENDED 0x00000008 /* Pattern extension (ignore whitespace and # comments). */
#define PCRE_ANCHORED 0x00000010 /* Force pattern anchoring. */ #define PCRE_ANCHORED 0x00000010 /* Force pattern anchoring. */
#define PCRE_DOLLAR_ENDONLY 0x00000020 /* $ not to match newline at end. */ #define PCRE_DOLLAR_ENDONLY 0x00000020 /* $ not to match newline at end. */
#define PCRE_UNGREEDY 0x00000200 /* Invert greediness of quantifiers */ #define PCRE_UNGREEDY 0x00000200 /* Invert greediness of quantifiers */
#define PCRE_NOTEMPTY 0x00000400 /* An empty string is not a valid match. */ #define PCRE_NOTEMPTY 0x00000400 /* An empty string is not a valid match. */
#define PCRE_UTF8 0x00000800 /* Use UTF-8 Chars */ #define PCRE_UTF8 0x00000800 /* Use UTF-8 Chars */
#define PCRE_NO_UTF8_CHECK 0x00002000 /* Do not check the pattern for UTF-8 validity (only relevant if PCRE_UTF8 is set) */ #define PCRE_NO_UTF8_CHECK 0x00002000 /* Do not check the pattern for UTF-8 validity (only relevant if PCRE_UTF8 is set) */
#define PCRE_UCP 0x20000000 /* Use Unicode properties for \ed, \ew, etc. */ #define PCRE_UCP 0x20000000 /* Use Unicode properties for \ed, \ew, etc. */
/** /**
@ -57,26 +57,26 @@
*/ */
enum RegexError enum RegexError
{ {
REGEX_ERROR_NONE = 0, /* No error */ REGEX_ERROR_NONE = 0, /* No error */
REGEX_ERROR_ASSERT = 1, /* internal error ? */ REGEX_ERROR_ASSERT = 1, /* internal error ? */
REGEX_ERROR_BADBR, /* invalid repeat counts in {} */ REGEX_ERROR_BADBR, /* invalid repeat counts in {} */
REGEX_ERROR_BADPAT, /* pattern error */ REGEX_ERROR_BADPAT, /* pattern error */
REGEX_ERROR_BADRPT, /* ? * + invalid */ REGEX_ERROR_BADRPT, /* ? * + invalid */
REGEX_ERROR_EBRACE, /* unbalanced {} */ REGEX_ERROR_EBRACE, /* unbalanced {} */
REGEX_ERROR_EBRACK, /* unbalanced [] */ REGEX_ERROR_EBRACK, /* unbalanced [] */
REGEX_ERROR_ECOLLATE, /* collation error - not relevant */ REGEX_ERROR_ECOLLATE, /* collation error - not relevant */
REGEX_ERROR_ECTYPE, /* bad class */ REGEX_ERROR_ECTYPE, /* bad class */
REGEX_ERROR_EESCAPE, /* bad escape sequence */ REGEX_ERROR_EESCAPE, /* bad escape sequence */
REGEX_ERROR_EMPTY, /* empty expression */ REGEX_ERROR_EMPTY, /* empty expression */
REGEX_ERROR_EPAREN, /* unbalanced () */ REGEX_ERROR_EPAREN, /* unbalanced () */
REGEX_ERROR_ERANGE, /* bad range inside [] */ REGEX_ERROR_ERANGE, /* bad range inside [] */
REGEX_ERROR_ESIZE, /* expression too big */ REGEX_ERROR_ESIZE, /* expression too big */
REGEX_ERROR_ESPACE, /* failed to get memory */ REGEX_ERROR_ESPACE, /* failed to get memory */
REGEX_ERROR_ESUBREG, /* bad back reference */ REGEX_ERROR_ESUBREG, /* bad back reference */
REGEX_ERROR_INVARG, /* bad argument */ REGEX_ERROR_INVARG, /* bad argument */
REGEX_ERROR_NOMATCH = -1, /* No match was found */ REGEX_ERROR_NOMATCH = -1, /* No match was found */
REGEX_ERROR_NULL = -2, REGEX_ERROR_NULL = -2,
REGEX_ERROR_BADOPTION = -3, REGEX_ERROR_BADOPTION = -3,
REGEX_ERROR_BADMAGIC = -4, REGEX_ERROR_BADMAGIC = -4,
@ -84,7 +84,7 @@ enum RegexError
REGEX_ERROR_NOMEMORY = -6, REGEX_ERROR_NOMEMORY = -6,
REGEX_ERROR_NOSUBSTRING = -7, REGEX_ERROR_NOSUBSTRING = -7,
REGEX_ERROR_MATCHLIMIT = -8, REGEX_ERROR_MATCHLIMIT = -8,
REGEX_ERROR_CALLOUT = -9, /* Never used by PCRE itself */ REGEX_ERROR_CALLOUT = -9, /* Never used by PCRE itself */
REGEX_ERROR_BADUTF8 = -10, REGEX_ERROR_BADUTF8 = -10,
REGEX_ERROR_BADUTF8_OFFSET = -11, REGEX_ERROR_BADUTF8_OFFSET = -11,
REGEX_ERROR_PARTIAL = -12, REGEX_ERROR_PARTIAL = -12,
@ -97,7 +97,7 @@ enum RegexError
REGEX_ERROR_DFA_WSSIZE = -19, REGEX_ERROR_DFA_WSSIZE = -19,
REGEX_ERROR_DFA_RECURSE = -20, REGEX_ERROR_DFA_RECURSE = -20,
REGEX_ERROR_RECURSIONLIMIT = -21, REGEX_ERROR_RECURSIONLIMIT = -21,
REGEX_ERROR_NULLWSLIMIT = -22, /* No longer actually used */ REGEX_ERROR_NULLWSLIMIT = -22, /* No longer actually used */
REGEX_ERROR_BADNEWLINE = -23, REGEX_ERROR_BADNEWLINE = -23,
REGEX_ERROR_BADOFFSET = -24, REGEX_ERROR_BADOFFSET = -24,
REGEX_ERROR_SHORTUTF8 = -25, REGEX_ERROR_SHORTUTF8 = -25,
@ -107,7 +107,7 @@ enum RegexError
REGEX_ERROR_BADENDIANNESS = -29, REGEX_ERROR_BADENDIANNESS = -29,
REGEX_ERROR_DFA_BADRESTART = -30, REGEX_ERROR_DFA_BADRESTART = -30,
REGEX_ERROR_JIT_BADOPTION = -31, REGEX_ERROR_JIT_BADOPTION = -31,
REGEX_ERROR_BADLENGTH = -32, REGEX_ERROR_BADLENGTH = -32
}; };
// Regular expression objects are used to match or decompose strings based on // Regular expression objects are used to match or decompose strings based on
@ -116,33 +116,33 @@ methodmap Regex < Handle
{ {
// Compile a regular expression. // Compile a regular expression.
// //
// @param pattern The regular expression pattern. // @param pattern The regular expression pattern.
// @param flags General flags for the regular expression. // @param flags General flags for the regular expression.
// @param error Error message encountered, if applicable. // @param error Error message encountered, if applicable.
// @param maxLen Maximum string length of the error buffer. // @param maxLen Maximum string length of the error buffer.
// @param errcode Regex type error code encountered, if applicable. // @param errcode Regex type error code encountered, if applicable.
public native Regex(const char[] pattern, int flags = 0, char[] error="", int maxLen = 0, RegexError &errcode = REGEX_ERROR_NONE); public native Regex(const char[] pattern, int flags = 0, char[] error="", int maxLen = 0, RegexError &errcode = REGEX_ERROR_NONE);
// Matches a string against a pre-compiled regular expression pattern. // Matches a string against a pre-compiled regular expression pattern.
// //
// @param str The string to check. // @param str The string to check.
// @param regex Regex Handle from CompileRegex() // @param regex Regex Handle from CompileRegex()
// @param ret Error code, if applicable. // @param ret Error code, if applicable.
// @param offset Offset in the string to start searching from. MatchOffset returns the offset of the match. // @param offset Offset in the string to start searching from. MatchOffset returns the offset of the match.
// @return Number of captures found or -1 on failure. // @return Number of captures found or -1 on failure.
// //
// @note Use the regex handle passed to this function to extract // @note Use the regex handle passed to this function to extract
// matches with GetSubString(). // matches with GetSubString().
public native int Match(const char[] str, RegexError &ret = REGEX_ERROR_NONE, int offset = 0); public native int Match(const char[] str, RegexError &ret = REGEX_ERROR_NONE, int offset = 0);
// Gets all matches from a string against a pre-compiled regular expression pattern. // Gets all matches from a string against a pre-compiled regular expression pattern.
// //
// @param str The string to check. // @param str The string to check.
// @param regex Regex Handle from CompileRegex() // @param regex Regex Handle from CompileRegex()
// @param ret Error code, if applicable. // @param ret Error code, if applicable.
// @return Number of matches found or -1 on failure. // @return Number of matches found or -1 on failure.
// //
// @note Use GetSubString() and loop from 0 -> totalmatches - 1. // @note Use GetSubString() and loop from 0 -> totalmatches - 1.
public native int MatchAll(const char[] str, RegexError &ret = REGEX_ERROR_NONE); public native int MatchAll(const char[] str, RegexError &ret = REGEX_ERROR_NONE);
// Returns a matched substring from a regex handle. // Returns a matched substring from a regex handle.
@ -150,35 +150,35 @@ methodmap Regex < Handle
// Substring ids start at 0 and end at captures-1, where captures is the // Substring ids start at 0 and end at captures-1, where captures is the
// number returned by Regex.Match or Regex.CaptureCount. // number returned by Regex.Match or Regex.CaptureCount.
// //
// @param regex The regex handle to extract data from. // @param regex The regex handle to extract data from.
// @param str_id The index of the expression to get - starts at 0, and ends at captures - 1. // @param str_id The index of the expression to get - starts at 0, and ends at captures - 1.
// @param buffer The buffer to set to the matching substring. // @param buffer The buffer to set to the matching substring.
// @param maxlen The maximum string length of the buffer. // @param maxlen The maximum string length of the buffer.
// @param match Match to get the captures for - starts at 0, and ends at MatchCount() -1 // @param match Match to get the captures for - starts at 0, and ends at MatchCount() -1
// @return True if a substring was found, False on fail/error // @return True if a substring was found, False on fail/error
// //
// @note str_id = 0 is the full captured string, anything else is the capture group index. // @note str_id = 0 is the full captured string, anything else is the capture group index.
// if Regex.Match is used match can only be 0 // if Regex.Match is used match can only be 0
public native bool GetSubString(int str_id, char[] buffer, int maxlen, int match = 0); public native bool GetSubString(int str_id, char[] buffer, int maxlen, int match = 0);
// Returns number of matches // Returns number of matches
// //
// When using Match this is always 1 or 0 (unless an error occured) // When using Match this is always 1 or 0 (unless an error occured)
// @return Total number of matches found. // @return Total number of matches found.
public native int MatchCount(); public native int MatchCount();
// Returns number of captures for a match // Returns number of captures for a match
// //
// @param match Match to get the number of captures for. Match starts at 0, and ends at MatchCount() -1 // @param match Match to get the number of captures for. Match starts at 0, and ends at MatchCount() -1
// @return Number of captures in the match. // @return Number of captures in the match.
// //
// @note Use GetSubString() and loop from 1 -> captures -1 for str_id to get all captures // @note Use GetSubString() and loop from 1 -> captures -1 for str_id to get all captures
public native int CaptureCount(int match = 0); public native int CaptureCount(int match = 0);
// Returns the string offset of a match. // Returns the string offset of a match.
// //
// @param match Match to get the offset of. Match starts at 0, and ends at MatchCount() -1 // @param match Match to get the offset of. Match starts at 0, and ends at MatchCount() -1
// @return Offset of the match in the string. // @return Offset of the match in the string.
public native int MatchOffset(int match = 0); public native int MatchOffset(int match = 0);
}; };
@ -187,25 +187,25 @@ methodmap Regex < Handle
* same expression multiple times. Pass the regex handle returned here to * same expression multiple times. Pass the regex handle returned here to
* MatchRegex to check for matches. * MatchRegex to check for matches.
* *
* @param pattern The regular expression pattern. * @param pattern The regular expression pattern.
* @param flags General flags for the regular expression. * @param flags General flags for the regular expression.
* @param error Error message encountered, if applicable. * @param error Error message encountered, if applicable.
* @param maxLen Maximum string length of the error buffer. * @param maxLen Maximum string length of the error buffer.
* @param errcode Regex type error code encountered, if applicable. * @param errcode Regex type error code encountered, if applicable.
* @return Valid regex handle on success, INVALID_HANDLE on failure. * @return Valid regex handle on success, INVALID_HANDLE on failure.
*/ */
native Regex CompileRegex(const char[] pattern, int flags = 0, char[] error="", int maxLen = 0, RegexError &errcode = REGEX_ERROR_NONE); native Regex CompileRegex(const char[] pattern, int flags = 0, char[] error="", int maxLen = 0, RegexError &errcode = REGEX_ERROR_NONE);
/** /**
* Matches a string against a pre-compiled regular expression pattern. * Matches a string against a pre-compiled regular expression pattern.
* *
* @param str The string to check. * @param str The string to check.
* @param regex Regex Handle from CompileRegex() * @param regex Regex Handle from CompileRegex()
* @param ret Error code, if applicable. * @param ret Error code, if applicable.
* @return Number of captures found or -1 on failure. * @return Number of captures found or -1 on failure.
* *
* @note Use the regex handle passed to this function to extract * @note Use the regex handle passed to this function to extract
* matches with GetRegexSubString(). * matches with GetRegexSubString().
*/ */
native int MatchRegex(Handle regex, const char[] str, RegexError &ret = REGEX_ERROR_NONE); native int MatchRegex(Handle regex, const char[] str, RegexError &ret = REGEX_ERROR_NONE);
@ -214,13 +214,13 @@ native int MatchRegex(Handle regex, const char[] str, RegexError &ret = REGEX_ER
* Substring ids start at 0 and end at captures-1, where captures is the number returned * Substring ids start at 0 and end at captures-1, where captures is the number returned
* by MatchRegex. * by MatchRegex.
* *
* @param regex The regex handle to extract data from. * @param regex The regex handle to extract data from.
* @param str_id The index of the expression to get - starts at 0, and ends at captures - 1. * @param str_id The index of the expression to get - starts at 0, and ends at captures - 1.
* @param buffer The buffer to set to the matching substring. * @param buffer The buffer to set to the matching substring.
* @param maxlen The maximum string length of the buffer. * @param maxlen The maximum string length of the buffer.
* @return True if a substring was found, False on fail/error * @return True if a substring was found, False on fail/error
* *
* @note str_id = 0 is the full captured string, anything else is the capture group index. * @note str_id = 0 is the full captured string, anything else is the capture group index.
* *
*/ */
native bool GetRegexSubString(Handle regex, int str_id, char[] buffer, int maxlen); native bool GetRegexSubString(Handle regex, int str_id, char[] buffer, int maxlen);
@ -228,22 +228,24 @@ native bool GetRegexSubString(Handle regex, int str_id, char[] buffer, int maxle
/** /**
* Matches a string against a regular expression pattern. * Matches a string against a regular expression pattern.
* *
* @note If you intend on using the same regular expression pattern * @note If you intend on using the same regular expression pattern
* multiple times, consider using CompileRegex and MatchRegex * multiple times, consider using CompileRegex and MatchRegex
* instead of making this function reparse the expression each time. * instead of making this function reparse the expression each time.
* *
* @param str The string to check. * @param str The string to check.
* @param pattern The regular expression pattern. * @param pattern The regular expression pattern.
* @param flags General flags for the regular expression. * @param flags General flags for the regular expression.
* @param error Error message, if applicable. * @param error Error message, if applicable.
* @param maxLen Maximum length of the error buffer. * @param maxLen Maximum length of the error buffer.
* @return Number of substrings found or -1 on failure. * @return Number of substrings found or -1 on failure.
*/ */
stock int SimpleRegexMatch(const char[] str, const char[] pattern, int flags = 0, char[] error="", int maxLen = 0) stock int SimpleRegexMatch(const char[] str, const char[] pattern, int flags = 0, char[] error="", int maxLen = 0)
{ {
Regex regex = new Regex(pattern, flags, error, maxLen); Regex regex = new Regex(pattern, flags, error, maxLen);
if (!regex) if (!regex)
{
return -1; return -1;
}
int substrings = regex.Match(str); int substrings = regex.Match(str);
delete regex; delete regex;

View File

@ -35,68 +35,70 @@
// this is obviously _not_ a robust check, but it will solve most conflict and is clean // this is obviously _not_ a robust check, but it will solve most conflict and is clean
#if !defined DMG_GENERIC #if !defined DMG_GENERIC
#define DMG_GENERIC 0 /**< generic damage was done */ #define DMG_GENERIC 0 /**< generic damage was done */
#define DMG_CRUSH (1 << 0) /**< crushed by falling or moving object. #define DMG_CRUSH (1 << 0) /**< crushed by falling or moving object.
NOTE: It's assumed crush damage is occurring as a result of physics collision, so no extra physics force is generated by crush damage. NOTE: It's assumed crush damage is occurring as a result of physics collision,
DON'T use DMG_CRUSH when damaging entities unless it's the result of a physics collision. You probably want DMG_CLUB instead. */ so no extra physics force is generated by crush damage.
#define DMG_BULLET (1 << 1) /**< shot */ DON'T use DMG_CRUSH when damaging entities unless it's the result of a physics
#define DMG_SLASH (1 << 2) /**< cut, clawed, stabbed */ collision. You probably want DMG_CLUB instead. */
#define DMG_BURN (1 << 3) /**< heat burned */ #define DMG_BULLET (1 << 1) /**< shot */
#define DMG_VEHICLE (1 << 4) /**< hit by a vehicle */ #define DMG_SLASH (1 << 2) /**< cut, clawed, stabbed */
#define DMG_FALL (1 << 5) /**< fell too far */ #define DMG_BURN (1 << 3) /**< heat burned */
#define DMG_BLAST (1 << 6) /**< explosive blast damage */ #define DMG_VEHICLE (1 << 4) /**< hit by a vehicle */
#define DMG_CLUB (1 << 7) /**< crowbar, punch, headbutt */ #define DMG_FALL (1 << 5) /**< fell too far */
#define DMG_SHOCK (1 << 8) /**< electric shock */ #define DMG_BLAST (1 << 6) /**< explosive blast damage */
#define DMG_SONIC (1 << 9) /**< sound pulse shockwave */ #define DMG_CLUB (1 << 7) /**< crowbar, punch, headbutt */
#define DMG_ENERGYBEAM (1 << 10) /**< laser or other high energy beam */ #define DMG_SHOCK (1 << 8) /**< electric shock */
#define DMG_PREVENT_PHYSICS_FORCE (1 << 11) /**< Prevent a physics force */ #define DMG_SONIC (1 << 9) /**< sound pulse shockwave */
#define DMG_NEVERGIB (1 << 12) /**< with this bit OR'd in, no damage type will be able to gib victims upon death */ #define DMG_ENERGYBEAM (1 << 10) /**< laser or other high energy beam */
#define DMG_ALWAYSGIB (1 << 13) /**< with this bit OR'd in, any damage type can be made to gib victims upon death. */ #define DMG_PREVENT_PHYSICS_FORCE (1 << 11) /**< Prevent a physics force */
#define DMG_DROWN (1 << 14) /**< Drowning */ #define DMG_NEVERGIB (1 << 12) /**< with this bit OR'd in, no damage type will be able to gib victims upon death */
#define DMG_PARALYZE (1 << 15) /**< slows affected creature down */ #define DMG_ALWAYSGIB (1 << 13) /**< with this bit OR'd in, any damage type can be made to gib victims upon death. */
#define DMG_NERVEGAS (1 << 16) /**< nerve toxins, very bad */ #define DMG_DROWN (1 << 14) /**< Drowning */
#define DMG_POISON (1 << 17) /**< blood poisoning - heals over time like drowning damage */ #define DMG_PARALYZE (1 << 15) /**< slows affected creature down */
#define DMG_RADIATION (1 << 18) /**< radiation exposure */ #define DMG_NERVEGAS (1 << 16) /**< nerve toxins, very bad */
#define DMG_DROWNRECOVER (1 << 19) /**< drowning recovery */ #define DMG_POISON (1 << 17) /**< blood poisoning - heals over time like drowning damage */
#define DMG_ACID (1 << 20) /**< toxic chemicals or acid burns */ #define DMG_RADIATION (1 << 18) /**< radiation exposure */
#define DMG_SLOWBURN (1 << 21) /**< in an oven */ #define DMG_DROWNRECOVER (1 << 19) /**< drowning recovery */
#define DMG_REMOVENORAGDOLL (1 << 22) /**< with this bit OR'd in, no ragdoll will be created, and the target will be quietly removed. #define DMG_ACID (1 << 20) /**< toxic chemicals or acid burns */
use this to kill an entity that you've already got a server-side ragdoll for */ #define DMG_SLOWBURN (1 << 21) /**< in an oven */
#define DMG_PHYSGUN (1 << 23) /**< Hit by manipulator. Usually doesn't do any damage. */ #define DMG_REMOVENORAGDOLL (1 << 22) /**< with this bit OR'd in, no ragdoll will be created, and the target will be quietly removed.
#define DMG_PLASMA (1 << 24) /**< Shot by Cremator */ use this to kill an entity that you've already got a server-side ragdoll for */
#define DMG_AIRBOAT (1 << 25) /**< Hit by the airboat's gun */ #define DMG_PHYSGUN (1 << 23) /**< Hit by manipulator. Usually doesn't do any damage. */
#define DMG_DISSOLVE (1 << 26) /**< Dissolving! */ #define DMG_PLASMA (1 << 24) /**< Shot by Cremator */
#define DMG_BLAST_SURFACE (1 << 27) /**< A blast on the surface of water that cannot harm things underwater */ #define DMG_AIRBOAT (1 << 25) /**< Hit by the airboat's gun */
#define DMG_DIRECT (1 << 28) #define DMG_DISSOLVE (1 << 26) /**< Dissolving! */
#define DMG_BUCKSHOT (1 << 29) /**< not quite a bullet. Little, rounder, different. */ #define DMG_BLAST_SURFACE (1 << 27) /**< A blast on the surface of water that cannot harm things underwater */
#define DMG_DIRECT (1 << 28)
#define DMG_BUCKSHOT (1 << 29) /**< not quite a bullet. Little, rounder, different. */
#endif #endif
#if !defined DMG_CRIT #if !defined DMG_CRIT
#define DMG_CRIT DMG_ACID /**< TF2 crits and minicrits */ #define DMG_CRIT DMG_ACID /**< TF2 crits and minicrits */
#endif #endif
#if !defined DMG_RADIUS_MAX #if !defined DMG_RADIUS_MAX
#define DMG_RADIUS_MAX DMG_ENERGYBEAM /**< No damage falloff */ #define DMG_RADIUS_MAX DMG_ENERGYBEAM /**< No damage falloff */
#endif #endif
#if !defined DMG_NOCLOSEDISTANCEMOD #if !defined DMG_NOCLOSEDISTANCEMOD
#define DMG_NOCLOSEDISTANCEMOD DMG_POISON /**< Don't do damage falloff too close */ #define DMG_NOCLOSEDISTANCEMOD DMG_POISON /**< Don't do damage falloff too close */
#endif #endif
#if !defined DMG_HALF_FALLOFF #if !defined DMG_HALF_FALLOFF
#define DMG_HALF_FALLOFF DMG_RADIATION /**< 50% damage falloff */ #define DMG_HALF_FALLOFF DMG_RADIATION /**< 50% damage falloff */
#endif #endif
#if !defined DMG_USEDISTANCEMOD #if !defined DMG_USEDISTANCEMOD
#define DMG_USEDISTANCEMOD DMG_SLOWBURN /**< Do damage falloff */ #define DMG_USEDISTANCEMOD DMG_SLOWBURN /**< Do damage falloff */
#endif #endif
#if !defined DMG_IGNITE #if !defined DMG_IGNITE
#define DMG_IGNITE DMG_PLASMA /**< Ignite victim */ #define DMG_IGNITE DMG_PLASMA /**< Ignite victim */
#endif #endif
#if !defined DMG_USE_HITLOCATIONS #if !defined DMG_USE_HITLOCATIONS
#define DMG_USE_HITLOCATIONS DMG_AIRBOAT /**< Do hit location damage (Like the sniperrifle and ambassador) */ #define DMG_USE_HITLOCATIONS DMG_AIRBOAT /**< Do hit location damage (Like the sniperrifle and ambassador) */
#endif #endif
enum SDKHookType enum SDKHookType
@ -144,7 +146,7 @@ enum SDKHookType
SDKHook_BlockedPost, SDKHook_BlockedPost,
SDKHook_OnTakeDamageAlive, SDKHook_OnTakeDamageAlive,
SDKHook_OnTakeDamageAlivePost, SDKHook_OnTakeDamageAlivePost,
SDKHook_CanBeAutobalanced, SDKHook_CanBeAutobalanced
}; };
/* /*
@ -324,93 +326,93 @@ typeset SDKHookCB
/** /**
* @brief When an entity is created * When an entity is created
* *
* @param entity Entity index * @param entity Entity index
* @param classname Class name * @param classname Class name
*/ */
forward void OnEntityCreated(int entity, const char[] classname); forward void OnEntityCreated(int entity, const char[] classname);
/** /**
* @brief When an entity is destroyed * When an entity is destroyed
* *
* @param entity Entity index * @param entity Entity index
*/ */
forward void OnEntityDestroyed(int entity); forward void OnEntityDestroyed(int entity);
/** /**
* @brief When the game description is retrieved * When the game description is retrieved
* *
* @note Not supported on ep2v. * @note Not supported on ep2v.
* *
* @param gameDesc Game description * @param gameDesc Game description
* @return Plugin_Changed if gameDesc has been edited, else no change. * @return Plugin_Changed if gameDesc has been edited, else no change.
*/ */
forward Action OnGetGameDescription(char gameDesc[64]); forward Action OnGetGameDescription(char gameDesc[64]);
/** /**
* @brief When the level is initialized * When the level is initialized
* *
* @param mapName Name of the map * @param mapName Name of the map
* @param mapEntities Entities of the map * @param mapEntities Entities of the map
* @return Plugin_Changed if mapEntities has been edited, else no change. * @return Plugin_Changed if mapEntities has been edited, else no change.
*/ */
forward Action OnLevelInit(const char[] mapName, char mapEntities[2097152]); forward Action OnLevelInit(const char[] mapName, char mapEntities[2097152]);
/** /**
* @brief Hooks an entity * Hooks an entity
* *
* @param entity Entity index * @param entity Entity index
* @param type Type of function to hook * @param type Type of function to hook
* @param callback Function to call when hook is called * @param callback Function to call when hook is called
*/ */
native void SDKHook(int entity, SDKHookType type, SDKHookCB callback); native void SDKHook(int entity, SDKHookType type, SDKHookCB callback);
/** /**
* @brief Hooks an entity * Hooks an entity
* *
* @param entity Entity index * @param entity Entity index
* @param type Type of function to hook * @param type Type of function to hook
* @param callback Function to call when hook is called * @param callback Function to call when hook is called
* @return bool Hook Successful * @return Hook Successful
*/ */
native bool SDKHookEx(int entity, SDKHookType type, SDKHookCB callback); native bool SDKHookEx(int entity, SDKHookType type, SDKHookCB callback);
/** /**
* @brief Unhooks an entity * Unhooks an entity
* *
* @param entity Entity index * @param entity Entity index
* @param type Type of function to unhook * @param type Type of function to unhook
* @param callback Callback function to unhook * @param callback Callback function to unhook
*/ */
native void SDKUnhook(int entity, SDKHookType type, SDKHookCB callback); native void SDKUnhook(int entity, SDKHookType type, SDKHookCB callback);
/** /**
* @brief Applies damage to an entity * Applies damage to an entity
* *
* @note Force application is dependent on game and damage type(s) * @note Force application is dependent on game and damage type(s)
* *
* @param entity Entity index taking damage * @param entity Entity index taking damage
* @param inflictor Inflictor entity index * @param inflictor Inflictor entity index
* @param attacker Attacker entity index * @param attacker Attacker entity index
* @param damage Amount of damage * @param damage Amount of damage
* @param damageType Bitfield of damage types * @param damageType Bitfield of damage types
* @param weapon Weapon index (orangebox and later) or -1 for unspecified * @param weapon Weapon index (orangebox and later) or -1 for unspecified
* @param damageForce Velocity of damage force * @param damageForce Velocity of damage force
* @param damagePosition Origin of damage * @param damagePosition Origin of damage
*/ */
native void SDKHooks_TakeDamage(int entity, int inflictor, int attacker, native void SDKHooks_TakeDamage(int entity, int inflictor, int attacker,
float damage, int damageType=DMG_GENERIC, int weapon=-1, float damage, int damageType=DMG_GENERIC, int weapon=-1,
const float damageForce[3]=NULL_VECTOR, const float damagePosition[3]=NULL_VECTOR); const float damageForce[3]=NULL_VECTOR, const float damagePosition[3]=NULL_VECTOR);
/** /**
* @brief Forces a client to drop the specified weapon * Forces a client to drop the specified weapon
* *
* @param client Client index. * @param client Client index.
* @param weapon Weapon entity index. * @param weapon Weapon entity index.
* @param vecTarget Location to toss weapon to, or NULL_VECTOR for default. * @param vecTarget Location to toss weapon to, or NULL_VECTOR for default.
* @param vecVelocity Velocity at which to toss weapon, or NULL_VECTOR for default. * @param vecVelocity Velocity at which to toss weapon, or NULL_VECTOR for default.
* @error Invalid client or weapon entity, weapon not owned by client. * @error Invalid client or weapon entity, weapon not owned by client.
*/ */
native void SDKHooks_DropWeapon(int client, int weapon, const float vecTarget[3]=NULL_VECTOR, native void SDKHooks_DropWeapon(int client, int weapon, const float vecTarget[3]=NULL_VECTOR,
const float vecVelocity[3]=NULL_VECTOR); const float vecVelocity[3]=NULL_VECTOR);

View File

@ -31,7 +31,7 @@
*/ */
#if defined _sdktools_included #if defined _sdktools_included
#endinput #endinput
#endif #endif
#define _sdktools_included #define _sdktools_included
@ -55,86 +55,86 @@
enum SDKCallType enum SDKCallType
{ {
SDKCall_Static, /**< Static call */ SDKCall_Static, /**< Static call */
SDKCall_Entity, /**< CBaseEntity call */ SDKCall_Entity, /**< CBaseEntity call */
SDKCall_Player, /**< CBasePlayer call */ SDKCall_Player, /**< CBasePlayer call */
SDKCall_GameRules, /**< CGameRules call */ SDKCall_GameRules, /**< CGameRules call */
SDKCall_EntityList, /**< CGlobalEntityList call */ SDKCall_EntityList, /**< CGlobalEntityList call */
SDKCall_Raw, /**< |this| pointer with an arbitrary address */ SDKCall_Raw /**< |this| pointer with an arbitrary address */
}; };
enum SDKLibrary enum SDKLibrary
{ {
SDKLibrary_Server, /**< server.dll/server_i486.so */ SDKLibrary_Server, /**< server.dll/server_i486.so */
SDKLibrary_Engine, /**< engine.dll/engine_*.so */ SDKLibrary_Engine /**< engine.dll/engine_*.so */
}; };
enum SDKFuncConfSource enum SDKFuncConfSource
{ {
SDKConf_Virtual = 0, /**< Read a virtual index from the Offsets section */ SDKConf_Virtual = 0, /**< Read a virtual index from the Offsets section */
SDKConf_Signature = 1, /**< Read a signature from the Signatures section */ SDKConf_Signature = 1, /**< Read a signature from the Signatures section */
SDKConf_Address = 2, /**< Read an address from the Addresses section */ SDKConf_Address = 2 /**< Read an address from the Addresses section */
}; };
enum SDKType enum SDKType
{ {
SDKType_CBaseEntity, /**< CBaseEntity (always as pointer) */ SDKType_CBaseEntity, /**< CBaseEntity (always as pointer) */
SDKType_CBasePlayer, /**< CBasePlayer (always as pointer) */ SDKType_CBasePlayer, /**< CBasePlayer (always as pointer) */
SDKType_Vector, /**< Vector (pointer, byval, or byref) */ SDKType_Vector, /**< Vector (pointer, byval, or byref) */
SDKType_QAngle, /**< QAngles (pointer, byval, or byref) */ SDKType_QAngle, /**< QAngles (pointer, byval, or byref) */
SDKType_PlainOldData, /**< Integer/generic data <=32bit (any) */ SDKType_PlainOldData, /**< Integer/generic data <=32bit (any) */
SDKType_Float, /**< Float (any) */ SDKType_Float, /**< Float (any) */
SDKType_Edict, /**< edict_t (always as pointer) */ SDKType_Edict, /**< edict_t (always as pointer) */
SDKType_String, /**< NULL-terminated string (always as pointer) */ SDKType_String, /**< NULL-terminated string (always as pointer) */
SDKType_Bool, /**< Boolean (any) */ SDKType_Bool /**< Boolean (any) */
}; };
enum SDKPassMethod enum SDKPassMethod
{ {
SDKPass_Pointer, /**< Pass as a pointer */ SDKPass_Pointer, /**< Pass as a pointer */
SDKPass_Plain, /**< Pass as plain data */ SDKPass_Plain, /**< Pass as plain data */
SDKPass_ByValue, /**< Pass an object by value */ SDKPass_ByValue, /**< Pass an object by value */
SDKPass_ByRef, /**< Pass an object by reference */ SDKPass_ByRef /**< Pass an object by reference */
}; };
#define VDECODE_FLAG_ALLOWNULL (1<<0) /**< Allow NULL for pointers */ #define VDECODE_FLAG_ALLOWNULL (1<<0) /**< Allow NULL for pointers */
#define VDECODE_FLAG_ALLOWNOTINGAME (1<<1) /**< Allow players not in game */ #define VDECODE_FLAG_ALLOWNOTINGAME (1<<1) /**< Allow players not in game */
#define VDECODE_FLAG_ALLOWWORLD (1<<2) /**< Allow World entity */ #define VDECODE_FLAG_ALLOWWORLD (1<<2) /**< Allow World entity */
#define VDECODE_FLAG_BYREF (1<<3) /**< Floats/ints by reference */ #define VDECODE_FLAG_BYREF (1<<3) /**< Floats/ints by reference */
#define VENCODE_FLAG_COPYBACK (1<<0) /**< Copy back data once done */ #define VENCODE_FLAG_COPYBACK (1<<0) /**< Copy back data once done */
/** /**
* Starts the preparation of an SDK call. * Starts the preparation of an SDK call.
* *
* @param type Type of function call this will be. * @param type Type of function call this will be.
*/ */
native void StartPrepSDKCall(SDKCallType type); native void StartPrepSDKCall(SDKCallType type);
/** /**
* Sets the virtual index of the SDK call if it is virtual. * Sets the virtual index of the SDK call if it is virtual.
* *
* @param vtblidx Virtual table index. * @param vtblidx Virtual table index.
*/ */
native void PrepSDKCall_SetVirtual(int vtblidx); native void PrepSDKCall_SetVirtual(int vtblidx);
/** /**
* Finds an address in a library and sets it as the address to use for the SDK call. * Finds an address in a library and sets it as the address to use for the SDK call.
* *
* @param lib Library to use. * @param lib Library to use.
* @param signature Binary data to search for in the library. If it starts with '@', * @param signature Binary data to search for in the library. If it starts with '@',
* the bytes parameter is ignored and the signature is interpreted * the bytes parameter is ignored and the signature is interpreted
* as a symbol lookup in the library. * as a symbol lookup in the library.
* @param bytes Number of bytes in the binary search string. * @param bytes Number of bytes in the binary search string.
* @return True on success, false if nothing was found. * @return True on success, false if nothing was found.
*/ */
native bool PrepSDKCall_SetSignature(SDKLibrary lib, const char[] signature, int bytes); native bool PrepSDKCall_SetSignature(SDKLibrary lib, const char[] signature, int bytes);
/** /**
* Uses the given function address for the SDK call. * Uses the given function address for the SDK call.
* *
* @param addr Address of function to use. * @param addr Address of function to use.
* @return True on success, false on failure. * @return True on success, false on failure.
*/ */
native bool PrepSDKCall_SetAddress(Address addr); native bool PrepSDKCall_SetAddress(Address addr);
@ -142,10 +142,10 @@ native bool PrepSDKCall_SetAddress(Address addr);
* Finds an address or virtual function index in a GameConfig file and sets it as * Finds an address or virtual function index in a GameConfig file and sets it as
* the calling information for the SDK call. * the calling information for the SDK call.
* *
* @param gameconf GameConfig Handle, or INVALID_HANDLE to use sdktools.games.txt. * @param gameconf GameConfig Handle, or INVALID_HANDLE to use sdktools.games.txt.
* @param source Whether to look in Offsets or Signatures. * @param source Whether to look in Offsets or Signatures.
* @param name Name of the property to find. * @param name Name of the property to find.
* @return True on success, false if nothing was found. * @return True on success, false if nothing was found.
*/ */
native bool PrepSDKCall_SetFromConf(Handle gameconf, SDKFuncConfSource source, const char[] name); native bool PrepSDKCall_SetFromConf(Handle gameconf, SDKFuncConfSource source, const char[] name);
@ -154,27 +154,27 @@ native bool PrepSDKCall_SetFromConf(Handle gameconf, SDKFuncConfSource source, c
* This must be called if there is a return value (i.e. it is not necessarily safe to ignore * This must be called if there is a return value (i.e. it is not necessarily safe to ignore
* the data). * the data).
* *
* @param type Data type to convert to/from. * @param type Data type to convert to/from.
* @param pass How the data is passed in C++. * @param pass How the data is passed in C++.
* @param decflags Flags on decoding from the plugin to C++. * @param decflags Flags on decoding from the plugin to C++.
* @param encflags Flags on encoding from C++ to the plugin. * @param encflags Flags on encoding from C++ to the plugin.
*/ */
native void PrepSDKCall_SetReturnInfo(SDKType type, SDKPassMethod pass, int decflags=0, int encflags=0); native void PrepSDKCall_SetReturnInfo(SDKType type, SDKPassMethod pass, int decflags=0, int encflags=0);
/** /**
* Adds a parameter to the calling convention. This should be called in normal ascending order. * Adds a parameter to the calling convention. This should be called in normal ascending order.
* *
* @param type Data type to convert to/from. * @param type Data type to convert to/from.
* @param pass How the data is passed in C++. * @param pass How the data is passed in C++.
* @param decflags Flags on decoding from the plugin to C++. * @param decflags Flags on decoding from the plugin to C++.
* @param encflags Flags on encoding from C++ to the plugin. * @param encflags Flags on encoding from C++ to the plugin.
*/ */
native void PrepSDKCall_AddParameter(SDKType type, SDKPassMethod pass, int decflags=0, int encflags=0); native void PrepSDKCall_AddParameter(SDKType type, SDKPassMethod pass, int decflags=0, int encflags=0);
/** /**
* Finalizes an SDK call preparation and returns the resultant Handle. * Finalizes an SDK call preparation and returns the resultant Handle.
* *
* @return A new SDKCall Handle on success, or INVALID_HANDLE on failure. * @return A new SDKCall Handle on success, or INVALID_HANDLE on failure.
*/ */
native Handle EndPrepSDKCall(); native Handle EndPrepSDKCall();
@ -191,19 +191,19 @@ native Handle EndPrepSDKCall();
* *
* If the return value is a float or integer, the return value will be this value. * If the return value is a float or integer, the return value will be this value.
* If the return value is a CBaseEntity, CBasePlayer, or edict, the return value will * If the return value is a CBaseEntity, CBasePlayer, or edict, the return value will
* always be the entity index, or -1 for NULL. * always be the entity index, or -1 for NULL.
* *
* @param call SDKCall Handle. * @param call SDKCall Handle.
* @param ... Call Parameters. * @param ... Call Parameters.
* @return Simple return value, if any. * @return Simple return value, if any.
* @error Invalid Handle or internal decoding error. * @error Invalid Handle or internal decoding error.
*/ */
native any SDKCall(Handle call, any ...); native any SDKCall(Handle call, any ...);
/** /**
* Returns the entity index of the player resource/manager entity. * Returns the entity index of the player resource/manager entity.
* *
* @return Index of resource entity or -1 if not found. * @return Index of resource entity or -1 if not found.
*/ */
native int GetPlayerResourceEntity(); native int GetPlayerResourceEntity();

View File

@ -31,20 +31,20 @@
*/ */
#if defined _sdktools_client_included #if defined _sdktools_client_included
#endinput #endinput
#endif #endif
#define _sdktools_client_included #define _sdktools_client_included
/** /**
* Sets the client to an inactive state waiting for a new map * Sets the client to an inactive state waiting for a new map
* *
* @param client The client index * @param client The client index
*/ */
native void InactivateClient(int client); native void InactivateClient(int client);
/** /**
* Reconnect a client without dropping the netchannel * Reconnect a client without dropping the netchannel
* *
* @param client The client index * @param client The client index
*/ */
native void ReconnectClient(int client); native void ReconnectClient(int client);

View File

@ -31,36 +31,36 @@
*/ */
#if defined _sdktools_engine_included #if defined _sdktools_engine_included
#endinput #endinput
#endif #endif
#define _sdktools_engine_included #define _sdktools_engine_included
#define MAX_LIGHTSTYLES 64 #define MAX_LIGHTSTYLES 64
/** /**
* Sets a client's "viewing entity." * Sets a client's "viewing entity."
* *
* @param client Client index. * @param client Client index.
* @param entity Entity index. * @param entity Entity index.
* @error Invalid client or entity, lack of mod support, or client not in * @error Invalid client or entity, lack of mod support, or client not in
* game. * game.
*/ */
native void SetClientViewEntity(int client, int entity); native void SetClientViewEntity(int client, int entity);
/** /**
* Sets a light style. * Sets a light style.
* *
* @param style Light style (from 0 to MAX_LIGHTSTYLES-1) * @param style Light style (from 0 to MAX_LIGHTSTYLES-1)
* @param value Light value string (see world.cpp/light.cpp in dlls) * @param value Light value string (see world.cpp/light.cpp in dlls)
* @error Light style index is out of range. * @error Light style index is out of range.
*/ */
native void SetLightStyle(int style, const char[] value); native void SetLightStyle(int style, const char[] value);
/** /**
* Returns the client's eye position. * Returns the client's eye position.
* *
* @param client Player's index. * @param client Player's index.
* @param pos Destination vector to store the client's eye position. * @param pos Destination vector to store the client's eye position.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void GetClientEyePosition(int client, float pos[3]); native void GetClientEyePosition(int client, float pos[3]);

View File

@ -31,7 +31,7 @@
*/ */
#if defined _sdktools_entinput_included #if defined _sdktools_entinput_included
#endinput #endinput
#endif #endif
#define _sdktools_entinput_included #define _sdktools_entinput_included
@ -40,12 +40,12 @@
* *
* After completion (successful or not), the current global variant is re-initialized. * After completion (successful or not), the current global variant is re-initialized.
* *
* @param dest Destination entity index. * @param dest Destination entity index.
* @param input Input action. * @param input Input action.
* @param activator Entity index which initiated the sequence of actions (-1 for a NULL entity). * @param activator Entity index which initiated the sequence of actions (-1 for a NULL entity).
* @param caller Entity index from which this event is sent (-1 for a NULL entity). * @param caller Entity index from which this event is sent (-1 for a NULL entity).
* @param outputid Unknown. * @param outputid Unknown.
* @return True if successful otherwise false. * @return True if successful otherwise false.
* @error Invalid entity index or no mod support. * @error Invalid entity index or no mod support.
*/ */
native bool AcceptEntityInput(int dest, const char[] input, int activator=-1, int caller=-1, int outputid=0); native bool AcceptEntityInput(int dest, const char[] input, int activator=-1, int caller=-1, int outputid=0);

View File

@ -31,20 +31,20 @@
*/ */
#if defined _sdktools_entoutput_included #if defined _sdktools_entoutput_included
#endinput #endinput
#endif #endif
#define _sdktools_entoutput_included #define _sdktools_entoutput_included
/** /**
* Called when an entity output is fired. * Called when an entity output is fired.
* *
* @param output Name of the output that fired. * @param output Name of the output that fired.
* @param caller Entity index of the caller. * @param caller Entity index of the caller.
* @param activator Entity index of the activator. * @param activator Entity index of the activator.
* @param delay Delay in seconds? before the event gets fired. * @param delay Delay in seconds? before the event gets fired.
* @return Anything other than Plugin_Continue will supress this event, * @return Anything other than Plugin_Continue will supress this event,
* returning Plugin_Continue will allow it to propagate the results * returning Plugin_Continue will allow it to propagate the results
* of this output to any entity inputs. * of this output to any entity inputs.
*/ */
typeset EntityOutput typeset EntityOutput
{ {
@ -55,42 +55,42 @@ typeset EntityOutput
/** /**
* Add an entity output hook on a entity classname * Add an entity output hook on a entity classname
* *
* @param classname The classname to hook. * @param classname The classname to hook.
* @param output The output name to hook. * @param output The output name to hook.
* @param callback An EntityOutput function pointer. * @param callback An EntityOutput function pointer.
* @error Entity Outputs disabled. * @error Entity Outputs disabled.
*/ */
native void HookEntityOutput(const char[] classname, const char[] output, EntityOutput callback); native void HookEntityOutput(const char[] classname, const char[] output, EntityOutput callback);
/** /**
* Remove an entity output hook. * Remove an entity output hook.
* @param classname The classname to hook. * @param classname The classname to hook.
* @param output The output name to hook. * @param output The output name to hook.
* @param callback An EntityOutput function pointer. * @param callback An EntityOutput function pointer.
* @return True on success, false if no valid hook was found. * @return True on success, false if no valid hook was found.
* @error Entity Outputs disabled. * @error Entity Outputs disabled.
*/ */
native bool UnhookEntityOutput(const char[] classname, const char[] output, EntityOutput callback); native bool UnhookEntityOutput(const char[] classname, const char[] output, EntityOutput callback);
/** /**
* Add an entity output hook on a single entity instance * Add an entity output hook on a single entity instance
* *
* @param entity The entity on which to add a hook. * @param entity The entity on which to add a hook.
* @param output The output name to hook. * @param output The output name to hook.
* @param callback An EntityOutput function pointer. * @param callback An EntityOutput function pointer.
* @param once Only fire this hook once and then remove itself. * @param once Only fire this hook once and then remove itself.
* @error Entity Outputs disabled or Invalid Entity index. * @error Entity Outputs disabled or Invalid Entity index.
*/ */
native void HookSingleEntityOutput(int entity, const char[] output, EntityOutput callback, bool once=false); native void HookSingleEntityOutput(int entity, const char[] output, EntityOutput callback, bool once=false);
/** /**
* Remove a single entity output hook. * Remove a single entity output hook.
* *
* @param entity The entity on which to remove the hook. * @param entity The entity on which to remove the hook.
* @param output The output name to hook. * @param output The output name to hook.
* @param callback An EntityOutput function pointer. * @param callback An EntityOutput function pointer.
* @return True on success, false if no valid hook was found. * @return True on success, false if no valid hook was found.
* @error Entity Outputs disabled or Invalid Entity index. * @error Entity Outputs disabled or Invalid Entity index.
*/ */
native bool UnhookSingleEntityOutput(int entity, const char[] output, EntityOutput callback); native bool UnhookSingleEntityOutput(int entity, const char[] output, EntityOutput callback);
@ -99,10 +99,10 @@ native bool UnhookSingleEntityOutput(int entity, const char[] output, EntityOutp
* *
* After completion (successful or not), the current global variant is re-initialized. * After completion (successful or not), the current global variant is re-initialized.
* *
* @param caller Entity index from where the output is fired. * @param caller Entity index from where the output is fired.
* @param output Output name. * @param output Output name.
* @param activator Entity index which initiated the sequence of actions (-1 for a NULL entity). * @param activator Entity index which initiated the sequence of actions (-1 for a NULL entity).
* @param delay Delay before firing the output. * @param delay Delay before firing the output.
* @error Invalid entity index or no mod support. * @error Invalid entity index or no mod support.
*/ */
native void FireEntityOutput(int caller, const char[] output, int activator=-1, float delay=0.0); native void FireEntityOutput(int caller, const char[] output, int activator=-1, float delay=0.0);

View File

@ -31,109 +31,109 @@
*/ */
#if defined _sdktools_functions_included #if defined _sdktools_functions_included
#endinput #endinput
#endif #endif
#define _sdktools_functions_included #define _sdktools_functions_included
/** /**
* Removes a player's item. * Removes a player's item.
* *
* @param client Client index. * @param client Client index.
* @param item CBaseCombatWeapon entity index. * @param item CBaseCombatWeapon entity index.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid client or entity, lack of mod support, or client not in * @error Invalid client or entity, lack of mod support, or client not in
* game. * game.
*/ */
native bool RemovePlayerItem(int client, int item); native bool RemovePlayerItem(int client, int item);
/** /**
* Gives a named item to a player. * Gives a named item to a player.
* *
* @param client Client index. * @param client Client index.
* @param item Item classname (such as weapon_ak47). * @param item Item classname (such as weapon_ak47).
* @param iSubType Unknown. * @param iSubType Unknown.
* @return Entity index on success, or -1 on failure. * @return Entity index on success, or -1 on failure.
* @error Invalid client or client not in game, or lack of mod support. * @error Invalid client or client not in game, or lack of mod support.
*/ */
native int GivePlayerItem(int client, const char[] item, int iSubType=0); native int GivePlayerItem(int client, const char[] item, int iSubType=0);
/** /**
* Returns the weapon in a player's slot. * Returns the weapon in a player's slot.
* *
* @param client Client index. * @param client Client index.
* @param slot Slot index (mod specific). * @param slot Slot index (mod specific).
* @return Entity index on success, -1 if no weapon existed. * @return Entity index on success, -1 if no weapon existed.
* @error Invalid client or client not in game, or lack of mod support. * @error Invalid client or client not in game, or lack of mod support.
*/ */
native int GetPlayerWeaponSlot(int client, int slot); native int GetPlayerWeaponSlot(int client, int slot);
/** /**
* Ignites an entity on fire. * Ignites an entity on fire.
* *
* @param entity Entity index. * @param entity Entity index.
* @param time Number of seconds to set on fire. * @param time Number of seconds to set on fire.
* @param npc True to only affect NPCs. * @param npc True to only affect NPCs.
* @param size Unknown. * @param size Unknown.
* @param level Unknown. * @param level Unknown.
* @error Invalid entity or client not in game, or lack of mod support. * @error Invalid entity or client not in game, or lack of mod support.
*/ */
native void IgniteEntity(int entity, float time, bool npc=false, float size=0.0, bool level=false); native void IgniteEntity(int entity, float time, bool npc=false, float size=0.0, bool level=false);
/** /**
* Extinguishes an entity that is on fire. * Extinguishes an entity that is on fire.
* *
* @param entity Entity index. * @param entity Entity index.
* @error Invalid entity or client not in game, or lack of mod support. * @error Invalid entity or client not in game, or lack of mod support.
*/ */
native void ExtinguishEntity(int entity); native void ExtinguishEntity(int entity);
/** /**
* Teleports an entity. * Teleports an entity.
* *
* @param entity Client index. * @param entity Client index.
* @param origin New origin, or NULL_VECTOR for no change. * @param origin New origin, or NULL_VECTOR for no change.
* @param angles New angles, or NULL_VECTOR for no change. * @param angles New angles, or NULL_VECTOR for no change.
* @param velocity New velocity, or NULL_VECTOR for no change. * @param velocity New velocity, or NULL_VECTOR for no change.
* @error Invalid entity or client not in game, or lack of mod support. * @error Invalid entity or client not in game, or lack of mod support.
*/ */
native void TeleportEntity(int entity, const float origin[3], const float angles[3], const float velocity[3]); native void TeleportEntity(int entity, const float origin[3], const float angles[3], const float velocity[3]);
/** /**
* Forces a player to commit suicide. * Forces a player to commit suicide.
* *
* @param client Client index. * @param client Client index.
* @error Invalid client or client not in game, or lack of mod support. * @error Invalid client or client not in game, or lack of mod support.
*/ */
native void ForcePlayerSuicide(int client); native void ForcePlayerSuicide(int client);
/** /**
* Slaps a player in a random direction. * Slaps a player in a random direction.
* *
* @param client Client index. * @param client Client index.
* @param health Health to subtract. * @param health Health to subtract.
* @param sound False to disable the sound effects. * @param sound False to disable the sound effects.
* @error Invalid client or client not in game, or lack of mod support. * @error Invalid client or client not in game, or lack of mod support.
*/ */
native void SlapPlayer(int client, int health=5, bool sound=true); native void SlapPlayer(int client, int health=5, bool sound=true);
/** /**
* Searches for an entity by classname. * Searches for an entity by classname.
* *
* @param startEnt The entity index after which to begin searching from. * @param startEnt The entity index after which to begin searching from.
* Use -1 to start from the first entity. * Use -1 to start from the first entity.
* @param classname Classname of the entity to find. * @param classname Classname of the entity to find.
* @return Entity index >= 0 if found, -1 otherwise. * @return Entity index >= 0 if found, -1 otherwise.
* @error Lack of mod support. * @error Lack of mod support.
*/ */
native int FindEntityByClassname(int startEnt, const char[] classname); native int FindEntityByClassname(int startEnt, const char[] classname);
/** /**
* Returns the client's eye angles. * Returns the client's eye angles.
* *
* @param client Player's index. * @param client Player's index.
* @param ang Destination vector to store the client's eye angles. * @param ang Destination vector to store the client's eye angles.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native bool GetClientEyeAngles(int client, float ang[3]); native bool GetClientEyeAngles(int client, float ang[3]);
@ -142,64 +142,64 @@ native bool GetClientEyeAngles(int client, float ang[3]);
* If ForceEdictIndex is not -1, then it will use the edict by that index. If the index is * If ForceEdictIndex is not -1, then it will use the edict by that index. If the index is
* invalid or there is already an edict using that index, it will error out. * invalid or there is already an edict using that index, it will error out.
* *
* @param classname Entity classname. * @param classname Entity classname.
* @param ForceEdictIndex Edict index used by the created entity (ignored on Orangebox and above). * @param ForceEdictIndex Edict index used by the created entity (ignored on Orangebox and above).
* @return Entity index on success, or -1 on failure. * @return Entity index on success, or -1 on failure.
* @error Invalid edict index, or no mod support. * @error Invalid edict index, or no mod support.
*/ */
native int CreateEntityByName(const char[] classname, int ForceEdictIndex=-1); native int CreateEntityByName(const char[] classname, int ForceEdictIndex=-1);
/** /**
* Spawns an entity into the game. * Spawns an entity into the game.
* *
* @param entity Entity index of the created entity. * @param entity Entity index of the created entity.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid entity index, or no mod support. * @error Invalid entity index, or no mod support.
*/ */
native bool DispatchSpawn(int entity); native bool DispatchSpawn(int entity);
/** /**
* Dispatches a KeyValue into given entity using a string value. * Dispatches a KeyValue into given entity using a string value.
* *
* @param entity Destination entity index. * @param entity Destination entity index.
* @param keyName Name of the key. * @param keyName Name of the key.
* @param value String value. * @param value String value.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid entity index, or no mod support. * @error Invalid entity index, or no mod support.
*/ */
native bool DispatchKeyValue(int entity, const char[] keyName, const char[] value); native bool DispatchKeyValue(int entity, const char[] keyName, const char[] value);
/** /**
* Dispatches a KeyValue into given entity using a floating point value. * Dispatches a KeyValue into given entity using a floating point value.
* *
* @param entity Destination entity index. * @param entity Destination entity index.
* @param keyName Name of the key. * @param keyName Name of the key.
* @param value Floating point value. * @param value Floating point value.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid entity index, or no mod support. * @error Invalid entity index, or no mod support.
*/ */
native bool DispatchKeyValueFloat(int entity, const char[] keyName, float value); native bool DispatchKeyValueFloat(int entity, const char[] keyName, float value);
/** /**
* Dispatches a KeyValue into given entity using a vector value. * Dispatches a KeyValue into given entity using a vector value.
* *
* @param entity Destination entity index. * @param entity Destination entity index.
* @param keyName Name of the key. * @param keyName Name of the key.
* @param vec Vector value. * @param vec Vector value.
* @return True on success, false otherwise. * @return True on success, false otherwise.
* @error Invalid entity index, or no mod support. * @error Invalid entity index, or no mod support.
*/ */
native bool DispatchKeyValueVector(int entity, const char[] keyName, const float vec[3]); native bool DispatchKeyValueVector(int entity, const char[] keyName, const float vec[3]);
/** /**
* Returns the entity a client is aiming at. * Returns the entity a client is aiming at.
* *
* @param client Client performing the aiming. * @param client Client performing the aiming.
* @param only_clients True to exclude all entities but clients. * @param only_clients True to exclude all entities but clients.
* @return Entity index being aimed at. * @return Entity index being aimed at.
* -1 if no entity is being aimed at. * -1 if no entity is being aimed at.
* -2 if the function is not supported. * -2 if the function is not supported.
* @error Invalid client index or client not in game. * @error Invalid client index or client not in game.
*/ */
native int GetClientAimTarget(int client, bool only_clients=true); native int GetClientAimTarget(int client, bool only_clients=true);
@ -207,7 +207,7 @@ native int GetClientAimTarget(int client, bool only_clients=true);
* Returns the total number of teams in a game. * Returns the total number of teams in a game.
* Note: This native should not be called before OnMapStart. * Note: This native should not be called before OnMapStart.
* *
* @return Total number of teams. * @return Total number of teams.
*/ */
native int GetTeamCount(); native int GetTeamCount();
@ -215,10 +215,10 @@ native int GetTeamCount();
* Retrieves the team name based on a team index. * Retrieves the team name based on a team index.
* Note: This native should not be called before OnMapStart. * Note: This native should not be called before OnMapStart.
* *
* @param index Team index. * @param index Team index.
* @param name Buffer to store string in. * @param name Buffer to store string in.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @error Invalid team index. * @error Invalid team index.
*/ */
native void GetTeamName(int index, char[] name, int maxlength); native void GetTeamName(int index, char[] name, int maxlength);
@ -226,9 +226,9 @@ native void GetTeamName(int index, char[] name, int maxlength);
* Returns the score of a team based on a team index. * Returns the score of a team based on a team index.
* Note: This native should not be called before OnMapStart. * Note: This native should not be called before OnMapStart.
* *
* @param index Team index. * @param index Team index.
* @return Score. * @return Score.
* @error Invalid team index. * @error Invalid team index.
*/ */
native int GetTeamScore(int index); native int GetTeamScore(int index);
@ -236,9 +236,9 @@ native int GetTeamScore(int index);
* Sets the score of a team based on a team index. * Sets the score of a team based on a team index.
* Note: This native should not be called before OnMapStart. * Note: This native should not be called before OnMapStart.
* *
* @param index Team index. * @param index Team index.
* @param value New score value. * @param value New score value.
* @error Invalid team index. * @error Invalid team index.
*/ */
native void SetTeamScore(int index, int value); native void SetTeamScore(int index, int value);
@ -246,75 +246,75 @@ native void SetTeamScore(int index, int value);
* Retrieves the number of players in a certain team. * Retrieves the number of players in a certain team.
* Note: This native should not be called before OnMapStart. * Note: This native should not be called before OnMapStart.
* *
* @param index Team index. * @param index Team index.
* @return Number of players in the team. * @return Number of players in the team.
* @error Invalid team index. * @error Invalid team index.
*/ */
native int GetTeamClientCount(int index); native int GetTeamClientCount(int index);
/** /**
* Returns the entity index of a team. * Returns the entity index of a team.
* *
* @param teamIndex Team index. * @param teamIndex Team index.
* @return Entity index of team. * @return Entity index of team.
* @error Invalid team index. * @error Invalid team index.
*/ */
native int GetTeamEntity(int teamIndex); native int GetTeamEntity(int teamIndex);
/** /**
* Sets the model to a given entity. * Sets the model to a given entity.
* *
* @param entity Entity index. * @param entity Entity index.
* @param model Model name. * @param model Model name.
* @error Invalid entity index, or no mod support. * @error Invalid entity index, or no mod support.
*/ */
native void SetEntityModel(int entity, const char[] model); native void SetEntityModel(int entity, const char[] model);
/** /**
* Retrieves the decal file name associated with a given client. * Retrieves the decal file name associated with a given client.
* *
* @param client Player's index. * @param client Player's index.
* @param hex Buffer to store the logo filename. * @param hex Buffer to store the logo filename.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @return True on success, otherwise false. * @return True on success, otherwise false.
* @error Invalid client or client not in game. * @error Invalid client or client not in game.
*/ */
native bool GetPlayerDecalFile(int client, char[] hex, int maxlength); native bool GetPlayerDecalFile(int client, char[] hex, int maxlength);
/** /**
* Retrieves the jingle file name associated with a given client. * Retrieves the jingle file name associated with a given client.
* *
* @param client Player's index. * @param client Player's index.
* @param hex Buffer to store the jingle filename. * @param hex Buffer to store the jingle filename.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @return True on success, otherwise false. * @return True on success, otherwise false.
* @error Invalid client or client not in game. * @error Invalid client or client not in game.
*/ */
native bool GetPlayerJingleFile(int client, char[] hex, int maxlength); native bool GetPlayerJingleFile(int client, char[] hex, int maxlength);
/** /**
* Returns the average server network traffic in bytes/sec. * Returns the average server network traffic in bytes/sec.
* *
* @param in Buffer to store the input traffic velocity. * @param in Buffer to store the input traffic velocity.
* @param out Buffer to store the output traffic velocity. * @param out Buffer to store the output traffic velocity.
*/ */
native void GetServerNetStats(float &inAmount, float &outAmout); native void GetServerNetStats(float &inAmount, float &outAmout);
/** /**
* Equip's a player's weapon. * Equip's a player's weapon.
* *
* @param client Client index. * @param client Client index.
* @param weapon CBaseCombatWeapon entity index. * @param weapon CBaseCombatWeapon entity index.
* @error Invalid client or entity, lack of mod support, or client not in * @error Invalid client or entity, lack of mod support, or client not in
* game. * game.
*/ */
native void EquipPlayerWeapon(int client, int weapon); native void EquipPlayerWeapon(int client, int weapon);
/** /**
* Activates an entity (CBaseAnimating::Activate) * Activates an entity (CBaseAnimating::Activate)
* *
* @param entity Entity index. * @param entity Entity index.
* @error Invalid entity or lack of mod support. * @error Invalid entity or lack of mod support.
*/ */
native void ActivateEntity(int entity); native void ActivateEntity(int entity);
@ -322,18 +322,18 @@ native void ActivateEntity(int entity);
* Sets values to client info buffer keys and notifies the engine of the change. * Sets values to client info buffer keys and notifies the engine of the change.
* The change does not get propagated to mods until the next frame. * The change does not get propagated to mods until the next frame.
* *
* @param client Player's index. * @param client Player's index.
* @param key Key string. * @param key Key string.
* @param value Value string. * @param value Value string.
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native void SetClientInfo(int client, const char[] key, const char[] value); native void SetClientInfo(int client, const char[] key, const char[] value);
/** /**
* Changes a client's name. * Changes a client's name.
* *
* @param client Player's index. * @param client Player's index.
* @param name New name. * @param name New name.
* @error Invalid client index, or client not connected. * @error Invalid client index, or client not connected.
*/ */
native void SetClientName(int client, const char[] name); native void SetClientName(int client, const char[] name);
@ -346,7 +346,6 @@ native void SetClientName(int client, const char[] name);
* @param amount Amount of ammo to give. Is capped at ammotype's limit. * @param amount Amount of ammo to give. Is capped at ammotype's limit.
* @param ammotype Type of ammo to give to player. * @param ammotype Type of ammo to give to player.
* @param suppressSound If true, don't play the ammo pickup sound. * @param suppressSound If true, don't play the ammo pickup sound.
* * @return Amount of ammo actually given.
* @return Amount of ammo actually given.
*/ */
native int GivePlayerAmmo(int client, int amount, int ammotype, bool suppressSound=false); native int GivePlayerAmmo(int client, int amount, int ammotype, bool suppressSound=false);

View File

@ -31,7 +31,7 @@
*/ */
#if defined _sdktools_gamerules_included #if defined _sdktools_gamerules_included
#endinput #endinput
#endif #endif
#define _sdktools_gamerules_included #define _sdktools_gamerules_included
@ -68,128 +68,128 @@ enum RoundState {
RoundState_Bonus, RoundState_Bonus,
//Between rounds //Between rounds
RoundState_BetweenRounds, RoundState_BetweenRounds
}; };
/** /**
* Retrieves an integer value from a property of the gamerules entity. * Retrieves an integer value from a property of the gamerules entity.
* *
* @param prop Property name. * @param prop Property name.
* @param size Number of bytes to read (valid values are 1, 2, or 4). * @param size Number of bytes to read (valid values are 1, 2, or 4).
* This value is auto-detected, and the size parameter is * This value is auto-detected, and the size parameter is
* only used as a fallback in case detection fails. * only used as a fallback in case detection fails.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @return Value at the given property offset. * @return Value at the given property offset.
* @error Not supported. * @error Not supported.
*/ */
native int GameRules_GetProp(const char[] prop, int size=4, int element=0); native int GameRules_GetProp(const char[] prop, int size=4, int element=0);
/** /**
* Sets an integer value for a property of the gamerules entity. * Sets an integer value for a property of the gamerules entity.
* *
* @param prop Property name. * @param prop Property name.
* @param value Value to set. * @param value Value to set.
* @param size Number of bytes to write (valid values are 1, 2, or 4). * @param size Number of bytes to write (valid values are 1, 2, or 4).
* This value is auto-detected, and the size parameter is * This value is auto-detected, and the size parameter is
* only used as a fallback in case detection fails. * only used as a fallback in case detection fails.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @param changeState This parameter is ignored. * @param changeState This parameter is ignored.
* @error Not supported. * @error Not supported.
*/ */
native void GameRules_SetProp(const char[] prop, any value, int size=4, int element=0, bool changeState=false); native void GameRules_SetProp(const char[] prop, any value, int size=4, int element=0, bool changeState=false);
/** /**
* Retrieves a float value from a property of the gamerules entity. * Retrieves a float value from a property of the gamerules entity.
* *
* @param prop Property name. * @param prop Property name.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @return Value at the given property offset. * @return Value at the given property offset.
* @error Not supported. * @error Not supported.
*/ */
native float GameRules_GetPropFloat(const char[] prop, int element=0); native float GameRules_GetPropFloat(const char[] prop, int element=0);
/** /**
* Sets a float value for a property of the gamerules entity. * Sets a float value for a property of the gamerules entity.
* *
* @param prop Property name. * @param prop Property name.
* @param value Value to set. * @param value Value to set.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @param changeState This parameter is ignored. * @param changeState This parameter is ignored.
* @error Not supported. * @error Not supported.
*/ */
native void GameRules_SetPropFloat(const char[] prop, float value, int element=0, bool changeState=false); native void GameRules_SetPropFloat(const char[] prop, float value, int element=0, bool changeState=false);
/** /**
* Retrieves a entity index from a property of the gamerules entity. * Retrieves a entity index from a property of the gamerules entity.
* *
* @param prop Property name. * @param prop Property name.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @return Entity index at the given property. * @return Entity index at the given property.
* If there is no entity, or the entity is not valid, * If there is no entity, or the entity is not valid,
* then -1 is returned. * then -1 is returned.
* @error Not supported. * @error Not supported.
*/ */
native int GameRules_GetPropEnt(const char[] prop, int element=0); native int GameRules_GetPropEnt(const char[] prop, int element=0);
/** /**
* Sets an entity index for a property of the gamerules entity. * Sets an entity index for a property of the gamerules entity.
* *
* @param prop Property name. * @param prop Property name.
* @param other Entity index to set, or -1 to unset. * @param other Entity index to set, or -1 to unset.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @param changeState This parameter is ignored. * @param changeState This parameter is ignored.
* @error Not supported. * @error Not supported.
*/ */
native void GameRules_SetPropEnt(const char[] prop, int other, int element=0, bool changeState=false); native void GameRules_SetPropEnt(const char[] prop, int other, int element=0, bool changeState=false);
/** /**
* Retrieves a vector of floats from the gamerules entity, given a named network property. * Retrieves a vector of floats from the gamerules entity, given a named network property.
* *
* @param prop Property name. * @param prop Property name.
* @param vec Vector buffer to store data in. * @param vec Vector buffer to store data in.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @error Not supported. * @error Not supported.
*/ */
native void GameRules_GetPropVector(const char[] prop, float vec[3], int element=0); native void GameRules_GetPropVector(const char[] prop, float vec[3], int element=0);
/** /**
* Sets a vector of floats in the gamerules entity, given a named network property. * Sets a vector of floats in the gamerules entity, given a named network property.
* *
* @param prop Property name. * @param prop Property name.
* @param vec Vector to set. * @param vec Vector to set.
* @param element Element # (starting from 0) if property is an array. * @param element Element # (starting from 0) if property is an array.
* @param changeState This parameter is ignored. * @param changeState This parameter is ignored.
* @error Not supported. * @error Not supported.
*/ */
native void GameRules_SetPropVector(const char[] prop, const float vec[3], int element=0, bool changeState=false); native void GameRules_SetPropVector(const char[] prop, const float vec[3], int element=0, bool changeState=false);
/** /**
* Gets a gamerules property as a string. * Gets a gamerules property as a string.
* *
* @param prop Property to use. * @param prop Property to use.
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlen Maximum length of output string buffer. * @param maxlen Maximum length of output string buffer.
* @return Number of non-null bytes written. * @return Number of non-null bytes written.
* @error Not supported. * @error Not supported.
*/ */
native int GameRules_GetPropString(const char[] prop, char[] buffer, int maxlen); native int GameRules_GetPropString(const char[] prop, char[] buffer, int maxlen);
/** /**
* Sets a gamerules property as a string. * Sets a gamerules property as a string.
* *
* @param prop Property to use. * @param prop Property to use.
* @param buffer String to set. * @param buffer String to set.
* @param changeState This parameter is ignored. * @param changeState This parameter is ignored.
* @return Number of non-null bytes written. * @return Number of non-null bytes written.
* @error Not supported. * @error Not supported.
*/ */
native int GameRules_SetPropString(const char[] prop, const char[] buffer, bool changeState=false); native int GameRules_SetPropString(const char[] prop, const char[] buffer, bool changeState=false);
/** /**
* Gets the current round state. * Gets the current round state.
* *
* @return Round state. * @return Round state.
* @error Game doesn't support round state. * @error Game doesn't support round state.
*/ */
stock RoundState GameRules_GetRoundState() stock RoundState GameRules_GetRoundState()
{ {

View File

@ -31,66 +31,65 @@
*/ */
#if defined _sdktools_hooks_included #if defined _sdktools_hooks_included
#endinput #endinput
#endif #endif
#define _sdktools_hooks_included #define _sdktools_hooks_included
#define FEATURECAP_PLAYERRUNCMD_11PARAMS "SDKTools PlayerRunCmd 11Params" #define FEATURECAP_PLAYERRUNCMD_11PARAMS "SDKTools PlayerRunCmd 11Params"
/** /**
* Called when a clients movement buttons are being processed * Called when a clients movement buttons are being processed
* *
* @param client Index of the client. * @param client Index of the client.
* @param buttons Copyback buffer containing the current commands (as bitflags - see entity_prop_stocks.inc). * @param buttons Copyback buffer containing the current commands (as bitflags - see entity_prop_stocks.inc).
* @param impulse Copyback buffer containing the current impulse command. * @param impulse Copyback buffer containing the current impulse command.
* @param vel Players desired velocity. * @param vel Players desired velocity.
* @param angles Players desired view angles. * @param angles Players desired view angles.
* @param weapon Entity index of the new weapon if player switches weapon, 0 otherwise. * @param weapon Entity index of the new weapon if player switches weapon, 0 otherwise.
* @param subtype Weapon subtype when selected from a menu. * @param subtype Weapon subtype when selected from a menu.
* @param cmdnum Command number. Increments from the first command sent. * @param cmdnum Command number. Increments from the first command sent.
* @param tickcount Tick count. A client's prediction based on the server's GetGameTickCount value. * @param tickcount Tick count. A client's prediction based on the server's GetGameTickCount value.
* @param seed Random seed. Used to determine weapon recoil, spread, and other predicted elements. * @param seed Random seed. Used to determine weapon recoil, spread, and other predicted elements.
* @param mouse Mouse direction (x, y). * @param mouse Mouse direction (x, y).
* @return Plugin_Handled to block the commands from being processed, Plugin_Continue otherwise. * @return Plugin_Handled to block the commands from being processed, Plugin_Continue otherwise.
* *
* @note To see if all 11 params are available, use FeatureType_Capability and * @note To see if all 11 params are available, use FeatureType_Capability and FEATURECAP_PLAYERRUNCMD_11PARAMS.
* FEATURECAP_PLAYERRUNCMD_11PARAMS.
*/ */
forward Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2]); forward Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2]);
/** /**
* Called after a clients movement buttons were processed. * Called after a clients movement buttons were processed.
* *
* @param client Index of the client. * @param client Index of the client.
* @param buttons The current commands (as bitflags - see entity_prop_stocks.inc). * @param buttons The current commands (as bitflags - see entity_prop_stocks.inc).
* @param impulse The current impulse command. * @param impulse The current impulse command.
* @param vel Players desired velocity. * @param vel Players desired velocity.
* @param angles Players desired view angles. * @param angles Players desired view angles.
* @param weapon Entity index of the new weapon if player switches weapon, 0 otherwise. * @param weapon Entity index of the new weapon if player switches weapon, 0 otherwise.
* @param subtype Weapon subtype when selected from a menu. * @param subtype Weapon subtype when selected from a menu.
* @param cmdnum Command number. Increments from the first command sent. * @param cmdnum Command number. Increments from the first command sent.
* @param tickcount Tick count. A client's prediction based on the server's GetGameTickCount value. * @param tickcount Tick count. A client's prediction based on the server's GetGameTickCount value.
* @param seed Random seed. Used to determine weapon recoil, spread, and other predicted elements. * @param seed Random seed. Used to determine weapon recoil, spread, and other predicted elements.
* @param mouse Mouse direction (x, y). * @param mouse Mouse direction (x, y).
*/ */
forward void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3], int weapon, int subtype, int cmdnum, int tickcount, int seed, const int mouse[2]); forward void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3], int weapon, int subtype, int cmdnum, int tickcount, int seed, const int mouse[2]);
/** /**
* Called when a client requests a file from the server. * Called when a client requests a file from the server.
* *
* @param client Client index. * @param client Client index.
* @param sFile Requested file path. * @param sFile Requested file path.
* *
* @return Plugin_Handled to block the transfer, Plugin_Continue to let it proceed. * @return Plugin_Handled to block the transfer, Plugin_Continue to let it proceed.
*/ */
forward Action OnFileSend(int client, const char[] sFile); forward Action OnFileSend(int client, const char[] sFile);
/** /**
* Called when a client sends a file to the server. * Called when a client sends a file to the server.
* *
* @param client Client index. * @param client Client index.
* @param sFile Requested file path. * @param sFile Requested file path.
* *
* @return Plugin_Handled to block the transfer, Plugin_Continue to let it proceed. * @return Plugin_Handled to block the transfer, Plugin_Continue to let it proceed.
*/ */
forward Action OnFileReceive(int client, const char[] sFile); forward Action OnFileReceive(int client, const char[] sFile);

View File

@ -31,40 +31,40 @@
*/ */
#if defined _sdktools_sound_included #if defined _sdktools_sound_included
#endinput #endinput
#endif #endif
#define _sdktools_sound_included #define _sdktools_sound_included
/** /**
* Sound should be from the target client. * Sound should be from the target client.
*/ */
#define SOUND_FROM_PLAYER -2 #define SOUND_FROM_PLAYER -2
/** /**
* Sound should be from the listen server player. * Sound should be from the listen server player.
*/ */
#define SOUND_FROM_LOCAL_PLAYER -1 #define SOUND_FROM_LOCAL_PLAYER -1
/** /**
* Sound is from the world. * Sound is from the world.
*/ */
#define SOUND_FROM_WORLD 0 #define SOUND_FROM_WORLD 0
/** /**
* Sound channels. * Sound channels.
*/ */
enum enum
{ {
SNDCHAN_REPLACE = -1, /**< Unknown */ SNDCHAN_REPLACE = -1, /**< Unknown */
SNDCHAN_AUTO = 0, /**< Auto */ SNDCHAN_AUTO = 0, /**< Auto */
SNDCHAN_WEAPON = 1, /**< Weapons */ SNDCHAN_WEAPON = 1, /**< Weapons */
SNDCHAN_VOICE = 2, /**< Voices */ SNDCHAN_VOICE = 2, /**< Voices */
SNDCHAN_ITEM = 3, /**< Items */ SNDCHAN_ITEM = 3, /**< Items */
SNDCHAN_BODY = 4, /**< Player? */ SNDCHAN_BODY = 4, /**< Player? */
SNDCHAN_STREAM = 5, /**< "Stream channel from the static or dynamic area" */ SNDCHAN_STREAM = 5, /**< "Stream channel from the static or dynamic area" */
SNDCHAN_STATIC = 6, /**< "Stream channel from the static area" */ SNDCHAN_STATIC = 6, /**< "Stream channel from the static area" */
SNDCHAN_VOICE_BASE = 7, /**< "Channel for network voice data" */ SNDCHAN_VOICE_BASE = 7, /**< "Channel for network voice data" */
SNDCHAN_USER_BASE = 135 /**< Anything >= this is allocated to game code */ SNDCHAN_USER_BASE = 135 /**< Anything >= this is allocated to game code */
}; };
/** /**
@ -72,15 +72,15 @@ enum
*/ */
enum enum
{ {
SND_NOFLAGS= 0, /**< Nothing */ SND_NOFLAGS= 0, /**< Nothing */
SND_CHANGEVOL = 1, /**< Change sound volume */ SND_CHANGEVOL = 1, /**< Change sound volume */
SND_CHANGEPITCH = 2, /**< Change sound pitch */ SND_CHANGEPITCH = 2, /**< Change sound pitch */
SND_STOP = 3, /**< Stop the sound */ SND_STOP = 3, /**< Stop the sound */
SND_SPAWNING = 4, /**< Used in some cases for ambients */ SND_SPAWNING = 4, /**< Used in some cases for ambients */
SND_DELAY = 5, /**< Sound has an initial delay */ SND_DELAY = 5, /**< Sound has an initial delay */
SND_STOPLOOPING = 6, /**< Stop looping all sounds on the entity */ SND_STOPLOOPING = 6, /**< Stop looping all sounds on the entity */
SND_SPEAKER = 7, /**< Being played by a mic through a speaker */ SND_SPEAKER = 7, /**< Being played by a mic through a speaker */
SND_SHOULDPAUSE = 8, /**< Pause if game is paused */ SND_SHOULDPAUSE = 8 /**< Pause if game is paused */
}; };
/** /**
@ -88,43 +88,43 @@ enum
*/ */
enum enum
{ {
SNDLEVEL_NONE = 0, /**< None */ SNDLEVEL_NONE = 0, /**< None */
SNDLEVEL_RUSTLE = 20, /**< Rustling leaves */ SNDLEVEL_RUSTLE = 20, /**< Rustling leaves */
SNDLEVEL_WHISPER = 25, /**< Whispering */ SNDLEVEL_WHISPER = 25, /**< Whispering */
SNDLEVEL_LIBRARY = 30, /**< In a library */ SNDLEVEL_LIBRARY = 30, /**< In a library */
SNDLEVEL_FRIDGE = 45, /**< Refrigerator */ SNDLEVEL_FRIDGE = 45, /**< Refrigerator */
SNDLEVEL_HOME = 50, /**< Average home (3.9 attn) */ SNDLEVEL_HOME = 50, /**< Average home (3.9 attn) */
SNDLEVEL_CONVO = 60, /**< Normal conversation (2.0 attn) */ SNDLEVEL_CONVO = 60, /**< Normal conversation (2.0 attn) */
SNDLEVEL_DRYER = 60, /**< Clothes dryer */ SNDLEVEL_DRYER = 60, /**< Clothes dryer */
SNDLEVEL_DISHWASHER = 65, /**< Dishwasher/washing machine (1.5 attn) */ SNDLEVEL_DISHWASHER = 65, /**< Dishwasher/washing machine (1.5 attn) */
SNDLEVEL_CAR = 70, /**< Car or vacuum cleaner (1.0 attn) */ SNDLEVEL_CAR = 70, /**< Car or vacuum cleaner (1.0 attn) */
SNDLEVEL_NORMAL = 75, /**< Normal sound level */ SNDLEVEL_NORMAL = 75, /**< Normal sound level */
SNDLEVEL_TRAFFIC = 75, /**< Busy traffic (0.8 attn) */ SNDLEVEL_TRAFFIC = 75, /**< Busy traffic (0.8 attn) */
SNDLEVEL_MINIBIKE = 80, /**< Mini-bike, alarm clock (0.7 attn) */ SNDLEVEL_MINIBIKE = 80, /**< Mini-bike, alarm clock (0.7 attn) */
SNDLEVEL_SCREAMING = 90, /**< Screaming child (0.5 attn) */ SNDLEVEL_SCREAMING = 90, /**< Screaming child (0.5 attn) */
SNDLEVEL_TRAIN = 100, /**< Subway train, pneumatic drill (0.4 attn) */ SNDLEVEL_TRAIN = 100, /**< Subway train, pneumatic drill (0.4 attn) */
SNDLEVEL_HELICOPTER = 105, /**< Helicopter */ SNDLEVEL_HELICOPTER = 105, /**< Helicopter */
SNDLEVEL_SNOWMOBILE = 110, /**< Snow mobile */ SNDLEVEL_SNOWMOBILE = 110, /**< Snow mobile */
SNDLEVEL_AIRCRAFT = 120, /**< Auto horn, aircraft */ SNDLEVEL_AIRCRAFT = 120, /**< Auto horn, aircraft */
SNDLEVEL_RAIDSIREN = 130, /**< Air raid siren */ SNDLEVEL_RAIDSIREN = 130, /**< Air raid siren */
SNDLEVEL_GUNFIRE = 140, /**< Gunshot, jet engine (0.27 attn) */ SNDLEVEL_GUNFIRE = 140, /**< Gunshot, jet engine (0.27 attn) */
SNDLEVEL_ROCKET = 180, /**< Rocket launching (0.2 attn) */ SNDLEVEL_ROCKET = 180 /**< Rocket launching (0.2 attn) */
}; };
#define SNDVOL_NORMAL 1.0 /**< Normal volume */ #define SNDVOL_NORMAL 1.0 /**< Normal volume */
#define SNDPITCH_NORMAL 100 /**< Normal pitch */ #define SNDPITCH_NORMAL 100 /**< Normal pitch */
#define SNDPITCH_LOW 95 /**< A low pitch */ #define SNDPITCH_LOW 95 /**< A low pitch */
#define SNDPITCH_HIGH 120 /**< A high pitch */ #define SNDPITCH_HIGH 120 /**< A high pitch */
#define SNDATTN_NONE 0.0 /**< No attenuation */ #define SNDATTN_NONE 0.0 /**< No attenuation */
#define SNDATTN_NORMAL 0.8 /**< Normal attenuation */ #define SNDATTN_NORMAL 0.8 /**< Normal attenuation */
#define SNDATTN_STATIC 1.25 /**< Static attenuation? */ #define SNDATTN_STATIC 1.25 /**< Static attenuation? */
#define SNDATTN_RICOCHET 1.5 /**< Ricochet effect */ #define SNDATTN_RICOCHET 1.5 /**< Ricochet effect */
#define SNDATTN_IDLE 2.0 /**< Idle attenuation? */ #define SNDATTN_IDLE 2.0 /**< Idle attenuation? */
/** /**
* Prefetches a sound. * Prefetches a sound.
* *
* @param name Sound file name relative to the "sound" folder. * @param name Sound file name relative to the "sound" folder.
*/ */
native void PrefetchSound(const char[] name); native void PrefetchSound(const char[] name);
@ -132,8 +132,9 @@ native void PrefetchSound(const char[] name);
* This function is not known to work, and may crash. You should * This function is not known to work, and may crash. You should
* not use it. It is provided for backwards compatibility only. * not use it. It is provided for backwards compatibility only.
* *
* @param name Sound file name relative to the "sound" folder. * @param name Sound file name relative to the "sound" folder.
* @return Duration in seconds. * @return Duration in seconds.
* @deprecated Does not work, may crash.
*/ */
#pragma deprecated Does not work, may crash. #pragma deprecated Does not work, may crash.
native float GetSoundDuration(const char[] name); native float GetSoundDuration(const char[] name);
@ -141,14 +142,14 @@ native float GetSoundDuration(const char[] name);
/** /**
* Emits an ambient sound. * Emits an ambient sound.
* *
* @param name Sound file name relative to the "sound" folder. * @param name Sound file name relative to the "sound" folder.
* @param pos Origin of sound. * @param pos Origin of sound.
* @param entity Entity index to associate sound with. * @param entity Entity index to associate sound with.
* @param level Sound level (from 0 to 255). * @param level Sound level (from 0 to 255).
* @param flags Sound flags. * @param flags Sound flags.
* @param vol Volume (from 0.0 to 1.0). * @param vol Volume (from 0.0 to 1.0).
* @param pitch Pitch (from 0 to 255). * @param pitch Pitch (from 0 to 255).
* @param delay Play delay. * @param delay Play delay.
*/ */
native void EmitAmbientSound(const char[] name, native void EmitAmbientSound(const char[] name,
const float pos[3], const float pos[3],
@ -162,43 +163,43 @@ native void EmitAmbientSound(const char[] name,
/** /**
* Fades a client's volume level toward silence or a given percentage. * Fades a client's volume level toward silence or a given percentage.
* *
* @param client Client index. * @param client Client index.
* @param percent Fade percentage. * @param percent Fade percentage.
* @param outtime Fade out time, in seconds. * @param outtime Fade out time, in seconds.
* @param holdtime Hold time, in seconds. * @param holdtime Hold time, in seconds.
* @param intime Fade in time, in seconds. * @param intime Fade in time, in seconds.
* @error Invalid client index or client not in game. * @error Invalid client index or client not in game.
*/ */
native void FadeClientVolume(int client, float percent, float outtime, float holdtime, float intime); native void FadeClientVolume(int client, float percent, float outtime, float holdtime, float intime);
/** /**
* Stops a sound. * Stops a sound.
* *
* @param entity Entity index. * @param entity Entity index.
* @param channel Channel number. * @param channel Channel number.
* @param name Sound file name relative to the "sound" folder. * @param name Sound file name relative to the "sound" folder.
*/ */
native void StopSound(int entity, int channel, const char[] name); native void StopSound(int entity, int channel, const char[] name);
/** /**
* Emits a sound to a list of clients. * Emits a sound to a list of clients.
* *
* @param clients Array of client indexes. * @param clients Array of client indexes.
* @param numClients Number of clients in the array. * @param numClients Number of clients in the array.
* @param sample Sound file name relative to the "sound" folder. * @param sample Sound file name relative to the "sound" folder.
* @param entity Entity to emit from. * @param entity Entity to emit from.
* @param channel Channel to emit with. * @param channel Channel to emit with.
* @param level Sound level. * @param level Sound level.
* @param flags Sound flags. * @param flags Sound flags.
* @param volume Sound volume. * @param volume Sound volume.
* @param pitch Sound pitch. * @param pitch Sound pitch.
* @param speakerentity Unknown. * @param speakerentity Unknown.
* @param origin Sound origin. * @param origin Sound origin.
* @param dir Sound direction. * @param dir Sound direction.
* @param updatePos Unknown (updates positions?) * @param updatePos Unknown (updates positions?)
* @param soundtime Alternate time to play sound for. * @param soundtime Alternate time to play sound for.
* @param ... Optional list of Float[3] arrays to specify additional origins. * @param ... Optional list of Float[3] arrays to specify additional origins.
* @error Invalid client index. * @error Invalid client index.
*/ */
native void EmitSound(const int[] clients, native void EmitSound(const int[] clients,
int numClients, int numClients,
@ -220,24 +221,24 @@ native void EmitSound(const int[] clients,
* Emits a sound or game sound to a list of clients using the latest version of the engine sound interface. * Emits a sound or game sound to a list of clients using the latest version of the engine sound interface.
* This native is only available in engines that are greater than or equal to Portal 2. * This native is only available in engines that are greater than or equal to Portal 2.
* *
* @param clients Array of client indexes. * @param clients Array of client indexes.
* @param numClients Number of clients in the array. * @param numClients Number of clients in the array.
* @param soundEntry Sound entry name. * @param soundEntry Sound entry name.
* @param sample Sound file name relative to the "sound" folder. * @param sample Sound file name relative to the "sound" folder.
* @param entity Entity to emit from. * @param entity Entity to emit from.
* @param channel Channel to emit with. * @param channel Channel to emit with.
* @param level Sound level. * @param level Sound level.
* @param seed Sound seed. * @param seed Sound seed.
* @param flags Sound flags. * @param flags Sound flags.
* @param volume Sound volume. * @param volume Sound volume.
* @param pitch Sound pitch. * @param pitch Sound pitch.
* @param speakerentity Unknown. * @param speakerentity Unknown.
* @param origin Sound origin. * @param origin Sound origin.
* @param dir Sound direction. * @param dir Sound direction.
* @param updatePos Unknown (updates positions?) * @param updatePos Unknown (updates positions?)
* @param soundtime Alternate time to play sound for. * @param soundtime Alternate time to play sound for.
* @param ... Optional list of Float[3] arrays to specify additional origins. * @param ... Optional list of Float[3] arrays to specify additional origins.
* @error Invalid client index. * @error Invalid client index.
*/ */
native void EmitSoundEntry(const int[] clients, native void EmitSoundEntry(const int[] clients,
int numClients, int numClients,
@ -260,22 +261,22 @@ native void EmitSoundEntry(const int[] clients,
/** /**
* Emits a sentence to a list of clients. * Emits a sentence to a list of clients.
* *
* @param clients Array of client indexes. * @param clients Array of client indexes.
* @param numClients Number of clients in the array. * @param numClients Number of clients in the array.
* @param sentence Sentence index (from PrecacheSentenceFile). * @param sentence Sentence index (from PrecacheSentenceFile).
* @param entity Entity to emit from. * @param entity Entity to emit from.
* @param channel Channel to emit with. * @param channel Channel to emit with.
* @param level Sound level. * @param level Sound level.
* @param flags Sound flags. * @param flags Sound flags.
* @param volume Sound volume. * @param volume Sound volume.
* @param pitch Sound pitch. * @param pitch Sound pitch.
* @param speakerentity Unknown. * @param speakerentity Unknown.
* @param origin Sound origin. * @param origin Sound origin.
* @param dir Sound direction. * @param dir Sound direction.
* @param updatePos Unknown (updates positions?) * @param updatePos Unknown (updates positions?)
* @param soundtime Alternate time to play sound for. * @param soundtime Alternate time to play sound for.
* @param ... Optional list of Float[3] arrays to specify additional origins. * @param ... Optional list of Float[3] arrays to specify additional origins.
* @error Invalid client index. * @error Invalid client index.
*/ */
native void EmitSentence(const int[] clients, native void EmitSentence(const int[] clients,
int numClients, int numClients,
@ -296,9 +297,9 @@ native void EmitSentence(const int[] clients,
/** /**
* Calculates gain of sound on given distance with given sound level in decibel * Calculates gain of sound on given distance with given sound level in decibel
* *
* @param soundlevel decibel of sound, like SNDLEVEL_NORMAL or integer value * @param soundlevel decibel of sound, like SNDLEVEL_NORMAL or integer value
* @param distance distance of sound to calculate, not meter or feet, but Source Engine`s normal Coordinate unit * @param distance distance of sound to calculate, not meter or feet, but Source Engine`s normal Coordinate unit
* @return gain of sound. you can multiply this with original sound`s volume to calculate volume on given distance * @return gain of sound. you can multiply this with original sound`s volume to calculate volume on given distance
*/ */
native float GetDistGainFromSoundLevel(int soundlevel, float distance); native float GetDistGainFromSoundLevel(int soundlevel, float distance);
@ -307,16 +308,16 @@ native float GetDistGainFromSoundLevel(int soundlevel, float distance);
* *
* NOTICE: all parameters can be overwritten to modify the default behavior. * NOTICE: all parameters can be overwritten to modify the default behavior.
* *
* @param sample Sound file name relative to the "sound" folder. * @param sample Sound file name relative to the "sound" folder.
* @param entity Entity index associated to the sound. * @param entity Entity index associated to the sound.
* @param volume Volume (from 0.0 to 1.0). * @param volume Volume (from 0.0 to 1.0).
* @param level Sound level (from 0 to 255). * @param level Sound level (from 0 to 255).
* @param pitch Pitch (from 0 to 255). * @param pitch Pitch (from 0 to 255).
* @param pos Origin of sound. * @param pos Origin of sound.
* @param flags Sound flags. * @param flags Sound flags.
* @param delay Play delay. * @param delay Play delay.
* @return Plugin_Continue to allow the sound to be played, Plugin_Stop to block it, * @return Plugin_Continue to allow the sound to be played, Plugin_Stop to block it,
* Plugin_Changed when any parameter has been modified. * Plugin_Changed when any parameter has been modified.
*/ */
typedef AmbientSHook = function Action ( typedef AmbientSHook = function Action (
char sample[PLATFORM_MAX_PATH], char sample[PLATFORM_MAX_PATH],
@ -364,52 +365,52 @@ typeset NormalSHook
/** /**
* Hooks all played ambient sounds. * Hooks all played ambient sounds.
* *
* @param hook Function to use as a hook. * @param hook Function to use as a hook.
* @error Invalid function hook. * @error Invalid function hook.
*/ */
native void AddAmbientSoundHook(AmbientSHook hook); native void AddAmbientSoundHook(AmbientSHook hook);
/** /**
* Hooks all played normal sounds. * Hooks all played normal sounds.
* *
* @param hook Function to use as a hook. * @param hook Function to use as a hook.
* @error Invalid function hook. * @error Invalid function hook.
*/ */
native void AddNormalSoundHook(NormalSHook hook); native void AddNormalSoundHook(NormalSHook hook);
/** /**
* Unhooks all played ambient sounds. * Unhooks all played ambient sounds.
* *
* @param hook Function used for the hook. * @param hook Function used for the hook.
* @error Invalid function hook. * @error Invalid function hook.
*/ */
native void RemoveAmbientSoundHook(AmbientSHook hook); native void RemoveAmbientSoundHook(AmbientSHook hook);
/** /**
* Unhooks all played normal sounds. * Unhooks all played normal sounds.
* *
* @param hook Function used for the hook. * @param hook Function used for the hook.
* @error Invalid function hook. * @error Invalid function hook.
*/ */
native void RemoveNormalSoundHook(NormalSHook hook); native void RemoveNormalSoundHook(NormalSHook hook);
/** /**
* Wrapper to emit sound to one client. * Wrapper to emit sound to one client.
* *
* @param client Client index. * @param client Client index.
* @param sample Sound file name relative to the "sound" folder. * @param sample Sound file name relative to the "sound" folder.
* @param entity Entity to emit from. * @param entity Entity to emit from.
* @param channel Channel to emit with. * @param channel Channel to emit with.
* @param level Sound level. * @param level Sound level.
* @param flags Sound flags. * @param flags Sound flags.
* @param volume Sound volume. * @param volume Sound volume.
* @param pitch Sound pitch. * @param pitch Sound pitch.
* @param speakerentity Unknown. * @param speakerentity Unknown.
* @param origin Sound origin. * @param origin Sound origin.
* @param dir Sound direction. * @param dir Sound direction.
* @param updatePos Unknown (updates positions?) * @param updatePos Unknown (updates positions?)
* @param soundtime Alternate time to play sound for. * @param soundtime Alternate time to play sound for.
* @error Invalid client index. * @error Invalid client index.
*/ */
stock void EmitSoundToClient(int client, stock void EmitSoundToClient(int client,
const char[] sample, const char[] sample,
@ -437,19 +438,19 @@ stock void EmitSoundToClient(int client,
/** /**
* Wrapper to emit sound to all clients. * Wrapper to emit sound to all clients.
* *
* @param sample Sound file name relative to the "sound" folder. * @param sample Sound file name relative to the "sound" folder.
* @param entity Entity to emit from. * @param entity Entity to emit from.
* @param channel Channel to emit with. * @param channel Channel to emit with.
* @param level Sound level. * @param level Sound level.
* @param flags Sound flags. * @param flags Sound flags.
* @param volume Sound volume. * @param volume Sound volume.
* @param pitch Sound pitch. * @param pitch Sound pitch.
* @param speakerentity Unknown. * @param speakerentity Unknown.
* @param origin Sound origin. * @param origin Sound origin.
* @param dir Sound direction. * @param dir Sound direction.
* @param updatePos Unknown (updates positions?) * @param updatePos Unknown (updates positions?)
* @param soundtime Alternate time to play sound for. * @param soundtime Alternate time to play sound for.
* @error Invalid client index. * @error Invalid client index.
*/ */
stock void EmitSoundToAll(const char[] sample, stock void EmitSoundToAll(const char[] sample,
int entity = SOUND_FROM_PLAYER, int entity = SOUND_FROM_PLAYER,
@ -475,22 +476,20 @@ stock void EmitSoundToAll(const char[] sample,
} }
} }
if (!total) if (total)
{ {
return; EmitSound(clients, total, sample, entity, channel,
level, flags, volume, pitch, speakerentity,
origin, dir, updatePos, soundtime);
} }
EmitSound(clients, total, sample, entity, channel,
level, flags, volume, pitch, speakerentity,
origin, dir, updatePos, soundtime);
} }
/** /**
* Converts an attenuation value to a sound level. * Converts an attenuation value to a sound level.
* This function is from the HL2SDK. * This function is from the HL2SDK.
* *
* @param attn Attenuation value. * @param attn Attenuation value.
* @return Integer sound level. * @return Integer sound level.
*/ */
stock int ATTN_TO_SNDLEVEL(float attn) stock int ATTN_TO_SNDLEVEL(float attn)
{ {
@ -510,16 +509,16 @@ stock int ATTN_TO_SNDLEVEL(float attn)
* Note that if a game sound has a rndwave section, one of them will be returned * Note that if a game sound has a rndwave section, one of them will be returned
* at random. * at random.
* *
* @param gameSound Name of game sound. * @param gameSound Name of game sound.
* @param channel Channel to emit with. * @param channel Channel to emit with.
* @param level Sound level. * @param level Sound level.
* @param volume Sound volume. * @param volume Sound volume.
* @param pitch Sound pitch. * @param pitch Sound pitch.
* @param sample Sound file name relative to the "sound" folder. * @param sample Sound file name relative to the "sound" folder.
* @param maxlength Maximum length of sample string buffer. * @param maxlength Maximum length of sample string buffer.
* @param entity Entity the sound is being emitted from. * @param entity Entity the sound is being emitted from.
* @return True if the sound was successfully retrieved, false if it * @return True if the sound was successfully retrieved, false if it
* was not found * was not found
*/ */
native bool GetGameSoundParams(const char[] gameSound, native bool GetGameSoundParams(const char[] gameSound,
int &channel, int &channel,
@ -539,18 +538,18 @@ native bool GetGameSoundParams(const char[] gameSound,
* Note that if a game sound has a rndwave section, one of them will be returned * Note that if a game sound has a rndwave section, one of them will be returned
* at random. * at random.
* *
* @param clients Array of client indexes. * @param clients Array of client indexes.
* @param numClients Number of clients in the array. * @param numClients Number of clients in the array.
* @param gameSound Name of game sound. * @param gameSound Name of game sound.
* @param entity Entity to emit from. * @param entity Entity to emit from.
* @param flags Sound flags. * @param flags Sound flags.
* @param speakerentity Unknown. * @param speakerentity Unknown.
* @param origin Sound origin. * @param origin Sound origin.
* @param dir Sound direction. * @param dir Sound direction.
* @param updatePos Unknown (updates positions?) * @param updatePos Unknown (updates positions?)
* @param soundtime Alternate time to play sound for. * @param soundtime Alternate time to play sound for.
* @return True if the sound was played successfully, false if it failed * @return True if the sound was played successfully, false if it failed
* @error Invalid client index. * @error Invalid client index.
*/ */
stock bool EmitGameSound(const int[] clients, stock bool EmitGameSound(const int[] clients,
int numClients, int numClients,
@ -574,10 +573,8 @@ stock bool EmitGameSound(const int[] clients,
EmitSound(clients, numClients, sample, entity, channel, level, flags, volume, pitch, speakerentity, origin, dir, updatePos, soundtime); EmitSound(clients, numClients, sample, entity, channel, level, flags, volume, pitch, speakerentity, origin, dir, updatePos, soundtime);
return true; return true;
} }
else
{ return false;
return false;
}
} }
/** /**
@ -589,11 +586,11 @@ stock bool EmitGameSound(const int[] clients,
* Note that if a game sound has a rndwave section, one of them will be returned * Note that if a game sound has a rndwave section, one of them will be returned
* at random. * at random.
* *
* @param gameSound Name of game sound. * @param gameSound Name of game sound.
* @param pos Origin of sound. * @param pos Origin of sound.
* @param entity Entity index to associate sound with. * @param entity Entity index to associate sound with.
* @param flags Sound flags. * @param flags Sound flags.
* @param delay Play delay. * @param delay Play delay.
*/ */
stock bool EmitAmbientGameSound(const char[] gameSound, stock bool EmitAmbientGameSound(const char[] gameSound,
const float pos[3], const float pos[3],
@ -612,10 +609,8 @@ stock bool EmitAmbientGameSound(const char[] gameSound,
EmitAmbientSound(sample, pos, entity, level, flags, volume, pitch, delay); EmitAmbientSound(sample, pos, entity, level, flags, volume, pitch, delay);
return true; return true;
} }
else
{ return false;
return false;
}
} }
/** /**
@ -627,16 +622,16 @@ stock bool EmitAmbientGameSound(const char[] gameSound,
* Note that if a game sound has a rndwave section, one of them will be returned * Note that if a game sound has a rndwave section, one of them will be returned
* at random. * at random.
* *
* @param client Client index. * @param client Client index.
* @param gameSound Name of game sound. * @param gameSound Name of game sound.
* @param entity Entity to emit from. * @param entity Entity to emit from.
* @param flags Sound flags. * @param flags Sound flags.
* @param speakerentity Unknown. * @param speakerentity Unknown.
* @param origin Sound origin. * @param origin Sound origin.
* @param dir Sound direction. * @param dir Sound direction.
* @param updatePos Unknown (updates positions?) * @param updatePos Unknown (updates positions?)
* @param soundtime Alternate time to play sound for. * @param soundtime Alternate time to play sound for.
* @error Invalid client index. * @error Invalid client index.
*/ */
stock bool EmitGameSoundToClient(int client, stock bool EmitGameSoundToClient(int client,
const char[] gameSound, const char[] gameSound,
@ -665,15 +660,15 @@ stock bool EmitGameSoundToClient(int client,
* Note that if a game sound has a rndwave section, one of them will be returned * Note that if a game sound has a rndwave section, one of them will be returned
* at random. * at random.
* *
* @param gameSound Name of game sound. * @param gameSound Name of game sound.
* @param entity Entity to emit from. * @param entity Entity to emit from.
* @param flags Sound flags. * @param flags Sound flags.
* @param speakerentity Unknown. * @param speakerentity Unknown.
* @param origin Sound origin. * @param origin Sound origin.
* @param dir Sound direction. * @param dir Sound direction.
* @param updatePos Unknown (updates positions?) * @param updatePos Unknown (updates positions?)
* @param soundtime Alternate time to play sound for. * @param soundtime Alternate time to play sound for.
* @error Invalid client index. * @error Invalid client index.
*/ */
stock bool EmitGameSoundToAll(const char[] gameSound, stock bool EmitGameSoundToAll(const char[] gameSound,
int entity = SOUND_FROM_PLAYER, int entity = SOUND_FROM_PLAYER,
@ -717,9 +712,8 @@ stock bool EmitGameSoundToAll(const char[] gameSound,
* *
* Note: It precaches all files for a game sound. * Note: It precaches all files for a game sound.
* *
* @param soundname Game sound to precache * @param soundname Game sound to precache
* * @return True if the game sound was found, false if sound did not exist
* @return True if the game sound was found, false if sound did not exist * or had no files
* or had no files
*/ */
native bool PrecacheScriptSound(const char[] soundname); native bool PrecacheScriptSound(const char[] soundname);

View File

@ -31,7 +31,7 @@
*/ */
#if defined _sdktools_stocks_included #if defined _sdktools_stocks_included
#endinput #endinput
#endif #endif
#define _sdktools_stocks_included #define _sdktools_stocks_included
@ -42,10 +42,10 @@
* first N characters of the team names, where N is the number of * first N characters of the team names, where N is the number of
* characters in the search pattern. * characters in the search pattern.
* *
* @param name Partial or full team name. * @param name Partial or full team name.
* @return A valid team index on success. * @return A valid team index on success.
* -1 if no team matched. * -1 if no team matched.
* -2 if more than one team matched. * -2 if more than one team matched.
*/ */
stock int FindTeamByName(const char[] name) stock int FindTeamByName(const char[] name)
{ {

View File

@ -31,131 +31,131 @@
*/ */
#if defined _sdktools_stringtables_included #if defined _sdktools_stringtables_included
#endinput #endinput
#endif #endif
#define _sdktools_stringtables_included #define _sdktools_stringtables_included
#define INVALID_STRING_TABLE -1 /**< An invalid string table index */ #define INVALID_STRING_TABLE -1 /**< An invalid string table index */
#define INVALID_STRING_INDEX -1 /**< An invalid string index in a table */ #define INVALID_STRING_INDEX -1 /**< An invalid string index in a table */
/** /**
* Searches for a string table. * Searches for a string table.
* *
* @param name Name of string table to find. * @param name Name of string table to find.
* @return A string table index number if found, INVALID_STRING_TABLE otherwise. * @return A string table index number if found, INVALID_STRING_TABLE otherwise.
*/ */
native int FindStringTable(const char[] name); native int FindStringTable(const char[] name);
/** /**
* Returns the number of string tables that currently exist. * Returns the number of string tables that currently exist.
* *
* @return Number of string tables that currently exist. * @return Number of string tables that currently exist.
*/ */
native int GetNumStringTables(); native int GetNumStringTables();
/** /**
* Returns the number of strings that currently exist in a given string table. * Returns the number of strings that currently exist in a given string table.
* *
* @param tableidx A string table index. * @param tableidx A string table index.
* @return Number of strings that currently exist. * @return Number of strings that currently exist.
* @error Invalid string table index. * @error Invalid string table index.
*/ */
native int GetStringTableNumStrings(int tableidx); native int GetStringTableNumStrings(int tableidx);
/** /**
* Returns the maximum number of strings that are allowed in a given string table. * Returns the maximum number of strings that are allowed in a given string table.
* *
* @param tableidx A string table index. * @param tableidx A string table index.
* @return Maximum number of strings allowed. * @return Maximum number of strings allowed.
* @error Invalid string table index. * @error Invalid string table index.
*/ */
native int GetStringTableMaxStrings(int tableidx); native int GetStringTableMaxStrings(int tableidx);
/** /**
* Retrieves the name of a string table. * Retrieves the name of a string table.
* *
* @param tableidx A string table index. * @param tableidx A string table index.
* @param name Buffer to store the name of the string table. * @param name Buffer to store the name of the string table.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @return Number of bytes written to the buffer (UTF-8 safe). * @return Number of bytes written to the buffer (UTF-8 safe).
* @error Invalid string table index. * @error Invalid string table index.
*/ */
native int GetStringTableName(int tableidx, char[] name, int maxlength); native int GetStringTableName(int tableidx, char[] name, int maxlength);
/** /**
* Searches for the index of a given string in a string table. * Searches for the index of a given string in a string table.
* *
* @param tableidx A string table index. * @param tableidx A string table index.
* @param str String to find. * @param str String to find.
* @return String index if found, INVALID_STRING_INDEX otherwise. * @return String index if found, INVALID_STRING_INDEX otherwise.
* @error Invalid string table index. * @error Invalid string table index.
*/ */
native int FindStringIndex(int tableidx, const char[] str); native int FindStringIndex(int tableidx, const char[] str);
/** /**
* Retrieves the string at a given index of a string table. * Retrieves the string at a given index of a string table.
* *
* @param tableidx A string table index. * @param tableidx A string table index.
* @param stringidx A string index. * @param stringidx A string index.
* @param str Buffer to store the string value. * @param str Buffer to store the string value.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @return Number of bytes written to the buffer (UTF-8 safe). * @return Number of bytes written to the buffer (UTF-8 safe).
* @error Invalid string table index or string index. * @error Invalid string table index or string index.
*/ */
native int ReadStringTable(int tableidx, int stringidx, char[] str, int maxlength); native int ReadStringTable(int tableidx, int stringidx, char[] str, int maxlength);
/** /**
* Returns the length of the user data associated with a given string index. * Returns the length of the user data associated with a given string index.
* *
* @param tableidx A string table index. * @param tableidx A string table index.
* @param stringidx A string index. * @param stringidx A string index.
* @return Length of user data. This will be 0 if there is no user data. * @return Length of user data. This will be 0 if there is no user data.
* @error Invalid string table index or string index. * @error Invalid string table index or string index.
*/ */
native int GetStringTableDataLength(int tableidx, int stringidx); native int GetStringTableDataLength(int tableidx, int stringidx);
/** /**
* Retrieves the user data associated with a given string index. * Retrieves the user data associated with a given string index.
* *
* @param tableidx A string table index. * @param tableidx A string table index.
* @param stringidx A string index. * @param stringidx A string index.
* @param userdata Buffer to store the user data. This will be set to "" if there is no user data. * @param userdata Buffer to store the user data. This will be set to "" if there is no user data.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @return Number of bytes written to the buffer (UTF-8 safe). * @return Number of bytes written to the buffer (UTF-8 safe).
* @error Invalid string table index or string index. * @error Invalid string table index or string index.
*/ */
native int GetStringTableData(int tableidx, int stringidx, char[] userdata, int maxlength); native int GetStringTableData(int tableidx, int stringidx, char[] userdata, int maxlength);
/** /**
* Sets the user data associated with a given string index. * Sets the user data associated with a given string index.
* *
* @param tableidx A string table index. * @param tableidx A string table index.
* @param stringidx A string index. * @param stringidx A string index.
* @param userdata User data string that will be set. * @param userdata User data string that will be set.
* @param length Length of user data string. This should include the null terminator. * @param length Length of user data string. This should include the null terminator.
* @return Number of bytes written to the buffer (UTF-8 safe). * @return Number of bytes written to the buffer (UTF-8 safe).
* @error Invalid string table index or string index. * @error Invalid string table index or string index.
*/ */
native int SetStringTableData(int tableidx, int stringidx, const char[] userdata, int length); native int SetStringTableData(int tableidx, int stringidx, const char[] userdata, int length);
/** /**
* Adds a string to a given string table. * Adds a string to a given string table.
* *
* @param tableidx A string table index. * @param tableidx A string table index.
* @param str String to add. * @param str String to add.
* @param userdata An optional user data string. * @param userdata An optional user data string.
* @param length Length of user data string. This should include the null terminator. * @param length Length of user data string. This should include the null terminator.
* If set to -1, then user data will be not be altered if the specified string * If set to -1, then user data will be not be altered if the specified string
* already exists in the string table. * already exists in the string table.
*/ */
native void AddToStringTable(int tableidx, const char[] str, const char[] userdata="", int length=-1); native void AddToStringTable(int tableidx, const char[] str, const char[] userdata="", int length=-1);
/** /**
* Locks or unlocks the network string tables. * Locks or unlocks the network string tables.
* *
* @param lock Determines whether network string tables should be locked. * @param lock Determines whether network string tables should be locked.
* True means the tables should be locked for writing; false means unlocked. * True means the tables should be locked for writing; false means unlocked.
* @return Previous lock state. * @return Previous lock state.
*/ */
native bool LockStringTables(bool lock); native bool LockStringTables(bool lock);
@ -163,7 +163,7 @@ native bool LockStringTables(bool lock);
* Adds a file to the downloadables network string table. * Adds a file to the downloadables network string table.
* This forces a client to download the file if they do not already have it. * This forces a client to download the file if they do not already have it.
* *
* @param filename File that will be added to downloadables table. * @param filename File that will be added to downloadables table.
*/ */
stock void AddFileToDownloadsTable(const char[] filename) stock void AddFileToDownloadsTable(const char[] filename)
{ {

View File

@ -38,128 +38,128 @@
/** /**
* Called when a temp entity is going to be sent. * Called when a temp entity is going to be sent.
* *
* @param te_name TE name. * @param te_name TE name.
* @param Players Array containing target player indexes. * @param Players Array containing target player indexes.
* @param numClients Number of players in the array. * @param numClients Number of players in the array.
* @param delay Delay in seconds to send the TE. * @param delay Delay in seconds to send the TE.
* @return Plugin_Continue to allow the transmission of the TE, Plugin_Stop to block it. * @return Plugin_Continue to allow the transmission of the TE, Plugin_Stop to block it.
*/ */
typedef TEHook = function Action (const char[] te_name, const int[] Players, int numClients, float delay); typedef TEHook = function Action (const char[] te_name, const int[] Players, int numClients, float delay);
/** /**
* Hooks a temp entity. * Hooks a temp entity.
* *
* @param te_name TE name to hook. * @param te_name TE name to hook.
* @param hook Function to use as a hook. * @param hook Function to use as a hook.
* @error Temp Entity name not available or invalid function hook. * @error Temp Entity name not available or invalid function hook.
*/ */
native void AddTempEntHook(const char[] te_name, TEHook hook); native void AddTempEntHook(const char[] te_name, TEHook hook);
/** /**
* Removes a temp entity hook. * Removes a temp entity hook.
* *
* @param te_name TE name to unhook. * @param te_name TE name to unhook.
* @param hook Function used for the hook. * @param hook Function used for the hook.
* @error Temp Entity name not available or invalid function hook. * @error Temp Entity name not available or invalid function hook.
*/ */
native void RemoveTempEntHook(const char[] te_name, TEHook hook); native void RemoveTempEntHook(const char[] te_name, TEHook hook);
/** /**
* Starts a temp entity transmission. * Starts a temp entity transmission.
* *
* @param te_name TE name. * @param te_name TE name.
* @error Temp Entity name not available. * @error Temp Entity name not available.
*/ */
native void TE_Start(const char[] te_name); native void TE_Start(const char[] te_name);
/** /**
* Checks if a certain TE property exists. * Checks if a certain TE property exists.
* *
* @param prop Property to use. * @param prop Property to use.
* @return True if the property exists, otherwise false. * @return True if the property exists, otherwise false.
*/ */
native bool TE_IsValidProp(const char[] prop); native bool TE_IsValidProp(const char[] prop);
/** /**
* Sets an integer value in the current temp entity. * Sets an integer value in the current temp entity.
* *
* @param prop Property to use. * @param prop Property to use.
* @param value Integer value to set. * @param value Integer value to set.
* @error Property not found. * @error Property not found.
*/ */
native void TE_WriteNum(const char[] prop, int value); native void TE_WriteNum(const char[] prop, int value);
/** /**
* Reads an integer value in the current temp entity. * Reads an integer value in the current temp entity.
* *
* @param prop Property to use. * @param prop Property to use.
* @return Property value. * @return Property value.
* @error Property not found. * @error Property not found.
*/ */
native int TE_ReadNum(const char[] prop); native int TE_ReadNum(const char[] prop);
/** /**
* Sets a floating point number in the current temp entity. * Sets a floating point number in the current temp entity.
* *
* @param prop Property to use. * @param prop Property to use.
* @param value Floating point number to set. * @param value Floating point number to set.
* @error Property not found. * @error Property not found.
*/ */
native void TE_WriteFloat(const char[] prop, float value); native void TE_WriteFloat(const char[] prop, float value);
/** /**
* Reads a floating point number in the current temp entity. * Reads a floating point number in the current temp entity.
* *
* @param prop Property to use. * @param prop Property to use.
* @return Property value. * @return Property value.
* @error Property not found. * @error Property not found.
*/ */
native float TE_ReadFloat(const char[] prop); native float TE_ReadFloat(const char[] prop);
/** /**
* Sets a vector in the current temp entity. * Sets a vector in the current temp entity.
* *
* @param prop Property to use. * @param prop Property to use.
* @param vector Vector to set. * @param vector Vector to set.
* @error Property not found. * @error Property not found.
*/ */
native void TE_WriteVector(const char[] prop, const float vector[3]); native void TE_WriteVector(const char[] prop, const float vector[3]);
/** /**
* Reads a vector in the current temp entity. * Reads a vector in the current temp entity.
* *
* @param prop Property to use. * @param prop Property to use.
* @param vector Vector to read. * @param vector Vector to read.
* @error Property not found. * @error Property not found.
*/ */
native void TE_ReadVector(const char[] prop, float vector[3]); native void TE_ReadVector(const char[] prop, float vector[3]);
/** /**
* Sets a QAngle in the current temp entity. * Sets a QAngle in the current temp entity.
* *
* @param prop Property to use. * @param prop Property to use.
* @param angles Angles to set. * @param angles Angles to set.
* @error Property not found. * @error Property not found.
*/ */
native void TE_WriteAngles(const char[] prop, const float angles[3]); native void TE_WriteAngles(const char[] prop, const float angles[3]);
/** /**
* Sets an array of floats in the current temp entity. * Sets an array of floats in the current temp entity.
* *
* @param prop Property to use. * @param prop Property to use.
* @param array Array of values to copy. * @param array Array of values to copy.
* @param arraySize Number of values to copy. * @param arraySize Number of values to copy.
* @error Property not found. * @error Property not found.
*/ */
native void TE_WriteFloatArray(const char[] prop, const float[] array, int arraySize); native void TE_WriteFloatArray(const char[] prop, const float[] array, int arraySize);
/** /**
* Sends the current temp entity to one or more clients. * Sends the current temp entity to one or more clients.
* *
* @param clients Array containing player indexes to broadcast to. * @param clients Array containing player indexes to broadcast to.
* @param numClients Number of players in the array. * @param numClients Number of players in the array.
* @param delay Delay in seconds to send the TE. * @param delay Delay in seconds to send the TE.
* @error Invalid client index or client not in game. * @error Invalid client index or client not in game.
*/ */
native void TE_Send(const int[] clients, int numClients, float delay=0.0); native void TE_Send(const int[] clients, int numClients, float delay=0.0);
@ -167,9 +167,9 @@ native void TE_Send(const int[] clients, int numClients, float delay=0.0);
* Sets an encoded entity index in the current temp entity. * Sets an encoded entity index in the current temp entity.
* (This is usually used for m_nStartEntity and m_nEndEntity). * (This is usually used for m_nStartEntity and m_nEndEntity).
* *
* @param prop Property to use. * @param prop Property to use.
* @param value Value to set. * @param value Value to set.
* @error Property not found. * @error Property not found.
*/ */
stock void TE_WriteEncodedEnt(const char[] prop, int value) stock void TE_WriteEncodedEnt(const char[] prop, int value)
{ {
@ -181,7 +181,7 @@ stock void TE_WriteEncodedEnt(const char[] prop, int value)
* Broadcasts the current temp entity to all clients. * Broadcasts the current temp entity to all clients.
* @note See TE_Start(). * @note See TE_Start().
* *
* @param delay Delay in seconds to send the TE. * @param delay Delay in seconds to send the TE.
*/ */
stock void TE_SendToAll(float delay=0.0) stock void TE_SendToAll(float delay=0.0)
{ {
@ -201,9 +201,9 @@ stock void TE_SendToAll(float delay=0.0)
* Sends the current TE to only a client. * Sends the current TE to only a client.
* @note See TE_Start(). * @note See TE_Start().
* *
* @param client Client to send to. * @param client Client to send to.
* @param delay Delay in seconds to send the TE. * @param delay Delay in seconds to send the TE.
* @error Invalid client index or client not in game. * @error Invalid client index or client not in game.
*/ */
stock void TE_SendToClient(int client, float delay=0.0) stock void TE_SendToClient(int client, float delay=0.0)
{ {
@ -220,9 +220,9 @@ stock void TE_SendToClient(int client, float delay=0.0)
* @note See TE_Start(). * @note See TE_Start().
* @note See GetClientsInRange() * @note See GetClientsInRange()
* *
* @param origin Coordinates from which to test range. * @param origin Coordinates from which to test range.
* @param rangeType Range type to use for filtering clients. * @param rangeType Range type to use for filtering clients.
* @param delay Delay in seconds to send the TE. * @param delay Delay in seconds to send the TE.
*/ */
stock void TE_SendToAllInRange(float origin[3], ClientRangeType rangeType, float delay=0.0) stock void TE_SendToAllInRange(float origin[3], ClientRangeType rangeType, float delay=0.0)
{ {

View File

@ -38,15 +38,15 @@
/** /**
* @section TE Explosion flags. * @section TE Explosion flags.
*/ */
#define TE_EXPLFLAG_NONE 0x0 /**< all flags clear makes default Half-Life explosion */ #define TE_EXPLFLAG_NONE 0x0 /**< all flags clear makes default Half-Life explosion */
#define TE_EXPLFLAG_NOADDITIVE 0x1 /**< sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite) */ #define TE_EXPLFLAG_NOADDITIVE 0x1 /**< sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite) */
#define TE_EXPLFLAG_NODLIGHTS 0x2 /**< do not render dynamic lights */ #define TE_EXPLFLAG_NODLIGHTS 0x2 /**< do not render dynamic lights */
#define TE_EXPLFLAG_NOSOUND 0x4 /**< do not play client explosion sound */ #define TE_EXPLFLAG_NOSOUND 0x4 /**< do not play client explosion sound */
#define TE_EXPLFLAG_NOPARTICLES 0x8 /**< do not draw particles */ #define TE_EXPLFLAG_NOPARTICLES 0x8 /**< do not draw particles */
#define TE_EXPLFLAG_DRAWALPHA 0x10 /**< sprite will be drawn alpha */ #define TE_EXPLFLAG_DRAWALPHA 0x10 /**< sprite will be drawn alpha */
#define TE_EXPLFLAG_ROTATE 0x20 /**< rotate the sprite randomly */ #define TE_EXPLFLAG_ROTATE 0x20 /**< rotate the sprite randomly */
#define TE_EXPLFLAG_NOFIREBALL 0x40 /**< do not draw a fireball */ #define TE_EXPLFLAG_NOFIREBALL 0x40 /**< do not draw a fireball */
#define TE_EXPLFLAG_NOFIREBALLSMOKE 0x80 /**< do not draw smoke with the fireball */ #define TE_EXPLFLAG_NOFIREBALLSMOKE 0x80 /**< do not draw smoke with the fireball */
/** /**
* @endsection * @endsection
@ -55,22 +55,22 @@
/** /**
* @section TE Beam flags. * @section TE Beam flags.
*/ */
#define FBEAM_STARTENTITY 0x00000001 #define FBEAM_STARTENTITY 0x00000001
#define FBEAM_ENDENTITY 0x00000002 #define FBEAM_ENDENTITY 0x00000002
#define FBEAM_FADEIN 0x00000004 #define FBEAM_FADEIN 0x00000004
#define FBEAM_FADEOUT 0x00000008 #define FBEAM_FADEOUT 0x00000008
#define FBEAM_SINENOISE 0x00000010 #define FBEAM_SINENOISE 0x00000010
#define FBEAM_SOLID 0x00000020 #define FBEAM_SOLID 0x00000020
#define FBEAM_SHADEIN 0x00000040 #define FBEAM_SHADEIN 0x00000040
#define FBEAM_SHADEOUT 0x00000080 #define FBEAM_SHADEOUT 0x00000080
#define FBEAM_ONLYNOISEONCE 0x00000100 /**< Only calculate our noise once */ #define FBEAM_ONLYNOISEONCE 0x00000100 /**< Only calculate our noise once */
#define FBEAM_NOTILE 0x00000200 #define FBEAM_NOTILE 0x00000200
#define FBEAM_USE_HITBOXES 0x00000400 /**< Attachment indices represent hitbox indices instead when this is set. */ #define FBEAM_USE_HITBOXES 0x00000400 /**< Attachment indices represent hitbox indices instead when this is set. */
#define FBEAM_STARTVISIBLE 0x00000800 /**< Has this client actually seen this beam's start entity yet? */ #define FBEAM_STARTVISIBLE 0x00000800 /**< Has this client actually seen this beam's start entity yet? */
#define FBEAM_ENDVISIBLE 0x00001000 /**< Has this client actually seen this beam's end entity yet? */ #define FBEAM_ENDVISIBLE 0x00001000 /**< Has this client actually seen this beam's end entity yet? */
#define FBEAM_ISACTIVE 0x00002000 #define FBEAM_ISACTIVE 0x00002000
#define FBEAM_FOREVER 0x00004000 #define FBEAM_FOREVER 0x00004000
#define FBEAM_HALOBEAM 0x00008000 /**< When drawing a beam with a halo, don't ignore the segments and endwidth */ #define FBEAM_HALOBEAM 0x00008000 /**< When drawing a beam with a halo, don't ignore the segments and endwidth */
/** /**
* @endsection * @endsection
@ -79,10 +79,10 @@
/** /**
* Sets up a sparks effect. * Sets up a sparks effect.
* *
* @param pos Position of the sparks. * @param pos Position of the sparks.
* @param dir Direction of the sparks. * @param dir Direction of the sparks.
* @param Magnitude Sparks size. * @param Magnitude Sparks size.
* @param TrailLength Trail lenght of the sparks. * @param TrailLength Trail lenght of the sparks.
*/ */
stock void TE_SetupSparks(const float pos[3], const float dir[3], int Magnitude, int TrailLength) stock void TE_SetupSparks(const float pos[3], const float dir[3], int Magnitude, int TrailLength)
{ {
@ -96,10 +96,10 @@ stock void TE_SetupSparks(const float pos[3], const float dir[3], int Magnitude,
/** /**
* Sets up a smoke effect. * Sets up a smoke effect.
* *
* @param pos Position of the smoke. * @param pos Position of the smoke.
* @param Model Precached model index. * @param Model Precached model index.
* @param Scale Scale of the smoke. * @param Scale Scale of the smoke.
* @param FrameRate Frame rate of the smoke. * @param FrameRate Frame rate of the smoke.
*/ */
stock void TE_SetupSmoke(const float pos[3], int Model, float Scale, int FrameRate) stock void TE_SetupSmoke(const float pos[3], int Model, float Scale, int FrameRate)
{ {
@ -113,10 +113,10 @@ stock void TE_SetupSmoke(const float pos[3], int Model, float Scale, int FrameRa
/** /**
* Sets up a dust cloud effect. * Sets up a dust cloud effect.
* *
* @param pos Position of the dust. * @param pos Position of the dust.
* @param dir Direction of the dust. * @param dir Direction of the dust.
* @param Size Dust cloud size. * @param Size Dust cloud size.
* @param Speed Dust cloud speed. * @param Speed Dust cloud speed.
*/ */
stock void TE_SetupDust(const float pos[3], const float dir[3], float Size, float Speed) stock void TE_SetupDust(const float pos[3], const float dir[3], float Size, float Speed)
{ {
@ -130,10 +130,10 @@ stock void TE_SetupDust(const float pos[3], const float dir[3], float Size, floa
/** /**
* Sets up a muzzle flash effect. * Sets up a muzzle flash effect.
* *
* @param pos Position of the muzzle flash. * @param pos Position of the muzzle flash.
* @param angles Rotation angles of the muzzle flash. * @param angles Rotation angles of the muzzle flash.
* @param Scale Scale of the muzzle flash. * @param Scale Scale of the muzzle flash.
* @param Type Muzzle flash type to render (Mod specific). * @param Type Muzzle flash type to render (Mod specific).
*/ */
stock void TE_SetupMuzzleFlash(const float pos[3], const float angles[3], float Scale, int Type) stock void TE_SetupMuzzleFlash(const float pos[3], const float angles[3], float Scale, int Type)
{ {
@ -147,8 +147,8 @@ stock void TE_SetupMuzzleFlash(const float pos[3], const float angles[3], float
/** /**
* Sets up a metal sparks effect. * Sets up a metal sparks effect.
* *
* @param pos Position of the metal sparks. * @param pos Position of the metal sparks.
* @param dir Direction of the metal sparks. * @param dir Direction of the metal sparks.
*/ */
stock void TE_SetupMetalSparks(const float pos[3], const float dir[3]) stock void TE_SetupMetalSparks(const float pos[3], const float dir[3])
{ {
@ -160,9 +160,9 @@ stock void TE_SetupMetalSparks(const float pos[3], const float dir[3])
/** /**
* Sets up an energy splash effect. * Sets up an energy splash effect.
* *
* @param pos Position of the energy splash. * @param pos Position of the energy splash.
* @param dir Direction of the energy splash. * @param dir Direction of the energy splash.
* @param Explosive Makes the effect explosive. * @param Explosive Makes the effect explosive.
*/ */
stock void TE_SetupEnergySplash(const float pos[3], const float dir[3], bool Explosive) stock void TE_SetupEnergySplash(const float pos[3], const float dir[3], bool Explosive)
{ {
@ -175,8 +175,8 @@ stock void TE_SetupEnergySplash(const float pos[3], const float dir[3], bool Exp
/** /**
* Sets up an armor ricochet effect. * Sets up an armor ricochet effect.
* *
* @param pos Position of the armor ricochet. * @param pos Position of the armor ricochet.
* @param dir Direction of the armor ricochet. * @param dir Direction of the armor ricochet.
*/ */
stock void TE_SetupArmorRicochet(const float pos[3], const float dir[3]) stock void TE_SetupArmorRicochet(const float pos[3], const float dir[3])
{ {
@ -188,11 +188,11 @@ stock void TE_SetupArmorRicochet(const float pos[3], const float dir[3])
/** /**
* Sets up a glowing sprite effect. * Sets up a glowing sprite effect.
* *
* @param pos Position of the sprite. * @param pos Position of the sprite.
* @param Model Precached model index. * @param Model Precached model index.
* @param Life Time duration of the sprite. * @param Life Time duration of the sprite.
* @param Size Sprite size. * @param Size Sprite size.
* @param Brightness Sprite brightness. * @param Brightness Sprite brightness.
*/ */
stock void TE_SetupGlowSprite(const float pos[3], int Model, float Life, float Size, int Brightness) stock void TE_SetupGlowSprite(const float pos[3], int Model, float Life, float Size, int Brightness)
{ {
@ -207,15 +207,15 @@ stock void TE_SetupGlowSprite(const float pos[3], int Model, float Life, float S
/** /**
* Sets up a explosion effect. * Sets up a explosion effect.
* *
* @param pos Explosion position. * @param pos Explosion position.
* @param Model Precached model index. * @param Model Precached model index.
* @param Scale Explosion scale. * @param Scale Explosion scale.
* @param Framerate Explosion frame rate. * @param Framerate Explosion frame rate.
* @param Flags Explosion flags. * @param Flags Explosion flags.
* @param Radius Explosion radius. * @param Radius Explosion radius.
* @param Magnitude Explosion size. * @param Magnitude Explosion size.
* @param normal Normal vector to the explosion. * @param normal Normal vector to the explosion.
* @param MaterialType Exploded material type. * @param MaterialType Exploded material type.
*/ */
stock void TE_SetupExplosion(const float pos[3], int Model, float Scale, int Framerate, int Flags, int Radius, int Magnitude, const float normal[3]={0.0, 0.0, 1.0}, int MaterialType='C') stock void TE_SetupExplosion(const float pos[3], int Model, float Scale, int Framerate, int Flags, int Radius, int Magnitude, const float normal[3]={0.0, 0.0, 1.0}, int MaterialType='C')
{ {
@ -234,12 +234,12 @@ stock void TE_SetupExplosion(const float pos[3], int Model, float Scale, int Fra
/** /**
* Sets up a blood sprite effect. * Sets up a blood sprite effect.
* *
* @param pos Position of the sprite. * @param pos Position of the sprite.
* @param dir Sprite direction. * @param dir Sprite direction.
* @param color Color array (r, g, b, a). * @param color Color array (r, g, b, a).
* @param Size Sprite size. * @param Size Sprite size.
* @param SprayModel Precached model index. * @param SprayModel Precached model index.
* @param BloodDropModel Precached model index. * @param BloodDropModel Precached model index.
*/ */
stock void TE_SetupBloodSprite(const float pos[3], const float dir[3], const int color[4], int Size, int SprayModel, int BloodDropModel) stock void TE_SetupBloodSprite(const float pos[3], const float dir[3], const int color[4], int Size, int SprayModel, int BloodDropModel)
{ {
@ -258,19 +258,19 @@ stock void TE_SetupBloodSprite(const float pos[3], const float dir[3], const int
/** /**
* Sets up a beam ring point effect. * Sets up a beam ring point effect.
* *
* @param center Center position of the ring. * @param center Center position of the ring.
* @param Start_Radius Initial ring radius. * @param Start_Radius Initial ring radius.
* @param End_Radius Final ring radius. * @param End_Radius Final ring radius.
* @param ModelIndex Precached model index. * @param ModelIndex Precached model index.
* @param HaloIndex Precached model index. * @param HaloIndex Precached model index.
* @param StartFrame Initial frame to render. * @param StartFrame Initial frame to render.
* @param FrameRate Ring frame rate. * @param FrameRate Ring frame rate.
* @param Life Time duration of the ring. * @param Life Time duration of the ring.
* @param Width Beam width. * @param Width Beam width.
* @param Amplitude Beam amplitude. * @param Amplitude Beam amplitude.
* @param Color Color array (r, g, b, a). * @param Color Color array (r, g, b, a).
* @param Speed Speed of the beam. * @param Speed Speed of the beam.
* @param Flags Beam flags. * @param Flags Beam flags.
*/ */
stock void TE_SetupBeamRingPoint(const float center[3], float Start_Radius, float End_Radius, int ModelIndex, int HaloIndex, int StartFrame, stock void TE_SetupBeamRingPoint(const float center[3], float Start_Radius, float End_Radius, int ModelIndex, int HaloIndex, int StartFrame,
int FrameRate, float Life, float Width, float Amplitude, const int Color[4], int Speed, int Flags) int FrameRate, float Life, float Width, float Amplitude, const int Color[4], int Speed, int Flags)
@ -299,19 +299,19 @@ stock void TE_SetupBeamRingPoint(const float center[3], float Start_Radius, floa
/** /**
* Sets up a point to point beam effect. * Sets up a point to point beam effect.
* *
* @param start Start position of the beam. * @param start Start position of the beam.
* @param end End position of the beam. * @param end End position of the beam.
* @param ModelIndex Precached model index. * @param ModelIndex Precached model index.
* @param HaloIndex Precached model index. * @param HaloIndex Precached model index.
* @param StartFrame Initial frame to render. * @param StartFrame Initial frame to render.
* @param FrameRate Beam frame rate. * @param FrameRate Beam frame rate.
* @param Life Time duration of the beam. * @param Life Time duration of the beam.
* @param Width Initial beam width. * @param Width Initial beam width.
* @param EndWidth Final beam width. * @param EndWidth Final beam width.
* @param FadeLength Beam fade time duration. * @param FadeLength Beam fade time duration.
* @param Amplitude Beam amplitude. * @param Amplitude Beam amplitude.
* @param Color Color array (r, g, b, a). * @param Color Color array (r, g, b, a).
* @param Speed Speed of the beam. * @param Speed Speed of the beam.
*/ */
stock void TE_SetupBeamPoints(const float start[3], const float end[3], int ModelIndex, int HaloIndex, int StartFrame, int FrameRate, float Life, stock void TE_SetupBeamPoints(const float start[3], const float end[3], int ModelIndex, int HaloIndex, int StartFrame, int FrameRate, float Life,
float Width, float EndWidth, int FadeLength, float Amplitude, const int Color[4], int Speed) float Width, float EndWidth, int FadeLength, float Amplitude, const int Color[4], int Speed)
@ -338,19 +338,19 @@ stock void TE_SetupBeamPoints(const float start[3], const float end[3], int Mode
/** /**
* Sets up an entity to entity laser effect. * Sets up an entity to entity laser effect.
* *
* @param StartEntity Entity index from where the beam starts. * @param StartEntity Entity index from where the beam starts.
* @param EndEntity Entity index from where the beam ends. * @param EndEntity Entity index from where the beam ends.
* @param ModelIndex Precached model index. * @param ModelIndex Precached model index.
* @param HaloIndex Precached model index. * @param HaloIndex Precached model index.
* @param StartFrame Initial frame to render. * @param StartFrame Initial frame to render.
* @param FrameRate Beam frame rate. * @param FrameRate Beam frame rate.
* @param Life Time duration of the beam. * @param Life Time duration of the beam.
* @param Width Initial beam width. * @param Width Initial beam width.
* @param EndWidth Final beam width. * @param EndWidth Final beam width.
* @param FadeLength Beam fade time duration. * @param FadeLength Beam fade time duration.
* @param Amplitude Beam amplitude. * @param Amplitude Beam amplitude.
* @param Color Color array (r, g, b, a). * @param Color Color array (r, g, b, a).
* @param Speed Speed of the beam. * @param Speed Speed of the beam.
*/ */
stock void TE_SetupBeamLaser(int StartEntity, int EndEntity, int ModelIndex, int HaloIndex, int StartFrame, int FrameRate, float Life, stock void TE_SetupBeamLaser(int StartEntity, int EndEntity, int ModelIndex, int HaloIndex, int StartFrame, int FrameRate, float Life,
float Width, float EndWidth, int FadeLength, float Amplitude, const int Color[4], int Speed) float Width, float EndWidth, int FadeLength, float Amplitude, const int Color[4], int Speed)
@ -377,18 +377,18 @@ stock void TE_SetupBeamLaser(int StartEntity, int EndEntity, int ModelIndex, int
/** /**
* Sets up a beam ring effect. * Sets up a beam ring effect.
* *
* @param StartEntity Entity index from where the ring starts. * @param StartEntity Entity index from where the ring starts.
* @param EndEntity Entity index from where the ring ends. * @param EndEntity Entity index from where the ring ends.
* @param ModelIndex Precached model index. * @param ModelIndex Precached model index.
* @param HaloIndex Precached model index. * @param HaloIndex Precached model index.
* @param StartFrame Initial frame to render. * @param StartFrame Initial frame to render.
* @param FrameRate Ring frame rate. * @param FrameRate Ring frame rate.
* @param Life Time duration of the ring. * @param Life Time duration of the ring.
* @param Width Beam width. * @param Width Beam width.
* @param Amplitude Beam amplitude. * @param Amplitude Beam amplitude.
* @param Color Color array (r, g, b, a). * @param Color Color array (r, g, b, a).
* @param Speed Speed of the beam. * @param Speed Speed of the beam.
* @param Flags Beam flags. * @param Flags Beam flags.
*/ */
stock void TE_SetupBeamRing(int StartEntity, int EndEntity, int ModelIndex, int HaloIndex, int StartFrame, int FrameRate, float Life, float Width, float Amplitude, const int Color[4], int Speed, int Flags) stock void TE_SetupBeamRing(int StartEntity, int EndEntity, int ModelIndex, int HaloIndex, int StartFrame, int FrameRate, float Life, float Width, float Amplitude, const int Color[4], int Speed, int Flags)
{ {
@ -415,14 +415,14 @@ stock void TE_SetupBeamRing(int StartEntity, int EndEntity, int ModelIndex, int
/** /**
* Sets up a follow beam effect. * Sets up a follow beam effect.
* *
* @param EntIndex Entity index from where the beam starts. * @param EntIndex Entity index from where the beam starts.
* @param ModelIndex Precached model index. * @param ModelIndex Precached model index.
* @param HaloIndex Precached model index. * @param HaloIndex Precached model index.
* @param Life Time duration of the beam. * @param Life Time duration of the beam.
* @param Width Initial beam width. * @param Width Initial beam width.
* @param EndWidth Final beam width. * @param EndWidth Final beam width.
* @param FadeLength Beam fade time duration. * @param FadeLength Beam fade time duration.
* @param Color Color array (r, g, b, a). * @param Color Color array (r, g, b, a).
*/ */
stock void TE_SetupBeamFollow(int EntIndex, int ModelIndex, int HaloIndex, float Life, float Width, float EndWidth, int FadeLength, const int Color[4]) stock void TE_SetupBeamFollow(int EntIndex, int ModelIndex, int HaloIndex, float Life, float Width, float EndWidth, int FadeLength, const int Color[4])
{ {

View File

@ -169,19 +169,19 @@ typeset TraceEntityFilter
/** /**
* Called on entity filtering. * Called on entity filtering.
* *
* @param entity Entity index. * @param entity Entity index.
* @param contentsMask Contents Mask. * @param contentsMask Contents Mask.
* @return True to allow the current entity to be hit, otherwise false. * @return True to allow the current entity to be hit, otherwise false.
*/ */
function bool (int entity, int contentsMask); function bool (int entity, int contentsMask);
/** /**
* Called on entity filtering. * Called on entity filtering.
* *
* @param entity Entity index. * @param entity Entity index.
* @param contentsMask Contents Mask. * @param contentsMask Contents Mask.
* @param data Data value, if used. * @param data Data value, if used.
* @return True to allow the current entity to be hit, otherwise false. * @return True to allow the current entity to be hit, otherwise false.
*/ */
function bool (int entity, int contentsMask, any data); function bool (int entity, int contentsMask, any data);
}; };
@ -191,109 +191,109 @@ typeset TraceEntityEnumerator
/** /**
* Called for each entity enumerated with EnumerateEntities*. * Called for each entity enumerated with EnumerateEntities*.
* *
* @param entity Entity index. * @param entity Entity index.
* @return True to continue enumerating, otherwise false. * @return True to continue enumerating, otherwise false.
*/ */
function bool (int entity); function bool (int entity);
/** /**
* Called for each entity enumerated with EnumerateEntities*. * Called for each entity enumerated with EnumerateEntities*.
* *
* @param entity Entity index. * @param entity Entity index.
* @param data Data value, if used. * @param data Data value, if used.
* @return True to continue enumerating, otherwise false. */ * @return True to continue enumerating, otherwise false. */
function bool (int entity, any data); function bool (int entity, any data);
} }
/** /**
* Get the contents mask and the entity index at the given position. * Get the contents mask and the entity index at the given position.
* *
* @param pos World position to test. * @param pos World position to test.
* @param entindex Entity index found at the given position (by reference). * @param entindex Entity index found at the given position (by reference).
* @return Contents mask. * @return Contents mask.
*/ */
native int TR_GetPointContents(const float pos[3], int &entindex=-1); native int TR_GetPointContents(const float pos[3], int &entindex=-1);
/** /**
* Get the point contents testing only the given entity index. * Get the point contents testing only the given entity index.
* *
* @param entindex Entity index to test. * @param entindex Entity index to test.
* @param pos World position. * @param pos World position.
* @return Contents mask. * @return Contents mask.
*/ */
native int TR_GetPointContentsEnt(int entindex, const float pos[3]); native int TR_GetPointContentsEnt(int entindex, const float pos[3]);
/** /**
* Starts up a new trace ray using a global trace result. * Starts up a new trace ray using a global trace result.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Depending on RayType, it will be used as the * @param vec Depending on RayType, it will be used as the
* ending point, or the direction angle. * ending point, or the direction angle.
* @param flags Trace flags. * @param flags Trace flags.
* @param rtype Method to calculate the ray direction. * @param rtype Method to calculate the ray direction.
*/ */
native void TR_TraceRay(const float pos[3], native void TR_TraceRay(const float pos[3],
const float vec[3], const float vec[3],
int flags, int flags,
RayType rtype); RayType rtype);
/** /**
* Starts up a new trace hull using a global trace result. * Starts up a new trace hull using a global trace result.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Ending position of the ray. * @param vec Ending position of the ray.
* @param mins Hull minimum size. * @param mins Hull minimum size.
* @param maxs Hull maximum size. * @param maxs Hull maximum size.
* @param flags Trace flags. * @param flags Trace flags.
*/ */
native void TR_TraceHull(const float pos[3], native void TR_TraceHull(const float pos[3],
const float vec[3], const float vec[3],
const float mins[3], const float mins[3],
const float maxs[3], const float maxs[3],
int flags); int flags);
/** /**
* Enumerates over entities along a ray. This may find entities that are * Enumerates over entities along a ray. This may find entities that are
* close to the ray but do not actually intersect it. Use TR_Clip*RayToEntity * close to the ray but do not actually intersect it. Use TR_Clip*RayToEntity
* with TR_DidHit to check if the ray actually intersects the entity. * with TR_DidHit to check if the ray actually intersects the entity.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Depending on RayType, it will be used as the ending * @param vec Depending on RayType, it will be used as the ending
* point, or the direction angle. * point, or the direction angle.
* @param mask Mask to use for the trace. See PARTITION_* flags. * @param mask Mask to use for the trace. See PARTITION_* flags.
* @param rtype Method to calculate the ray direction. * @param rtype Method to calculate the ray direction.
* @param enumerator Function to use as enumerator. For each entity found * @param enumerator Function to use as enumerator. For each entity found
* along the ray, this function is called. * along the ray, this function is called.
* @param data Arbitrary data value to pass through to the enumerator. * @param data Arbitrary data value to pass through to the enumerator.
*/ */
native void TR_EnumerateEntities(const float pos[3], native void TR_EnumerateEntities(const float pos[3],
const float vec[3], const float vec[3],
int mask, int mask,
RayType rtype, RayType rtype,
TraceEntityEnumerator enumerator, TraceEntityEnumerator enumerator,
any data=0); any data=0);
/** /**
* Enumerates over entities along a ray hull. This may find entities that are * Enumerates over entities along a ray hull. This may find entities that are
* close to the ray but do not actually intersect it. Use TR_Clip*RayToEntity * close to the ray but do not actually intersect it. Use TR_Clip*RayToEntity
* with TR_DidHit to check if the ray actually intersects the entity. * with TR_DidHit to check if the ray actually intersects the entity.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Ending position of the ray. * @param vec Ending position of the ray.
* @param mins Hull minimum size. * @param mins Hull minimum size.
* @param maxs Hull maximum size. * @param maxs Hull maximum size.
* @param mask Mask to use for the trace. See PARTITION_* flags. * @param mask Mask to use for the trace. See PARTITION_* flags.
* @param enumerator Function to use as enumerator. For each entity found * @param enumerator Function to use as enumerator. For each entity found
* along the ray, this function is called. * along the ray, this function is called.
* @param data Arbitrary data value to pass through to the enumerator. * @param data Arbitrary data value to pass through to the enumerator.
*/ */
native void TR_EnumerateEntitiesHull(const float pos[3], native void TR_EnumerateEntitiesHull(const float pos[3],
const float vec[3], const float vec[3],
const float mins[3], const float mins[3],
const float maxs[3], const float maxs[3],
int mask, int mask,
TraceEntityEnumerator enumerator, TraceEntityEnumerator enumerator,
any data=0); any data=0);
/** /**
* Starts up a new trace ray using a global trace result and a customized * Starts up a new trace ray using a global trace result and a customized
@ -302,21 +302,21 @@ native void TR_EnumerateEntitiesHull(const float pos[3],
* Calling TR_Trace*Filter or TR_Trace*FilterEx from inside a filter * Calling TR_Trace*Filter or TR_Trace*FilterEx from inside a filter
* function is currently not allowed and may not work. * function is currently not allowed and may not work.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Depending on RayType, it will be used as the ending * @param vec Depending on RayType, it will be used as the ending
* point, or the direction angle. * point, or the direction angle.
* @param flags Trace flags. * @param flags Trace flags.
* @param rtype Method to calculate the ray direction. * @param rtype Method to calculate the ray direction.
* @param filter Function to use as a filter. * @param filter Function to use as a filter.
* @param data Arbitrary data value to pass through to the filter * @param data Arbitrary data value to pass through to the filter
* function. * function.
*/ */
native void TR_TraceRayFilter(const float pos[3], native void TR_TraceRayFilter(const float pos[3],
const float vec[3], const float vec[3],
int flags, int flags,
RayType rtype, RayType rtype,
TraceEntityFilter filter, TraceEntityFilter filter,
any data=0); any data=0);
/** /**
* Starts up a new trace hull using a global trace result and a customized * Starts up a new trace hull using a global trace result and a customized
@ -325,94 +325,94 @@ native void TR_TraceRayFilter(const float pos[3],
* Calling TR_Trace*Filter or TR_Trace*FilterEx from inside a filter * Calling TR_Trace*Filter or TR_Trace*FilterEx from inside a filter
* function is currently not allowed and may not work. * function is currently not allowed and may not work.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Ending position of the ray. * @param vec Ending position of the ray.
* @param mins Hull minimum size. * @param mins Hull minimum size.
* @param maxs Hull maximum size. * @param maxs Hull maximum size.
* @param flags Trace flags. * @param flags Trace flags.
* @param filter Function to use as a filter. * @param filter Function to use as a filter.
* @param data Arbitrary data value to pass through to the filter * @param data Arbitrary data value to pass through to the filter
* function. * function.
*/ */
native void TR_TraceHullFilter(const float pos[3], native void TR_TraceHullFilter(const float pos[3],
const float vec[3], const float vec[3],
const float mins[3], const float mins[3],
const float maxs[3], const float maxs[3],
int flags, int flags,
TraceEntityFilter filter, TraceEntityFilter filter,
any data=0); any data=0);
/** /**
* Clips a ray to a particular entity. * Clips a ray to a particular entity.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Depending on RayType, it will be used as the ending * @param vec Depending on RayType, it will be used as the ending
* point, or the direction angle. * point, or the direction angle.
* @param flags Trace flags. * @param flags Trace flags.
* @param rtype Method to calculate the ray direction. * @param rtype Method to calculate the ray direction.
* @param entity Entity to clip to. * @param entity Entity to clip to.
*/ */
native void TR_ClipRayToEntity(const float pos[3], native void TR_ClipRayToEntity(const float pos[3],
const float vec[3], const float vec[3],
int flags, int flags,
RayType rtype, RayType rtype,
int entity); int entity);
/** /**
* Clips a ray hull to a particular entity. * Clips a ray hull to a particular entity.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Ending position of the ray. * @param vec Ending position of the ray.
* @param mins Hull minimum size. * @param mins Hull minimum size.
* @param maxs Hull maximum size. * @param maxs Hull maximum size.
* @param flags Trace flags. * @param flags Trace flags.
* @param entity Entity to clip to. * @param entity Entity to clip to.
*/ */
native void TR_ClipRayHullToEntity(const float pos[3], native void TR_ClipRayHullToEntity(const float pos[3],
const float vec[3], const float vec[3],
const float mins[3], const float mins[3],
const float maxs[3], const float maxs[3],
int flags, int flags,
int entity); int entity);
/** /**
* Clips the current global ray (or hull) to a particular entity. * Clips the current global ray (or hull) to a particular entity.
* *
* @param flags Trace flags. * @param flags Trace flags.
* @param entity Entity to clip to. * @param entity Entity to clip to.
*/ */
native void TR_ClipCurrentRayToEntity(int flags, int entity); native void TR_ClipCurrentRayToEntity(int flags, int entity);
/** /**
* Starts up a new trace ray using a new trace result. * Starts up a new trace ray using a new trace result.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Depending on RayType, it will be used as the ending * @param vec Depending on RayType, it will be used as the ending
* point, or the direction angle. * point, or the direction angle.
* @param flags Trace flags. * @param flags Trace flags.
* @param rtype Method to calculate the ray direction. * @param rtype Method to calculate the ray direction.
* @return Ray trace handle, which must be closed via CloseHandle(). * @return Ray trace handle, which must be closed via CloseHandle().
*/ */
native Handle TR_TraceRayEx(const float pos[3], native Handle TR_TraceRayEx(const float pos[3],
const float vec[3], const float vec[3],
int flags, int flags,
RayType rtype); RayType rtype);
/** /**
* Starts up a new trace hull using a new trace result. * Starts up a new trace hull using a new trace result.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Ending position of the ray. * @param vec Ending position of the ray.
* @param mins Hull minimum size. * @param mins Hull minimum size.
* @param maxs Hull maximum size. * @param maxs Hull maximum size.
* @param flags Trace flags. * @param flags Trace flags.
* @return Ray trace handle, which must be closed via CloseHandle(). * @return Ray trace handle, which must be closed via CloseHandle().
*/ */
native Handle TR_TraceHullEx(const float pos[3], native Handle TR_TraceHullEx(const float pos[3],
const float vec[3], const float vec[3],
const float mins[3], const float mins[3],
const float maxs[3], const float maxs[3],
int flags); int flags);
/** /**
* Starts up a new trace ray using a new trace result and a customized * Starts up a new trace ray using a new trace result and a customized
@ -421,21 +421,21 @@ native Handle TR_TraceHullEx(const float pos[3],
* Calling TR_Trace*Filter or TR_TraceRay*Ex from inside a filter * Calling TR_Trace*Filter or TR_TraceRay*Ex from inside a filter
* function is currently not allowed and may not work. * function is currently not allowed and may not work.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Depending on RayType, it will be used as the ending * @param vec Depending on RayType, it will be used as the ending
* point, or the direction angle. * point, or the direction angle.
* @param flags Trace flags. * @param flags Trace flags.
* @param rtype Method to calculate the ray direction. * @param rtype Method to calculate the ray direction.
* @param filter Function to use as a filter. * @param filter Function to use as a filter.
* @param data Arbitrary data value to pass through to the filter function. * @param data Arbitrary data value to pass through to the filter function.
* @return Ray trace handle, which must be closed via CloseHandle(). * @return Ray trace handle, which must be closed via CloseHandle().
*/ */
native Handle TR_TraceRayFilterEx(const float pos[3], native Handle TR_TraceRayFilterEx(const float pos[3],
const float vec[3], const float vec[3],
int flags, int flags,
RayType rtype, RayType rtype,
TraceEntityFilter filter, TraceEntityFilter filter,
any data=0); any data=0);
/** /**
* Starts up a new trace hull using a new trace result and a customized * Starts up a new trace hull using a new trace result and a customized
@ -444,73 +444,73 @@ native Handle TR_TraceRayFilterEx(const float pos[3],
* Calling TR_Trace*Filter or TR_Trace*FilterEx from inside a filter * Calling TR_Trace*Filter or TR_Trace*FilterEx from inside a filter
* function is currently not allowed and may not work. * function is currently not allowed and may not work.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Ending position of the ray. * @param vec Ending position of the ray.
* @param mins Hull minimum size. * @param mins Hull minimum size.
* @param maxs Hull maximum size. * @param maxs Hull maximum size.
* @param flags Trace flags. * @param flags Trace flags.
* @param filter Function to use as a filter. * @param filter Function to use as a filter.
* @param data Arbitrary data value to pass through to the filter function. * @param data Arbitrary data value to pass through to the filter function.
* @return Ray trace handle, which must be closed via CloseHandle(). * @return Ray trace handle, which must be closed via CloseHandle().
*/ */
native Handle TR_TraceHullFilterEx(const float pos[3], native Handle TR_TraceHullFilterEx(const float pos[3],
const float vec[3], const float vec[3],
const float mins[3], const float mins[3],
const float maxs[3], const float maxs[3],
int flags, int flags,
TraceEntityFilter filter, TraceEntityFilter filter,
any data=0); any data=0);
/** /**
* Clips a ray to a particular entity. * Clips a ray to a particular entity.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Depending on RayType, it will be used as the ending * @param vec Depending on RayType, it will be used as the ending
* point, or the direction angle. * point, or the direction angle.
* @param flags Trace flags. * @param flags Trace flags.
* @param rtype Method to calculate the ray direction. * @param rtype Method to calculate the ray direction.
* @param entity Entity to clip to. * @param entity Entity to clip to.
* @return Ray trace handle, which must be closed via CloseHandle(). * @return Ray trace handle, which must be closed via CloseHandle().
*/ */
native Handle TR_ClipRayToEntityEx(const float pos[3], native Handle TR_ClipRayToEntityEx(const float pos[3],
const float vec[3], const float vec[3],
int flags, int flags,
RayType rtype, RayType rtype,
int entity); int entity);
/** /**
* Clips a ray hull to a particular entity. * Clips a ray hull to a particular entity.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Ending position of the ray. * @param vec Ending position of the ray.
* @param mins Hull minimum size. * @param mins Hull minimum size.
* @param maxs Hull maximum size. * @param maxs Hull maximum size.
* @param flags Trace flags. * @param flags Trace flags.
* @param entity Entity to clip to. * @param entity Entity to clip to.
* @return Ray trace handle, which must be closed via CloseHandle(). * @return Ray trace handle, which must be closed via CloseHandle().
*/ */
native Handle TR_ClipRayHullToEntityEx(const float pos[3], native Handle TR_ClipRayHullToEntityEx(const float pos[3],
const float vec[3], const float vec[3],
const float mins[3], const float mins[3],
const float maxs[3], const float maxs[3],
int flags, int flags,
int entity); int entity);
/** /**
* Clips the current global ray (or hull) to a particular entity. * Clips the current global ray (or hull) to a particular entity.
* *
* @param flags Trace flags. * @param flags Trace flags.
* @param entity Entity to clip to. * @param entity Entity to clip to.
* @return Ray trace handle, which must be closed via CloseHandle(). * @return Ray trace handle, which must be closed via CloseHandle().
*/ */
native Handle TR_ClipCurrentRayToEntityEx(int flags, int entity); native Handle TR_ClipCurrentRayToEntityEx(int flags, int entity);
/** /**
* Returns the time fraction from a trace result (1.0 means no collision). * Returns the time fraction from a trace result (1.0 means no collision).
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return Time fraction value of the trace. * @return Time fraction value of the trace.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native float TR_GetFraction(Handle hndl=INVALID_HANDLE); native float TR_GetFraction(Handle hndl=INVALID_HANDLE);
@ -518,135 +518,134 @@ native float TR_GetFraction(Handle hndl=INVALID_HANDLE);
* Returns the time fraction from a trace result when it left a solid. * Returns the time fraction from a trace result when it left a solid.
* Only valid if trace started in solid * Only valid if trace started in solid
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return Time fraction left solid value of the trace. * @return Time fraction left solid value of the trace.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native float TR_GetFractionLeftSolid(Handle hndl=INVALID_HANDLE); native float TR_GetFractionLeftSolid(Handle hndl=INVALID_HANDLE);
/** /**
* Returns the starting position of a trace. * Returns the starting position of a trace.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @param pos Vector buffer to store data in. * @param pos Vector buffer to store data in.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void TR_GetStartPosition(Handle hndl, float pos[3]); native void TR_GetStartPosition(Handle hndl, float pos[3]);
/** /**
* Returns the collision position of a trace result. * Returns the collision position of a trace result.
* *
* @param pos Vector buffer to store data in. * @param pos Vector buffer to store data in.
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void TR_GetEndPosition(float pos[3], Handle hndl=INVALID_HANDLE); native void TR_GetEndPosition(float pos[3], Handle hndl=INVALID_HANDLE);
/** /**
* Returns the entity index that collided with the trace. * Returns the entity index that collided with the trace.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return Entity index or -1 for no collision. * @return Entity index or -1 for no collision.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int TR_GetEntityIndex(Handle hndl=INVALID_HANDLE); native int TR_GetEntityIndex(Handle hndl=INVALID_HANDLE);
/** /**
* Returns the displacement flags for the surface that was hit. See DISPSURF_FLAG_*. * Returns the displacement flags for the surface that was hit. See DISPSURF_FLAG_*.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return Displacement flags. * @return Displacement flags.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int TR_GetDisplacementFlags(Handle hndl=INVALID_HANDLE); native int TR_GetDisplacementFlags(Handle hndl=INVALID_HANDLE);
/** /**
* Returns the name of the surface that was hit. * Returns the name of the surface that was hit.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @param buffer Buffer to store surface name in * @param buffer Buffer to store surface name in
* @param maxlen Maximum length of output buffer * @param maxlen Maximum length of output buffer
* @noreturn * @error Invalid Handle.
* @error Invalid Handle.
*/ */
native void TR_GetSurfaceName(Handle hndl, char[] buffer, int maxlen); native void TR_GetSurfaceName(Handle hndl, char[] buffer, int maxlen);
/** /**
* Returns the surface properties index of the surface that was hit. * Returns the surface properties index of the surface that was hit.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return Surface props. * @return Surface props.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int TR_GetSurfaceProps(Handle hndl=INVALID_HANDLE); native int TR_GetSurfaceProps(Handle hndl=INVALID_HANDLE);
/** /**
* Returns the surface flags. See SURF_*. * Returns the surface flags. See SURF_*.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return Surface flags. * @return Surface flags.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int TR_GetSurfaceFlags(Handle hndl=INVALID_HANDLE); native int TR_GetSurfaceFlags(Handle hndl=INVALID_HANDLE);
/** /**
* Returns the index of the physics bone that was hit. * Returns the index of the physics bone that was hit.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return Physics bone index. * @return Physics bone index.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int TR_GetPhysicsBone(Handle hndl=INVALID_HANDLE); native int TR_GetPhysicsBone(Handle hndl=INVALID_HANDLE);
/** /**
* Returns whether the entire trace was in a solid area. * Returns whether the entire trace was in a solid area.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return True if entire trace was in a solid area, otherwise false. * @return True if entire trace was in a solid area, otherwise false.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool TR_AllSolid(Handle hndl=INVALID_HANDLE); native bool TR_AllSolid(Handle hndl=INVALID_HANDLE);
/** /**
* Returns whether the initial point was in a solid area. * Returns whether the initial point was in a solid area.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return True if initial point was in a solid area, otherwise false. * @return True if initial point was in a solid area, otherwise false.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool TR_StartSolid(Handle hndl=INVALID_HANDLE); native bool TR_StartSolid(Handle hndl=INVALID_HANDLE);
/** /**
* Returns if there was any kind of collision along the trace ray. * Returns if there was any kind of collision along the trace ray.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return True if any collision found, otherwise false. * @return True if any collision found, otherwise false.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool TR_DidHit(Handle hndl=INVALID_HANDLE); native bool TR_DidHit(Handle hndl=INVALID_HANDLE);
/** /**
* Returns in which body hit group the trace collided if any. * Returns in which body hit group the trace collided if any.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return Body hit group. * @return Body hit group.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native int TR_GetHitGroup(Handle hndl=INVALID_HANDLE); native int TR_GetHitGroup(Handle hndl=INVALID_HANDLE);
/** /**
* Find the normal vector to the collision plane of a trace. * Find the normal vector to the collision plane of a trace.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @param normal Vector buffer to store the vector normal to the collision plane * @param normal Vector buffer to store the vector normal to the collision plane
* @error Invalid Handle * @error Invalid Handle
*/ */
native void TR_GetPlaneNormal(Handle hndl, float normal[3]); native void TR_GetPlaneNormal(Handle hndl, float normal[3]);
/** /**
* Tests a point to see if it's outside any playable area * Tests a point to see if it's outside any playable area
* *
* @param pos Vector buffer to store data in. * @param pos Vector buffer to store data in.
* @return True if outside world, otherwise false. * @return True if outside world, otherwise false.
*/ */
native bool TR_PointOutsideWorld(float pos[3]); native bool TR_PointOutsideWorld(float pos[3]);

View File

@ -31,63 +31,63 @@
*/ */
#if defined _sdktools_variant_t_included #if defined _sdktools_variant_t_included
#endinput #endinput
#endif #endif
#define _sdktools_variant_t_included #define _sdktools_variant_t_included
/** /**
* Sets a bool value in the global variant object. * Sets a bool value in the global variant object.
* *
* @param val Input value. * @param val Input value.
*/ */
native void SetVariantBool(bool val); native void SetVariantBool(bool val);
/** /**
* Sets a string in the global variant object. * Sets a string in the global variant object.
* *
* @param str Input string. * @param str Input string.
*/ */
native void SetVariantString(const char[] str); native void SetVariantString(const char[] str);
/** /**
* Sets an integer value in the global variant object. * Sets an integer value in the global variant object.
* *
* @param val Input value. * @param val Input value.
*/ */
native void SetVariantInt(int val); native void SetVariantInt(int val);
/** /**
* Sets a floating point value in the global variant object. * Sets a floating point value in the global variant object.
* *
* @param val Input value. * @param val Input value.
*/ */
native void SetVariantFloat(float val); native void SetVariantFloat(float val);
/** /**
* Sets a 3D vector in the global variant object. * Sets a 3D vector in the global variant object.
* *
* @param vec Input vector. * @param vec Input vector.
*/ */
native void SetVariantVector3D(const float vec[3]); native void SetVariantVector3D(const float vec[3]);
/** /**
* Sets a 3D position vector in the global variant object. * Sets a 3D position vector in the global variant object.
* *
* @param vec Input position vector. * @param vec Input position vector.
*/ */
native void SetVariantPosVector3D(const float vec[3]); native void SetVariantPosVector3D(const float vec[3]);
/** /**
* Sets a color in the global variant object. * Sets a color in the global variant object.
* *
* @param color Input color. * @param color Input color.
*/ */
native void SetVariantColor(const int color[4]); native void SetVariantColor(const int color[4]);
/** /**
* Sets an entity in the global variant object. * Sets an entity in the global variant object.
* *
* @param entity Entity index. * @param entity Entity index.
* @error Invalid entity index. * @error Invalid entity index.
*/ */
native void SetVariantEntity(int entity); native void SetVariantEntity(int entity);

View File

@ -31,19 +31,19 @@
*/ */
#if defined _sdktools_voice_included #if defined _sdktools_voice_included
#endinput #endinput
#endif #endif
#define _sdktools_voice_included #define _sdktools_voice_included
/** /**
* @section voice flags. * @section voice flags.
*/ */
#define VOICE_NORMAL 0 /**< Allow the client to listen and speak normally. */ #define VOICE_NORMAL 0 /**< Allow the client to listen and speak normally. */
#define VOICE_MUTED 1 /**< Mutes the client from speaking to everyone. */ #define VOICE_MUTED 1 /**< Mutes the client from speaking to everyone. */
#define VOICE_SPEAKALL 2 /**< Allow the client to speak to everyone. */ #define VOICE_SPEAKALL 2 /**< Allow the client to speak to everyone. */
#define VOICE_LISTENALL 4 /**< Allow the client to listen to everyone. */ #define VOICE_LISTENALL 4 /**< Allow the client to listen to everyone. */
#define VOICE_TEAM 8 /**< Allow the client to always speak to team, even when dead. */ #define VOICE_TEAM 8 /**< Allow the client to always speak to team, even when dead. */
#define VOICE_LISTENTEAM 16 /**< Allow the client to always hear teammates, including dead ones. */ #define VOICE_LISTENTEAM 16 /**< Allow the client to always hear teammates, including dead ones. */
/** /**
* @endsection * @endsection
@ -51,34 +51,35 @@
enum ListenOverride enum ListenOverride
{ {
Listen_Default = 0, /**< Leave it up to the game */ Listen_Default = 0, /**< Leave it up to the game */
Listen_No, /**< Can't hear */ Listen_No, /**< Can't hear */
Listen_Yes, /**< Can hear */ Listen_Yes /**< Can hear */
}; };
/** /**
* Set the client listening flags. * Set the client listening flags.
* *
* @param client The client index * @param client The client index
* @param flags The voice flags * @param flags The voice flags
*/ */
native void SetClientListeningFlags(int client, int flags); native void SetClientListeningFlags(int client, int flags);
/** /**
* Retrieve the client current listening flags. * Retrieve the client current listening flags.
* *
* @param client The client index * @param client The client index
* @return The current voice flags * @return The current voice flags
*/ */
native int GetClientListeningFlags(int client); native int GetClientListeningFlags(int client);
/** /**
* Set the receiver ability to listen to the sender. * Set the receiver ability to listen to the sender.
* *
* @param iReceiver The listener index. * @param iReceiver The listener index.
* @param iSender The sender index. * @param iSender The sender index.
* @param bListen True if the receiver can listen to the sender, false otherwise. * @param bListen True if the receiver can listen to the sender, false otherwise.
* @return True if successful otherwise false. * @return True if successful otherwise false.
* @deprecated Use SetListenOverride() instead.
*/ */
#pragma deprecated Use SetListenOverride() instead #pragma deprecated Use SetListenOverride() instead
native bool SetClientListening(int iReceiver, int iSender, bool bListen); native bool SetClientListening(int iReceiver, int iSender, bool bListen);
@ -86,9 +87,10 @@ native bool SetClientListening(int iReceiver, int iSender, bool bListen);
/** /**
* Retrieves if the receiver can listen to the sender. * Retrieves if the receiver can listen to the sender.
* *
* @param iReceiver The listener index. * @param iReceiver The listener index.
* @param iSender The sender index. * @param iSender The sender index.
* @return True if successful otherwise false. * @return True if successful otherwise false.
* @deprecated GetListenOverride() instead.
*/ */
#pragma deprecated GetListenOverride() instead #pragma deprecated GetListenOverride() instead
native bool GetClientListening(int iReceiver, int iSender); native bool GetClientListening(int iReceiver, int iSender);
@ -96,27 +98,27 @@ native bool GetClientListening(int iReceiver, int iSender);
/** /**
* Override the receiver's ability to listen to the sender. * Override the receiver's ability to listen to the sender.
* *
* @param iReceiver The listener index. * @param iReceiver The listener index.
* @param iSender The sender index. * @param iSender The sender index.
* @param override The override of the receiver's ability to listen to the sender. * @param override The override of the receiver's ability to listen to the sender.
* @return True if successful otherwise false. * @return True if successful otherwise false.
*/ */
native bool SetListenOverride(int iReceiver, int iSender, ListenOverride override); native bool SetListenOverride(int iReceiver, int iSender, ListenOverride override);
/** /**
* Retrieves the override of the receiver's ability to listen to the sender. * Retrieves the override of the receiver's ability to listen to the sender.
* *
* @param iReceiver The listener index. * @param iReceiver The listener index.
* @param iSender The sender index. * @param iSender The sender index.
* @return The override value. * @return The override value.
*/ */
native ListenOverride GetListenOverride(int iReceiver, int iSender); native ListenOverride GetListenOverride(int iReceiver, int iSender);
/** /**
* Retrieves if the muter has muted the mutee. * Retrieves if the muter has muted the mutee.
* *
* @param iMuter The muter index. * @param iMuter The muter index.
* @param iMutee The mutee index. * @param iMutee The mutee index.
* @return True if muter has muted mutee, false otherwise. * @return True if muter has muted mutee, false otherwise.
*/ */
native bool IsClientMuted(int iMuter, int iMutee); native bool IsClientMuted(int iMuter, int iMutee);

View File

@ -32,7 +32,7 @@
#if defined _sorting_included #if defined _sorting_included
#endinput #endinput
#endif #endif
#define _sorting_included #define _sorting_included
@ -41,9 +41,9 @@
*/ */
enum SortOrder enum SortOrder
{ {
Sort_Ascending = 0, /**< Ascending order */ Sort_Ascending = 0, /**< Ascending order */
Sort_Descending = 1, /**< Descending order */ Sort_Descending = 1, /**< Descending order */
Sort_Random = 2 /**< Random order */ Sort_Random = 2 /**< Random order */
}; };
/** /**
@ -51,35 +51,35 @@ enum SortOrder
*/ */
enum SortType enum SortType
{ {
Sort_Integer = 0, Sort_Integer = 0,
Sort_Float, Sort_Float,
Sort_String, Sort_String
}; };
/** /**
* Sorts an array of integers. * Sorts an array of integers.
* *
* @param array Array of integers to sort in-place. * @param array Array of integers to sort in-place.
* @param array_size Size of the array. * @param array_size Size of the array.
* @param order Sorting order to use. * @param order Sorting order to use.
*/ */
native void SortIntegers(int[] array, int array_size, SortOrder order = Sort_Ascending); native void SortIntegers(int[] array, int array_size, SortOrder order = Sort_Ascending);
/** /**
* Sorts an array of float point numbers. * Sorts an array of float point numbers.
* *
* @param array Array of floating point numbers to sort in-place. * @param array Array of floating point numbers to sort in-place.
* @param array_size Size of the array. * @param array_size Size of the array.
* @param order Sorting order to use. * @param order Sorting order to use.
*/ */
native void SortFloats(float[] array, int array_size, SortOrder order = Sort_Ascending); native void SortFloats(float[] array, int array_size, SortOrder order = Sort_Ascending);
/** /**
* Sorts an array of strings. * Sorts an array of strings.
* *
* @param array Array of strings to sort in-place. * @param array Array of strings to sort in-place.
* @param array_size Size of the array. * @param array_size Size of the array.
* @param order Sorting order to use. * @param order Sorting order to use.
*/ */
native void SortStrings(char[][] array, int array_size, SortOrder order = Sort_Ascending); native void SortStrings(char[][] array, int array_size, SortOrder order = Sort_Ascending);
@ -87,23 +87,23 @@ native void SortStrings(char[][] array, int array_size, SortOrder order = Sort_A
* Sort comparison function for 1D array elements. * Sort comparison function for 1D array elements.
* @note You may need to use explicit tags in order to use data properly. * @note You may need to use explicit tags in order to use data properly.
* *
* @param elem1 First element to compare. * @param elem1 First element to compare.
* @param elem2 Second element to compare. * @param elem2 Second element to compare.
* @param array Array that is being sorted (order is undefined). * @param array Array that is being sorted (order is undefined).
* @param hndl Handle optionally passed in while sorting. * @param hndl Handle optionally passed in while sorting.
* @return -1 if first should go before second * @return -1 if first should go before second
* 0 if first is equal to second * 0 if first is equal to second
* 1 if first should go after second * 1 if first should go after second
*/ */
typedef SortFunc1D = function int (int elem1, int elem2, const int[] array, Handle hndl); typedef SortFunc1D = function int (int elem1, int elem2, const int[] array, Handle hndl);
/** /**
* Sorts a custom 1D array. You must pass in a comparison function. * Sorts a custom 1D array. You must pass in a comparison function.
* *
* @param array Array to sort. * @param array Array to sort.
* @param array_size Size of the array to sort. * @param array_size Size of the array to sort.
* @param sortfunc Sort function. * @param sortfunc Sort function.
* @param hndl Optional Handle to pass through the comparison calls. * @param hndl Optional Handle to pass through the comparison calls.
*/ */
native void SortCustom1D(int[] array, int array_size, SortFunc1D sortfunc, Handle hndl=INVALID_HANDLE); native void SortCustom1D(int[] array, int array_size, SortFunc1D sortfunc, Handle hndl=INVALID_HANDLE);
@ -111,13 +111,13 @@ native void SortCustom1D(int[] array, int array_size, SortFunc1D sortfunc, Handl
* Sort comparison function for 2D array elements (sub-arrays). * Sort comparison function for 2D array elements (sub-arrays).
* @note You may need to use explicit tags in order to use data properly. * @note You may need to use explicit tags in order to use data properly.
* *
* @param elem1 First array to compare. * @param elem1 First array to compare.
* @param elem2 Second array to compare. * @param elem2 Second array to compare.
* @param array Array that is being sorted (order is undefined). * @param array Array that is being sorted (order is undefined).
* @param hndl Handle optionally passed in while sorting. * @param hndl Handle optionally passed in while sorting.
* @return -1 if first should go before second * @return -1 if first should go before second
* 0 if first is equal to second * 0 if first is equal to second
* 1 if first should go after second * 1 if first should go after second
*/ */
typeset SortFunc2D typeset SortFunc2D
{ {
@ -128,19 +128,19 @@ typeset SortFunc2D
/** /**
* Sorts a custom 2D array. You must pass in a comparison function. * Sorts a custom 2D array. You must pass in a comparison function.
* *
* @param array Array to sort. * @param array Array to sort.
* @param array_size Size of the major array to sort (first index, outermost). * @param array_size Size of the major array to sort (first index, outermost).
* @param sortfunc Sort comparison function to use. * @param sortfunc Sort comparison function to use.
* @param hndl Optional Handle to pass through the comparison calls. * @param hndl Optional Handle to pass through the comparison calls.
*/ */
native void SortCustom2D(any[][] array, int array_size, SortFunc2D sortfunc, Handle hndl=INVALID_HANDLE); native void SortCustom2D(any[][] array, int array_size, SortFunc2D sortfunc, Handle hndl=INVALID_HANDLE);
/** /**
* Sort an ADT Array. Specify the type as Integer, Float, or String. * Sort an ADT Array. Specify the type as Integer, Float, or String.
* *
* @param array Array Handle to sort * @param array Array Handle to sort
* @param order Sort order to use, same as other sorts. * @param order Sort order to use, same as other sorts.
* @param type Data type stored in the ADT Array * @param type Data type stored in the ADT Array
*/ */
native void SortADTArray(Handle array, SortOrder order, SortType type); native void SortADTArray(Handle array, SortOrder order, SortType type);
@ -149,21 +149,21 @@ native void SortADTArray(Handle array, SortOrder order, SortType type);
* indexes currently being sorted, use ADT Array functions to retrieve the * indexes currently being sorted, use ADT Array functions to retrieve the
* index values and compare. * index values and compare.
* *
* @param index1 First index to compare. * @param index1 First index to compare.
* @param index2 Second index to compare. * @param index2 Second index to compare.
* @param array Array that is being sorted (order is undefined). * @param array Array that is being sorted (order is undefined).
* @param hndl Handle optionally passed in while sorting. * @param hndl Handle optionally passed in while sorting.
* @return -1 if first should go before second * @return -1 if first should go before second
* 0 if first is equal to second * 0 if first is equal to second
* 1 if first should go after second * 1 if first should go after second
*/ */
typedef SortFuncADTArray = function int (int index1, int index2, Handle array, Handle hndl); typedef SortFuncADTArray = function int (int index1, int index2, Handle array, Handle hndl);
/** /**
* Custom sorts an ADT Array. You must pass in a comparison function. * Custom sorts an ADT Array. You must pass in a comparison function.
* *
* @param array Array Handle to sort * @param array Array Handle to sort
* @param sortfunc Sort comparison function to use * @param sortfunc Sort comparison function to use
* @param hndl Optional Handle to pass through the comparison calls. * @param hndl Optional Handle to pass through the comparison calls.
*/ */
native void SortADTArrayCustom(Handle array, SortFuncADTArray sortfunc, Handle hndl=INVALID_HANDLE); native void SortADTArrayCustom(Handle array, SortFuncADTArray sortfunc, Handle hndl=INVALID_HANDLE);

View File

@ -40,11 +40,11 @@
*/ */
struct Plugin struct Plugin
{ {
public const char[] name; /**< Plugin Name */ public const char[] name; /**< Plugin Name */
public const char[] description; /**< Plugin Description */ public const char[] description; /**< Plugin Description */
public const char[] author; /**< Plugin Author */ public const char[] author; /**< Plugin Author */
public const char[] version; /**< Plugin Version */ public const char[] version; /**< Plugin Version */
public const char[] url; /**< Plugin URL */ public const char[] url; /**< Plugin URL */
}; };
#include <core> #include <core>
@ -79,39 +79,39 @@ struct Plugin
enum APLRes enum APLRes
{ {
APLRes_Success = 0, /**< Plugin should load */ APLRes_Success = 0, /**< Plugin should load */
APLRes_Failure, /**< Plugin shouldn't load and should display an error */ APLRes_Failure, /**< Plugin shouldn't load and should display an error */
APLRes_SilentFailure /**< Plugin shouldn't load but do so silently */ APLRes_SilentFailure /**< Plugin shouldn't load but do so silently */
}; };
methodmap GameData < Handle methodmap GameData < Handle
{ {
// Loads a game config file. // Loads a game config file.
// //
// @param file File to load. The path must be relative to the 'gamedata' folder under the config folder // @param file File to load. The path must be relative to the 'gamedata' folder under the config folder
// and the extension should be omitted. // and the extension should be omitted.
// @return A handle to the game config file or null on failure. // @return A handle to the game config file or null on failure.
public native GameData(const char[] file); public native GameData(const char[] file);
// Returns an offset value. // Returns an offset value.
// //
// @param key Key to retrieve from the offset section. // @param key Key to retrieve from the offset section.
// @return An offset, or -1 on failure. // @return An offset, or -1 on failure.
public native int GetOffset(const char[] key); public native int GetOffset(const char[] key);
// Gets the value of a key from the "Keys" section. // Gets the value of a key from the "Keys" section.
// //
// @param key Key to retrieve from the Keys section. // @param key Key to retrieve from the Keys section.
// @param buffer Destination string buffer. // @param buffer Destination string buffer.
// @param maxlen Maximum length of output string buffer. // @param maxlen Maximum length of output string buffer.
// @return True if key existed, false otherwise. // @return True if key existed, false otherwise.
public native bool GetKeyValue(const char[] key, char[] buffer, int maxlen); public native bool GetKeyValue(const char[] key, char[] buffer, int maxlen);
// Finds an address calculation in a GameConfig file, // Finds an address calculation in a GameConfig file,
// performs LoadFromAddress on it as appropriate, then returns the final address. // performs LoadFromAddress on it as appropriate, then returns the final address.
// //
// @param name Name of the property to find. // @param name Name of the property to find.
// @return An address calculated on success, or 0 on failure. // @return An address calculated on success, or 0 on failure.
public native Address GetAddress(const char[] name); public native Address GetAddress(const char[] name);
}; };
@ -145,12 +145,11 @@ forward bool AskPluginLoad(Handle myself, bool late, char[] error, int err_max);
* @note If you do not return anything, it is treated like returning success. * @note If you do not return anything, it is treated like returning success.
* @note If a plugin has an AskPluginLoad2(), AskPluginLoad() will not be called. * @note If a plugin has an AskPluginLoad2(), AskPluginLoad() will not be called.
* *
* * @param myself Handle to the plugin.
* @param myself Handle to the plugin. * @param late Whether or not the plugin was loaded "late" (after map load).
* @param late Whether or not the plugin was loaded "late" (after map load). * @param error Error message buffer in case load failed.
* @param error Error message buffer in case load failed. * @param err_max Maximum number of characters for error message buffer.
* @param err_max Maximum number of characters for error message buffer. * @return APLRes_Success for load success, APLRes_Failure or APLRes_SilentFailure otherwise
* @return APLRes_Success for load success, APLRes_Failure or APLRes_SilentFailure otherwise
*/ */
forward APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max); forward APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max);
@ -166,7 +165,7 @@ forward void OnPluginEnd();
/** /**
* Called when the plugin's pause status is changing. * Called when the plugin's pause status is changing.
* *
* @param pause True if the plugin is being paused, false otherwise. * @param pause True if the plugin is being paused, false otherwise.
*/ */
forward void OnPluginPauseChange(bool pause); forward void OnPluginPauseChange(bool pause);
@ -180,7 +179,7 @@ forward void OnGameFrame();
* Called when the map is loaded. * Called when the map is loaded.
* *
* @note This used to be OnServerLoad(), which is now deprecated. * @note This used to be OnServerLoad(), which is now deprecated.
* Plugins still using the old forward will work. * Plugins still using the old forward will work.
*/ */
forward void OnMapStart(); forward void OnMapStart();
@ -195,7 +194,7 @@ forward void OnMapEnd();
* place to initialize plugin functions which are based on cvar data. * place to initialize plugin functions which are based on cvar data.
* *
* @note This will always be called once and only once per map. It will be * @note This will always be called once and only once per map. It will be
* called after OnMapStart(). * called after OnMapStart().
*/ */
forward void OnConfigsExecuted(); forward void OnConfigsExecuted();
@ -215,7 +214,7 @@ forward void OnConfigsExecuted();
forward void OnAutoConfigsBuffered(); forward void OnAutoConfigsBuffered();
/** /**
* @deprecated Use OnConfigsExecuted() instead. * @deprecated Use OnConfigsExecuted() instead.
*/ */
#pragma deprecated Use OnConfigsExecuted() instead #pragma deprecated Use OnConfigsExecuted() instead
forward void OnServerCfg(); forward void OnServerCfg();
@ -230,75 +229,75 @@ forward void OnAllPluginsLoaded();
/** /**
* Returns the calling plugin's Handle. * Returns the calling plugin's Handle.
* *
* @return Handle of the calling plugin. * @return Handle of the calling plugin.
*/ */
native Handle GetMyHandle(); native Handle GetMyHandle();
/** /**
* Returns an iterator that can be used to search through plugins. * Returns an iterator that can be used to search through plugins.
* *
* @return Handle to iterate with. Must be closed via * @return Handle to iterate with. Must be closed via
* CloseHandle(). * CloseHandle().
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native Handle GetPluginIterator(); native Handle GetPluginIterator();
/** /**
* Returns whether there are more plugins available in the iterator. * Returns whether there are more plugins available in the iterator.
* *
* @param iter Handle to the plugin iterator. * @param iter Handle to the plugin iterator.
* @return True on more plugins, false otherwise. * @return True on more plugins, false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool MorePlugins(Handle iter); native bool MorePlugins(Handle iter);
/** /**
* Returns the current plugin in the iterator and advances the iterator. * Returns the current plugin in the iterator and advances the iterator.
* *
* @param iter Handle to the plugin iterator. * @param iter Handle to the plugin iterator.
* @return Current plugin the iterator is at, before * @return Current plugin the iterator is at, before
* the iterator is advanced. * the iterator is advanced.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native Handle ReadPlugin(Handle iter); native Handle ReadPlugin(Handle iter);
/** /**
* Returns a plugin's status. * Returns a plugin's status.
* *
* @param plugin Plugin Handle (INVALID_HANDLE uses the calling plugin). * @param plugin Plugin Handle (INVALID_HANDLE uses the calling plugin).
* @return Status code for the plugin. * @return Status code for the plugin.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native PluginStatus GetPluginStatus(Handle plugin); native PluginStatus GetPluginStatus(Handle plugin);
/** /**
* Retrieves a plugin's file name relative to the plugins folder. * Retrieves a plugin's file name relative to the plugins folder.
* *
* @param plugin Plugin Handle (INVALID_HANDLE uses the calling plugin). * @param plugin Plugin Handle (INVALID_HANDLE uses the calling plugin).
* @param buffer Buffer to the store the file name. * @param buffer Buffer to the store the file name.
* @param maxlength Maximum length of the name buffer. * @param maxlength Maximum length of the name buffer.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native void GetPluginFilename(Handle plugin, char[] buffer, int maxlength); native void GetPluginFilename(Handle plugin, char[] buffer, int maxlength);
/** /**
* Retrieves whether or not a plugin is being debugged. * Retrieves whether or not a plugin is being debugged.
* *
* @param plugin Plugin Handle (INVALID_HANDLE uses the calling plugin). * @param plugin Plugin Handle (INVALID_HANDLE uses the calling plugin).
* @return True if being debugged, false otherwise. * @return True if being debugged, false otherwise.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool IsPluginDebugging(Handle plugin); native bool IsPluginDebugging(Handle plugin);
/** /**
* Retrieves a plugin's public info. * Retrieves a plugin's public info.
* *
* @param plugin Plugin Handle (INVALID_HANDLE uses the calling plugin). * @param plugin Plugin Handle (INVALID_HANDLE uses the calling plugin).
* @param info Plugin info property to retrieve. * @param info Plugin info property to retrieve.
* @param buffer Buffer to store info in. * @param buffer Buffer to store info in.
* @param maxlength Maximum length of buffer. * @param maxlength Maximum length of buffer.
* @return True on success, false if property is not available. * @return True on success, false if property is not available.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool GetPluginInfo(Handle plugin, PluginInfo info, char[] buffer, int maxlength); native bool GetPluginInfo(Handle plugin, PluginInfo info, char[] buffer, int maxlength);
@ -308,9 +307,9 @@ native bool GetPluginInfo(Handle plugin, PluginInfo info, char[] buffer, int max
* use the iterator instead. Looping through all plugins using this native * use the iterator instead. Looping through all plugins using this native
* is O(n^2), whereas using the iterator is O(n). * is O(n^2), whereas using the iterator is O(n).
* *
* @param order_num Number of the plugin as it appears in "sm plugins list". * @param order_num Number of the plugin as it appears in "sm plugins list".
* @return Plugin Handle on success, INVALID_HANDLE if no plugin * @return Plugin Handle on success, INVALID_HANDLE if no plugin
* matches the given number. * matches the given number.
*/ */
native Handle FindPluginByNumber(int order_num); native Handle FindPluginByNumber(int order_num);
@ -327,9 +326,9 @@ native Handle FindPluginByNumber(int order_num);
* This function does not return, and no further code in the plugin is * This function does not return, and no further code in the plugin is
* executed. * executed.
* *
* @param string Format specifier string. * @param string Format specifier string.
* @param ... Formatting arguments. * @param ... Formatting arguments.
* @error Always throws SP_ERROR_ABORT. * @error Always throws SP_ERROR_ABORT.
*/ */
native void SetFailState(const char[] string, any ...); native void SetFailState(const char[] string, any ...);
@ -337,9 +336,9 @@ native void SetFailState(const char[] string, any ...);
* Aborts the current callback and throws an error. This function * Aborts the current callback and throws an error. This function
* does not return in that no code is executed following it. * does not return in that no code is executed following it.
* *
* @param fmt String format. * @param fmt String format.
* @param ... Format arguments. * @param ... Format arguments.
* @error Always! * @error Always!
*/ */
native void ThrowError(const char[] fmt, any ...); native void ThrowError(const char[] fmt, any ...);
@ -347,17 +346,17 @@ native void ThrowError(const char[] fmt, any ...);
* Logs a stack trace from the current function call. Code * Logs a stack trace from the current function call. Code
* execution continues after the call * execution continues after the call
* *
* @param fmt Format string to send with the stack trace. * @param fmt Format string to send with the stack trace.
* @param ... Format arguments. * @param ... Format arguments.
* @error Always logs a stack trace. * @error Always logs a stack trace.
*/ */
native void LogStackTrace(const char[] fmt, any ...); native void LogStackTrace(const char[] fmt, any ...);
/** /**
* Gets the system time as a unix timestamp. * Gets the system time as a unix timestamp.
* *
* @param bigStamp Optional array to store the 64bit timestamp in. * @param bigStamp Optional array to store the 64bit timestamp in.
* @return 32bit timestamp (number of seconds since unix epoch). * @return 32bit timestamp (number of seconds since unix epoch).
*/ */
native int GetTime(int bigStamp[2]={0,0}); native int GetTime(int bigStamp[2]={0,0});
@ -371,40 +370,40 @@ native int GetTime(int bigStamp[2]={0,0});
* In particular, ones highlighted in yellow on that page are not currently * In particular, ones highlighted in yellow on that page are not currently
* available on Windows and should be avoided for portable plugins. * available on Windows and should be avoided for portable plugins.
* *
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer. * @param maxlength Maximum length of output string buffer.
* @param format Formatting rules (passing NULL_STRING will use the rules defined in sm_datetime_format). * @param format Formatting rules (passing NULL_STRING will use the rules defined in sm_datetime_format).
* @param stamp Optional time stamp. * @param stamp Optional time stamp.
* @error Buffer too small or invalid time format. * @error Buffer too small or invalid time format.
*/ */
native void FormatTime(char[] buffer, int maxlength, const char[] format, int stamp=-1); native void FormatTime(char[] buffer, int maxlength, const char[] format, int stamp=-1);
/** /**
* Loads a game config file. * Loads a game config file.
* *
* @param file File to load. The path must be relative to the 'gamedata' folder under the config folder * @param file File to load. The path must be relative to the 'gamedata' folder under the config folder
* and the extension should be omitted. * and the extension should be omitted.
* @return A handle to the game config file or INVALID_HANDLE on failure. * @return A handle to the game config file or INVALID_HANDLE on failure.
*/ */
native GameData LoadGameConfigFile(const char[] file); native GameData LoadGameConfigFile(const char[] file);
/** /**
* Returns an offset value. * Returns an offset value.
* *
* @param gc Game config handle. * @param gc Game config handle.
* @param key Key to retrieve from the offset section. * @param key Key to retrieve from the offset section.
* @return An offset, or -1 on failure. * @return An offset, or -1 on failure.
*/ */
native int GameConfGetOffset(Handle gc, const char[] key); native int GameConfGetOffset(Handle gc, const char[] key);
/** /**
* Gets the value of a key from the "Keys" section. * Gets the value of a key from the "Keys" section.
* *
* @param gc Game config handle. * @param gc Game config handle.
* @param key Key to retrieve from the Keys section. * @param key Key to retrieve from the Keys section.
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlen Maximum length of output string buffer. * @param maxlen Maximum length of output string buffer.
* @return True if key existed, false otherwise. * @return True if key existed, false otherwise.
*/ */
native bool GameConfGetKeyValue(Handle gc, const char[] key, char[] buffer, int maxlen); native bool GameConfGetKeyValue(Handle gc, const char[] key, char[] buffer, int maxlen);
@ -423,7 +422,7 @@ native Address GameConfGetAddress(Handle gameconf, const char[] name);
* milliseconds since the operating system loaded. This can be used * milliseconds since the operating system loaded. This can be used
* for basic benchmarks. * for basic benchmarks.
* *
* @return Tick count in milliseconds. * @return Tick count in milliseconds.
*/ */
native int GetSysTickCount(); native int GetSysTickCount();
@ -432,12 +431,12 @@ native int GetSysTickCount();
* OnConfigsExecuted() will not be called until the config file has executed, * OnConfigsExecuted() will not be called until the config file has executed,
* but it will be called if the execution fails. * but it will be called if the execution fails.
* *
* @param autoCreate If true, and the config file does not exist, such a config * @param autoCreate If true, and the config file does not exist, such a config
* file will be automatically created and populated with * file will be automatically created and populated with
* information from the plugin's registered cvars. * information from the plugin's registered cvars.
* @param name Name of the config file, excluding the .cfg extension. * @param name Name of the config file, excluding the .cfg extension.
* If empty, <plugin.filename.cfg> is assumed. * If empty, <plugin.filename.cfg> is assumed.
* @param folder Folder under cfg/ to use. By default this is "sourcemod." * @param folder Folder under cfg/ to use. By default this is "sourcemod."
*/ */
native void AutoExecConfig(bool autoCreate=true, const char[] name="", const char[] folder="sourcemod"); native void AutoExecConfig(bool autoCreate=true, const char[] name="", const char[] folder="sourcemod");
@ -445,7 +444,7 @@ native void AutoExecConfig(bool autoCreate=true, const char[] name="", const cha
* Registers a library name for identifying as a dependency to * Registers a library name for identifying as a dependency to
* other plugins. * other plugins.
* *
* @param name Library name. * @param name Library name.
*/ */
native void RegPluginLibrary(const char[] name); native void RegPluginLibrary(const char[] name);
@ -455,21 +454,21 @@ native void RegPluginLibrary(const char[] name);
* of resources. Use OnLibraryAdded()/OnLibraryRemoved() to detect changes * of resources. Use OnLibraryAdded()/OnLibraryRemoved() to detect changes
* in optional resources. * in optional resources.
* *
* @param name Library name of a plugin or extension. * @param name Library name of a plugin or extension.
* @return True if exists, false otherwise. * @return True if exists, false otherwise.
*/ */
native bool LibraryExists(const char[] name); native bool LibraryExists(const char[] name);
/** /**
* Returns the status of an extension, by filename. * Returns the status of an extension, by filename.
* *
* @param name Extension name (like "sdktools.ext"). * @param name Extension name (like "sdktools.ext").
* @param error Optional error message buffer. * @param error Optional error message buffer.
* @param maxlength Length of optional error message buffer. * @param maxlength Length of optional error message buffer.
* @return -2 if the extension was not found. * @return -2 if the extension was not found.
* -1 if the extension was found but failed to load. * -1 if the extension was found but failed to load.
* 0 if the extension loaded but reported an error. * 0 if the extension loaded but reported an error.
* 1 if the extension is running without error. * 1 if the extension is running without error.
*/ */
native int GetExtensionFileStatus(const char[] name, char[] error="", int maxlength=0); native int GetExtensionFileStatus(const char[] name, char[] error="", int maxlength=0);
@ -478,7 +477,7 @@ native int GetExtensionFileStatus(const char[] name, char[] error="", int maxlen
* optionally. A library is either a plugin name or extension name, as * optionally. A library is either a plugin name or extension name, as
* exposed via its include file. * exposed via its include file.
* *
* @param name Library name. * @param name Library name.
*/ */
forward void OnLibraryAdded(const char[] name); forward void OnLibraryAdded(const char[] name);
@ -487,13 +486,13 @@ forward void OnLibraryAdded(const char[] name);
* optionally. A library is either a plugin name or extension name, as * optionally. A library is either a plugin name or extension name, as
* exposed via its include file. * exposed via its include file.
* *
* @param name Library name. * @param name Library name.
*/ */
forward void OnLibraryRemoved(const char[] name); forward void OnLibraryRemoved(const char[] name);
#define MAPLIST_FLAG_MAPSFOLDER (1<<0) /**< On failure, use all maps in the maps folder. */ #define MAPLIST_FLAG_MAPSFOLDER (1<<0) /**< On failure, use all maps in the maps folder. */
#define MAPLIST_FLAG_CLEARARRAY (1<<1) /**< If an input array is specified, clear it before adding. */ #define MAPLIST_FLAG_CLEARARRAY (1<<1) /**< If an input array is specified, clear it before adding. */
#define MAPLIST_FLAG_NO_DEFAULT (1<<2) /**< Do not read "default" or "mapcyclefile" on failure. */ #define MAPLIST_FLAG_NO_DEFAULT (1<<2) /**< Do not read "default" or "mapcyclefile" on failure. */
/** /**
* Loads a map list to an ADT Array. * Loads a map list to an ADT Array.
@ -515,46 +514,46 @@ forward void OnLibraryRemoved(const char[] name);
* Modifying arrays created by this function will not affect future return values or * Modifying arrays created by this function will not affect future return values or
* or the contents of arrays returned to other plugins. * or the contents of arrays returned to other plugins.
* *
* @param array Array to store the map list. If INVALID_HANDLE, a new blank * @param array Array to store the map list. If INVALID_HANDLE, a new blank
* array will be created. The blocksize should be at least 16; * array will be created. The blocksize should be at least 16;
* otherwise results may be truncated. Items are added to the array * otherwise results may be truncated. Items are added to the array
* as strings. The array is never checked for duplicates, and it is * as strings. The array is never checked for duplicates, and it is
* not read beforehand. Only the serial number is used to detect * not read beforehand. Only the serial number is used to detect
* changes. * changes.
* @param serial Serial number to identify last known map list change. If -1, the * @param serial Serial number to identify last known map list change. If -1, the
* the value will not be checked. If the map list has since changed, * the value will not be checked. If the map list has since changed,
* the serial is updated (even if -1 was passed). If there is an error * the serial is updated (even if -1 was passed). If there is an error
* finding a valid maplist, then the serial is set to -1. * finding a valid maplist, then the serial is set to -1.
* @param str Config name, or "default" for the default map list. Config names * @param str Config name, or "default" for the default map list. Config names
* should be somewhat descriptive. For example, the admin menu uses * should be somewhat descriptive. For example, the admin menu uses
* a config name of "admin menu". The list names can be configured * a config name of "admin menu". The list names can be configured
* by users in addons/sourcemod/configs/maplists.cfg. * by users in addons/sourcemod/configs/maplists.cfg.
* @param flags MAPLIST_FLAG flags. * @param flags MAPLIST_FLAG flags.
* @return On failure: * @return On failure:
* INVALID_HANDLE is returned, the serial is set to -1, and the input * INVALID_HANDLE is returned, the serial is set to -1, and the input
* array (if any) is left unchanged. * array (if any) is left unchanged.
* On no change: * On no change:
INVALID_HANDLE is returned, the serial is unchanged, and the input * INVALID_HANDLE is returned, the serial is unchanged, and the input
array (if any) is left unchanged. * array (if any) is left unchanged.
* On success: * On success:
* A valid array Handle is returned, containing at least one map string. * A valid array Handle is returned, containing at least one map string.
* If an array was passed, the return value is equal to the passed Array * If an array was passed, the return value is equal to the passed Array
* Handle. If the passed array was not cleared, it will have grown by at * Handle. If the passed array was not cleared, it will have grown by at
* least one item. The serial number is updated to a positive number. * least one item. The serial number is updated to a positive number.
* @error Invalid array Handle that is not INVALID_HANDLE. * @error Invalid array Handle that is not INVALID_HANDLE.
*/ */
native Handle ReadMapList(Handle array=INVALID_HANDLE, native Handle ReadMapList(Handle array=INVALID_HANDLE,
int &serial=-1, int &serial=-1,
const char[] str="default", const char[] str="default",
int flags=MAPLIST_FLAG_CLEARARRAY); int flags=MAPLIST_FLAG_CLEARARRAY);
/** /**
* Makes a compatibility binding for map lists. For example, if a function previously used * Makes a compatibility binding for map lists. For example, if a function previously used
* "clam.cfg" for map lists, this function will insert a "fake" binding to "clam.cfg" that * "clam.cfg" for map lists, this function will insert a "fake" binding to "clam.cfg" that
* will be overridden if it's in the maplists.cfg file. * will be overridden if it's in the maplists.cfg file.
* *
* @param name Configuration name that would be used with ReadMapList(). * @param name Configuration name that would be used with ReadMapList().
* @param file Default file to use. * @param file Default file to use.
*/ */
native void SetMapListCompatBind(const char[] name, const char[] file); native void SetMapListCompatBind(const char[] name, const char[] file);
@ -565,8 +564,8 @@ native void SetMapListCompatBind(const char[] name, const char[] file);
* The return value is a hint only. Core or another plugin may decide * The return value is a hint only. Core or another plugin may decide
* otherwise. * otherwise.
* *
* @param client Client index. The server (0) will never be passed. * @param client Client index. The server (0) will never be passed.
* @return True if client is spamming the server, false otherwise. * @return True if client is spamming the server, false otherwise.
*/ */
forward bool OnClientFloodCheck(int client); forward bool OnClientFloodCheck(int client);
@ -578,8 +577,8 @@ forward bool OnClientFloodCheck(int client);
* final result, it is generally a good idea to use this to play with other * final result, it is generally a good idea to use this to play with other
* algorithms nicely. * algorithms nicely.
* *
* @param client Client index. The server (0) will never be passed. * @param client Client index. The server (0) will never be passed.
* @param blocked True if client flooded last "say", false otherwise. * @param blocked True if client flooded last "say", false otherwise.
*/ */
forward void OnClientFloodResult(int client, bool blocked); forward void OnClientFloodResult(int client, bool blocked);
@ -669,7 +668,7 @@ enum NumberType
enum Address enum Address
{ {
Address_Null = 0, // a typical invalid result when an address lookup fails Address_Null = 0 // a typical invalid result when an address lookup fails
}; };
/** /**
@ -692,12 +691,12 @@ native void StoreToAddress(Address addr, int data, NumberType size);
methodmap FrameIterator < Handle { methodmap FrameIterator < Handle {
// Creates a stack frame iterator to build your own stack traces. // Creates a stack frame iterator to build your own stack traces.
// @return New handle to a FrameIterator. // @return New handle to a FrameIterator.
public native FrameIterator(); public native FrameIterator();
// Advances the iterator to the next stack frame. // Advances the iterator to the next stack frame.
// @return True if another frame was fetched and data can be successfully read. // @return True if another frame was fetched and data can be successfully read.
// @error No next element exception. // @error No next element exception.
public native bool Next(); public native bool Next();
// Resets the iterator back to it's starting position. // Resets the iterator back to it's starting position.

View File

@ -45,53 +45,53 @@
/** /**
* Calculates the length of a string. * Calculates the length of a string.
* *
* @param str String to check. * @param str String to check.
* @return Number of valid character bytes in the string. * @return Number of valid character bytes in the string.
*/ */
native int strlen(const char[] str); native int strlen(const char[] str);
/** /**
* Tests whether a string is found inside another string. * Tests whether a string is found inside another string.
* *
* @param str String to search in. * @param str String to search in.
* @param substr Substring to find inside the original string. * @param substr Substring to find inside the original string.
* @param caseSensitive If true (default), search is case sensitive. * @param caseSensitive If true (default), search is case sensitive.
* If false, search is case insensitive. * If false, search is case insensitive.
* @return -1 on failure (no match found). Any other value * @return -1 on failure (no match found). Any other value
* indicates a position in the string where the match starts. * indicates a position in the string where the match starts.
*/ */
native int StrContains(const char[] str, const char[] substr, bool caseSensitive=true); native int StrContains(const char[] str, const char[] substr, bool caseSensitive=true);
/** /**
* Compares two strings lexographically. * Compares two strings lexographically.
* *
* @param str1 First string (left). * @param str1 First string (left).
* @param str2 Second string (right). * @param str2 Second string (right).
* @param caseSensitive If true (default), comparison is case sensitive. * @param caseSensitive If true (default), comparison is case sensitive.
* If false, comparison is case insensitive. * If false, comparison is case insensitive.
* @return -1 if str1 < str2 * @return -1 if str1 < str2
* 0 if str1 == str2 * 0 if str1 == str2
* 1 if str1 > str2 * 1 if str1 > str2
*/ */
native int strcmp(const char[] str1, const char[] str2, bool caseSensitive=true); native int strcmp(const char[] str1, const char[] str2, bool caseSensitive=true);
/** /**
* Compares two strings parts lexographically. * Compares two strings parts lexographically.
* *
* @param str1 First string (left). * @param str1 First string (left).
* @param str2 Second string (right). * @param str2 Second string (right).
* @param num Number of characters to compare. * @param num Number of characters to compare.
* @param caseSensitive If true (default), comparison is case sensitive. * @param caseSensitive If true (default), comparison is case sensitive.
* If false, comparison is case insensitive. * If false, comparison is case insensitive.
* @return -1 if str1 < str2 * @return -1 if str1 < str2
* 0 if str1 == str2 * 0 if str1 == str2
* 1 if str1 > str2 * 1 if str1 > str2
*/ */
native int strncmp(const char[] str1, const char[] str2, int num, bool caseSensitive=true); native int strncmp(const char[] str1, const char[] str2, int num, bool caseSensitive=true);
/** /**
* Backwards compatible stock - StrCompare is now strcmp * Backwards compatible stock - StrCompare is now strcmp
* @deprecated Renamed to strcmp * @deprecated Renamed to strcmp
*/ */
#pragma deprecated Use strcmp() instead #pragma deprecated Use strcmp() instead
stock int StrCompare(const char[] str1, const char[] str2, bool caseSensitive=true) stock int StrCompare(const char[] str1, const char[] str2, bool caseSensitive=true)
@ -102,11 +102,11 @@ stock int StrCompare(const char[] str1, const char[] str2, bool caseSensitive=tr
/** /**
* Returns whether two strings are equal. * Returns whether two strings are equal.
* *
* @param str1 First string (left). * @param str1 First string (left).
* @param str2 Second string (right). * @param str2 Second string (right).
* @param caseSensitive If true (default), comparison is case sensitive. * @param caseSensitive If true (default), comparison is case sensitive.
* If false, comparison is case insensitive. * If false, comparison is case insensitive.
* @return True if equal, false otherwise. * @return True if equal, false otherwise.
*/ */
stock bool StrEqual(const char[] str1, const char[] str2, bool caseSensitive=true) stock bool StrEqual(const char[] str1, const char[] str2, bool caseSensitive=true)
{ {
@ -118,16 +118,16 @@ stock bool StrEqual(const char[] str1, const char[] str2, bool caseSensitive=tru
* @note If the destination buffer is too small to hold the source string, the * @note If the destination buffer is too small to hold the source string, the
* destination will be truncated. * destination will be truncated.
* *
* @param dest Destination string buffer to copy to. * @param dest Destination string buffer to copy to.
* @param destLen Destination buffer length (includes null terminator). * @param destLen Destination buffer length (includes null terminator).
* @param source Source string buffer to copy from. * @param source Source string buffer to copy from.
* @return Number of cells written. * @return Number of cells written.
*/ */
native int strcopy(char[] dest, int destLen, const char[] source); native int strcopy(char[] dest, int destLen, const char[] source);
/** /**
* Backwards compatibility stock - use strcopy * Backwards compatibility stock - use strcopy
* @deprecated Renamed to strcopy * @deprecated Renamed to strcopy
*/ */
#pragma deprecated Use strcopy() instead #pragma deprecated Use strcopy() instead
stock int StrCopy(char[] dest, int destLen, const char[] source) stock int StrCopy(char[] dest, int destLen, const char[] source)
@ -138,11 +138,11 @@ stock int StrCopy(char[] dest, int destLen, const char[] source)
/** /**
* Formats a string according to the SourceMod format rules (see documentation). * Formats a string according to the SourceMod format rules (see documentation).
* *
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer. * @param maxlength Maximum length of output string buffer.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @return Number of cells written. * @return Number of cells written.
*/ */
native int Format(char[] buffer, int maxlength, const char[] format, any ...); native int Format(char[] buffer, int maxlength, const char[] format, any ...);
@ -152,11 +152,11 @@ native int Format(char[] buffer, int maxlength, const char[] format, any ...);
* overlap the same memory as the output buffer. Since this security * overlap the same memory as the output buffer. Since this security
* check is removed, it is slightly faster. * check is removed, it is slightly faster.
* *
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer. * @param maxlength Maximum length of output string buffer.
* @param format Formatting rules. * @param format Formatting rules.
* @param ... Variable number of format parameters. * @param ... Variable number of format parameters.
* @return Number of cells written. * @return Number of cells written.
*/ */
native int FormatEx(char[] buffer, int maxlength, const char[] format, any ...); native int FormatEx(char[] buffer, int maxlength, const char[] format, any ...);
@ -166,68 +166,68 @@ native int FormatEx(char[] buffer, int maxlength, const char[] format, any ...);
* parent parameter stack, rather than a local. This is useful for * parent parameter stack, rather than a local. This is useful for
* implementing your own variable argument functions. * implementing your own variable argument functions.
* *
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer. * @param maxlength Maximum length of output string buffer.
* @param format Formatting rules. * @param format Formatting rules.
* @param varpos Argument number which contains the '...' symbol. * @param varpos Argument number which contains the '...' symbol.
* Note: Arguments start at 1. * Note: Arguments start at 1.
* @return Number of bytes written. * @return Number of bytes written.
*/ */
native int VFormat(char[] buffer, int maxlength, const char[] format, int varpos); native int VFormat(char[] buffer, int maxlength, const char[] format, int varpos);
/** /**
* Converts a string to an integer. * Converts a string to an integer.
* *
* @param str String to convert. * @param str String to convert.
* @param nBase Numerical base to use. 10 is default. * @param nBase Numerical base to use. 10 is default.
* @return Integer conversion of string, or 0 on failure. * @return Integer conversion of string, or 0 on failure.
*/ */
native int StringToInt(const char[] str, int nBase=10); native int StringToInt(const char[] str, int nBase=10);
/** /**
* Converts a string to an integer with some more options. * Converts a string to an integer with some more options.
* *
* @param str String to convert. * @param str String to convert.
* @param result Variable to store the result in. * @param result Variable to store the result in.
* @param nBase Numerical base to use. 10 is default. * @param nBase Numerical base to use. 10 is default.
* @return Number of characters consumed. * @return Number of characters consumed.
*/ */
native int StringToIntEx(const char[] str, int &result, int nBase=10); native int StringToIntEx(const char[] str, int &result, int nBase=10);
/** /**
* Converts an integer to a string. * Converts an integer to a string.
* *
* @param num Integer to convert. * @param num Integer to convert.
* @param str Buffer to store string in. * @param str Buffer to store string in.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @return Number of cells written to buffer. * @return Number of cells written to buffer.
*/ */
native int IntToString(int num, char[] str, int maxlength); native int IntToString(int num, char[] str, int maxlength);
/** /**
* Converts a string to a floating point number. * Converts a string to a floating point number.
* *
* @param str String to convert to a float. * @param str String to convert to a float.
* @return Floating point result, or 0.0 on error. * @return Floating point result, or 0.0 on error.
*/ */
native float StringToFloat(const char[] str); native float StringToFloat(const char[] str);
/** /**
* Converts a string to a floating point number with some more options. * Converts a string to a floating point number with some more options.
* *
* @param str String to convert to a float. * @param str String to convert to a float.
* @param result Variable to store result in. * @param result Variable to store result in.
* @return Number of characters consumed. * @return Number of characters consumed.
*/ */
native int StringToFloatEx(const char[] str, float &result); native int StringToFloatEx(const char[] str, float &result);
/** /**
* Converts a floating point number to a string. * Converts a floating point number to a string.
* *
* @param num Floating point number to convert. * @param num Floating point number to convert.
* @param str Buffer to store string in. * @param str Buffer to store string in.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @return Number of cells written to buffer. * @return Number of cells written to buffer.
*/ */
native int FloatToString(float num, char[] str, int maxlength); native int FloatToString(float num, char[] str, int maxlength);
@ -238,16 +238,16 @@ native int FloatToString(float num, char[] str, int maxlength);
* of the string is reached. If nothing remains, -1 is returned. * of the string is reached. If nothing remains, -1 is returned.
* Otherwise, the index to the first character is returned. * Otherwise, the index to the first character is returned.
* *
* @param source Source input string. * @param source Source input string.
* @param arg Stores argument read from string. * @param arg Stores argument read from string.
* @param argLen Maximum length of argument buffer. * @param argLen Maximum length of argument buffer.
* @return Index to next piece of string, or -1 if none. * @return Index to next piece of string, or -1 if none.
*/ */
native int BreakString(const char[] source, char[] arg, int argLen); native int BreakString(const char[] source, char[] arg, int argLen);
/** /**
* Backwards compatibility stock - use BreakString * Backwards compatibility stock - use BreakString
* @deprecated Renamed to BreakString. * @deprecated Renamed to BreakString.
*/ */
#pragma deprecated Use BreakString() instead #pragma deprecated Use BreakString() instead
stock int StrBreak(const char[] source, char[] arg, int argLen) stock int StrBreak(const char[] source, char[] arg, int argLen)
@ -258,21 +258,21 @@ stock int StrBreak(const char[] source, char[] arg, int argLen)
/** /**
* Removes whitespace characters from the beginning and end of a string. * Removes whitespace characters from the beginning and end of a string.
* *
* @param str The string to trim. * @param str The string to trim.
* @return Number of bytes written (UTF-8 safe). * @return Number of bytes written (UTF-8 safe).
*/ */
native int TrimString(char[] str); native int TrimString(char[] str);
/** /**
* Returns text in a string up until a certain character sequence is reached. * Returns text in a string up until a certain character sequence is reached.
* *
* @param source Source input string. * @param source Source input string.
* @param split A string which specifies a search point to break at. * @param split A string which specifies a search point to break at.
* @param part Buffer to store string part. * @param part Buffer to store string part.
* @param partLen Maximum length of the string part buffer. * @param partLen Maximum length of the string part buffer.
* @return -1 if no match was found; otherwise, an index into source * @return -1 if no match was found; otherwise, an index into source
* marking the first index after the searched text. The * marking the first index after the searched text. The
* index is always relative to the start of the input string. * index is always relative to the start of the input string.
*/ */
native int SplitString(const char[] source, const char[] split, char[] part, int partLen); native int SplitString(const char[] source, const char[] split, char[] part, int partLen);
@ -280,12 +280,12 @@ native int SplitString(const char[] source, const char[] split, char[] part, int
* Given a string, replaces all occurrences of a search string with a * Given a string, replaces all occurrences of a search string with a
* replacement string. * replacement string.
* *
* @param text String to perform search and replacements on. * @param text String to perform search and replacements on.
* @param maxlength Maximum length of the string buffer. * @param maxlength Maximum length of the string buffer.
* @param search String to search for. * @param search String to search for.
* @param replace String to replace the search string with. * @param replace String to replace the search string with.
* @param caseSensitive If true (default), search is case sensitive. * @param caseSensitive If true (default), search is case sensitive.
* @return Number of replacements that were performed. * @return Number of replacements that were performed.
*/ */
native int ReplaceString(char[] text, int maxlength, const char[] search, const char[] replace, bool caseSensitive=true); native int ReplaceString(char[] text, int maxlength, const char[] search, const char[] replace, bool caseSensitive=true);
@ -293,18 +293,18 @@ native int ReplaceString(char[] text, int maxlength, const char[] search, const
* Given a string, replaces the first occurrence of a search string with a * Given a string, replaces the first occurrence of a search string with a
* replacement string. * replacement string.
* *
* @param text String to perform search and replacements on. * @param text String to perform search and replacements on.
* @param maxlength Maximum length of the string buffer. * @param maxlength Maximum length of the string buffer.
* @param search String to search for. * @param search String to search for.
* @param replace String to replace the search string with. * @param replace String to replace the search string with.
* @param searchLen If higher than -1, its value will be used instead of * @param searchLen If higher than -1, its value will be used instead of
* a strlen() call on the search parameter. * a strlen() call on the search parameter.
* @param replaceLen If higher than -1, its value will be used instead of * @param replaceLen If higher than -1, its value will be used instead of
* a strlen() call on the replace parameter. * a strlen() call on the replace parameter.
* @param caseSensitive If true (default), search is case sensitive. * @param caseSensitive If true (default), search is case sensitive.
* @return Index into the buffer (relative to the start) from where * @return Index into the buffer (relative to the start) from where
* the last replacement ended, or -1 if no replacements were * the last replacement ended, or -1 if no replacements were
* made. * made.
*/ */
native int ReplaceStringEx(char[] text, int maxlength, const char[] search, const char[] replace, int searchLen=-1, int replaceLen=-1, bool caseSensitive=true); native int ReplaceStringEx(char[] text, int maxlength, const char[] search, const char[] replace, int searchLen=-1, int replaceLen=-1, bool caseSensitive=true);
@ -313,8 +313,8 @@ native int ReplaceStringEx(char[] text, int maxlength, const char[] search, cons
* for multi-byte characters (UTF-8). For normal ASCII characters, * for multi-byte characters (UTF-8). For normal ASCII characters,
* this will return 1. * this will return 1.
* *
* @param source Source input string. * @param source Source input string.
* @return Number of bytes the current character uses. * @return Number of bytes the current character uses.
*/ */
native int GetCharBytes(const char[] source); native int GetCharBytes(const char[] source);
@ -323,8 +323,8 @@ native int GetCharBytes(const char[] source);
* *
* @note Multi-byte characters will always return false. * @note Multi-byte characters will always return false.
* *
* @param chr Character to test. * @param chr Character to test.
* @return True if character is alphabetical, otherwise false. * @return True if character is alphabetical, otherwise false.
*/ */
native bool IsCharAlpha(int chr); native bool IsCharAlpha(int chr);
@ -333,8 +333,8 @@ native bool IsCharAlpha(int chr);
* *
* @note Multi-byte characters will always return false. * @note Multi-byte characters will always return false.
* *
* @param chr Character to test. * @param chr Character to test.
* @return True if character is numeric, otherwise false. * @return True if character is numeric, otherwise false.
*/ */
native bool IsCharNumeric(int chr); native bool IsCharNumeric(int chr);
@ -343,17 +343,17 @@ native bool IsCharNumeric(int chr);
* *
* @note Multi-byte characters will always return false. * @note Multi-byte characters will always return false.
* *
* @param chr Character to test. * @param chr Character to test.
* @return True if character is whitespace, otherwise false. * @return True if character is whitespace, otherwise false.
*/ */
native bool IsCharSpace(int chr); native bool IsCharSpace(int chr);
/** /**
* Returns if a character is multi-byte or not. * Returns if a character is multi-byte or not.
* *
* @param chr Character to test. * @param chr Character to test.
* @return 0 for a normal 7-bit ASCII character, * @return 0 for a normal 7-bit ASCII character,
* otherwise number of bytes in multi-byte character. * otherwise number of bytes in multi-byte character.
*/ */
native int IsCharMB(int chr); native int IsCharMB(int chr);
@ -362,8 +362,8 @@ native int IsCharMB(int chr);
* *
* @note Multi-byte characters will always return false. * @note Multi-byte characters will always return false.
* *
* @param chr Character to test. * @param chr Character to test.
* @return True if character is uppercase, otherwise false. * @return True if character is uppercase, otherwise false.
*/ */
native bool IsCharUpper(int chr); native bool IsCharUpper(int chr);
@ -372,8 +372,8 @@ native bool IsCharUpper(int chr);
* *
* @note Multi-byte characters will always return false. * @note Multi-byte characters will always return false.
* *
* @param chr Character to test. * @param chr Character to test.
* @return True if character is lowercase, otherwise false. * @return True if character is lowercase, otherwise false.
*/ */
native bool IsCharLower(int chr); native bool IsCharLower(int chr);
@ -385,18 +385,18 @@ native bool IsCharLower(int chr);
* exist. Otherwise, the string is left unmodified. This function should * exist. Otherwise, the string is left unmodified. This function should
* be considered O(k) (all characters get shifted down). * be considered O(k) (all characters get shifted down).
* *
* @param text String to modify (in place). * @param text String to modify (in place).
* @return True if string was modified, false if there was no * @return True if string was modified, false if there was no
* set of quotes. * set of quotes.
*/ */
native bool StripQuotes(char[] text); native bool StripQuotes(char[] text);
/** /**
* Converts a lowercase character to its uppercase counterpart. * Converts a lowercase character to its uppercase counterpart.
* *
* @param chr Character to convert. * @param chr Character to convert.
* @return Uppercase character on success, * @return Uppercase character on success,
* no change on failure. * no change on failure.
*/ */
stock int CharToUpper(int chr) stock int CharToUpper(int chr)
{ {
@ -404,15 +404,16 @@ stock int CharToUpper(int chr)
{ {
return (chr & ~(1<<5)); return (chr & ~(1<<5));
} }
return chr; return chr;
} }
/** /**
* Converts an uppercase character to its lowercase counterpart. * Converts an uppercase character to its lowercase counterpart.
* *
* @param chr Character to convert. * @param chr Character to convert.
* @return Lowercase character on success, * @return Lowercase character on success,
* no change on failure. * no change on failure.
*/ */
stock int CharToLower(int chr) stock int CharToLower(int chr)
{ {
@ -420,32 +421,42 @@ stock int CharToLower(int chr)
{ {
return (chr | (1<<5)); return (chr | (1<<5));
} }
return chr; return chr;
} }
/** /**
* Finds the first occurrence of a character in a string. * Finds the first occurrence of a character in a string.
* *
* @param str String. * @param str String.
* @param c Character to search for. * @param c Character to search for.
* @param reverse False (default) to search forward, true to search * @param reverse False (default) to search forward, true to search
* backward. * backward.
* @return The index of the first occurrence of the character * @return The index of the first occurrence of the character
* in the string, or -1 if the character was not found. * in the string, or -1 if the character was not found.
*/ */
stock int FindCharInString(const char[] str, char c, bool reverse = false) stock int FindCharInString(const char[] str, char c, bool reverse = false)
{ {
int len = strlen(str); int len = strlen(str);
if (!reverse) { if (!reverse)
for (int i = 0; i < len; i++) { {
for (int i = 0; i < len; i++)
{
if (str[i] == c) if (str[i] == c)
{
return i; return i;
}
} }
} else { }
for (int i = len - 1; i >= 0; i--) { else
{
for (int i = len - 1; i >= 0; i--)
{
if (str[i] == c) if (str[i] == c)
{
return i; return i;
}
} }
} }
@ -455,10 +466,10 @@ stock int FindCharInString(const char[] str, char c, bool reverse = false)
/** /**
* Concatenates one string onto another. * Concatenates one string onto another.
* *
* @param buffer String to append to. * @param buffer String to append to.
* @param maxlength Maximum length of entire buffer. * @param maxlength Maximum length of entire buffer.
* @param source Source string to concatenate. * @param source Source string to concatenate.
* @return Number of bytes written. * @return Number of bytes written.
*/ */
stock int StrCat(char[] buffer, int maxlength, const char[] source) stock int StrCat(char[] buffer, int maxlength, const char[] source)
{ {
@ -474,14 +485,14 @@ stock int StrCat(char[] buffer, int maxlength, const char[] source)
/** /**
* Breaks a string into pieces and stores each piece into an array of buffers. * Breaks a string into pieces and stores each piece into an array of buffers.
* *
* @param text The string to split. * @param text The string to split.
* @param split The string to use as a split delimiter. * @param split The string to use as a split delimiter.
* @param buffers An array of string buffers (2D array). * @param buffers An array of string buffers (2D array).
* @param maxStrings Number of string buffers (first dimension size). * @param maxStrings Number of string buffers (first dimension size).
* @param maxStringLength Maximum length of each string buffer. * @param maxStringLength Maximum length of each string buffer.
* @param copyRemainder False (default) discard excess pieces, true to ignore * @param copyRemainder False (default) discard excess pieces, true to ignore
* delimiters after last piece. * delimiters after last piece.
* @return Number of strings retrieved. * @return Number of strings retrieved.
*/ */
stock int ExplodeString(const char[] text, const char[] split, char[][] buffers, int maxStrings, stock int ExplodeString(const char[] text, const char[] split, char[][] buffers, int maxStrings,
int maxStringLength, bool copyRemainder = false) int maxStringLength, bool copyRemainder = false)
@ -515,12 +526,12 @@ stock int ExplodeString(const char[] text, const char[] split, char[][] buffers,
* Joins an array of strings into one string, with a "join" string inserted in * Joins an array of strings into one string, with a "join" string inserted in
* between each given string. This function complements ExplodeString. * between each given string. This function complements ExplodeString.
* *
* @param strings An array of strings. * @param strings An array of strings.
* @param numStrings Number of strings in the array. * @param numStrings Number of strings in the array.
* @param join The join string to insert between each string. * @param join The join string to insert between each string.
* @param buffer Output buffer to write the joined string to. * @param buffer Output buffer to write the joined string to.
* @param maxLength Maximum length of the output buffer. * @param maxLength Maximum length of the output buffer.
* @return Number of bytes written to the output buffer. * @return Number of bytes written to the output buffer.
*/ */
stock int ImplodeStrings(const char[][] strings, int numStrings, const char[] join, char[] buffer, int maxLength) stock int ImplodeStrings(const char[][] strings, int numStrings, const char[] join, char[] buffer, int maxLength)
{ {

View File

@ -41,9 +41,12 @@ stock void SetTestContext(const char[] context)
stock void AssertEq(const char[] text, int cell1, int cell2) stock void AssertEq(const char[] text, int cell1, int cell2)
{ {
TestNumber++; TestNumber++;
if (cell1 == cell2) { if (cell1 == cell2)
{
PrintToServer("[%d] %s: %s == %d OK", TestNumber, TestContext, text, cell2); PrintToServer("[%d] %s: %s == %d OK", TestNumber, TestContext, text, cell2);
} else { }
else
{
PrintToServer("[%d] %s FAIL: %s should be %d, got %d", TestNumber, TestContext, text, cell2, cell1); PrintToServer("[%d] %s FAIL: %s should be %d, got %d", TestNumber, TestContext, text, cell2, cell1);
ThrowError("test %d (%s in %s) failed", TestNumber, text, TestContext); ThrowError("test %d (%s in %s) failed", TestNumber, text, TestContext);
} }
@ -52,9 +55,12 @@ stock void AssertEq(const char[] text, int cell1, int cell2)
stock void AssertFalse(const char[] text, bool value) stock void AssertFalse(const char[] text, bool value)
{ {
TestNumber++; TestNumber++;
if (!value) { if (!value)
{
PrintToServer("[%d] %s: %s == false OK", TestNumber, TestContext, text, value); PrintToServer("[%d] %s: %s == false OK", TestNumber, TestContext, text, value);
} else { }
else
{
PrintToServer("[%d] %s FAIL: %s should be false, got true", TestNumber, TestContext, text); PrintToServer("[%d] %s FAIL: %s should be false, got true", TestNumber, TestContext, text);
ThrowError("test %d (%s in %s) failed", TestNumber, text, TestContext); ThrowError("test %d (%s in %s) failed", TestNumber, text, TestContext);
} }
@ -63,9 +69,12 @@ stock void AssertFalse(const char[] text, bool value)
stock void AssertTrue(const char[] text, bool value) stock void AssertTrue(const char[] text, bool value)
{ {
TestNumber++; TestNumber++;
if (value) { if (value)
{
PrintToServer("[%d] %s: %s == true OK", TestNumber, TestContext, text, value); PrintToServer("[%d] %s: %s == true OK", TestNumber, TestContext, text, value);
} else { }
else
{
PrintToServer("[%d] %s FAIL: %s should be true, got false", TestNumber, TestContext, text); PrintToServer("[%d] %s FAIL: %s should be true, got false", TestNumber, TestContext, text);
ThrowError("test %d (%s in %s) failed", TestNumber, text, TestContext); ThrowError("test %d (%s in %s) failed", TestNumber, text, TestContext);
} }

View File

@ -47,9 +47,9 @@
*/ */
enum SMCResult enum SMCResult
{ {
SMCParse_Continue, /**< Continue parsing */ SMCParse_Continue, /**< Continue parsing */
SMCParse_Halt, /**< Stop parsing here */ SMCParse_Halt, /**< Stop parsing here */
SMCParse_HaltFail /**< Stop parsing and return failure */ SMCParse_HaltFail /**< Stop parsing and return failure */
}; };
/** /**
@ -57,66 +57,77 @@ enum SMCResult
*/ */
enum SMCError enum SMCError
{ {
SMCError_Okay = 0, /**< No error */ SMCError_Okay = 0, /**< No error */
SMCError_StreamOpen, /**< Stream failed to open */ SMCError_StreamOpen, /**< Stream failed to open */
SMCError_StreamError, /**< The stream died... somehow */ SMCError_StreamError, /**< The stream died... somehow */
SMCError_Custom, /**< A custom handler threw an error */ SMCError_Custom, /**< A custom handler threw an error */
SMCError_InvalidSection1, /**< A section was declared without quotes, and had extra tokens */ SMCError_InvalidSection1, /**< A section was declared without quotes, and had extra tokens */
SMCError_InvalidSection2, /**< A section was declared without any header */ SMCError_InvalidSection2, /**< A section was declared without any header */
SMCError_InvalidSection3, /**< A section ending was declared with too many unknown tokens */ SMCError_InvalidSection3, /**< A section ending was declared with too many unknown tokens */
SMCError_InvalidSection4, /**< A section ending has no matching beginning */ SMCError_InvalidSection4, /**< A section ending has no matching beginning */
SMCError_InvalidSection5, /**< A section beginning has no matching ending */ SMCError_InvalidSection5, /**< A section beginning has no matching ending */
SMCError_InvalidTokens, /**< There were too many unidentifiable strings on one line */ SMCError_InvalidTokens, /**< There were too many unidentifiable strings on one line */
SMCError_TokenOverflow, /**< The token buffer overflowed */ SMCError_TokenOverflow, /**< The token buffer overflowed */
SMCError_InvalidProperty1, /**< A property was declared outside of any section */ SMCError_InvalidProperty1 /**< A property was declared outside of any section */
}; };
// Called when parsing is started. /**
// * Called when parsing is started.
// @param smc The SMC Parse Handle. *
* @param smc The SMC Parse Handle.
*/
typedef SMC_ParseStart = function void (SMCParser smc); typedef SMC_ParseStart = function void (SMCParser smc);
// Called when the parser is entering a new section or sub-section. /**
// * Called when the parser is entering a new section or sub-section.
// Note: Enclosing quotes are always stripped. *
// * Note: Enclosing quotes are always stripped.
// @param smc The SMC Parser. *
// @param name String containing section name. * @param smc The SMC Parser.
// @param opt_quotes True if the section name was quote-enclosed in the file. * @param name String containing section name.
// @return An SMCResult action to take. * @param opt_quotes True if the section name was quote-enclosed in the file.
* @return An SMCResult action to take.
*/
typedef SMC_NewSection = function SMCResult (SMCParser smc, const char[] name, bool opt_quotes); typedef SMC_NewSection = function SMCResult (SMCParser smc, const char[] name, bool opt_quotes);
// Called when the parser finds a new key/value pair. /**
// * Called when the parser finds a new key/value pair.
// Note: Enclosing quotes are always stripped. *
// * Note: Enclosing quotes are always stripped.
// @param smc The SMCParser. *
// @param key String containing key name. * @param smc The SMCParser.
// @param value String containing value name. * @param key String containing key name.
// @param key_quotes Whether or not the key was enclosed in quotes. * @param value String containing value name.
// @param value_quotes Whether or not the value was enclosed in quotes. * @param key_quotes Whether or not the key was enclosed in quotes.
// @return An SMCResult action to take. * @param value_quotes Whether or not the value was enclosed in quotes.
* @return An SMCResult action to take.
*/
typedef SMC_KeyValue = function SMCResult (SMCParser smc, const char[] key, const char[] value, bool key_quotes, bool value_quotes); typedef SMC_KeyValue = function SMCResult (SMCParser smc, const char[] key, const char[] value, bool key_quotes, bool value_quotes);
// Called when the parser finds the end of the current section. /** Called when the parser finds the end of the current section.
// *
// @param smc The SMCParser. * @param smc The SMCParser.
// @return An SMCResult action to take. * @return An SMCResult action to take.
*/
typedef SMC_EndSection = function SMCResult (SMCParser smc); typedef SMC_EndSection = function SMCResult (SMCParser smc);
// Called when parsing is halted. /**
// * Called when parsing is halted.
// @param smc The SMCParser. *
// @param halted True if abnormally halted, false otherwise. * @param smc The SMCParser.
// @param failed True if parsing failed, false otherwise. * @param halted True if abnormally halted, false otherwise.
* @param failed True if parsing failed, false otherwise.
*/
typedef SMC_ParseEnd = function void (SMCParser smc, bool halted, bool failed); typedef SMC_ParseEnd = function void (SMCParser smc, bool halted, bool failed);
// Callback for whenever a new line of text is about to be parsed. /**
// * Callback for whenever a new line of text is about to be parsed.
// @param smc The SMCParser. *
// @param line A string containing the raw line from the file. * @param smc The SMCParser.
// @param lineno The line number it occurs on. * @param line A string containing the raw line from the file.
// @return An SMCResult action to take. * @param lineno The line number it occurs on.
* @return An SMCResult action to take.
*/
typedef SMC_RawLine = function SMCResult (SMCParser smc, const char[] line, int lineno); typedef SMC_RawLine = function SMCResult (SMCParser smc, const char[] line, int lineno);
// An SMCParser is a callback-driven parser for SourceMod configuration files. // An SMCParser is a callback-driven parser for SourceMod configuration files.
@ -130,10 +141,10 @@ methodmap SMCParser < Handle
// Parses an SMC file. // Parses an SMC file.
// //
// @param file A string containing the file path. // @param file A string containing the file path.
// @param line An optional variable to store the last line number read. // @param line An optional variable to store the last line number read.
// @param col An optional variable to store the last column number read. // @param col An optional variable to store the last column number read.
// @return An SMCParseError result. // @return An SMCParseError result.
public native SMCError ParseFile(const char[] file, int &line = 0, int &col = 0); public native SMCError ParseFile(const char[] file, int &line = 0, int &col = 0);
// Sets the callback for receiving SMC_ParseStart events. // Sets the callback for receiving SMC_ParseStart events.
@ -168,76 +179,77 @@ methodmap SMCParser < Handle
// Gets an error string for an SMCError code. // Gets an error string for an SMCError code.
// //
// @param error The SMCParseError code. // @param error The SMCParseError code.
// @param buffer A string buffer for the error (contents undefined on failure). // @param buffer A string buffer for the error (contents undefined on failure).
// @param buf_max The maximum size of the buffer. // @param buf_max The maximum size of the buffer.
// @return The number of characters written to buffer. // @return The number of characters written to buffer.
public native void GetErrorString(SMCError error, char[] buffer, int buf_max); public native void GetErrorString(SMCError error, char[] buffer, int buf_max);
}; };
/** /**
* Creates a new SMC file format parser. This is used to set parse hooks. * Creates a new SMC file format parser. This is used to set parse hooks.
* *
* @return A new Handle to an SMC Parse structure. * @return A new Handle to an SMC Parse structure.
*/ */
native SMCParser SMC_CreateParser(); native SMCParser SMC_CreateParser();
/** /**
* Parses an SMC file. * Parses an SMC file.
* *
* @param smc A Handle to an SMC Parse structure. * @param smc A Handle to an SMC Parse structure.
* @param file A string containing the file path. * @param file A string containing the file path.
* @param line An optional by reference cell to store the last line number read. * @param line An optional by reference cell to store the last line number read.
* @param col An optional by reference cell to store the last column number read. * @param col An optional by reference cell to store the last column number read.
* @return An SMCParseError result. * @return An SMCParseError result.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native SMCError SMC_ParseFile(Handle smc, const char[] file, int &line=0, int &col=0); native SMCError SMC_ParseFile(Handle smc, const char[] file, int &line=0, int &col=0);
/** /**
* Gets an error string for an SMCError code. * Gets an error string for an SMCError code.
*
* @note SMCError_Okay returns false. * @note SMCError_Okay returns false.
* @note SMCError_Custom (which is thrown on SMCParse_HaltFail) returns false. * @note SMCError_Custom (which is thrown on SMCParse_HaltFail) returns false.
* *
* @param error The SMCParseError code. * @param error The SMCParseError code.
* @param buffer A string buffer for the error (contents undefined on failure). * @param buffer A string buffer for the error (contents undefined on failure).
* @param buf_max The maximum size of the buffer. * @param buf_max The maximum size of the buffer.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
native bool SMC_GetErrorString(SMCError error, char[] buffer, int buf_max); native bool SMC_GetErrorString(SMCError error, char[] buffer, int buf_max);
/** /**
* Sets the SMC_ParseStart function of a parse Handle. * Sets the SMC_ParseStart function of a parse Handle.
* *
* @param smc Handle to an SMC Parse. * @param smc Handle to an SMC Parse.
* @param func SMC_ParseStart function. * @param func SMC_ParseStart function.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void SMC_SetParseStart(Handle smc, SMC_ParseStart func); native void SMC_SetParseStart(Handle smc, SMC_ParseStart func);
/** /**
* Sets the SMC_ParseEnd of a parse handle. * Sets the SMC_ParseEnd of a parse handle.
* *
* @param smc Handle to an SMC Parse. * @param smc Handle to an SMC Parse.
* @param func SMC_ParseEnd function. * @param func SMC_ParseEnd function.
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native void SMC_SetParseEnd(Handle smc, SMC_ParseEnd func); native void SMC_SetParseEnd(Handle smc, SMC_ParseEnd func);
/** /**
* Sets the three main reader functions. * Sets the three main reader functions.
* *
* @param smc An SMC parse Handle. * @param smc An SMC parse Handle.
* @param ns An SMC_NewSection function pointer. * @param ns An SMC_NewSection function pointer.
* @param kv An SMC_KeyValue function pointer. * @param kv An SMC_KeyValue function pointer.
* @param es An SMC_EndSection function pointer. * @param es An SMC_EndSection function pointer.
*/ */
native void SMC_SetReaders(Handle smc, SMC_NewSection ns, SMC_KeyValue kv, SMC_EndSection es); native void SMC_SetReaders(Handle smc, SMC_NewSection ns, SMC_KeyValue kv, SMC_EndSection es);
/** /**
* Sets a raw line reader on an SMC parser Handle. * Sets a raw line reader on an SMC parser Handle.
* *
* @param smc Handle to an SMC Parse. * @param smc Handle to an SMC Parse.
* @param func SMC_RawLine function. * @param func SMC_RawLine function.
*/ */
native void SMC_SetRawLine(Handle smc, SMC_RawLine func); native void SMC_SetRawLine(Handle smc, SMC_RawLine func);

View File

@ -35,14 +35,14 @@
#endif #endif
#define _tf2_included #define _tf2_included
#define TF_STUNFLAG_SLOWDOWN (1 << 0) /**< activates slowdown modifier */ #define TF_STUNFLAG_SLOWDOWN (1 << 0) /**< activates slowdown modifier */
#define TF_STUNFLAG_BONKSTUCK (1 << 1) /**< bonk sound, stuck */ #define TF_STUNFLAG_BONKSTUCK (1 << 1) /**< bonk sound, stuck */
#define TF_STUNFLAG_LIMITMOVEMENT (1 << 2) /**< disable forward/backward movement */ #define TF_STUNFLAG_LIMITMOVEMENT (1 << 2) /**< disable forward/backward movement */
#define TF_STUNFLAG_CHEERSOUND (1 << 3) /**< cheering sound */ #define TF_STUNFLAG_CHEERSOUND (1 << 3) /**< cheering sound */
#define TF_STUNFLAG_NOSOUNDOREFFECT (1 << 5) /**< no sound or particle */ #define TF_STUNFLAG_NOSOUNDOREFFECT (1 << 5) /**< no sound or particle */
#define TF_STUNFLAG_THIRDPERSON (1 << 6) /**< panic animation */ #define TF_STUNFLAG_THIRDPERSON (1 << 6) /**< panic animation */
#define TF_STUNFLAG_GHOSTEFFECT (1 << 7) /**< ghost particles */ #define TF_STUNFLAG_GHOSTEFFECT (1 << 7) /**< ghost particles */
#define TF_STUNFLAG_SOUND (1 << 8) /**< sound */ #define TF_STUNFLAG_SOUND (1 << 8) /**< sound */
#define TF_STUNFLAGS_LOSERSTATE TF_STUNFLAG_SLOWDOWN|TF_STUNFLAG_NOSOUNDOREFFECT|TF_STUNFLAG_THIRDPERSON #define TF_STUNFLAGS_LOSERSTATE TF_STUNFLAG_SLOWDOWN|TF_STUNFLAG_NOSOUNDOREFFECT|TF_STUNFLAG_THIRDPERSON
#define TF_STUNFLAGS_GHOSTSCARE TF_STUNFLAG_GHOSTEFFECT|TF_STUNFLAG_THIRDPERSON #define TF_STUNFLAGS_GHOSTSCARE TF_STUNFLAG_GHOSTEFFECT|TF_STUNFLAG_THIRDPERSON
@ -206,7 +206,7 @@ enum TFCond
TFCond_BurningPyro, TFCond_BurningPyro,
TFCond_RocketPack, TFCond_RocketPack,
TFCond_LostFooting, TFCond_LostFooting,
TFCond_AirCurrent, TFCond_AirCurrent
}; };
const float TFCondDuration_Infinite = -1.0; const float TFCondDuration_Infinite = -1.0;
@ -247,55 +247,55 @@ enum TFObjectMode
/** /**
* Sets a client on fire for 10 seconds. * Sets a client on fire for 10 seconds.
* *
* @param client Player's index. * @param client Player's index.
* @param attacker Attacker's index. * @param attacker Attacker's index.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void TF2_IgnitePlayer(int client, int attacker); native void TF2_IgnitePlayer(int client, int attacker);
/** /**
* Respawns a client * Respawns a client
* *
* @param client Player's index. * @param client Player's index.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void TF2_RespawnPlayer(int client); native void TF2_RespawnPlayer(int client);
/** /**
* Regenerates a client's health and ammunition * Regenerates a client's health and ammunition
* *
* @param client Player's index. * @param client Player's index.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void TF2_RegeneratePlayer(int client); native void TF2_RegeneratePlayer(int client);
/** /**
* Adds a condition to a player * Adds a condition to a player
* *
* @param client Player's index. * @param client Player's index.
* @param condition Integer identifier of condition to apply. * @param condition Integer identifier of condition to apply.
* @param duration Duration of condition (does not apply to all conditions). * @param duration Duration of condition (does not apply to all conditions).
* Pass TFCondDuration_Infinite to apply until manually removed. * Pass TFCondDuration_Infinite to apply until manually removed.
* @param inflictor Condition inflictor's index (0 for no inflictor). * @param inflictor Condition inflictor's index (0 for no inflictor).
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void TF2_AddCondition(int client, TFCond condition, float duration=TFCondDuration_Infinite, int inflictor=0); native void TF2_AddCondition(int client, TFCond condition, float duration=TFCondDuration_Infinite, int inflictor=0);
/** /**
* Removes a condition from a player * Removes a condition from a player
* *
* @param client Player's index. * @param client Player's index.
* @param condition Integer identifier of condition to remove. * @param condition Integer identifier of condition to remove.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void TF2_RemoveCondition(int client, TFCond condition); native void TF2_RemoveCondition(int client, TFCond condition);
/** /**
* Enables/disables PowerPlay mode on a player. * Enables/disables PowerPlay mode on a player.
* *
* @param client Player's index. * @param client Player's index.
* @param enabled Whether to enable or disable PowerPlay on player. * @param enabled Whether to enable or disable PowerPlay on player.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void TF2_SetPlayerPowerPlay(int client, bool enabled); native void TF2_SetPlayerPowerPlay(int client, bool enabled);
@ -304,47 +304,48 @@ native void TF2_SetPlayerPowerPlay(int client, bool enabled);
* *
* Note: This only starts the disguise process and a delay occurs before the spy is fully disguised * Note: This only starts the disguise process and a delay occurs before the spy is fully disguised
* *
* @param client Player's index. * @param client Player's index.
* @param team Team to disguise the player as (only TFTeam_Red and TFTeam_Blue have an effect) * @param team Team to disguise the player as (only TFTeam_Red and TFTeam_Blue have an effect)
* @param classType TFClassType class to disguise the player as * @param classType TFClassType class to disguise the player as
* @param target Specific target player to disguise as (0 for any) * @param target Specific target player to disguise as (0 for any)
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void TF2_DisguisePlayer(int client, TFTeam team, TFClassType classType, int target=0); native void TF2_DisguisePlayer(int client, TFTeam team, TFClassType classType, int target=0);
/** /**
* Removes the current disguise from a client. Only has an effect on spies. * Removes the current disguise from a client. Only has an effect on spies.
* *
* @param client Player's index. * @param client Player's index.
* @error Invalid client index, client not in game, or no mod support. * @error Invalid client index, client not in game, or no mod support.
*/ */
native void TF2_RemovePlayerDisguise(int client); native void TF2_RemovePlayerDisguise(int client);
/** /**
* Stuns a client * Stuns a client
* *
* @param client Player's index. * @param client Player's index.
* @param duration Duration of stun. * @param duration Duration of stun.
* @param slowdown Slowdown percent (as decimal, 0.00-1.00) * @param slowdown Slowdown percent (as decimal, 0.00-1.00)
* Ignored if TF_STUNFLAG_SLOWDOWN is not set. * Ignored if TF_STUNFLAG_SLOWDOWN is not set.
* @param stunflags Stun flags. * @param stunflags Stun flags.
* @param attacker Attacker's index (0 is allowed for world). * @param attacker Attacker's index (0 is allowed for world).
*/ */
native void TF2_StunPlayer(int client, float duration, float slowdown=0.0, int stunflags, int attacker=0); native void TF2_StunPlayer(int client, float duration, float slowdown=0.0, int stunflags, int attacker=0);
/** /**
* Induces the bleed effect on a client * Induces the bleed effect on a client
* *
* @param client Player's index. * @param client Player's index.
* @param attacker Attacker's index. * @param attacker Attacker's index.
* @param duration Duration of bleeding (in seconds). * @param duration Duration of bleeding (in seconds).
*/ */
native void TF2_MakeBleed(int client, int attacker, float duration); native void TF2_MakeBleed(int client, int attacker, float duration);
/** /**
* Retrieves the entity index of the CPlayerResource entity * Retrieves the entity index of the CPlayerResource entity
* *
* @return The current resource entity index. * @return The current resource entity index.
* @deprecated Use GetPlayerResourceEntity instead
*/ */
#pragma deprecated Use GetPlayerResourceEntity instead #pragma deprecated Use GetPlayerResourceEntity instead
native int TF2_GetResourceEntity(); native int TF2_GetResourceEntity();
@ -352,8 +353,8 @@ native int TF2_GetResourceEntity();
/** /**
* Finds the TFClassType for a given class name. * Finds the TFClassType for a given class name.
* *
* @param classname A classname string such as "sniper" or "demoman" * @param classname A classname string such as "sniper" or "demoman"
* @return A TFClassType constant. * @return A TFClassType constant.
*/ */
native TFClassType TF2_GetClass(const char[] classname); native TFClassType TF2_GetClass(const char[] classname);
@ -363,19 +364,19 @@ native TFClassType TF2_GetClass(const char[] classname);
* action to override the decision with the value of 'result' * action to override the decision with the value of 'result'
* *
* @note Since critical shots are also calculated client side any changes made with * @note Since critical shots are also calculated client side any changes made with
* this will not show for the shooter. Projectile weapons such as the rocketlauncher * this will not show for the shooter. Projectile weapons such as the rocketlauncher
* and demoman weapons will show a critical bullet but no critical sound effect. * and demoman weapons will show a critical bullet but no critical sound effect.
* Bullet hits should appear as expected. * Bullet hits should appear as expected.
* *
* @param client Client Index. * @param client Client Index.
* @param weapon Weapon entity Index. * @param weapon Weapon entity Index.
* @param weaponname Classname of the weapon. * @param weaponname Classname of the weapon.
* @param result Buffer param for the result of the decision. * @param result Buffer param for the result of the decision.
*/ */
forward Action TF2_CalcIsAttackCritical(int client, int weapon, char[] weaponname, bool &result); forward Action TF2_CalcIsAttackCritical(int client, int weapon, char[] weaponname, bool &result);
/** /**
* @deprecated No longer called. Use TF2_OnIsHolidayActive. * @deprecated No longer called. Use TF2_OnIsHolidayActive.
*/ */
#pragma deprecated No longer called. Use TF2_OnIsHolidayActive. #pragma deprecated No longer called. Use TF2_OnIsHolidayActive.
forward Action TF2_OnGetHoliday(TFHoliday &holiday); forward Action TF2_OnGetHoliday(TFHoliday &holiday);
@ -385,17 +386,17 @@ forward Action TF2_OnGetHoliday(TFHoliday &holiday);
* Return Plugin_Continue to let the original calculation or return a higher * Return Plugin_Continue to let the original calculation or return a higher
* action to override the decision with the value of 'result' * action to override the decision with the value of 'result'
* *
* @param holiday Holiday being checked. * @param holiday Holiday being checked.
* @param result Buffer param for the result of the decision. * @param result Buffer param for the result of the decision.
* @return Plugin_Continue for original calculation, higher value to use 'result'. * @return Plugin_Continue for original calculation, higher value to use 'result'.
*/ */
forward Action TF2_OnIsHolidayActive(TFHoliday holiday, bool &result); forward Action TF2_OnIsHolidayActive(TFHoliday holiday, bool &result);
/** /**
* Returns whether or not a holiday is active * Returns whether or not a holiday is active
* *
* @param holiday Holiday being checked. * @param holiday Holiday being checked.
* @return Boolean of whether or not the holiday is active. * @return Boolean of whether or not the holiday is active.
*/ */
native bool TF2_IsHolidayActive(TFHoliday holiday); native bool TF2_IsHolidayActive(TFHoliday holiday);
@ -403,7 +404,7 @@ native bool TF2_IsHolidayActive(TFHoliday holiday);
* Returns whether or not a client (Player) is in a duel. * Returns whether or not a client (Player) is in a duel.
* *
* @param client Client Index. * @param client Client Index.
* @return Boolean of whether or not the client/player is dueling. * @return Boolean of whether or not the client/player is dueling.
*/ */
native bool TF2_IsPlayerInDuel(int client); native bool TF2_IsPlayerInDuel(int client);
@ -411,16 +412,16 @@ native bool TF2_IsPlayerInDuel(int client);
* Removes an econ wearable (hat, misc, etc) from a player. * Removes an econ wearable (hat, misc, etc) from a player.
* This also deletes the wearable entity. * This also deletes the wearable entity.
* *
* @param client Client index. * @param client Client index.
* @param wearable Index of the wearable entity. * @param wearable Index of the wearable entity.
* @error Invalid client index, client not in game, invalid wearable entity, or no mod support. * @error Invalid client index, client not in game, invalid wearable entity, or no mod support.
*/ */
native void TF2_RemoveWearable(int client, int wearable); native void TF2_RemoveWearable(int client, int wearable);
/** /**
* Called after a condition is added to a player * Called after a condition is added to a player
* *
* @param client Index of the client to which the condition is being added. * @param client Index of the client to which the condition is being added.
* @param condition Condition that is being added. * @param condition Condition that is being added.
*/ */
forward void TF2_OnConditionAdded(int client, TFCond condition); forward void TF2_OnConditionAdded(int client, TFCond condition);
@ -428,8 +429,8 @@ forward void TF2_OnConditionAdded(int client, TFCond condition);
/** /**
* Called after a condition is removed from a player * Called after a condition is removed from a player
* *
* @param client Index of the client to which the condition is being removed. * @param client Index of the client to which the condition is being removed.
* @param condition Condition that is being removed. * @param condition Condition that is being removed.
*/ */
forward void TF2_OnConditionRemoved(int client, TFCond condition); forward void TF2_OnConditionRemoved(int client, TFCond condition);
@ -448,11 +449,11 @@ forward void TF2_OnWaitingForPlayersEnd();
* Return Plugin_Continue to let the original calculation or return a higher * Return Plugin_Continue to let the original calculation or return a higher
* action to override the decision with the value of 'result' * action to override the decision with the value of 'result'
* *
* @param client Client index. * @param client Client index.
* @param teleporter Teleporter entity index. * @param teleporter Teleporter entity index.
* @param result Buffer param for the result of the decision. * @param result Buffer param for the result of the decision.
* This is prepopulated with the game's original decision to let a player teleport. * This is prepopulated with the game's original decision to let a player teleport.
* @return Plugin_Continue for original calculation, higher value to use 'result'. * @return Plugin_Continue for original calculation, higher value to use 'result'.
*/ */
forward Action TF2_OnPlayerTeleport(int client, int teleporter, bool &result); forward Action TF2_OnPlayerTeleport(int client, int teleporter, bool &result);

View File

@ -166,7 +166,7 @@ enum {
TF_CUSTOM_SLAP_KILL, TF_CUSTOM_SLAP_KILL,
TF_CUSTOM_CROC, TF_CUSTOM_CROC,
TF_CUSTOM_TAUNTATK_GASBLAST, TF_CUSTOM_TAUNTATK_GASBLAST,
TF_CUSTOM_AXTINGUISHER_BOOSTED, TF_CUSTOM_AXTINGUISHER_BOOSTED
}; };
// Weapon codes as used in some events, such as player_death // Weapon codes as used in some events, such as player_death
@ -281,7 +281,7 @@ enum {
TF_WEAPON_SLAP, TF_WEAPON_SLAP,
TF_WEAPON_JAR_GAS, TF_WEAPON_JAR_GAS,
TF_WEAPON_GRENADE_JAR_GAS, TF_WEAPON_GRENADE_JAR_GAS,
TF_WEAPON_FLAME_BALL, TF_WEAPON_FLAME_BALL
}; };
// TF2 Weapon Loadout Slots // TF2 Weapon Loadout Slots
@ -353,9 +353,9 @@ static const char TFResourceNames[TFResourceType][] =
/** /**
* Gets a client's current team. * Gets a client's current team.
* *
* @param client Client index. * @param client Client index.
* @return Current TFTeam of client. * @return Current TFTeam of client.
* @error Invalid client index. * @error Invalid client index.
*/ */
stock TFTeam TF2_GetClientTeam(int client) stock TFTeam TF2_GetClientTeam(int client)
{ {
@ -377,9 +377,9 @@ stock void TF2_ChangeClientTeam(int client, TFTeam team)
/** /**
* Gets a client's current class. * Gets a client's current class.
* *
* @param client Player's index. * @param client Player's index.
* @return Current TFClassType of player. * @return Current TFClassType of player.
* @error Invalid client index. * @error Invalid client index.
*/ */
stock TFClassType TF2_GetPlayerClass(int client) stock TFClassType TF2_GetPlayerClass(int client)
{ {
@ -391,11 +391,11 @@ stock TFClassType TF2_GetPlayerClass(int client)
* *
* Note: If setting player class in a player spawn hook weapons should be set to false. * Note: If setting player class in a player spawn hook weapons should be set to false.
* *
* @param client Player's index. * @param client Player's index.
* @param classType TFClassType class symbol. * @param classType TFClassType class symbol.
* @param weapons This parameter is ignored. * @param weapons This parameter is ignored.
* @param persistent If true, changes the player's desired class so the change stays after death. * @param persistent If true, changes the player's desired class so the change stays after death.
* @error Invalid client index. * @error Invalid client index.
*/ */
stock void TF2_SetPlayerClass(int client, TFClassType classType, bool weapons=true, bool persistent=true) stock void TF2_SetPlayerClass(int client, TFClassType classType, bool weapons=true, bool persistent=true)
{ {
@ -414,6 +414,7 @@ stock void TF2_SetPlayerClass(int client, TFClassType classType, bool weapons=tr
* @param type ResourceType constant * @param type ResourceType constant
* @return Value or -1 on failure. * @return Value or -1 on failure.
* @error Invalid client index, client not in game or failed to find resource entity. * @error Invalid client index, client not in game or failed to find resource entity.
* @deprecated Use GetPlayerResourceEntity and GetEntProp instead.
*/ */
#pragma deprecated Use GetPlayerResourceEntity and GetEntProp instead #pragma deprecated Use GetPlayerResourceEntity and GetEntProp instead
stock int TF2_GetPlayerResourceData(int client, TFResourceType type) stock int TF2_GetPlayerResourceData(int client, TFResourceType type)
@ -445,11 +446,12 @@ stock int TF2_GetPlayerResourceData(int client, TFResourceType type)
* *
* Note: The game overwrites these values every frame, so changing them will have very little effect. * Note: The game overwrites these values every frame, so changing them will have very little effect.
* *
* @param client Player's index. * @param client Player's index.
* @param type ResourceType constant * @param type ResourceType constant
* @param value Value to set. * @param value Value to set.
* @return Value or -1 on failure. * @return Value or -1 on failure.
* @error Invalid client index, client not in game or failed to find resource entity. * @error Invalid client index, client not in game or failed to find resource entity.
* @deprecated Use GetPlayerResourceEntity and SetEntProp instead.
*/ */
#pragma deprecated Use GetPlayerResourceEntity and SetEntProp instead #pragma deprecated Use GetPlayerResourceEntity and SetEntProp instead
stock bool TF2_SetPlayerResourceData(int client, TFResourceType type, any value) stock bool TF2_SetPlayerResourceData(int client, TFResourceType type, any value)
@ -481,9 +483,9 @@ stock bool TF2_SetPlayerResourceData(int client, TFResourceType type, any value)
/** /**
* Removes all weapons from a client's weapon slot * Removes all weapons from a client's weapon slot
* *
* @param client Player's index. * @param client Player's index.
* @param slot Slot index (0-5) * @param slot Slot index (0-5)
* @error Invalid client, invalid slot or lack of mod support * @error Invalid client, invalid slot or lack of mod support
*/ */
stock void TF2_RemoveWeaponSlot(int client, int slot) stock void TF2_RemoveWeaponSlot(int client, int slot)
{ {
@ -512,7 +514,7 @@ stock void TF2_RemoveWeaponSlot(int client, int slot)
/** /**
* Removes all weapons from a client * Removes all weapons from a client
* *
* @param client Player's index. * @param client Player's index.
*/ */
stock void TF2_RemoveAllWeapons(int client) stock void TF2_RemoveAllWeapons(int client)
{ {
@ -525,8 +527,9 @@ stock void TF2_RemoveAllWeapons(int client)
/** /**
* Gets a player's condition bits * Gets a player's condition bits
* *
* @param client Player's index. * @param client Player's index.
* @return Player's condition bits * @return Player's condition bits
* @deprecated Use TF2_IsPlayerInCondition instead.
*/ */
#pragma deprecated Use TF2_IsPlayerInCondition instead. #pragma deprecated Use TF2_IsPlayerInCondition instead.
stock int TF2_GetPlayerConditionFlags(int client) stock int TF2_GetPlayerConditionFlags(int client)
@ -537,9 +540,9 @@ stock int TF2_GetPlayerConditionFlags(int client)
/** /**
* Check whether or not a condition is set on a player * Check whether or not a condition is set on a player
* *
* @param client Player's index. * @param client Player's index.
* @param cond TFCond constant * @param cond TFCond constant
* @return True if set, false otherwise * @return True if set, false otherwise
*/ */
stock bool TF2_IsPlayerInCondition(int client, TFCond cond) stock bool TF2_IsPlayerInCondition(int client, TFCond cond)
{ {
@ -547,7 +550,7 @@ stock bool TF2_IsPlayerInCondition(int client, TFCond cond)
int iCond = view_as<int>(cond); int iCond = view_as<int>(cond);
switch (iCond / 32) switch (iCond / 32)
{ {
case 0: case 0:
{ {
int bit = 1 << iCond; int bit = 1 << iCond;
if ((GetEntProp(client, Prop_Send, "m_nPlayerCond") & bit) == bit) if ((GetEntProp(client, Prop_Send, "m_nPlayerCond") & bit) == bit)
@ -560,7 +563,7 @@ stock bool TF2_IsPlayerInCondition(int client, TFCond cond)
return true; return true;
} }
} }
case 1: case 1:
{ {
int bit = (1 << (iCond - 32)); int bit = (1 << (iCond - 32));
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx") & bit) == bit) if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx") & bit) == bit)
@ -568,7 +571,7 @@ stock bool TF2_IsPlayerInCondition(int client, TFCond cond)
return true; return true;
} }
} }
case 2: case 2:
{ {
int bit = (1 << (iCond - 64)); int bit = (1 << (iCond - 64));
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx2") & bit) == bit) if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx2") & bit) == bit)
@ -576,7 +579,7 @@ stock bool TF2_IsPlayerInCondition(int client, TFCond cond)
return true; return true;
} }
} }
case 3: case 3:
{ {
int bit = (1 << (iCond - 96)); int bit = (1 << (iCond - 96));
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx3") & bit) == bit) if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx3") & bit) == bit)
@ -584,7 +587,7 @@ stock bool TF2_IsPlayerInCondition(int client, TFCond cond)
return true; return true;
} }
} }
case 4: case 4:
{ {
int bit = (1 << (iCond - 128)); int bit = (1 << (iCond - 128));
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx4") & bit) == bit) if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx4") & bit) == bit)
@ -592,8 +595,10 @@ stock bool TF2_IsPlayerInCondition(int client, TFCond cond)
return true; return true;
} }
} }
default: default:
ThrowError("Invalid TFCond value %d", iCond); {
ThrowError("Invalid TFCond value %d", iCond);
}
} }
return false; return false;
@ -602,9 +607,9 @@ stock bool TF2_IsPlayerInCondition(int client, TFCond cond)
/** /**
* Gets an entity's object type. * Gets an entity's object type.
* *
* @param entity Entity index. * @param entity Entity index.
* @return Current TFObjectType of entity. * @return Current TFObjectType of entity.
* @error Invalid entity index. * @error Invalid entity index.
*/ */
stock TFObjectType TF2_GetObjectType(int entity) stock TFObjectType TF2_GetObjectType(int entity)
{ {
@ -621,9 +626,9 @@ stock TFObjectType TF2_GetObjectType(int entity)
/** /**
* Gets an entity's object mode. * Gets an entity's object mode.
* *
* @param entity Entity index. * @param entity Entity index.
* @return Current TFObjectMode of entity. * @return Current TFObjectMode of entity.
* @error Invalid entity index. * @error Invalid entity index.
*/ */
stock TFObjectMode TF2_GetObjectMode(int entity) stock TFObjectMode TF2_GetObjectMode(int entity)
{ {

View File

@ -37,10 +37,10 @@
#include <datapack> #include <datapack>
#define TIMER_REPEAT (1<<0) /**< Timer will repeat until it returns Plugin_Stop */ #define TIMER_REPEAT (1<<0) /**< Timer will repeat until it returns Plugin_Stop */
#define TIMER_FLAG_NO_MAPCHANGE (1<<1) /**< Timer will not carry over mapchanges */ #define TIMER_FLAG_NO_MAPCHANGE (1<<1) /**< Timer will not carry over mapchanges */
#define TIMER_HNDL_CLOSE (1<<9) /**< Deprecated define, replaced by below */ #define TIMER_HNDL_CLOSE (1<<9) /**< Deprecated define, replaced by below */
#define TIMER_DATA_HNDL_CLOSE (1<<9) /**< Timer will automatically call CloseHandle() on its data when finished */ #define TIMER_DATA_HNDL_CLOSE (1<<9) /**< Timer will automatically call CloseHandle() on its data when finished */
/** /**
* Any of the following prototypes will work for a timed function. * Any of the following prototypes will work for a timed function.
@ -48,63 +48,63 @@
typeset Timer typeset Timer
{ {
/** /**
* Called when the timer interval has elapsed. * Called when the timer interval has elapsed.
* *
* @param timer Handle to the timer object. * @param timer Handle to the timer object.
* @param hndl Handle passed to CreateTimer() when timer was created. * @param hndl Handle passed to CreateTimer() when timer was created.
* @return Plugin_Stop to stop a repeating timer, any other value for * @return Plugin_Stop to stop a repeating timer, any other value for
* default behavior. * default behavior.
*/ */
function Action(Handle timer, Handle hndl); function Action(Handle timer, Handle hndl);
/** /**
* Called when the timer interval has elapsed. * Called when the timer interval has elapsed.
* *
* @param timer Handle to the timer object. * @param timer Handle to the timer object.
* @param data Data passed to CreateTimer() when timer was created. * @param data Data passed to CreateTimer() when timer was created.
* @return Plugin_Stop to stop a repeating timer, any other value for * @return Plugin_Stop to stop a repeating timer, any other value for
* default behavior. * default behavior.
*/ */
function Action(Handle timer, any data); function Action(Handle timer, any data);
/** /**
* Called when the timer interval has elapsed. * Called when the timer interval has elapsed.
* *
* @param timer Handle to the timer object. * @param timer Handle to the timer object.
* @return Plugin_Stop to stop a repeating timer, any other value for * @return Plugin_Stop to stop a repeating timer, any other value for
* default behavior. * default behavior.
*/ */
function Action(Handle timer); function Action(Handle timer);
}; };
/** /**
* Creates a basic timer. Calling CloseHandle() on a timer will end the timer. * Creates a basic timer. Calling CloseHandle() on a timer will end the timer.
* *
* @param interval Interval from the current game time to execute the given function. * @param interval Interval from the current game time to execute the given function.
* @param func Function to execute once the given interval has elapsed. * @param func Function to execute once the given interval has elapsed.
* @param data Handle or value to pass through to the timer callback function. * @param data Handle or value to pass through to the timer callback function.
* @param flags Flags to set (such as repeatability or auto-Handle closing). * @param flags Flags to set (such as repeatability or auto-Handle closing).
* @return Handle to the timer object. You do not need to call CloseHandle(). * @return Handle to the timer object. You do not need to call CloseHandle().
* If the timer could not be created, INVALID_HANDLE will be returned. * If the timer could not be created, INVALID_HANDLE will be returned.
*/ */
native Handle CreateTimer(float interval, Timer func, any data=INVALID_HANDLE, int flags=0); native Handle CreateTimer(float interval, Timer func, any data=INVALID_HANDLE, int flags=0);
/** /**
* Kills a timer. Use this instead of CloseHandle() if you need more options. * Kills a timer. Use this instead of CloseHandle() if you need more options.
* *
* @param timer Timer Handle to kill. * @param timer Timer Handle to kill.
* @param autoClose If autoClose is true, the data that was passed to CreateTimer() will * @param autoClose If autoClose is true, the data that was passed to CreateTimer() will
* be closed as a handle if TIMER_DATA_HNDL_CLOSE was not specified. * be closed as a handle if TIMER_DATA_HNDL_CLOSE was not specified.
* @error Invalid handles will cause a run time error. * @error Invalid handles will cause a run time error.
*/ */
native void KillTimer(Handle timer, bool autoClose=false); native void KillTimer(Handle timer, bool autoClose=false);
/** /**
* Manually triggers a timer so its function will be called. * Manually triggers a timer so its function will be called.
* *
* @param timer Timer Handle to trigger. * @param timer Timer Handle to trigger.
* @param reset If reset is true, the elapsed time counter is reset * @param reset If reset is true, the elapsed time counter is reset
* so the full interval must pass again. * so the full interval must pass again.
*/ */
native void TriggerTimer(Handle timer, bool reset=false); native void TriggerTimer(Handle timer, bool reset=false);
@ -117,7 +117,7 @@ native void TriggerTimer(Handle timer, bool reset=false);
* it will not increment based on the system clock (i.e. it is still bound * it will not increment based on the system clock (i.e. it is still bound
* to the ticking process). * to the ticking process).
* *
* @return Time based on the game tick count. * @return Time based on the game tick count.
*/ */
native float GetTickedTime(); native float GetTickedTime();
@ -126,9 +126,9 @@ native float GetTickedTime();
* has not processed any frames yet (i.e. no players have joined the map yet), * has not processed any frames yet (i.e. no players have joined the map yet),
* then the time left returned will always be infinite. * then the time left returned will always be infinite.
* *
* @param timeleft Variable to store the time, in seconds. If the * @param timeleft Variable to store the time, in seconds. If the
* value is less than 0, the time limit is infinite. * value is less than 0, the time limit is infinite.
* @return True if the operation is supported, false otherwise. * @return True if the operation is supported, false otherwise.
*/ */
native bool GetMapTimeLeft(int &timeleft); native bool GetMapTimeLeft(int &timeleft);
@ -137,19 +137,19 @@ native bool GetMapTimeLeft(int &timeleft);
* frames yet (i.e. no players have joined the map yet), then the time limit * frames yet (i.e. no players have joined the map yet), then the time limit
* returned will always be 0. * returned will always be 0.
* *
* @param time Set to the number of total seconds in the map time * @param time Set to the number of total seconds in the map time
* limit, or 0 if there is no time limit set. * limit, or 0 if there is no time limit set.
* @return True on success, false if operation is not supported. * @return True on success, false if operation is not supported.
*/ */
native bool GetMapTimeLimit(int &time); native bool GetMapTimeLimit(int &time);
/** /**
* Extends the map time limit in a way that will notify all plugins. * Extends the map time limit in a way that will notify all plugins.
* *
* @param time Number of seconds to extend map time limit by. * @param time Number of seconds to extend map time limit by.
* The number can be negative to decrease the time limit. * The number can be negative to decrease the time limit.
* If 0, the map will be set to have no time limit. * If 0, the map will be set to have no time limit.
* @return True on success, false if operation is not supported. * @return True on success, false if operation is not supported.
*/ */
native bool ExtendMapTimeLimit(int time); native bool ExtendMapTimeLimit(int time);
@ -158,7 +158,7 @@ native bool ExtendMapTimeLimit(int time);
* *
* Note: A tick, in this context, is a frame. * Note: A tick, in this context, is a frame.
* *
* @return Number of seconds in between ticks. * @return Number of seconds in between ticks.
*/ */
native float GetTickInterval(); native float GetTickInterval();
@ -185,7 +185,7 @@ forward void OnMapTimeLeftChanged();
* Once the first player has in, even if that player, leaves, the server's * Once the first player has in, even if that player, leaves, the server's
* timers and entities will work. * timers and entities will work.
* *
* @return True if the server is ticking, false otherwise. * @return True if the server is ticking, false otherwise.
*/ */
native bool IsServerProcessing(); native bool IsServerProcessing();
@ -194,12 +194,12 @@ native bool IsServerProcessing();
* @note The datapack is automatically freed when the timer ends. * @note The datapack is automatically freed when the timer ends.
* @note The position of the datapack is not reset or changed for the timer function. * @note The position of the datapack is not reset or changed for the timer function.
* *
* @param interval Interval from the current game time to execute the given function. * @param interval Interval from the current game time to execute the given function.
* @param func Function to execute once the given interval has elapsed. * @param func Function to execute once the given interval has elapsed.
* @param datapack The newly created datapack is passed though this by-reference * @param datapack The newly created datapack is passed though this by-reference
* parameter to the timer callback function. * parameter to the timer callback function.
* @param flags Timer flags. * @param flags Timer flags.
* @return Handle to the timer object. You do not need to call CloseHandle(). * @return Handle to the timer object. You do not need to call CloseHandle().
*/ */
stock Handle CreateDataTimer(float interval, Timer func, Handle &datapack, int flags=0) stock Handle CreateDataTimer(float interval, Timer func, Handle &datapack, int flags=0)
{ {

View File

@ -75,8 +75,8 @@ enum TopMenuAction
* *
* INPUT : TopMenu Handle, topobj ID, client index. * INPUT : TopMenu Handle, topobj ID, client index.
* OUTPUT: The first byte of the 'buffer' string should be set * OUTPUT: The first byte of the 'buffer' string should be set
* to the desired flags. By default, it will contain * to the desired flags. By default, it will contain
* ITEMDRAW_DEFAULT. * ITEMDRAW_DEFAULT.
*/ */
TopMenuAction_DrawOption = 3, TopMenuAction_DrawOption = 3,
@ -86,7 +86,7 @@ enum TopMenuAction
* *
* INPUT : TopMenu Handle, topobj ID. * INPUT : TopMenu Handle, topobj ID.
*/ */
TopMenuAction_RemoveObject = 4, TopMenuAction_RemoveObject = 4
}; };
/** /**
@ -94,8 +94,8 @@ enum TopMenuAction
*/ */
enum TopMenuObjectType enum TopMenuObjectType
{ {
TopMenuObject_Category = 0, /**< Category (sub-menu branching from root) */ TopMenuObject_Category = 0, /**< Category (sub-menu branching from root) */
TopMenuObject_Item = 1 /**< Item on a sub-menu */ TopMenuObject_Item = 1 /**< Item on a sub-menu */
}; };
/** /**
@ -103,9 +103,9 @@ enum TopMenuObjectType
*/ */
enum TopMenuPosition enum TopMenuPosition
{ {
TopMenuPosition_Start = 0, /**< Start/root of the menu */ TopMenuPosition_Start = 0, /**< Start/root of the menu */
TopMenuPosition_LastRoot = 1, /**< Last position in the root menu */ TopMenuPosition_LastRoot = 1, /**< Last position in the root menu */
TopMenuPosition_LastCategory = 3, /**< Last position in their last category */ TopMenuPosition_LastCategory = 3 /**< Last position in their last category */
}; };
/** /**
@ -113,18 +113,18 @@ enum TopMenuPosition
*/ */
enum TopMenuObject enum TopMenuObject
{ {
INVALID_TOPMENUOBJECT = 0, INVALID_TOPMENUOBJECT = 0
}; };
/** /**
* TopMenu callback prototype. * TopMenu callback prototype.
* *
* @param topmenu Handle to the TopMenu. * @param topmenu Handle to the TopMenu.
* @param action TopMenuAction being performed. * @param action TopMenuAction being performed.
* @param topobj_id The topobj ID (if used). * @param topobj_id The topobj ID (if used).
* @param param Extra parameter (if used). * @param param Extra parameter (if used).
* @param buffer Output buffer (if used). * @param buffer Output buffer (if used).
* @param maxlength Output buffer (if used). * @param maxlength Output buffer (if used).
*/ */
typedef TopMenuHandler = function void ( typedef TopMenuHandler = function void (
TopMenu topmenu, TopMenu topmenu,
@ -172,7 +172,7 @@ methodmap TopMenu < Handle
// @param maxlength Maximum size of the error buffer. Error buffer // @param maxlength Maximum size of the error buffer. Error buffer
// will be filled with a zero-terminated string if // will be filled with a zero-terminated string if
// false is returned. // false is returned.
// @return True on success, false on failure. // @return True on success, false on failure.
public native bool LoadConfig(const char[] file, char[] error, int maxlength); public native bool LoadConfig(const char[] file, char[] error, int maxlength);
// Adds a category to a TopMenu. // Adds a category to a TopMenu.
@ -182,7 +182,7 @@ methodmap TopMenu < Handle
// @param cmdname Command name (for access overrides). // @param cmdname Command name (for access overrides).
// @param flags Default access flags. // @param flags Default access flags.
// @param info_string Arbitrary storage (max 255 bytes). // @param info_string Arbitrary storage (max 255 bytes).
// @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on failure. // @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on failure.
public native TopMenuObject AddCategory(const char[] name, TopMenuHandler handler, public native TopMenuObject AddCategory(const char[] name, TopMenuHandler handler,
const char[] cmdname = "", int flags = 0, const char[] cmdname = "", int flags = 0,
const char[] info_string = ""); const char[] info_string = "");
@ -195,7 +195,7 @@ methodmap TopMenu < Handle
// @param cmdname Command name (for access overrides). // @param cmdname Command name (for access overrides).
// @param flags Default access flags. // @param flags Default access flags.
// @param info_string Arbitrary storage (max 255 bytes). // @param info_string Arbitrary storage (max 255 bytes).
// @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on failure. // @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on failure.
public native TopMenuObject AddItem(const char[] name, TopMenuHandler handler, public native TopMenuObject AddItem(const char[] name, TopMenuHandler handler,
TopMenuObject parent, const char[] cmdname = "", TopMenuObject parent, const char[] cmdname = "",
int flags = 0, const char[] info_string = ""); int flags = 0, const char[] info_string = "");
@ -205,7 +205,7 @@ methodmap TopMenu < Handle
// @param parent TopMenuObject ID. // @param parent TopMenuObject ID.
// @param buffer Buffer to store info string. // @param buffer Buffer to store info string.
// @param maxlength Maximum size of info string. // @param maxlength Maximum size of info string.
// @return Number of bytes written, not including the null terminator. // @return Number of bytes written, not including the null terminator.
public native int GetInfoString(TopMenuObject parent, char[] buffer, int maxlength); public native int GetInfoString(TopMenuObject parent, char[] buffer, int maxlength);
// Retrieves the name string of a top menu item. // Retrieves the name string of a top menu item.
@ -213,7 +213,7 @@ methodmap TopMenu < Handle
// @param topobj TopMenuObject ID. // @param topobj TopMenuObject ID.
// @param buffer Buffer to store info string. // @param buffer Buffer to store info string.
// @param maxlength Maximum size of info string. // @param maxlength Maximum size of info string.
// @return Number of bytes written, not including the null terminator. // @return Number of bytes written, not including the null terminator.
public native int GetObjName(TopMenuObject topobj, char[] buffer, int maxlength); public native int GetObjName(TopMenuObject topobj, char[] buffer, int maxlength);
// Removes an topobj from a TopMenu. // Removes an topobj from a TopMenu.
@ -228,20 +228,20 @@ methodmap TopMenu < Handle
// //
// @param client Client index. // @param client Client index.
// @param position Position to display from. // @param position Position to display from.
// @return True on success, false on failure. // @return True on success, false on failure.
public native bool Display(int client, TopMenuPosition position); public native bool Display(int client, TopMenuPosition position);
// Displays a TopMenu category to a client. // Displays a TopMenu category to a client.
// //
// @param category Category topobj id. // @param category Category topobj id.
// @param client Client index. // @param client Client index.
// @return True on success, false on failure. // @return True on success, false on failure.
public native bool DisplayCategory(TopMenuObject category, int client); public native bool DisplayCategory(TopMenuObject category, int client);
// Finds a category's topobj ID in a TopMenu. // Finds a category's topobj ID in a TopMenu.
// //
// @param name Object's unique name. // @param name Object's unique name.
// @return TopMenuObject ID on success, or // @return TopMenuObject ID on success, or
// INVALID_TOPMENUOBJECT on failure. // INVALID_TOPMENUOBJECT on failure.
public native TopMenuObject FindCategory(const char[] name); public native TopMenuObject FindCategory(const char[] name);
@ -256,8 +256,8 @@ methodmap TopMenu < Handle
/** /**
* Creates a TopMenu. * Creates a TopMenu.
* *
* @param handler Handler to use for drawing the root title. * @param handler Handler to use for drawing the root title.
* @return A new TopMenu Handle, or INVALID_HANDLE on failure. * @return A new TopMenu Handle, or INVALID_HANDLE on failure.
*/ */
native TopMenu CreateTopMenu(TopMenuHandler handler); native TopMenu CreateTopMenu(TopMenuHandler handler);
@ -278,34 +278,34 @@ native TopMenu CreateTopMenu(TopMenuHandler handler);
* per-player based on how the handler function renders for that player. * per-player based on how the handler function renders for that player.
* These items appear after the configuration sorted items. * These items appear after the configuration sorted items.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param file File path. * @param file File path.
* @param error Error buffer. * @param error Error buffer.
* @param maxlength Maximum size of the error buffer. * @param maxlength Maximum size of the error buffer.
* Error buffer will be filled with a * Error buffer will be filled with a
* zero-terminated string if false is * zero-terminated string if false is
* returned. * returned.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid TopMenu Handle. * @error Invalid TopMenu Handle.
*/ */
native bool LoadTopMenuConfig(Handle topmenu, const char[] file, char[] error, int maxlength); native bool LoadTopMenuConfig(Handle topmenu, const char[] file, char[] error, int maxlength);
/** /**
* Adds an topobj to a TopMenu. * Adds an topobj to a TopMenu.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param name Object name (MUST be unique). * @param name Object name (MUST be unique).
* @param type Object type. * @param type Object type.
* @param handler Handler for topobj. * @param handler Handler for topobj.
* @param parent Parent topobj ID, or INVALID_TOPMENUOBJECT for none. * @param parent Parent topobj ID, or INVALID_TOPMENUOBJECT for none.
* Items must have a category parent. * Items must have a category parent.
* Categories must not have a parent. * Categories must not have a parent.
* @param cmdname Command name (for access overrides). * @param cmdname Command name (for access overrides).
* @param flags Default access flags. * @param flags Default access flags.
* @param info_string Arbitrary storage (max 255 bytes). * @param info_string Arbitrary storage (max 255 bytes).
* @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on * @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on
* failure. * failure.
* @error Invalid TopMenu Handle. * @error Invalid TopMenu Handle.
*/ */
native TopMenuObject AddToTopMenu(Handle topmenu, native TopMenuObject AddToTopMenu(Handle topmenu,
const char[] name, const char[] name,
@ -319,26 +319,26 @@ native TopMenuObject AddToTopMenu(Handle topmenu,
/** /**
* Retrieves the info string of a top menu item. * Retrieves the info string of a top menu item.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param parent TopMenuObject ID. * @param parent TopMenuObject ID.
* @param buffer Buffer to store info string. * @param buffer Buffer to store info string.
* @param maxlength Maximum size of info string. * @param maxlength Maximum size of info string.
* @return Number of bytes written, not including the * @return Number of bytes written, not including the
* null terminator. * null terminator.
* @error Invalid TopMenu Handle or TopMenuObject ID. * @error Invalid TopMenu Handle or TopMenuObject ID.
*/ */
native int GetTopMenuInfoString(Handle topmenu, TopMenuObject parent, char[] buffer, int maxlength); native int GetTopMenuInfoString(Handle topmenu, TopMenuObject parent, char[] buffer, int maxlength);
/** /**
* Retrieves the name string of a top menu item. * Retrieves the name string of a top menu item.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param topobj TopMenuObject ID. * @param topobj TopMenuObject ID.
* @param buffer Buffer to store info string. * @param buffer Buffer to store info string.
* @param maxlength Maximum size of info string. * @param maxlength Maximum size of info string.
* @return Number of bytes written, not including the * @return Number of bytes written, not including the
* null terminator. * null terminator.
* @error Invalid TopMenu Handle or TopMenuObject ID. * @error Invalid TopMenu Handle or TopMenuObject ID.
*/ */
native int GetTopMenuObjName(Handle topmenu, TopMenuObject topobj, char[] buffer, int maxlength); native int GetTopMenuObjName(Handle topmenu, TopMenuObject topobj, char[] buffer, int maxlength);
@ -348,42 +348,42 @@ native int GetTopMenuObjName(Handle topmenu, TopMenuObject topobj, char[] buffer
* Plugins' topobjs are automatically removed all TopMenus when the given * Plugins' topobjs are automatically removed all TopMenus when the given
* plugin unloads or pauses. In the case of unpausing, all items are restored. * plugin unloads or pauses. In the case of unpausing, all items are restored.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param topobj TopMenuObject ID. * @param topobj TopMenuObject ID.
* @error Invalid TopMenu Handle. * @error Invalid TopMenu Handle.
*/ */
native void RemoveFromTopMenu(Handle topmenu, TopMenuObject topobj); native void RemoveFromTopMenu(Handle topmenu, TopMenuObject topobj);
/** /**
* Displays a TopMenu to a client. * Displays a TopMenu to a client.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param client Client index. * @param client Client index.
* @param position Position to display from. * @param position Position to display from.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid TopMenu Handle or client not in game. * @error Invalid TopMenu Handle or client not in game.
*/ */
native bool DisplayTopMenu(Handle topmenu, int client, TopMenuPosition position); native bool DisplayTopMenu(Handle topmenu, int client, TopMenuPosition position);
/** /**
* Displays a TopMenu category to a client. * Displays a TopMenu category to a client.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param category Category topobj id. * @param category Category topobj id.
* @param client Client index. * @param client Client index.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid TopMenu Handle or client not in game. * @error Invalid TopMenu Handle or client not in game.
*/ */
native bool DisplayTopMenuCategory(Handle topmenu, TopMenuObject category, int client); native bool DisplayTopMenuCategory(Handle topmenu, TopMenuObject category, int client);
/** /**
* Finds a category's topobj ID in a TopMenu. * Finds a category's topobj ID in a TopMenu.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param name Object's unique name. * @param name Object's unique name.
* @return TopMenuObject ID on success, or * @return TopMenuObject ID on success, or
* INVALID_TOPMENUOBJECT on failure. * INVALID_TOPMENUOBJECT on failure.
* @error Invalid TopMenu Handle. * @error Invalid TopMenu Handle.
*/ */
native TopMenuObject FindTopMenuCategory(Handle topmenu, const char[] name); native TopMenuObject FindTopMenuCategory(Handle topmenu, const char[] name);

View File

@ -40,7 +40,7 @@
*/ */
enum UserMsg enum UserMsg
{ {
INVALID_MESSAGE_ID = -1, INVALID_MESSAGE_ID = -1
}; };
/** /**
@ -49,15 +49,15 @@ enum UserMsg
enum UserMessageType enum UserMessageType
{ {
UM_BitBuf = 0, UM_BitBuf = 0,
UM_Protobuf, UM_Protobuf
}; };
/** /**
* @section Message Flags. * @section Message Flags.
*/ */
#define USERMSG_RELIABLE (1<<2) /**< Message will be set on the reliable stream */ #define USERMSG_RELIABLE (1<<2) /**< Message will be set on the reliable stream */
#define USERMSG_INITMSG (1<<3) /**< Message will be considered to be an initmsg */ #define USERMSG_INITMSG (1<<3) /**< Message will be considered to be an initmsg */
#define USERMSG_BLOCKHOOKS (1<<7) /**< Prevents the message from triggering SourceMod and Metamod hooks */ #define USERMSG_BLOCKHOOKS (1<<7) /**< Prevents the message from triggering SourceMod and Metamod hooks */
/** /**
* @endsection * @endsection
@ -66,14 +66,17 @@ enum UserMessageType
/** /**
* Returns usermessage serialization type used for the current engine * Returns usermessage serialization type used for the current engine
* *
* @return The supported usermessage type. * @return The supported usermessage type.
*/ */
native UserMessageType GetUserMessageType(); native UserMessageType GetUserMessageType();
stock Protobuf UserMessageToProtobuf(Handle msg) stock Protobuf UserMessageToProtobuf(Handle msg)
{ {
if (GetUserMessageType() != UM_Protobuf) if (GetUserMessageType() != UM_Protobuf)
{
return null; return null;
}
return view_as<Protobuf>(msg); return view_as<Protobuf>(msg);
} }
@ -81,7 +84,10 @@ stock Protobuf UserMessageToProtobuf(Handle msg)
stock BfWrite UserMessageToBfWrite(Handle msg) stock BfWrite UserMessageToBfWrite(Handle msg)
{ {
if (GetUserMessageType() == UM_Protobuf) if (GetUserMessageType() == UM_Protobuf)
{
return null; return null;
}
return view_as<BfWrite>(msg); return view_as<BfWrite>(msg);
} }
@ -89,57 +95,62 @@ stock BfWrite UserMessageToBfWrite(Handle msg)
stock BfRead UserMessageToBfRead(Handle msg) stock BfRead UserMessageToBfRead(Handle msg)
{ {
if (GetUserMessageType() == UM_Protobuf) if (GetUserMessageType() == UM_Protobuf)
{
return null; return null;
}
return view_as<BfRead>(msg); return view_as<BfRead>(msg);
} }
/** /**
* Returns the ID of a given message, or -1 on failure. * Returns the ID of a given message, or -1 on failure.
* *
* @param msg String containing message name (case sensitive). * @param msg String containing message name (case sensitive).
* @return A message index, or INVALID_MESSAGE_ID on failure. * @return A message index, or INVALID_MESSAGE_ID on failure.
*/ */
native UserMsg GetUserMessageId(const char[] msg); native UserMsg GetUserMessageId(const char[] msg);
/** /**
* Retrieves the name of a message by ID. * Retrieves the name of a message by ID.
* *
* @param msg_id Message index. * @param msg_id Message index.
* @param msg Buffer to store the name of the message. * @param msg Buffer to store the name of the message.
* @param maxlength Maximum length of string buffer. * @param maxlength Maximum length of string buffer.
* @return True if message index is valid, false otherwise. * @return True if message index is valid, false otherwise.
*/ */
native bool GetUserMessageName(UserMsg msg_id, char[] msg, int maxlength); native bool GetUserMessageName(UserMsg msg_id, char[] msg, int maxlength);
/** /**
* Starts a usermessage (network message). * Starts a usermessage (network message).
*
* @note Only one message can be active at a time. * @note Only one message can be active at a time.
* @note It is illegal to send any message while a non-intercept hook is in progress. * @note It is illegal to send any message while a non-intercept hook is in progress.
* *
* @param msgname Message name to start. * @param msgname Message name to start.
* @param clients Array containing player indexes to broadcast to. * @param clients Array containing player indexes to broadcast to.
* @param numClients Number of players in the array. * @param numClients Number of players in the array.
* @param flags Optional flags to set. * @param flags Optional flags to set.
* @return A handle to a bf_write bit packing structure, or * @return A handle to a bf_write bit packing structure, or
* INVALID_HANDLE on failure. * INVALID_HANDLE on failure.
* @error Invalid message name, unable to start a message, invalid client, * @error Invalid message name, unable to start a message, invalid client,
* or client not connected. * or client not connected.
*/ */
native Handle StartMessage(const char[] msgname, const int[] clients, int numClients, int flags=0); native Handle StartMessage(const char[] msgname, const int[] clients, int numClients, int flags=0);
/** /**
* Starts a usermessage (network message). * Starts a usermessage (network message).
*
* @note Only one message can be active at a time. * @note Only one message can be active at a time.
* @note It is illegal to send any message while a non-intercept hook is in progress. * @note It is illegal to send any message while a non-intercept hook is in progress.
* *
* @param msg Message index to start. * @param msg Message index to start.
* @param clients Array containing player indexes to broadcast to. * @param clients Array containing player indexes to broadcast to.
* @param numClients Number of players in the array. * @param numClients Number of players in the array.
* @param flags Optional flags to set. * @param flags Optional flags to set.
* @return A handle to a bf_write bit packing structure, or * @return A handle to a bf_write bit packing structure, or
* INVALID_HANDLE on failure. * INVALID_HANDLE on failure.
* @error Invalid message name, unable to start a message, invalid client, * @error Invalid message name, unable to start a message, invalid client,
* or client not connected. * or client not connected.
*/ */
native Handle StartMessageEx(UserMsg msg, const int[] clients, int numClients, int flags=0); native Handle StartMessageEx(UserMsg msg, const int[] clients, int numClients, int flags=0);
@ -156,29 +167,29 @@ typeset MsgHook
/** /**
* Called when a bit buffer based usermessage is hooked * Called when a bit buffer based usermessage is hooked
* *
* @param msg_id Message index. * @param msg_id Message index.
* @param msg Handle to the input bit buffer. * @param msg Handle to the input bit buffer.
* @param players Array containing player indexes. * @param players Array containing player indexes.
* @param playersNum Number of players in the array. * @param playersNum Number of players in the array.
* @param reliable True if message is reliable, false otherwise. * @param reliable True if message is reliable, false otherwise.
* @param init True if message is an initmsg, false otherwise. * @param init True if message is an initmsg, false otherwise.
* @return Ignored for normal hooks. For intercept hooks, Plugin_Handled * @return Ignored for normal hooks. For intercept hooks, Plugin_Handled
* blocks the message from being sent, and Plugin_Continue * blocks the message from being sent, and Plugin_Continue
* resumes normal functionality. * resumes normal functionality.
*/ */
function Action (UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init); function Action (UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init);
/** /**
* Called when a protobuf based usermessage is hooked * Called when a protobuf based usermessage is hooked
* *
* @param msg_id Message index. * @param msg_id Message index.
* @param msg Handle to the input protobuf. * @param msg Handle to the input protobuf.
* @param players Array containing player indexes. * @param players Array containing player indexes.
* @param playersNum Number of players in the array. * @param playersNum Number of players in the array.
* @param reliable True if message is reliable, false otherwise. * @param reliable True if message is reliable, false otherwise.
* @param init True if message is an initmsg, false otherwise. * @param init True if message is an initmsg, false otherwise.
* @return Ignored for normal hooks. For intercept hooks, Plugin_Handled * @return Ignored for normal hooks. For intercept hooks, Plugin_Handled
* blocks the message from being sent, and Plugin_Continue * blocks the message from being sent, and Plugin_Continue
* resumes normal functionality. * resumes normal functionality.
*/ */
function Action (UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init); function Action (UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init);
}; };
@ -186,71 +197,73 @@ typeset MsgHook
/** /**
* Called when a message hook has completed. * Called when a message hook has completed.
* *
* @param msg_id Message index. * @param msg_id Message index.
* @param sent True if message was sent, false if blocked. * @param sent True if message was sent, false if blocked.
*/ */
typedef MsgPostHook = function void (UserMsg msg_id, bool sent); typedef MsgPostHook = function void (UserMsg msg_id, bool sent);
/** /**
* Hooks a user message. * Hooks a user message.
* *
* @param msg_id Message index. * @param msg_id Message index.
* @param hook Function to use as a hook. * @param hook Function to use as a hook.
* @param intercept If intercept is true, message will be fully intercepted, * @param intercept If intercept is true, message will be fully intercepted,
* allowing the user to block the message. Otherwise, * allowing the user to block the message. Otherwise,
* the hook is normal and ignores the return value. * the hook is normal and ignores the return value.
* @param post Notification function. * @param post Notification function.
* @error Invalid message index. * @error Invalid message index.
*/ */
native void HookUserMessage(UserMsg msg_id, MsgHook hook, bool intercept=false, MsgPostHook post=INVALID_FUNCTION); native void HookUserMessage(UserMsg msg_id, MsgHook hook, bool intercept=false, MsgPostHook post=INVALID_FUNCTION);
/** /**
* Removes one usermessage hook. * Removes one usermessage hook.
* *
* @param msg_id Message index. * @param msg_id Message index.
* @param hook Function used for the hook. * @param hook Function used for the hook.
* @param intercept Specifies whether the hook was an intercept hook or not. * @param intercept Specifies whether the hook was an intercept hook or not.
* @error Invalid message index. * @error Invalid message index.
*/ */
native void UnhookUserMessage(UserMsg msg_id, MsgHook hook, bool intercept=false); native void UnhookUserMessage(UserMsg msg_id, MsgHook hook, bool intercept=false);
/** /**
* Starts a usermessage (network message) that broadcasts to all clients. * Starts a usermessage (network message) that broadcasts to all clients.
*
* @note See StartMessage or StartMessageEx(). * @note See StartMessage or StartMessageEx().
* *
* @param msgname Message name to start. * @param msgname Message name to start.
* @param flags Optional flags to set. * @param flags Optional flags to set.
* @return A handle to a bf_write bit packing structure, or * @return A handle to a bf_write bit packing structure, or
* INVALID_HANDLE on failure. * INVALID_HANDLE on failure.
*/ */
stock Handle StartMessageAll(const char[] msgname, int flags=0) stock Handle StartMessageAll(const char[] msgname, int flags=0)
{ {
int total = 0; int total = 0;
int[] clients = new int[MaxClients]; int[] clients = new int[MaxClients];
for (int i=1; i<=MaxClients; i++) for (int i = 1; i <= MaxClients; i++)
{ {
if (IsClientConnected(i)) if (IsClientConnected(i))
{ {
clients[total++] = i; clients[total++] = i;
} }
} }
return StartMessage(msgname, clients, total, flags); return StartMessage(msgname, clients, total, flags);
} }
/** /**
* Starts a simpler usermessage (network message) for one client. * Starts a simpler usermessage (network message) for one client.
*
* @note See StartMessage or StartMessageEx(). * @note See StartMessage or StartMessageEx().
* *
* @param msgname Message name to start. * @param msgname Message name to start.
* @param client Client to send to. * @param client Client to send to.
* @param flags Optional flags to set. * @param flags Optional flags to set.
* @return A handle to a bf_write bit packing structure, or * @return A handle to a bf_write bit packing structure, or
* INVALID_HANDLE on failure. * INVALID_HANDLE on failure.
*/ */
stock Handle StartMessageOne(const char[] msgname, int client, int flags=0) stock Handle StartMessageOne(const char[] msgname, int client, int flags=0)
{ {
int players[1]; int players[1];
players[0] = client; players[0] = client;
return StartMessage(msgname, players, 1, flags); return StartMessage(msgname, players, 1, flags);

View File

@ -38,28 +38,28 @@
/** /**
* Calculates a vector's length. * Calculates a vector's length.
* *
* @param vec Vector. * @param vec Vector.
* @param squared If true, the result will be squared (for optimization). * @param squared If true, the result will be squared (for optimization).
* @return Vector length (magnitude). * @return Vector length (magnitude).
*/ */
native float GetVectorLength(const float vec[3], bool squared=false); native float GetVectorLength(const float vec[3], bool squared=false);
/** /**
* Calculates the distance between two vectors. * Calculates the distance between two vectors.
* *
* @param vec1 First vector. * @param vec1 First vector.
* @param vec2 Second vector. * @param vec2 Second vector.
* @param squared If true, the result will be squared (for optimization). * @param squared If true, the result will be squared (for optimization).
* @return Vector distance. * @return Vector distance.
*/ */
native float GetVectorDistance(const float vec1[3], const float vec2[3], bool squared=false); native float GetVectorDistance(const float vec1[3], const float vec2[3], bool squared=false);
/** /**
* Calculates the dot product of two vectors. * Calculates the dot product of two vectors.
* *
* @param vec1 First vector. * @param vec1 First vector.
* @param vec2 Second vector. * @param vec2 Second vector.
* @return Dot product of the two vectors. * @return Dot product of the two vectors.
*/ */
native float GetVectorDotProduct(const float vec1[3], const float vec2[3]); native float GetVectorDotProduct(const float vec1[3], const float vec2[3]);
@ -67,45 +67,45 @@ native float GetVectorDotProduct(const float vec1[3], const float vec2[3]);
* Computes the cross product of two vectors. Any input array can be the same * Computes the cross product of two vectors. Any input array can be the same
* as the output array. * as the output array.
* *
* @param vec1 First vector. * @param vec1 First vector.
* @param vec2 Second vector. * @param vec2 Second vector.
* @param result Resultant vector. * @param result Resultant vector.
*/ */
native void GetVectorCrossProduct(const float vec1[3], const float vec2[3], float result[3]); native void GetVectorCrossProduct(const float vec1[3], const float vec2[3], float result[3]);
/** /**
* Normalizes a vector. The input array can be the same as the output array. * Normalizes a vector. The input array can be the same as the output array.
* *
* @param vec Vector. * @param vec Vector.
* @param result Resultant vector. * @param result Resultant vector.
* @return Vector length. * @return Vector length.
*/ */
native float NormalizeVector(const float vec[3], float result[3]); native float NormalizeVector(const float vec[3], float result[3]);
/** /**
* Returns vectors in the direction of an angle. * Returns vectors in the direction of an angle.
* *
* @param angle Angle. * @param angle Angle.
* @param fwd Forward vector buffer or NULL_VECTOR. * @param fwd Forward vector buffer or NULL_VECTOR.
* @param right Right vector buffer or NULL_VECTOR. * @param right Right vector buffer or NULL_VECTOR.
* @param up Up vector buffer or NULL_VECTOR. * @param up Up vector buffer or NULL_VECTOR.
*/ */
native void GetAngleVectors(const float angle[3], float fwd[3], float right[3], float up[3]); native void GetAngleVectors(const float angle[3], float fwd[3], float right[3], float up[3]);
/** /**
* Returns angles from a vector. * Returns angles from a vector.
* *
* @param vec Vector. * @param vec Vector.
* @param angle Angle buffer. * @param angle Angle buffer.
*/ */
native void GetVectorAngles(const float vec[3], float angle[3]); native void GetVectorAngles(const float vec[3], float angle[3]);
/** /**
* Returns direction vectors from a vector. * Returns direction vectors from a vector.
* *
* @param vec Vector. * @param vec Vector.
* @param right Right vector buffer or NULL_VECTOR. * @param right Right vector buffer or NULL_VECTOR.
* @param up Up vector buffer or NULL_VECTOR. * @param up Up vector buffer or NULL_VECTOR.
*/ */
native void GetVectorVectors(const float vec[3], float right[3], float up[3]); native void GetVectorVectors(const float vec[3], float right[3], float up[3]);
@ -113,9 +113,9 @@ native void GetVectorVectors(const float vec[3], float right[3], float up[3]);
* Adds two vectors. It is safe to use either input buffer as an output * Adds two vectors. It is safe to use either input buffer as an output
* buffer. * buffer.
* *
* @param vec1 First vector. * @param vec1 First vector.
* @param vec2 Second vector. * @param vec2 Second vector.
* @param result Result buffer. * @param result Result buffer.
*/ */
stock void AddVectors(const float vec1[3], const float vec2[3], float result[3]) stock void AddVectors(const float vec1[3], const float vec2[3], float result[3])
{ {
@ -128,9 +128,9 @@ stock void AddVectors(const float vec1[3], const float vec2[3], float result[3])
* Subtracts a vector from another vector. It is safe to use either input * Subtracts a vector from another vector. It is safe to use either input
* buffer as an output buffer. * buffer as an output buffer.
* *
* @param vec1 First vector. * @param vec1 First vector.
* @param vec2 Second vector to subtract from first. * @param vec2 Second vector to subtract from first.
* @param result Result buffer. * @param result Result buffer.
*/ */
stock void SubtractVectors(const float vec1[3], const float vec2[3], float result[3]) stock void SubtractVectors(const float vec1[3], const float vec2[3], float result[3])
{ {
@ -142,8 +142,8 @@ stock void SubtractVectors(const float vec1[3], const float vec2[3], float resul
/** /**
* Scales a vector. * Scales a vector.
* *
* @param vec Vector. * @param vec Vector.
* @param scale Scale value. * @param scale Scale value.
*/ */
stock void ScaleVector(float vec[3], float scale) stock void ScaleVector(float vec[3], float scale)
{ {
@ -155,7 +155,7 @@ stock void ScaleVector(float vec[3], float scale)
/** /**
* Negatives a vector. * Negatives a vector.
* *
* @param vec Vector. * @param vec Vector.
*/ */
stock void NegateVector(float vec[3]) stock void NegateVector(float vec[3])
{ {
@ -167,9 +167,9 @@ stock void NegateVector(float vec[3])
/** /**
* Builds a vector from two points by subtracting the points. * Builds a vector from two points by subtracting the points.
* *
* @param pt1 First point (to be subtracted from the second). * @param pt1 First point (to be subtracted from the second).
* @param pt2 Second point. * @param pt2 Second point.
* @param output Output vector buffer. * @param output Output vector buffer.
*/ */
stock void MakeVectorFromPoints(const float pt1[3], const float pt2[3], float output[3]) stock void MakeVectorFromPoints(const float pt1[3], const float pt2[3], float output[3])
{ {

View File

@ -38,12 +38,12 @@
#tryinclude <version_auto> #tryinclude <version_auto>
#if !defined _auto_version_included #if !defined _auto_version_included
#define SOURCEMOD_V_TAG "manual" #define SOURCEMOD_V_TAG "manual"
#define SOURCEMOD_V_REV 0 #define SOURCEMOD_V_REV 0
#define SOURCEMOD_V_CSET "0" #define SOURCEMOD_V_CSET "0"
#define SOURCEMOD_V_MAJOR 1 /**< SourceMod Major version */ #define SOURCEMOD_V_MAJOR 1 /**< SourceMod Major version */
#define SOURCEMOD_V_MINOR 10 /**< SourceMod Minor version */ #define SOURCEMOD_V_MINOR 10 /**< SourceMod Minor version */
#define SOURCEMOD_V_RELEASE 0 /**< SourceMod Release version */ #define SOURCEMOD_V_RELEASE 0 /**< SourceMod Release version */
#define SOURCEMOD_VERSION "1.10.0-manual" /**< SourceMod version string (major.minor.release-tag) */ #define SOURCEMOD_VERSION "1.10.0-manual" /**< SourceMod version string (major.minor.release-tag) */
#endif #endif