plugins/include/sdktools_gamerules.inc
author Nicholas Hastings <skamonkey@gmail.com>
Sun Aug 25 11:01:55 2013 -0400 (2013-08-25)
changeset 4061 fffdcac63ac3
parent 3967 ceafb87d38a7
permissions -rw-r--r--
Add missing MarkNativeAsOptional calls for cstrike.inc (r=me).
     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 	//Between rounds
    71 	RoundState_BetweenRounds,
    72 };
    73 
    74 /**
    75  * Retrieves an integer value from a property of the gamerules entity.
    76  * 
    77  * @param prop			Property name.
    78  * @param size			Number of bytes to read (valid values are 1, 2, or 4).
    79  *						This value is auto-detected, and the size parameter is 
    80  *						only used as a fallback in case detection fails.
    81  * @param element		Element # (starting from 0) if property is an array.
    82  * @return				Value at the given property offset.
    83  * @error				Not supported.
    84  */
    85 native GameRules_GetProp(const String:prop[], size=4, element=0);
    86 
    87 /**
    88  * Sets an integer value for a property of the gamerules entity.
    89  *
    90  * @param prop			Property name.
    91  * @param value			Value to set.
    92  * @param size			Number of bytes to write (valid values are 1, 2, or 4).
    93  *						This value is auto-detected, and the size parameter is 
    94  *						only used as a fallback in case detection fails.
    95  * @param element		Element # (starting from 0) if property is an array.
    96  * @param changeState	If true, change will be sent over the network.
    97  * @error				Not supported.
    98  * @noreturn
    99  */
   100 native GameRules_SetProp(const String:prop[], any:value, size=4, element=0, bool:changeState=false);
   101 
   102 /**
   103  * Retrieves a float value from a property of the gamerules entity.
   104  * 
   105  * @param prop			Property name.
   106  * @param element		Element # (starting from 0) if property is an array.
   107  * @return				Value at the given property offset.
   108  * @error				Not supported.
   109  */
   110 native Float:GameRules_GetPropFloat(const String:prop[], element=0);
   111 
   112 /**
   113  * Sets a float value for a property of the gamerules entity.
   114  * 
   115  * @param prop			Property name.
   116  * @param value			Value to set.
   117  * @param element		Element # (starting from 0) if property is an array.
   118  * @param changeState	If true, change will be sent over the network.
   119  * @noreturn
   120  * @error				Not supported.
   121  */
   122 native GameRules_SetPropFloat(const String:prop[], Float:value, element=0, bool:changeState=false);
   123 
   124 /**
   125  * Retrieves a entity index from a property of the gamerules entity.
   126  * 
   127  * @param prop			Property name.
   128  * @param element		Element # (starting from 0) if property is an array.
   129  * @return				Entity index at the given property.
   130  *						If there is no entity, or the entity is not valid, 
   131  *						then -1 is returned.
   132  * @error				Not supported.
   133  */
   134 native GameRules_GetPropEnt(const String:prop[], element=0);
   135 
   136 /**
   137  * Sets an entity index for a property of the gamerules entity.
   138  * 
   139  * @param prop			Property name.
   140  * @param other			Entity index to set, or -1 to unset.
   141  * @param element		Element # (starting from 0) if property is an array.
   142  * @param changeState	If true, change will be sent over the network.
   143  * @noreturn
   144  * @error				Not supported.
   145  */
   146 native GameRules_SetPropEnt(const String:prop[], other, element=0, bool:changeState=false);
   147 
   148 /**
   149  * Retrieves a vector of floats from the gamerules entity, given a named network property.
   150  * 
   151  * @param prop			Property name.
   152  * @param vec			Vector buffer to store data in.
   153  * @param element		Element # (starting from 0) if property is an array.
   154  * @noreturn
   155  * @error				Not supported.
   156  */
   157 native GameRules_GetPropVector(const String:prop[], Float:vec[3], element=0);
   158 
   159 /**
   160  * Sets a vector of floats in the gamerules entity, given a named network property.
   161  *
   162  * @param prop			Property name.
   163  * @param vec			Vector to set.
   164  * @param element		Element # (starting from 0) if property is an array.
   165  * @param changeState	If true, change will be sent over the network.
   166  * @noreturn
   167  * @error				Not supported.
   168  */
   169 native GameRules_SetPropVector(const String:prop[], const Float:vec[3], element=0, bool:changeState=false);
   170 
   171 /**
   172  * Gets a gamerules property as a string.
   173  * 
   174  * @param prop			Property to use.
   175  * @param buffer		Destination string buffer.
   176  * @param maxlen		Maximum length of output string buffer.
   177  * @return				Number of non-null bytes written.
   178  * @error				Not supported.
   179  */
   180 native GameRules_GetPropString(const String:prop[], String:buffer[], maxlen);
   181 
   182 /**
   183  * Sets a gamerules property as a string.
   184  *
   185  * @param prop			Property to use.
   186  * @param buffer		String to set.		
   187  * @param changeState	If true, change will be sent over the network.
   188  * @return				Number of non-null bytes written.
   189  * @error				Not supported.
   190  */
   191 native GameRules_SetPropString(const String:prop[], const String:buffer[], bool:changeState=false);
   192 
   193 /**
   194  * Gets the current round state.
   195  *
   196  * @return				Round state.
   197  * @error				Game doesn't support round state.
   198  */
   199 stock RoundState:GameRules_GetRoundState()
   200 {
   201 	return RoundState:GameRules_GetProp("m_iRoundState");
   202 }