plugins/include/sdktools_gamerules.inc
changeset 3333 e247490894a1
child 3608 afa46954ccac
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/include/sdktools_gamerules.inc	Wed Jul 06 17:37:35 2011 -0400
     1.3 @@ -0,0 +1,194 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * =============================================================================
     1.7 + * SourceMod (C)2004-2011 AlliedModders LLC.  All rights reserved.
     1.8 + * =============================================================================
     1.9 + *
    1.10 + * This file is part of the SourceMod/SourcePawn SDK.
    1.11 + *
    1.12 + * This program is free software; you can redistribute it and/or modify it under
    1.13 + * the terms of the GNU General Public License, version 3.0, as published by the
    1.14 + * Free Software Foundation.
    1.15 + * 
    1.16 + * This program is distributed in the hope that it will be useful, but WITHOUT
    1.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.18 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.19 + * details.
    1.20 + *
    1.21 + * You should have received a copy of the GNU General Public License along with
    1.22 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.23 + *
    1.24 + * As a special exception, AlliedModders LLC gives you permission to link the
    1.25 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.26 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.27 + * by the Valve Corporation.  You must obey the GNU General Public License in
    1.28 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.29 + * this exception to all derivative works.  AlliedModders LLC defines further
    1.30 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.31 + * or <http://www.sourcemod.net/license.php>.
    1.32 + *
    1.33 + * Version: $Id$
    1.34 + */
    1.35 +
    1.36 +#if defined _sdktools_gamerules_included
    1.37 +  #endinput
    1.38 +#endif
    1.39 +#define _sdktools_gamerules_included
    1.40 +
    1.41 +enum RoundState {
    1.42 +	// initialize the game, create teams
    1.43 +	RoundState_Init,
    1.44 +	
    1.45 +	//Before players have joined the game. Periodically checks to see if enough players are ready
    1.46 +	//to start a game. Also reverts to this when there are no active players
    1.47 +	RoundState_Pregame,
    1.48 +	
    1.49 +	//The game is about to start, wait a bit and spawn everyone
    1.50 +	RoundState_StartGame,
    1.51 +	
    1.52 +	//All players are respawned, frozen in place
    1.53 +	RoundState_Preround,
    1.54 +	
    1.55 +	//Round is on, playing normally
    1.56 +	RoundState_RoundRunning,
    1.57 +	
    1.58 +	//Someone has won the round
    1.59 +	RoundState_TeamWin,
    1.60 +	
    1.61 +	//Noone has won, manually restart the game, reset scores
    1.62 +	RoundState_Restart,
    1.63 +	
    1.64 +	//Noone has won, restart the game
    1.65 +	RoundState_Stalemate,
    1.66 +	
    1.67 +	//Game is over, showing the scoreboard etc
    1.68 +	RoundState_GameOver,
    1.69 +	
    1.70 +	//Game is over, doing bonus round stuff
    1.71 +	RoundState_Bonus,
    1.72 +};
    1.73 +
    1.74 +/**
    1.75 + * Retrieves an integer value from a property of the gamerules entity.
    1.76 + * 
    1.77 + * @param prop			Property name.
    1.78 + * @param size			Number of bytes to read (valid values are 1, 2, or 4).
    1.79 + *						This value is auto-detected, and the size parameter is 
    1.80 + *						only used as a fallback in case detection fails.
    1.81 + * @param element		Element # (starting from 0) if property is an array.
    1.82 + * @return				Value at the given property offset.
    1.83 + * @error				Not supported.
    1.84 + */
    1.85 +native GameRules_GetProp(const String:prop[], size=4, element=0);
    1.86 +
    1.87 +/**
    1.88 + * Sets an integer value for a property of the gamerules entity.
    1.89 + *
    1.90 + * @param prop			Property name.
    1.91 + * @param value			Value to set.
    1.92 + * @param size			Number of bytes to write (valid values are 1, 2, or 4).
    1.93 + *						This value is auto-detected, and the size parameter is 
    1.94 + *						only used as a fallback in case detection fails.
    1.95 + * @param element		Element # (starting from 0) if property is an array.
    1.96 + * @error				Not supported.
    1.97 + * @noreturn
    1.98 + */
    1.99 +native GameRules_SetProp(const String:prop[], any:value, size=4, element=0, bool:changeState=false);
   1.100 +
   1.101 +/**
   1.102 + * Retrieves a float value from a property of the gamerules entity.
   1.103 + * 
   1.104 + * @param prop			Property name.
   1.105 + * @param element		Element # (starting from 0) if property is an array.
   1.106 + * @return				Value at the given property offset.
   1.107 + * @error				Not supported.
   1.108 + */
   1.109 +native Float:GameRules_GetPropFloat(const String:prop[], element=0);
   1.110 +
   1.111 +/**
   1.112 + * Sets a float value for a property of the gamerules entity.
   1.113 + * 
   1.114 + * @param prop			Property name.
   1.115 + * @param value			Value to set.
   1.116 + * @param element		Element # (starting from 0) if property is an array.
   1.117 + * @noreturn
   1.118 + * @error				Not supported.
   1.119 + */
   1.120 +native GameRules_SetPropFloat(const String:prop[], Float:value, element=0, bool:changeState=false);
   1.121 +
   1.122 +/**
   1.123 + * Retrieves a entity index from a property of the gamerules entity.
   1.124 + * 
   1.125 + * @param prop			Property name.
   1.126 + * @param element		Element # (starting from 0) if property is an array.
   1.127 + * @return				Entity index at the given property.
   1.128 + *						If there is no entity, or the entity is not valid, 
   1.129 + *						then -1 is returned.
   1.130 + * @error				Not supported.
   1.131 + */
   1.132 +native GameRules_GetPropEnt(const String:prop[], element=0);
   1.133 +
   1.134 +/**
   1.135 + * Sets an entity index for a property of the gamerules entity.
   1.136 + * 
   1.137 + * @param prop			Property name.
   1.138 + * @param other			Entity index to set, or -1 to unset.
   1.139 + * @param element		Element # (starting from 0) if property is an array.
   1.140 + * @noreturn
   1.141 + * @error				Not supported.
   1.142 + */
   1.143 +native GameRules_SetPropEnt(const String:prop[], other, element=0, bool:changeState=false);
   1.144 +
   1.145 +/**
   1.146 + * Retrieves a vector of floats from the gamerules entity, given a named network property.
   1.147 + * 
   1.148 + * @param prop			Property name.
   1.149 + * @param vec			Vector buffer to store data in.
   1.150 + * @param element		Element # (starting from 0) if property is an array.
   1.151 + * @noreturn
   1.152 + * @error				Not supported.
   1.153 + */
   1.154 +native GameRules_GetPropVector(const String:prop[], Float:vec[3], element=0);
   1.155 +
   1.156 +/**
   1.157 + * Sets a vector of floats in the gamerules entity, given a named network property.
   1.158 + *
   1.159 + * @param prop			Property name.
   1.160 + * @param vec			Vector to set.
   1.161 + * @param element		Element # (starting from 0) if property is an array.
   1.162 + * @noreturn
   1.163 + * @error				Not supported.
   1.164 + */
   1.165 +native GameRules_SetPropVector(const String:prop[], const Float:vec[3], element=0, bool:changeState=false);
   1.166 +
   1.167 +/**
   1.168 + * Gets a gamerules property as a string.
   1.169 + * 
   1.170 + * @param prop			Property to use.
   1.171 + * @param buffer		Destination string buffer.
   1.172 + * @param maxlen		Maximum length of output string buffer.
   1.173 + * @return				Number of non-null bytes written.
   1.174 + * @error				Not supported.
   1.175 + */
   1.176 +native GameRules_GetPropString(const String:prop[], String:buffer[], maxlen);
   1.177 +
   1.178 +/**
   1.179 + * Sets a gamerules property as a string.
   1.180 + *
   1.181 + * @param prop			Property to use.
   1.182 + * @param buffer		String to set.		
   1.183 + * @return				Number of non-null bytes written.
   1.184 + * @error				Not supported.
   1.185 + */
   1.186 +native GameRules_SetPropString(const String:prop[], const String:buffer[], bool:changeState=false);
   1.187 +
   1.188 +/**
   1.189 + * Gets the current round state.
   1.190 + *
   1.191 + * @return				Round state.
   1.192 + * @error				Game doesn't support round state.
   1.193 + */
   1.194 +stock RoundState:GameRules_GetRoundState()
   1.195 +{
   1.196 +	return RoundState:GameRules_GetProp("m_iRoundState");
   1.197 +}