plugins/include/halflife.inc
author Scott Ehlert <ds@alliedmods.net>
Fri Jun 01 06:33:54 2007 +0000 (2007-06-01)
changeset 873 a2136b3be10d
child 892 0702fda305f0
permissions -rw-r--r--
- Added natives: PrintToChat() and PrintCenterText()
- Bit of reorganization with moving some natives from sourcemod.inc to halflife.inc
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     7  *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
     8  * or modified under the Terms and Conditions of its License Agreement, which is found 
     9  * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    10  * may change at any time.  To view the latest information, see:
    11  *   http://www.sourcemod.net/license.php
    12  *
    13  * Version: $Id$
    14  */
    15 
    16 #if defined _halflife_included
    17  #endinput
    18 #endif
    19 #define _halflife_included
    20 
    21 enum DialogType
    22 {
    23 	DialogType_Msg = 0,		/**< just an on screen message */
    24 	DialogType_Menu, 		/**< an options menu */
    25 	DialogType_Text, 		/**< a richtext dialog */
    26 	DialogType_Entry 		/**< an entry box */
    27 };
    28 
    29 /**
    30  * Logs a generic message to the HL2 logs.
    31  *
    32  * @param format		String format.
    33  * @param ...			Format arguments.
    34  * @noreturn
    35  */
    36 native LogToGame(const String:format[], any:...);
    37 
    38 /**
    39  * Sets the seed value for the global Half-Life 2 Random Stream
    40  *
    41  * @param seed			Seed value.
    42  * @noreturn	
    43  */
    44 native SetRandomSeed(seed);
    45 
    46 /**
    47  * Returns a random floating point number from the Half-Life 2 Random Stream
    48  *
    49  * @param fMin			Minimum random bound.
    50  * @param fMax			Maximum random bound.
    51  * @return				A random number between (inclusive) fMin and fMax.
    52  */
    53 native Float:GetRandomFloat(Float:fMin=0.0, Float:fMax=1.0);
    54 
    55 /**
    56  * Returns a random number from the Half-Life 2 Random Stream
    57  *
    58  * @param nmin			Minimum random bound.
    59  * @param nmax			Maximum random bound.
    60  * @return				A random number between (inclusive) nmin and nmax.
    61  */
    62 native GetRandomInt(nmin, nmax);
    63 
    64 /**
    65  * Returns whether a map is valid or not.
    66  * 
    67  * @param 				Map name, excluding .bsp extension.
    68  * @return				True if valid, false otherwise.
    69  */
    70 native bool:IsMapValid(const String:map[]);
    71 
    72 /**
    73  * Returns whether the server is dedicated.
    74  *
    75  * @return				True if dedicated, false otherwise.
    76  */
    77 native bool:IsDedicatedServer();
    78 
    79 /**
    80  * Returns a high-precision time value for profiling the engine.
    81  *
    82  * @return				A floating point time value.
    83  */
    84 native Float:GetEngineTime();
    85 
    86 /** 
    87  * Returns the game time based on the game tick.
    88  *
    89  * @return				Game tick time.
    90  */
    91 native Float:GetGameTime();
    92 
    93 /**
    94  * Returns the game description from the mod.
    95  *
    96  * @param buffer		Buffer to store the description.
    97  * @param maxlength		Maximum size of the buffer.
    98  * @param original		If true, retrieves the original game description,
    99  *						ignoring any potential hooks from plugins.
   100  * @return				Number of bytes written to the buffer (UTF-8 safe).
   101  */
   102 native GetGameDescription(String:buffer[], maxlength, bool:original=false);
   103 
   104 /**
   105  * Returns the name of the game's directory.
   106  *
   107  * @param buffer		Buffer to store the directory name.
   108  * @param maxlength		Maximum size of the buffer.
   109  *
   110  * return				Number of bytes written to the buffer (UTF-8 safe).
   111  */
   112 native GetGameFolderName(String:buffer[], maxlength);
   113 
   114 /**
   115  * Returns the current map name.
   116  *
   117  * @param buffer		Buffer to store map name.
   118  * @param maxlength		Maximum length of buffer.
   119  * @return				Number of bytes written (UTF-8 safe).
   120  */
   121 native GetCurrentMap(String:buffer[], maxlength);
   122 
   123 /**
   124  * Precaches a given model.
   125  *
   126  * @param model			Name of the model to precache.
   127  * @param preload		If preload is true the file will be precached before level startup.
   128  * @return			Returns the model index, 0 for error.
   129  */
   130 native PrecacheModel(const String:model[], bool:preload=false);
   131 
   132 /**
   133  * Precaches a given sentence file.
   134  *
   135  * @param file			Name of the sentence file to precache.
   136  * @param preload		If preload is true the file will be precached before level startup.
   137  * @return			Returns a sentence file index.
   138  */
   139 native PrecacheSentenceFile(const String:file[], bool:preload=false);
   140 
   141 /**
   142  * Precaches a given decal.
   143  *
   144  * @param decal			Name of the decal to precache.
   145  * @param preload		If preload is true the file will be precached before level startup.
   146  * @return			Returns a decal index.
   147  */
   148 native PrecacheDecal(const String:decal[], bool:preload=false);
   149 
   150 /**
   151  * Precaches a given generic file.
   152  *
   153  * @param generic		Name of the generic file to precache.
   154  * @param preload		If preload is true the file will be precached before level startup.
   155  * @return			Returns a generic file index.
   156  */
   157 native PrecacheGeneric(const String:generic[], bool:preload=false);
   158 
   159 /**
   160  * Returns if a given model is precached.
   161  *
   162  * @param model			Name of the model to check.
   163  * @return			True if precached, false otherwise.
   164  */
   165 native bool:IsModelPrecached(const String:model[]);
   166 
   167 /**
   168  * Returns if a given decal is precached.
   169  *
   170  * @param decal			Name of the decal to check.
   171  * @return			True if precached, false otherwise.
   172  */
   173 native bool:IsDecalPrecached(const String:decal[]);
   174 
   175 /**
   176  * Returns if a given generic file is precached.
   177  *
   178  * @param decal			Name of the generic file to check.
   179  * @return			True if precached, false otherwise.
   180  */
   181 native bool:IsGenericPrecached(const String:generic[]);
   182 
   183 /**
   184  * Precaches a given sound.
   185  *
   186  * @param sound			Name of the sound to precache.
   187  * @param preload		If preload is true the file will be precached before level startup.
   188  * @return			True if successfully precached, false otherwise.
   189  */
   190 native bool:PrecacheSound(const String:sound[], bool:preload=false);
   191 
   192 /**
   193  * Returns if a given sound is precached.
   194  *
   195  * @param sound			Name of the sound to check.
   196  * @return			True if precached, false otherwise.
   197  */
   198 native bool:IsSoundPrecached(const String:sound[]);
   199 
   200 /**
   201  * Creates different types of ingame messages.
   202  *
   203  * @param client		Index of the client.
   204  * @param kv			KeyValues handle to set the menu keys and options. (Check iserverplugin.h for more information).
   205  * @param type			Message type to display ingame.
   206  * @noreturn
   207  * @error				Invalid client index, or client not connected.
   208  */
   209 native CreateDialog(client, Handle:kv, DialogType:type);
   210 
   211 /**
   212  * Prints a message in a client's chat area.
   213  *
   214  * @param client		Player index.
   215  * @param format		Formatting rules.
   216  * @param ...			Variable number of format parameters.
   217  * @noreturn
   218  * @error				If the client is not connected an error will be thrown.
   219  */
   220 native PrintToChat(client, const String:format[], any:...);
   221 
   222 /**
   223  * Prints a message in the center of a client's screen.
   224  *
   225  * @param client		Player index.
   226  * @param format		Formatting rules.
   227  * @param ...			Variable number of format parameters.
   228  * @noreturn
   229  * @error				If the client is not connected an error will be thrown.
   230  */
   231 native PrintCenterText(client, const String:format[], any:...);