plugins/include/sourcemod.inc
author Borja Ferrer <faluco@alliedmods.net>
Sun Mar 11 19:26:47 2007 +0000 (2007-03-11)
changeset 597 2309b109e2af
parent 595 1d8e56a119f2
child 601 fe5b368fcedc
permissions -rw-r--r--
user messages tested and working
fixed some floating point casts
     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 _sourcemod_included
    17  #endinput
    18 #endif
    19 #define _sourcemod_included
    20 
    21 struct Plugin
    22 {
    23    const String:name[],			/* Plugin Name */
    24    const String:description[],	/* Plugin Description */
    25    const String:author[],		/* Plugin Author */
    26    const String:version[],		/* Plugin Version */
    27    const String:url[],			/* Plugin URL */
    28 };
    29 
    30 #include <core>
    31 #include <float>
    32 #include <handles>
    33 #include <string>
    34 #include <admin>
    35 #include <files>
    36 #include <console>
    37 #include <bitbuffer>
    38 #include <sorting>
    39 #include <clients>
    40 #include <usermessages>
    41 #include <events>
    42 
    43 /**
    44  * Declare this as a struct in your plugin to expose its information.
    45  * Example:
    46  *
    47  * public Plugin:myinfo =
    48  * {
    49  *    name = "My Plugin",
    50  *    //etc
    51  * };
    52  */
    53 public Plugin:myinfo;
    54  
    55 /**
    56  * Called when the plugin is fully initialized and all known external references are resolved.
    57  * This is called even if the plugin type is "private."
    58  * NOTE: Errors in this function will cause the plugin to stop running.
    59  *
    60  * @noreturn
    61  */
    62 forward OnPluginStart();
    63  
    64 /**
    65  *   Called before OnPluginStart, in case the plugin wants to check for load failure.
    66  * This is called even if the plugin type is "private."  Any natives from modules are 
    67  * not available at this point.  Thus, this forward should only be used for explicit 
    68  * pre-emptive things, such as adding dynamic natives, or setting certain types of load filters.
    69  * 
    70  * NOTE: It is not safe to call externally resolved natives until OnPluginStart().
    71  * NOTE: Any sort of RTE in this function will cause the plugin to fail loading.
    72  *
    73  * @param myself	Handle to the plugin.
    74  * @param late		Whether or not the plugin was loaded "late" (after map load).
    75  * @param error		Error message buffer in case load failed.
    76  * @param err_max	Maximum number of characters for error message buffer.
    77  * @return			True if load success, false otherwise.
    78  */
    79 forward bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max);
    80 
    81 /**
    82  * Called when the plugin is about to be unloaded.
    83  *
    84  * @noreturn
    85  */
    86 forward OnPluginEnd();
    87 
    88 /**
    89  * Called when the plugin's pause status is changing.
    90  *
    91  * @param pause			True if the plugin is being paused, false otherwise.
    92  * @noreturn
    93  */
    94 forward OnPluginPauseChange(bool:pause);
    95 
    96 /**
    97  * Called before every server frame.  Note that you should avoid
    98  * doing expensive computations here, and you should declare large
    99  * local arrays using 'decl' instead of 'new'.
   100  */
   101 forward OnGameFrame();
   102 
   103 /**
   104  * Returns the calling plugin's Handle.
   105  *
   106  * @return				Handle of the calling plugin.
   107  */
   108 native Handle:GetMyHandle();
   109 
   110 
   111 /**
   112  * Aborts the current callback and throws an error.  This function
   113  * does not return in that no code is executed following it.
   114  *
   115  * @param format		String format.
   116  * @param ...			Format arguments.
   117  * @noreturn
   118  * @error				Always!
   119  */
   120 native ThrowError(const String:fmt[], {Handle,Float,String,_}:...);
   121 
   122 /**
   123  * Logs a generic message to the HL2 logs.
   124  *
   125  * @param format		String format.
   126  * @param ...			Format arguments.
   127  * @noreturn
   128  */
   129 native LogToGame(const String:format[], {Handle,Float,String,_}:...);
   130 
   131 /**
   132  * Logs a plugin message to the SourceMod logs.
   133  *
   134  * @param format		String format.
   135  * @param ...			Format arguments.
   136  * @noreturn
   137  */
   138 native LogMessage(const String:format[], {Handle,Float,String,_}:...);
   139 
   140 /**
   141  * Logs a plugin error message to the SourceMod logs.
   142  *
   143  * @param format		String format.
   144  * @param ...			Format arguments.
   145  * @noreturn
   146  */
   147 native LogError(const String:format[], {Handle,Float,String,_}:...);
   148 
   149 /**
   150  * Gets the system time as a unix timestamp.
   151  *
   152  * @param bigStamp		Optional array to store the 64bit timestamp in.
   153  * @return				32bit timestamp (number of seconds since unix epoch).
   154  */
   155 native GetTime(bigStamp[2]={0,0});
   156 
   157 /**
   158  * Sets the seed value for the global Half-Life 2 Random Stream
   159  *
   160  * @param seed			Seed value.
   161  * @noreturn	
   162  */
   163 native SetRandomSeed(seed);
   164 
   165 /**
   166  * Returns a random floating point number from the Half-Life 2 Random Stream
   167  *
   168  * @param fMin			Minimum random bound.
   169  * @param fMax			Maximum random bound.
   170  * @return				A random number between (inclusive) fMin and fMax.
   171  */
   172 native Float:GetRandomFloat(Float:fMin=0.0, Float:fMax=1.0);
   173 
   174 /**
   175  * Returns a random number from the Half-Life 2 Random Stream
   176  *
   177  * @param nmin			Minimum random bound.
   178  * @param nmax			Maximum random bound.
   179  * @return				A random number between (inclusive) nmin and nmax.
   180  */
   181 native GetRandomInt(nmin, nmax);
   182 
   183 /**
   184  * Returns whether a map is valid or not.
   185  * 
   186  * @param 				Map name, excluding .bsp extension.
   187  * @return				True if valid, false otherwise.
   188  */
   189 native bool:IsMapValid(const String:map[]);
   190 
   191 /**
   192  * Returns whether the server is dedicated.
   193  *
   194  * @return				True if dedicated, false otherwise.
   195  */
   196 native bool:IsDedicatedServer();
   197 
   198 /**
   199  * Returns a high-precision time value for profiling the engine.
   200  *
   201  * @return				A floating point time value.
   202  */
   203 native Float:GetEngineTime();
   204 
   205 /** 
   206  * Returns the game time based on the game tick.
   207  *
   208  * @return				Game tick time.
   209  */
   210 native Float:GetGameTime();
   211 
   212 /**
   213  * Returns the game description from the mod.
   214  *
   215  * @param buffer		Buffer to store the description.
   216  * @param maxlength		Maximum size of the buffer.
   217  * @param original		If true, retrieves the original game description,
   218  *						ignoring any potential hooks from plugins.
   219  * @return				Number of bytes written to the buffer (UTF-8 safe).
   220  */
   221 native GetGameDescription(String:buffer[], maxlength, bool:original=false);
   222 
   223 /**
   224  * Returns the current map name.
   225  *
   226  * @param buffer		Buffer to store map name.
   227  * @param maxlength		Maximum length of buffer.
   228  * @return				Number of bytes written (UTF-8 safe).
   229  */
   230 native GetCurrentMap(String:buffer[], maxlength);
   231 
   232 #include <helpers>
   233 #include <entity>