2007-06-01 08:33:54 +02:00
|
|
|
/**
|
|
|
|
* vim: set ts=4 :
|
|
|
|
* ===============================================================
|
|
|
|
* SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
|
|
|
|
* ===============================================================
|
|
|
|
*
|
|
|
|
* This file is part of the SourceMod/SourcePawn SDK. This file may only be used
|
|
|
|
* or modified under the Terms and Conditions of its License Agreement, which is found
|
|
|
|
* in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins
|
|
|
|
* may change at any time. To view the latest information, see:
|
|
|
|
* http://www.sourcemod.net/license.php
|
|
|
|
*
|
|
|
|
* Version: $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined _halflife_included
|
|
|
|
#endinput
|
|
|
|
#endif
|
|
|
|
#define _halflife_included
|
|
|
|
|
|
|
|
enum DialogType
|
|
|
|
{
|
|
|
|
DialogType_Msg = 0, /**< just an on screen message */
|
|
|
|
DialogType_Menu, /**< an options menu */
|
|
|
|
DialogType_Text, /**< a richtext dialog */
|
|
|
|
DialogType_Entry /**< an entry box */
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logs a generic message to the HL2 logs.
|
|
|
|
*
|
|
|
|
* @param format String format.
|
|
|
|
* @param ... Format arguments.
|
|
|
|
* @noreturn
|
|
|
|
*/
|
|
|
|
native LogToGame(const String:format[], any:...);
|
|
|
|
|
|
|
|
/**
|
2007-06-22 19:25:19 +02:00
|
|
|
* Sets the seed value for the global Half-Life 2 Random Stream.
|
2007-06-01 08:33:54 +02:00
|
|
|
*
|
|
|
|
* @param seed Seed value.
|
|
|
|
* @noreturn
|
|
|
|
*/
|
|
|
|
native SetRandomSeed(seed);
|
|
|
|
|
|
|
|
/**
|
2007-06-22 19:25:19 +02:00
|
|
|
* Returns a random floating point number from the Half-Life 2 Random Stream.
|
2007-06-01 08:33:54 +02:00
|
|
|
*
|
|
|
|
* @param fMin Minimum random bound.
|
|
|
|
* @param fMax Maximum random bound.
|
|
|
|
* @return A random number between (inclusive) fMin and fMax.
|
|
|
|
*/
|
|
|
|
native Float:GetRandomFloat(Float:fMin=0.0, Float:fMax=1.0);
|
|
|
|
|
|
|
|
/**
|
2007-06-22 19:25:19 +02:00
|
|
|
* Returns a random number from the Half-Life 2 Random Stream.
|
2007-06-01 08:33:54 +02:00
|
|
|
*
|
|
|
|
* @param nmin Minimum random bound.
|
|
|
|
* @param nmax Maximum random bound.
|
|
|
|
* @return A random number between (inclusive) nmin and nmax.
|
|
|
|
*/
|
|
|
|
native GetRandomInt(nmin, nmax);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether a map is valid or not.
|
|
|
|
*
|
|
|
|
* @param Map name, excluding .bsp extension.
|
|
|
|
* @return True if valid, false otherwise.
|
|
|
|
*/
|
|
|
|
native bool:IsMapValid(const String:map[]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the server is dedicated.
|
|
|
|
*
|
|
|
|
* @return True if dedicated, false otherwise.
|
|
|
|
*/
|
|
|
|
native bool:IsDedicatedServer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a high-precision time value for profiling the engine.
|
|
|
|
*
|
|
|
|
* @return A floating point time value.
|
|
|
|
*/
|
|
|
|
native Float:GetEngineTime();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the game time based on the game tick.
|
|
|
|
*
|
|
|
|
* @return Game tick time.
|
|
|
|
*/
|
|
|
|
native Float:GetGameTime();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the game description from the mod.
|
|
|
|
*
|
|
|
|
* @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).
|
|
|
|
*/
|
|
|
|
native GetGameDescription(String:buffer[], maxlength, bool:original=false);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the name of the game's directory.
|
|
|
|
*
|
|
|
|
* @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).
|
|
|
|
*/
|
|
|
|
native GetGameFolderName(String:buffer[], maxlength);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current map name.
|
|
|
|
*
|
|
|
|
* @param buffer Buffer to store map name.
|
|
|
|
* @param maxlength Maximum length of buffer.
|
|
|
|
* @return Number of bytes written (UTF-8 safe).
|
|
|
|
*/
|
|
|
|
native GetCurrentMap(String:buffer[], maxlength);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Precaches a given model.
|
|
|
|
*
|
|
|
|
* @param model Name of the model to precache.
|
|
|
|
* @param preload If preload is true the file will be precached before level startup.
|
2007-06-06 22:51:17 +02:00
|
|
|
* @return Returns the model index, 0 for error.
|
2007-06-01 08:33:54 +02:00
|
|
|
*/
|
|
|
|
native PrecacheModel(const String:model[], bool:preload=false);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Precaches a given sentence file.
|
|
|
|
*
|
|
|
|
* @param file Name of the sentence file to precache.
|
|
|
|
* @param preload If preload is true the file will be precached before level startup.
|
2007-06-06 22:51:17 +02:00
|
|
|
* @return Returns a sentence file index.
|
2007-06-01 08:33:54 +02:00
|
|
|
*/
|
|
|
|
native PrecacheSentenceFile(const String:file[], bool:preload=false);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Precaches a given decal.
|
|
|
|
*
|
|
|
|
* @param decal Name of the decal to precache.
|
|
|
|
* @param preload If preload is true the file will be precached before level startup.
|
2007-06-06 22:51:17 +02:00
|
|
|
* @return Returns a decal index.
|
2007-06-01 08:33:54 +02:00
|
|
|
*/
|
|
|
|
native PrecacheDecal(const String:decal[], bool:preload=false);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Precaches a given generic file.
|
|
|
|
*
|
|
|
|
* @param generic Name of the generic file to precache.
|
|
|
|
* @param preload If preload is true the file will be precached before level startup.
|
2007-06-06 22:51:17 +02:00
|
|
|
* @return Returns a generic file index.
|
2007-06-01 08:33:54 +02:00
|
|
|
*/
|
|
|
|
native PrecacheGeneric(const String:generic[], bool:preload=false);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if a given model is precached.
|
|
|
|
*
|
|
|
|
* @param model Name of the model to check.
|
2007-06-06 22:51:17 +02:00
|
|
|
* @return True if precached, false otherwise.
|
2007-06-01 08:33:54 +02:00
|
|
|
*/
|
|
|
|
native bool:IsModelPrecached(const String:model[]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if a given decal is precached.
|
|
|
|
*
|
|
|
|
* @param decal Name of the decal to check.
|
2007-06-06 22:51:17 +02:00
|
|
|
* @return True if precached, false otherwise.
|
2007-06-01 08:33:54 +02:00
|
|
|
*/
|
|
|
|
native bool:IsDecalPrecached(const String:decal[]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if a given generic file is precached.
|
|
|
|
*
|
|
|
|
* @param decal Name of the generic file to check.
|
2007-06-06 22:51:17 +02:00
|
|
|
* @return True if precached, false otherwise.
|
2007-06-01 08:33:54 +02:00
|
|
|
*/
|
|
|
|
native bool:IsGenericPrecached(const String:generic[]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Precaches a given sound.
|
|
|
|
*
|
|
|
|
* @param sound Name of the sound to precache.
|
|
|
|
* @param preload If preload is true the file will be precached before level startup.
|
2007-06-06 22:51:17 +02:00
|
|
|
* @return True if successfully precached, false otherwise.
|
2007-06-01 08:33:54 +02:00
|
|
|
*/
|
|
|
|
native bool:PrecacheSound(const String:sound[], bool:preload=false);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if a given sound is precached.
|
|
|
|
*
|
|
|
|
* @param sound Name of the sound to check.
|
2007-06-06 22:51:17 +02:00
|
|
|
* @return True if precached, false otherwise.
|
2007-06-01 08:33:54 +02:00
|
|
|
*/
|
|
|
|
native bool:IsSoundPrecached(const String:sound[]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates different types of ingame messages.
|
|
|
|
*
|
|
|
|
* @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.
|
|
|
|
* @noreturn
|
|
|
|
* @error Invalid client index, or client not connected.
|
|
|
|
*/
|
|
|
|
native CreateDialog(client, Handle:kv, DialogType:type);
|
|
|
|
|
|
|
|
/**
|
2007-06-06 22:51:17 +02:00
|
|
|
* Prints a message to a specific client in the chat area.
|
2007-06-01 08:33:54 +02:00
|
|
|
*
|
2007-06-06 22:51:17 +02:00
|
|
|
* @param client Client index.
|
2007-06-01 08:33:54 +02:00
|
|
|
* @param format Formatting rules.
|
|
|
|
* @param ... Variable number of format parameters.
|
|
|
|
* @noreturn
|
|
|
|
* @error If the client is not connected an error will be thrown.
|
|
|
|
*/
|
|
|
|
native PrintToChat(client, const String:format[], any:...);
|
|
|
|
|
|
|
|
/**
|
2007-06-06 22:51:17 +02:00
|
|
|
* Prints a message to all clients in the chat area.
|
2007-06-01 08:33:54 +02:00
|
|
|
*
|
2007-06-06 22:51:17 +02:00
|
|
|
* @param format Formatting rules.
|
|
|
|
* @param ... Variable number of format parameters.
|
|
|
|
* @noreturn
|
|
|
|
*/
|
|
|
|
stock PrintToChatAll(const String:format[], any:...)
|
|
|
|
{
|
2007-06-07 09:36:41 +02:00
|
|
|
new maxClients = GetMaxClients();
|
2007-06-07 04:04:05 +02:00
|
|
|
decl String:buffer[192];
|
2007-06-06 22:51:17 +02:00
|
|
|
|
2007-06-07 09:36:41 +02:00
|
|
|
for (new i = 1; i <= maxClients; i++)
|
2007-06-06 22:51:17 +02:00
|
|
|
{
|
|
|
|
if (IsClientInGame(i))
|
|
|
|
{
|
2007-07-03 22:16:40 +02:00
|
|
|
SetGlobalTransTarget(i);
|
|
|
|
VFormat(buffer, sizeof(buffer), format, 2);
|
2007-06-06 22:51:17 +02:00
|
|
|
PrintToChat(i, "%s", buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints a message to a specific client in the center of the screen.
|
|
|
|
*
|
|
|
|
* @param client Client index.
|
2007-06-01 08:33:54 +02:00
|
|
|
* @param format Formatting rules.
|
|
|
|
* @param ... Variable number of format parameters.
|
|
|
|
* @noreturn
|
|
|
|
* @error If the client is not connected an error will be thrown.
|
|
|
|
*/
|
|
|
|
native PrintCenterText(client, const String:format[], any:...);
|
2007-06-06 22:51:17 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints a message to all clients in the center of the screen.
|
|
|
|
*
|
|
|
|
* @param format Formatting rules.
|
|
|
|
* @param ... Variable number of format parameters.
|
|
|
|
* @noreturn
|
|
|
|
*/
|
|
|
|
stock PrintCenterTextAll(const String:format[], any:...)
|
|
|
|
{
|
2007-06-07 09:36:41 +02:00
|
|
|
new maxClients = GetMaxClients();
|
2007-06-07 04:04:05 +02:00
|
|
|
decl String:buffer[192];
|
2007-06-06 22:51:17 +02:00
|
|
|
|
|
|
|
VFormat(buffer, sizeof(buffer), format, 2);
|
|
|
|
|
2007-06-07 09:36:41 +02:00
|
|
|
for (new i = 1; i <= maxClients; i++)
|
2007-06-06 22:51:17 +02:00
|
|
|
{
|
|
|
|
if (IsClientInGame(i))
|
|
|
|
{
|
|
|
|
PrintCenterText(i, "%s", buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|