plugins/include/sdktools_gamerules.inc
author Nicholas Hastings <skamonkey@gmail.com>
Fri Aug 10 21:54:03 2012 -0400 (2012-08-10)
changeset 3603 d3fd010be8fe
parent 3333 e247490894a1
child 3608 afa46954ccac
permissions -rw-r--r--
Merge.
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2011 AlliedModders LLC.  All rights reserved.
     5  * =============================================================================
     6  *
     7  * This file is part of the SourceMod/SourcePawn SDK.
     8  *
     9  * This program is free software; you can redistribute it and/or modify it under
    10  * the terms of the GNU General Public License, version 3.0, as published by the
    11  * Free Software Foundation.
    12  * 
    13  * This program is distributed in the hope that it will be useful, but WITHOUT
    14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    16  * details.
    17  *
    18  * You should have received a copy of the GNU General Public License along with
    19  * this program.  If not, see <http://www.gnu.org/licenses/>.
    20  *
    21  * As a special exception, AlliedModders LLC gives you permission to link the
    22  * code of this program (as well as its derivative works) to "Half-Life 2," the
    23  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    24  * by the Valve Corporation.  You must obey the GNU General Public License in
    25  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    26  * this exception to all derivative works.  AlliedModders LLC defines further
    27  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    28  * or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32 
    33 #if defined _sdktools_gamerules_included
    34   #endinput
    35 #endif
    36 #define _sdktools_gamerules_included
    37 
    38 enum RoundState {
    39 	// initialize the game, create teams
    40 	RoundState_Init,
    41 	
    42 	//Before players have joined the game. Periodically checks to see if enough players are ready
    43 	//to start a game. Also reverts to this when there are no active players
    44 	RoundState_Pregame,
    45 	
    46 	//The game is about to start, wait a bit and spawn everyone
    47 	RoundState_StartGame,
    48 	
    49 	//All players are respawned, frozen in place
    50 	RoundState_Preround,
    51 	
    52 	//Round is on, playing normally
    53 	RoundState_RoundRunning,
    54 	
    55 	//Someone has won the round
    56 	RoundState_TeamWin,
    57 	
    58 	//Noone has won, manually restart the game, reset scores
    59 	RoundState_Restart,
    60 	
    61 	//Noone has won, restart the game
    62 	RoundState_Stalemate,
    63 	
    64 	//Game is over, showing the scoreboard etc
    65 	RoundState_GameOver,
    66 	
    67 	//Game is over, doing bonus round stuff
    68 	RoundState_Bonus,
    69 };
    70 
    71 /**
    72  * Retrieves an integer value from a property of the gamerules entity.
    73  * 
    74  * @param prop			Property name.
    75  * @param size			Number of bytes to read (valid values are 1, 2, or 4).
    76  *						This value is auto-detected, and the size parameter is 
    77  *						only used as a fallback in case detection fails.
    78  * @param element		Element # (starting from 0) if property is an array.
    79  * @return				Value at the given property offset.
    80  * @error				Not supported.
    81  */
    82 native GameRules_GetProp(const String:prop[], size=4, element=0);
    83 
    84 /**
    85  * Sets an integer value for a property of the gamerules entity.
    86  *
    87  * @param prop			Property name.
    88  * @param value			Value to set.
    89  * @param size			Number of bytes to write (valid values are 1, 2, or 4).
    90  *						This value is auto-detected, and the size parameter is 
    91  *						only used as a fallback in case detection fails.
    92  * @param element		Element # (starting from 0) if property is an array.
    93  * @error				Not supported.
    94  * @noreturn
    95  */
    96 native GameRules_SetProp(const String:prop[], any:value, size=4, element=0, bool:changeState=false);
    97 
    98 /**
    99  * Retrieves a float value from a property of the gamerules entity.
   100  * 
   101  * @param prop			Property name.
   102  * @param element		Element # (starting from 0) if property is an array.
   103  * @return				Value at the given property offset.
   104  * @error				Not supported.
   105  */
   106 native Float:GameRules_GetPropFloat(const String:prop[], element=0);
   107 
   108 /**
   109  * Sets a float value for a property of the gamerules entity.
   110  * 
   111  * @param prop			Property name.
   112  * @param value			Value to set.
   113  * @param element		Element # (starting from 0) if property is an array.
   114  * @noreturn
   115  * @error				Not supported.
   116  */
   117 native GameRules_SetPropFloat(const String:prop[], Float:value, element=0, bool:changeState=false);
   118 
   119 /**
   120  * Retrieves a entity index from a property of the gamerules entity.
   121  * 
   122  * @param prop			Property name.
   123  * @param element		Element # (starting from 0) if property is an array.
   124  * @return				Entity index at the given property.
   125  *						If there is no entity, or the entity is not valid, 
   126  *						then -1 is returned.
   127  * @error				Not supported.
   128  */
   129 native GameRules_GetPropEnt(const String:prop[], element=0);
   130 
   131 /**
   132  * Sets an entity index for a property of the gamerules entity.
   133  * 
   134  * @param prop			Property name.
   135  * @param other			Entity index to set, or -1 to unset.
   136  * @param element		Element # (starting from 0) if property is an array.
   137  * @noreturn
   138  * @error				Not supported.
   139  */
   140 native GameRules_SetPropEnt(const String:prop[], other, element=0, bool:changeState=false);
   141 
   142 /**
   143  * Retrieves a vector of floats from the gamerules entity, given a named network property.
   144  * 
   145  * @param prop			Property name.
   146  * @param vec			Vector buffer to store data in.
   147  * @param element		Element # (starting from 0) if property is an array.
   148  * @noreturn
   149  * @error				Not supported.
   150  */
   151 native GameRules_GetPropVector(const String:prop[], Float:vec[3], element=0);
   152 
   153 /**
   154  * Sets a vector of floats in the gamerules entity, given a named network property.
   155  *
   156  * @param prop			Property name.
   157  * @param vec			Vector to set.
   158  * @param element		Element # (starting from 0) if property is an array.
   159  * @noreturn
   160  * @error				Not supported.
   161  */
   162 native GameRules_SetPropVector(const String:prop[], const Float:vec[3], element=0, bool:changeState=false);
   163 
   164 /**
   165  * Gets a gamerules property as a string.
   166  * 
   167  * @param prop			Property to use.
   168  * @param buffer		Destination string buffer.
   169  * @param maxlen		Maximum length of output string buffer.
   170  * @return				Number of non-null bytes written.
   171  * @error				Not supported.
   172  */
   173 native GameRules_GetPropString(const String:prop[], String:buffer[], maxlen);
   174 
   175 /**
   176  * Sets a gamerules property as a string.
   177  *
   178  * @param prop			Property to use.
   179  * @param buffer		String to set.		
   180  * @return				Number of non-null bytes written.
   181  * @error				Not supported.
   182  */
   183 native GameRules_SetPropString(const String:prop[], const String:buffer[], bool:changeState=false);
   184 
   185 /**
   186  * Gets the current round state.
   187  *
   188  * @return				Round state.
   189  * @error				Game doesn't support round state.
   190  */
   191 stock RoundState:GameRules_GetRoundState()
   192 {
   193 	return RoundState:GameRules_GetProp("m_iRoundState");
   194 }