2008-10-04 22:59:11 +02:00
|
|
|
/**
|
|
|
|
* vim: set ts=4 :
|
|
|
|
* =============================================================================
|
2016-08-23 15:34:00 +02:00
|
|
|
* SourceMod (C)2004-2016 AlliedModders LLC. All rights reserved.
|
2008-10-04 22:59:11 +02:00
|
|
|
* =============================================================================
|
|
|
|
*
|
|
|
|
* This file is part of the SourceMod/SourcePawn SDK.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
|
|
* Free Software Foundation.
|
2019-09-27 13:14:44 +02:00
|
|
|
*
|
2008-10-04 22:59:11 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
|
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
|
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
|
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
|
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
|
|
* this exception to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
|
|
* or <http://www.sourcemod.net/license.php>.
|
|
|
|
*
|
2009-04-14 23:40:48 +02:00
|
|
|
* Version: $Id$
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined _halflife_included
|
|
|
|
#endinput
|
|
|
|
#endif
|
|
|
|
#define _halflife_included
|
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
#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_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_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_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_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_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_CSGO 80 /**< Engine released after CS:GO (no SDK yet) */
|
|
|
|
#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_INDEX 1 /**< Msg is auto determined by the engine */
|
|
|
|
#define MOTDPANEL_TYPE_URL 2 /**< Treat msg as an URL link */
|
|
|
|
#define MOTDPANEL_TYPE_FILE 3 /**< Treat msg as a filename to be opened */
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
enum DialogType
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
DialogType_Msg = 0, /**< just an on screen message */
|
|
|
|
DialogType_Menu, /**< an options menu */
|
|
|
|
DialogType_Text, /**< a richtext dialog */
|
|
|
|
DialogType_Entry, /**< an entry box */
|
|
|
|
DialogType_AskConnect /**< ask the client to connect to a specified IP */
|
2008-10-04 22:59:11 +02:00
|
|
|
};
|
|
|
|
|
2014-07-30 11:03:42 +02:00
|
|
|
enum EngineVersion
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
Engine_Unknown, /**< Could not determine the engine version */
|
|
|
|
Engine_Original, /**< Original Source Engine (used by The Ship) */
|
|
|
|
Engine_SourceSDK2006, /**< Episode 1 Source Engine (second major SDK) */
|
|
|
|
Engine_SourceSDK2007, /**< Orange Box Source Engine (third major SDK) */
|
|
|
|
Engine_Left4Dead, /**< Left 4 Dead */
|
|
|
|
Engine_DarkMessiah, /**< Dark Messiah Multiplayer (based on original engine) */
|
|
|
|
Engine_Left4Dead2 = 7, /**< Left 4 Dead 2 */
|
|
|
|
Engine_AlienSwarm, /**< Alien Swarm (and Alien Swarm SDK) */
|
|
|
|
Engine_BloodyGoodTime, /**< Bloody Good Time */
|
|
|
|
Engine_EYE, /**< E.Y.E Divine Cybermancy */
|
|
|
|
Engine_Portal2, /**< Portal 2 */
|
|
|
|
Engine_CSGO, /**< Counter-Strike: Global Offensive */
|
|
|
|
Engine_CSS, /**< Counter-Strike: Source */
|
|
|
|
Engine_DOTA, /**< Dota 2 */
|
|
|
|
Engine_HL2DM, /**< Half-Life 2 Deathmatch */
|
|
|
|
Engine_DODS, /**< Day of Defeat: Source */
|
|
|
|
Engine_TF2, /**< Team Fortress 2 */
|
|
|
|
Engine_NuclearDawn, /**< Nuclear Dawn */
|
|
|
|
Engine_SDK2013, /**< Source SDK 2013 */
|
|
|
|
Engine_Blade, /**< Blade Symphony */
|
|
|
|
Engine_Insurgency, /**< Insurgency (2013 Retail version)*/
|
|
|
|
Engine_Contagion, /**< Contagion */
|
|
|
|
Engine_BlackMesa, /**< Black Mesa Multiplayer */
|
|
|
|
Engine_DOI /**< Day of Infamy */
|
2016-08-23 15:34:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum FindMapResult
|
|
|
|
{
|
|
|
|
// A direct match for this name was found
|
|
|
|
FindMap_Found,
|
|
|
|
// No match for this map name could be found.
|
|
|
|
FindMap_NotFound,
|
|
|
|
// A fuzzy match for this map name was found.
|
|
|
|
// Ex: cp_dust -> cp_dustbowl, c1m1 -> c1m1_hotel
|
|
|
|
// Only supported for maps that the engine knows about. (This excludes workshop maps on Orangebox).
|
|
|
|
FindMap_FuzzyMatch,
|
|
|
|
// A non-canonical match for this map name was found.
|
|
|
|
// Ex: workshop/1234 -> workshop/cp_qualified_name.ugc1234
|
|
|
|
// Only supported on "Orangebox" games with workshop support.
|
|
|
|
FindMap_NonCanonical,
|
|
|
|
// No currently available match for this map name could be found, but it may be possible to load
|
|
|
|
// Only supported on "Orangebox" games with workshop support.
|
|
|
|
FindMap_PossiblyAvailable
|
2014-07-30 11:03:42 +02:00
|
|
|
};
|
|
|
|
|
2010-07-25 20:58:18 +02:00
|
|
|
#define INVALID_ENT_REFERENCE 0xFFFFFFFF
|
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
/**
|
|
|
|
* Logs a generic message to the HL2 logs.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param format String format.
|
|
|
|
* @param ... Format arguments.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native void LogToGame(const char[] format, any ...);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the seed value for the global Half-Life 2 Random Stream.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param seed Seed value.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native void SetRandomSeed(int seed);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a random floating point number from the Half-Life 2 Random Stream.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param fMin Minimum random bound.
|
|
|
|
* @param fMax Maximum random bound.
|
|
|
|
* @return A random number between (inclusive) fMin and fMax.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native float GetRandomFloat(float fMin=0.0, float fMax=1.0);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a random number from the Half-Life 2 Random Stream.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param nmin Minimum random bound.
|
|
|
|
* @param nmax Maximum random bound.
|
|
|
|
* @return A random number between (inclusive) nmin and nmax.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int GetRandomInt(int nmin, int nmax);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether a map is valid or not.
|
2019-09-27 13:14:44 +02:00
|
|
|
*
|
|
|
|
* @param map Map name, excluding .bsp extension.
|
|
|
|
* @return True if valid, false otherwise.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native bool IsMapValid(const char[] map);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether a full or partial map name is found or can be resolved
|
2019-09-27 13:14:44 +02:00
|
|
|
*
|
|
|
|
* @param map Map name (usually same as map path relative to maps/ dir,
|
|
|
|
* excluding .bsp extension).
|
|
|
|
* @param foundmap Resolved map name. If the return is FindMap_FuzzyMatch
|
|
|
|
* or FindMap_NonCanonical the buffer will be the full path.
|
|
|
|
* @param maxlen Maximum length to write to map var.
|
|
|
|
* @return Result of the find operation. Not all result types are supported on all games.
|
2016-08-23 15:34:00 +02:00
|
|
|
*/
|
|
|
|
native FindMapResult FindMap(const char[] map, char[] foundmap, int maxlen);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the display name of a workshop map.
|
2019-09-27 13:14:44 +02:00
|
|
|
*
|
2016-08-23 15:34:00 +02:00
|
|
|
* Note: You do not need to call FindMap first. This native will call FindMap internally.
|
2019-09-27 13:14:44 +02:00
|
|
|
*
|
|
|
|
* @param map Map name (usually same as map path relative to maps/ dir,
|
|
|
|
* excluding .bsp extension).
|
|
|
|
* @param displayName Map's display name, i.e. cp_mymapname or de_mymapname.
|
|
|
|
* If FindMap returns FindMap_PossiblyAvailable or FindMap_NotFound,
|
|
|
|
* the map cannot be resolved and this native will return false,
|
|
|
|
* but displayName will be a copy of map.
|
|
|
|
* @param maxlen Maximum length to write to displayName var.
|
|
|
|
* @return true if FindMap returns FindMap_Found, FindMap_FuzzyMatch, or
|
|
|
|
* FindMap_NonCanonical.
|
|
|
|
* false if FindMap returns FindMap_PossiblyAvailable or FindMap_NotFound.
|
2016-08-23 15:34:00 +02:00
|
|
|
*/
|
|
|
|
native bool GetMapDisplayName(const char[] map, char[] displayName, int maxlen);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the server is dedicated.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return True if dedicated, false otherwise.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native bool IsDedicatedServer();
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a high-precision time value for profiling the engine.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return A floating point time value.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native float GetEngineTime();
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
/**
|
2008-10-04 22:59:11 +02:00
|
|
|
* Returns the game time based on the game tick.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return Game tick time.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native float GetGameTime();
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
/**
|
2014-07-30 11:03:42 +02:00
|
|
|
* Returns the game's internal tick count.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return Game tick count.
|
2014-07-30 11:03:42 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int GetGameTickCount();
|
2014-07-30 11:03:42 +02:00
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
/**
|
|
|
|
* Returns the time the Game took processing the last frame.
|
|
|
|
*
|
|
|
|
* @return Game frame time.
|
|
|
|
*/
|
|
|
|
native float GetGameFrameTime();
|
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
/**
|
|
|
|
* Returns the game description from the mod.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param buffer Buffer to store the description.
|
|
|
|
* @param maxlength Maximum size of the buffer.
|
|
|
|
* @param original If true, retrieves the original game description,
|
|
|
|
* ignoring any potential hooks from plugins.
|
|
|
|
* @return Number of bytes written to the buffer (UTF-8 safe).
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int GetGameDescription(char[] buffer, int maxlength, bool original=false);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the name of the game's directory.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param buffer Buffer to store the directory name.
|
|
|
|
* @param maxlength Maximum size of the buffer.
|
|
|
|
* @return Number of bytes written to the buffer (UTF-8 safe).
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int GetGameFolderName(char[] buffer, int maxlength);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current map name.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param buffer Buffer to store map name.
|
|
|
|
* @param maxlength Maximum length of buffer.
|
|
|
|
* @return Number of bytes written (UTF-8 safe).
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int GetCurrentMap(char[] buffer, int maxlength);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Precaches a given model.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param model Name of the model to precache.
|
|
|
|
* @param preload If preload is true the file will be precached before level startup.
|
|
|
|
* @return Returns the model index, 0 for error.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int PrecacheModel(const char[] model, bool preload=false);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Precaches a given sentence file.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param file Name of the sentence file to precache.
|
|
|
|
* @param preload If preload is true the file will be precached before level startup.
|
|
|
|
* @return Returns a sentence file index.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int PrecacheSentenceFile(const char[] file, bool preload=false);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Precaches a given decal.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param decal Name of the decal to precache.
|
|
|
|
* @param preload If preload is true the file will be precached before level startup.
|
|
|
|
* @return Returns a decal index.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int PrecacheDecal(const char[] decal, bool preload=false);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Precaches a given generic file.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param generic Name of the generic file to precache.
|
|
|
|
* @param preload If preload is true the file will be precached before level startup.
|
|
|
|
* @return Returns a generic file index.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int PrecacheGeneric(const char[] generic, bool preload=false);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if a given model is precached.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param model Name of the model to check.
|
|
|
|
* @return True if precached, false otherwise.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native bool IsModelPrecached(const char[] model);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if a given decal is precached.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param decal Name of the decal to check.
|
|
|
|
* @return True if precached, false otherwise.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native bool IsDecalPrecached(const char[] decal);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if a given generic file is precached.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param generic Name of the generic file to check.
|
|
|
|
* @return True if precached, false otherwise.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native bool IsGenericPrecached(const char[] generic);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Precaches a given sound.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param sound Name of the sound to precache.
|
|
|
|
* @param preload If preload is true the file will be precached before level startup.
|
|
|
|
* @return True if successfully precached, false otherwise.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native bool PrecacheSound(const char[] sound, bool preload=false);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if a given sound is precached.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param sound Name of the sound to check.
|
|
|
|
* @return True if precached, false otherwise.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native bool IsSoundPrecached(const char[] sound);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates different types of ingame messages.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Index of the client.
|
|
|
|
* @param kv KeyValues handle to set the menu keys and options. (Check iserverplugin.h for more information).
|
|
|
|
* @param type Message type to display ingame.
|
|
|
|
* @error Invalid client index, or client not connected.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native void CreateDialog(int client, Handle kv, DialogType type);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Guesses the SDK version a mod was compiled against. If nothing
|
2008-10-04 22:59:11 +02:00
|
|
|
* specific is known about the game, the engine version is used instead.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* The return values are guaranteed to increase chronologically (that is,
|
2008-10-04 22:59:11 +02:00
|
|
|
* a later release will have a higher value).
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return SOURCE_SDK version code.
|
|
|
|
* @deprecated See GetEngineVersion()
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2014-07-30 11:03:42 +02:00
|
|
|
#pragma deprecated See GetEngineVersion()
|
2016-08-23 15:34:00 +02:00
|
|
|
native int GuessSDKVersion();
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2014-07-30 11:03:42 +02:00
|
|
|
/**
|
|
|
|
* Gets the engine version that the currently-loaded SM core was compiled against.
|
|
|
|
*
|
|
|
|
* The engine version values are not guaranteed to be in any particular order,
|
|
|
|
* and should only be compared by (in)equality.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return An EngineVersion value.
|
2014-07-30 11:03:42 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native EngineVersion GetEngineVersion();
|
2014-07-30 11:03:42 +02:00
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
/**
|
|
|
|
* Prints a message to a specific client in the chat area.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index.
|
|
|
|
* @param format Formatting rules.
|
|
|
|
* @param ... Variable number of format parameters.
|
|
|
|
* @error If the client is not connected an error will be thrown.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native void PrintToChat(int client, const char[] format, any ...);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints a message to all clients in the chat area.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param format Formatting rules.
|
|
|
|
* @param ... Variable number of format parameters.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
stock void PrintToChatAll(const char[] format, any ...)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2016-08-23 15:34:00 +02:00
|
|
|
char buffer[254];
|
2019-09-27 13:14:44 +02:00
|
|
|
|
2016-08-23 15:34:00 +02:00
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
if (IsClientInGame(i))
|
|
|
|
{
|
|
|
|
SetGlobalTransTarget(i);
|
|
|
|
VFormat(buffer, sizeof(buffer), format, 2);
|
|
|
|
PrintToChat(i, "%s", buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints a message to a specific client in the center of the screen.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index.
|
|
|
|
* @param format Formatting rules.
|
|
|
|
* @param ... Variable number of format parameters.
|
|
|
|
* @error If the client is not connected an error will be thrown.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native void PrintCenterText(int client, const char[] format, any ...);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints a message to all clients in the center of the screen.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param format Formatting rules.
|
|
|
|
* @param ... Variable number of format parameters.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
stock void PrintCenterTextAll(const char[] format, any ...)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2016-08-23 15:34:00 +02:00
|
|
|
char buffer[254];
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2016-08-23 15:34:00 +02:00
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
if (IsClientInGame(i))
|
|
|
|
{
|
|
|
|
SetGlobalTransTarget(i);
|
|
|
|
VFormat(buffer, sizeof(buffer), format, 2);
|
|
|
|
PrintCenterText(i, "%s", buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints a message to a specific client with a hint box.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index.
|
|
|
|
* @param format Formatting rules.
|
|
|
|
* @param ... Variable number of format parameters.
|
|
|
|
* @error If the client is not connected an error will be thrown.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native void PrintHintText(int client, const char[] format, any ...);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints a message to all clients with a hint box.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param format Formatting rules.
|
|
|
|
* @param ... Variable number of format parameters.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
stock void PrintHintTextToAll(const char[] format, any ...)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2016-08-23 15:34:00 +02:00
|
|
|
char buffer[254];
|
2019-09-27 13:14:44 +02:00
|
|
|
|
2016-08-23 15:34:00 +02:00
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
if (IsClientInGame(i))
|
|
|
|
{
|
|
|
|
SetGlobalTransTarget(i);
|
|
|
|
VFormat(buffer, sizeof(buffer), format, 2);
|
|
|
|
PrintHintText(i, "%s", buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows a VGUI panel to a specific client.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index.
|
|
|
|
* @param name Panel type name (Check viewport_panel_names.h to see a list of
|
|
|
|
* some panel names).
|
|
|
|
* @param Kv KeyValues handle with all the data for the panel setup (Depends
|
|
|
|
* on the panel type and may be unused).
|
|
|
|
* @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.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native void ShowVGUIPanel(int client, const char[] name, Handle Kv=INVALID_HANDLE, bool show=true);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Creates a HUD synchronization object. This object is used to automatically assign and
|
|
|
|
* re-use channels for a set of messages.
|
2008-10-04 22:59:11 +02:00
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* The HUD has a hardcoded number of channels (usually 6) for displaying
|
|
|
|
* text. You can use any channel for any area of the screen. Text on
|
|
|
|
* different channels can overlap, but text on the same channel will
|
2008-10-04 22:59:11 +02:00
|
|
|
* erase the old text first. This overlapping and overwriting gets problematic.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* A HUD synchronization object automatically selects channels for you based on
|
2008-10-04 22:59:11 +02:00
|
|
|
* the following heuristics:
|
2019-09-27 13:14:44 +02:00
|
|
|
* - If channel X was last used by the object, and hasn't been modified again,
|
2008-10-04 22:59:11 +02:00
|
|
|
* channel X gets re-used.
|
|
|
|
* - Otherwise, a new channel is chosen based on the least-recently-used channel.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* This ensures that if you display text on a sync object, that the previous text
|
|
|
|
* displayed on it will always be cleared first. This is because your new text
|
|
|
|
* will either overwrite the old text on the same channel, or because another
|
2008-10-04 22:59:11 +02:00
|
|
|
* channel has already erased your text.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* Note that messages can still overlap if they are on different synchronization
|
2008-10-04 22:59:11 +02:00
|
|
|
* objects, or they are displayed to manual channels.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* These are particularly useful for displaying repeating or refreshing HUD text, in
|
|
|
|
* addition to displaying multiple message sets in one area of the screen (for example,
|
|
|
|
* center-say messages that may pop up randomly that you don't want to overlap each
|
2008-10-04 22:59:11 +02:00
|
|
|
* other).
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return New HUD synchronization object.
|
|
|
|
* The Handle can be closed with CloseHandle().
|
|
|
|
* If HUD text is not supported on this mod, then
|
|
|
|
* INVALID_HANDLE is returned.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native Handle CreateHudSynchronizer();
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Sets the HUD parameters for drawing text. These parameters are stored
|
|
|
|
* globally, although nothing other than this function and SetHudTextParamsEx
|
2008-10-04 22:59:11 +02:00
|
|
|
* modify them.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* You must call this function before drawing text. If you are drawing
|
|
|
|
* text to multiple clients, you can set the parameters once, since
|
|
|
|
* they won't be modified. However, as soon as you pass control back
|
2008-10-04 22:59:11 +02:00
|
|
|
* to other plugins, you must reset the parameters next time you draw.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @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 holdTime Number of seconds to hold the text.
|
|
|
|
* @param r Red color value.
|
|
|
|
* @param g Green color value.
|
|
|
|
* @param b Blue color value.
|
|
|
|
* @param a Alpha transparency value.
|
|
|
|
* @param effect 0/1 causes the text to fade in and fade out.
|
|
|
|
* 2 causes the text to flash[?].
|
|
|
|
* @param fxTime Duration of chosen effect (may not apply to all effects).
|
|
|
|
* @param fadeIn Number of seconds to spend fading in.
|
|
|
|
* @param fadeOut Number of seconds to spend fading out.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
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);
|
2019-09-27 13:14:44 +02:00
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Sets the HUD parameters for drawing text. These parameters are stored
|
2008-10-04 22:59:11 +02:00
|
|
|
* globally, although nothing other than this function and SetHudTextParams
|
|
|
|
* modify them.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* This is the same as SetHudTextParams(), except it lets you set the alternate
|
|
|
|
* color for when effects require it.
|
|
|
|
*
|
|
|
|
* @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 holdTime Number of seconds to hold the text.
|
|
|
|
* @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 effect 0/1 causes the text to fade in and fade out.
|
|
|
|
* 2 causes the text to flash[?].
|
|
|
|
* @param fxTime Duration of chosen effect (may not apply to all effects).
|
|
|
|
* @param fadeIn Number of seconds to spend fading in.
|
|
|
|
* @param fadeOut Number of seconds to spend fading out.
|
|
|
|
*/
|
|
|
|
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,
|
2016-08-23 15:34:00 +02:00
|
|
|
float fadeIn=0.1, float fadeOut=0.2);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Shows a synchronized HUD message to a client.
|
2008-10-04 22:59:11 +02:00
|
|
|
*
|
|
|
|
* As of this writing, only TF, HL2MP, and SourceForts support HUD Text.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index to send the message to.
|
|
|
|
* @param sync Synchronization object.
|
|
|
|
* @param message Message text or formatting rules.
|
|
|
|
* @param ... Message formatting parameters.
|
|
|
|
* @return -1 on failure, anything else on success.
|
|
|
|
* This function fails if the mod does not support it.
|
|
|
|
* @error Client not in-game, or sync object not valid.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int ShowSyncHudText(int client, Handle sync, const char[] message, any ...);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-27 13:14:44 +02:00
|
|
|
* Clears the text on a synchronized HUD channel.
|
2008-10-04 22:59:11 +02:00
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* This is not the same as sending "" because it guarantees that it won't
|
|
|
|
* overwrite text on another channel. For example, consider the scenario:
|
2008-10-04 22:59:11 +02:00
|
|
|
*
|
|
|
|
* 1. Your synchronized message goes to channel 3.
|
|
|
|
* 2. Someone else's non-synchronized message goes to channel 3.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* If you were to simply send "" on your synchronized message,
|
2008-10-04 22:59:11 +02:00
|
|
|
* then someone else's text could be overwritten.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index to send the message to.
|
|
|
|
* @param sync Synchronization object.
|
|
|
|
* @error Client not in-game, or sync object not valid.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native void ClearSyncHud(int client, Handle sync);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows a HUD message to a client on the given channel.
|
|
|
|
*
|
|
|
|
* As of this writing, only TF, HL2MP, and SourceForts support HUD Text.
|
2019-09-27 13:14:44 +02:00
|
|
|
*
|
|
|
|
* @param client Client index to send the message to.
|
|
|
|
* @param channel A channel number.
|
|
|
|
* If -1, then a channel will automatically be selected
|
|
|
|
* based on the least-recently-used channel. If the
|
|
|
|
* channel is any other number, it will be modulo'd with
|
|
|
|
* the channel count to get a final channel number.
|
|
|
|
* @param message Message text or formatting rules.
|
|
|
|
* @param ... Message formatting parameters.
|
|
|
|
* @return -1 on failure (lack of mod support).
|
|
|
|
* Any other return value is the channel number that was
|
|
|
|
* used to render the text.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int ShowHudText(int client, int channel, const char[] message, any ...);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows a MOTD panel to a specific client.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index.
|
|
|
|
* @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
|
|
|
|
* 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.
|
|
|
|
* @error If the client is not connected an error will be thrown.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
stock void ShowMOTDPanel(int client, const char[] title, const char[] msg, int type=MOTDPANEL_TYPE_INDEX)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2015-03-21 15:43:24 +01:00
|
|
|
char num[3];
|
2008-10-04 22:59:11 +02:00
|
|
|
IntToString(type, num, sizeof(num));
|
|
|
|
|
2015-03-21 15:43:24 +01:00
|
|
|
KeyValues kv = new KeyValues("data");
|
|
|
|
kv.SetString("title", title);
|
|
|
|
kv.SetString("type", num);
|
|
|
|
kv.SetString("msg", msg);
|
|
|
|
ShowVGUIPanel(client, "info", kv);
|
|
|
|
delete kv;
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a panel asking the client to connect to a specified IP.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param client Client index.
|
|
|
|
* @param time Duration to hold the panel on the client's screen.
|
|
|
|
* @param ip Destination IP.
|
|
|
|
* @param password Password to connect to the destination IP. The client will be able to see this.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
stock void DisplayAskConnectBox(int client, float time, const char[] ip, const char[] password = "")
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2015-03-21 15:43:24 +01:00
|
|
|
char destination[288];
|
2014-07-30 11:03:42 +02:00
|
|
|
FormatEx(destination, sizeof(destination), "%s/%s", ip, password);
|
2015-03-21 15:43:24 +01:00
|
|
|
|
|
|
|
KeyValues kv = new KeyValues("data");
|
|
|
|
kv.SetFloat("time", time);
|
|
|
|
kv.SetString("title", destination);
|
|
|
|
CreateDialog(client, kv, DialogType_AskConnect);
|
|
|
|
delete kv;
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
2010-07-25 20:58:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts an entity index into a serial encoded entity reference.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param entity Entity index.
|
|
|
|
* @return Entity reference.
|
2010-07-25 20:58:18 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int EntIndexToEntRef(int entity);
|
2010-07-25 20:58:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the entity index from a reference.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param ref Entity reference.
|
|
|
|
* @return Entity index.
|
2010-07-25 20:58:18 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int EntRefToEntIndex(int ref);
|
2010-07-25 20:58:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a reference into a backwards compatible version.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param ref Entity reference.
|
|
|
|
* @return Bcompat reference.
|
2010-07-25 20:58:18 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int MakeCompatEntRef(int ref);
|
2010-07-25 20:58:18 +02:00
|
|
|
|
2015-03-21 15:43:24 +01:00
|
|
|
enum ClientRangeType
|
|
|
|
{
|
|
|
|
RangeType_Visibility = 0,
|
2019-09-27 13:14:44 +02:00
|
|
|
RangeType_Audibility
|
2015-03-21 15:43:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find clients that are potentially in range of a position.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param origin Coordinates from which to test range.
|
|
|
|
* @param rangeType Range type to use for filtering clients.
|
|
|
|
* @param clients Array to which found client indexes will be written.
|
|
|
|
* @param size Maximum size of clients array.
|
|
|
|
* @return Number of client indexes written to clients array.
|
2015-03-21 15:43:24 +01:00
|
|
|
*/
|
|
|
|
native int GetClientsInRange(float origin[3], ClientRangeType rangeType, int[] clients, int size);
|
|
|
|
|
2016-08-23 15:34:00 +02:00
|
|
|
/**
|
|
|
|
* Retrieves the server's authentication string (SteamID).
|
|
|
|
*
|
|
|
|
* Note: If called before server is connected to Steam, auth id
|
|
|
|
* will be invalid ([I:0:1], 1, etc.)
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param authType Auth id type and format to use.
|
|
|
|
* (Only AuthId_Steam3 and AuthId_SteamID64 are supported)
|
|
|
|
* @param auth Buffer to store the server's auth id.
|
|
|
|
* @param maxlen Maximum length of string buffer (includes NULL terminator).
|
|
|
|
* @error Invalid AuthIdType given.
|
2016-08-23 15:34:00 +02:00
|
|
|
*/
|
|
|
|
native void GetServerAuthId(AuthIdType authType, char[] auth, int maxlen);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the server's Steam account ID.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return Steam account ID or 0 if not available.
|
2016-08-23 15:34:00 +02:00
|
|
|
*/
|
|
|
|
native int GetServerSteamAccountId();
|