skamonkey@3333: /**
skamonkey@3333: * vim: set ts=4 :
skamonkey@3333: * =============================================================================
skamonkey@3333: * SourceMod (C)2004-2011 AlliedModders LLC. All rights reserved.
skamonkey@3333: * =============================================================================
skamonkey@3333: *
skamonkey@3333: * This file is part of the SourceMod/SourcePawn SDK.
skamonkey@3333: *
skamonkey@3333: * This program is free software; you can redistribute it and/or modify it under
skamonkey@3333: * the terms of the GNU General Public License, version 3.0, as published by the
skamonkey@3333: * Free Software Foundation.
skamonkey@3333: *
skamonkey@3333: * This program is distributed in the hope that it will be useful, but WITHOUT
skamonkey@3333: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
skamonkey@3333: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
skamonkey@3333: * details.
skamonkey@3333: *
skamonkey@3333: * You should have received a copy of the GNU General Public License along with
skamonkey@3333: * this program. If not, see .
skamonkey@3333: *
skamonkey@3333: * As a special exception, AlliedModders LLC gives you permission to link the
skamonkey@3333: * code of this program (as well as its derivative works) to "Half-Life 2," the
skamonkey@3333: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
skamonkey@3333: * by the Valve Corporation. You must obey the GNU General Public License in
skamonkey@3333: * all respects for all other code used. Additionally, AlliedModders LLC grants
skamonkey@3333: * this exception to all derivative works. AlliedModders LLC defines further
skamonkey@3333: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
skamonkey@3333: * or .
skamonkey@3333: *
skamonkey@3333: * Version: $Id$
skamonkey@3333: */
skamonkey@3333:
skamonkey@3333: #if defined _sdktools_gamerules_included
skamonkey@3333: #endinput
skamonkey@3333: #endif
skamonkey@3333: #define _sdktools_gamerules_included
skamonkey@3333:
skamonkey@3333: enum RoundState {
skamonkey@3333: // initialize the game, create teams
skamonkey@3333: RoundState_Init,
skamonkey@3333:
skamonkey@3333: //Before players have joined the game. Periodically checks to see if enough players are ready
skamonkey@3333: //to start a game. Also reverts to this when there are no active players
skamonkey@3333: RoundState_Pregame,
skamonkey@3333:
skamonkey@3333: //The game is about to start, wait a bit and spawn everyone
skamonkey@3333: RoundState_StartGame,
skamonkey@3333:
skamonkey@3333: //All players are respawned, frozen in place
skamonkey@3333: RoundState_Preround,
skamonkey@3333:
skamonkey@3333: //Round is on, playing normally
skamonkey@3333: RoundState_RoundRunning,
skamonkey@3333:
skamonkey@3333: //Someone has won the round
skamonkey@3333: RoundState_TeamWin,
skamonkey@3333:
skamonkey@3333: //Noone has won, manually restart the game, reset scores
skamonkey@3333: RoundState_Restart,
skamonkey@3333:
skamonkey@3333: //Noone has won, restart the game
skamonkey@3333: RoundState_Stalemate,
skamonkey@3333:
skamonkey@3333: //Game is over, showing the scoreboard etc
skamonkey@3333: RoundState_GameOver,
skamonkey@3333:
skamonkey@3333: //Game is over, doing bonus round stuff
skamonkey@3333: RoundState_Bonus,
skamonkey@3608:
skamonkey@3608: //Between rounds
skamonkey@3608: RoundState_BetweenRounds,
skamonkey@3333: };
skamonkey@3333:
skamonkey@3333: /**
skamonkey@3333: * Retrieves an integer value from a property of the gamerules entity.
skamonkey@3333: *
skamonkey@3333: * @param prop Property name.
skamonkey@3333: * @param size Number of bytes to read (valid values are 1, 2, or 4).
skamonkey@3333: * This value is auto-detected, and the size parameter is
skamonkey@3333: * only used as a fallback in case detection fails.
skamonkey@3333: * @param element Element # (starting from 0) if property is an array.
skamonkey@3333: * @return Value at the given property offset.
skamonkey@3333: * @error Not supported.
skamonkey@3333: */
skamonkey@3333: native GameRules_GetProp(const String:prop[], size=4, element=0);
skamonkey@3333:
skamonkey@3333: /**
skamonkey@3333: * Sets an integer value for a property of the gamerules entity.
skamonkey@3333: *
skamonkey@3333: * @param prop Property name.
skamonkey@3333: * @param value Value to set.
skamonkey@3333: * @param size Number of bytes to write (valid values are 1, 2, or 4).
skamonkey@3333: * This value is auto-detected, and the size parameter is
skamonkey@3333: * only used as a fallback in case detection fails.
skamonkey@3333: * @param element Element # (starting from 0) if property is an array.
erik@3967: * @param changeState If true, change will be sent over the network.
skamonkey@3333: * @error Not supported.
skamonkey@3333: * @noreturn
skamonkey@3333: */
skamonkey@3333: native GameRules_SetProp(const String:prop[], any:value, size=4, element=0, bool:changeState=false);
skamonkey@3333:
skamonkey@3333: /**
skamonkey@3333: * Retrieves a float value from a property of the gamerules entity.
skamonkey@3333: *
skamonkey@3333: * @param prop Property name.
skamonkey@3333: * @param element Element # (starting from 0) if property is an array.
skamonkey@3333: * @return Value at the given property offset.
skamonkey@3333: * @error Not supported.
skamonkey@3333: */
skamonkey@3333: native Float:GameRules_GetPropFloat(const String:prop[], element=0);
skamonkey@3333:
skamonkey@3333: /**
skamonkey@3333: * Sets a float value for a property of the gamerules entity.
skamonkey@3333: *
skamonkey@3333: * @param prop Property name.
skamonkey@3333: * @param value Value to set.
skamonkey@3333: * @param element Element # (starting from 0) if property is an array.
erik@3967: * @param changeState If true, change will be sent over the network.
skamonkey@3333: * @noreturn
skamonkey@3333: * @error Not supported.
skamonkey@3333: */
skamonkey@3333: native GameRules_SetPropFloat(const String:prop[], Float:value, element=0, bool:changeState=false);
skamonkey@3333:
skamonkey@3333: /**
skamonkey@3333: * Retrieves a entity index from a property of the gamerules entity.
skamonkey@3333: *
skamonkey@3333: * @param prop Property name.
skamonkey@3333: * @param element Element # (starting from 0) if property is an array.
skamonkey@3333: * @return Entity index at the given property.
skamonkey@3333: * If there is no entity, or the entity is not valid,
skamonkey@3333: * then -1 is returned.
skamonkey@3333: * @error Not supported.
skamonkey@3333: */
skamonkey@3333: native GameRules_GetPropEnt(const String:prop[], element=0);
skamonkey@3333:
skamonkey@3333: /**
skamonkey@3333: * Sets an entity index for a property of the gamerules entity.
skamonkey@3333: *
skamonkey@3333: * @param prop Property name.
skamonkey@3333: * @param other Entity index to set, or -1 to unset.
skamonkey@3333: * @param element Element # (starting from 0) if property is an array.
erik@3967: * @param changeState If true, change will be sent over the network.
skamonkey@3333: * @noreturn
skamonkey@3333: * @error Not supported.
skamonkey@3333: */
skamonkey@3333: native GameRules_SetPropEnt(const String:prop[], other, element=0, bool:changeState=false);
skamonkey@3333:
skamonkey@3333: /**
skamonkey@3333: * Retrieves a vector of floats from the gamerules entity, given a named network property.
skamonkey@3333: *
skamonkey@3333: * @param prop Property name.
skamonkey@3333: * @param vec Vector buffer to store data in.
skamonkey@3333: * @param element Element # (starting from 0) if property is an array.
skamonkey@3333: * @noreturn
skamonkey@3333: * @error Not supported.
skamonkey@3333: */
skamonkey@3333: native GameRules_GetPropVector(const String:prop[], Float:vec[3], element=0);
skamonkey@3333:
skamonkey@3333: /**
skamonkey@3333: * Sets a vector of floats in the gamerules entity, given a named network property.
skamonkey@3333: *
skamonkey@3333: * @param prop Property name.
skamonkey@3333: * @param vec Vector to set.
skamonkey@3333: * @param element Element # (starting from 0) if property is an array.
erik@3967: * @param changeState If true, change will be sent over the network.
skamonkey@3333: * @noreturn
skamonkey@3333: * @error Not supported.
skamonkey@3333: */
skamonkey@3333: native GameRules_SetPropVector(const String:prop[], const Float:vec[3], element=0, bool:changeState=false);
skamonkey@3333:
skamonkey@3333: /**
skamonkey@3333: * Gets a gamerules property as a string.
skamonkey@3333: *
skamonkey@3333: * @param prop Property to use.
skamonkey@3333: * @param buffer Destination string buffer.
skamonkey@3333: * @param maxlen Maximum length of output string buffer.
skamonkey@3333: * @return Number of non-null bytes written.
skamonkey@3333: * @error Not supported.
skamonkey@3333: */
skamonkey@3333: native GameRules_GetPropString(const String:prop[], String:buffer[], maxlen);
skamonkey@3333:
skamonkey@3333: /**
skamonkey@3333: * Sets a gamerules property as a string.
skamonkey@3333: *
skamonkey@3333: * @param prop Property to use.
skamonkey@3333: * @param buffer String to set.
erik@3967: * @param changeState If true, change will be sent over the network.
skamonkey@3333: * @return Number of non-null bytes written.
skamonkey@3333: * @error Not supported.
skamonkey@3333: */
skamonkey@3333: native GameRules_SetPropString(const String:prop[], const String:buffer[], bool:changeState=false);
skamonkey@3333:
skamonkey@3333: /**
skamonkey@3333: * Gets the current round state.
skamonkey@3333: *
skamonkey@3333: * @return Round state.
skamonkey@3333: * @error Game doesn't support round state.
skamonkey@3333: */
skamonkey@3333: stock RoundState:GameRules_GetRoundState()
skamonkey@3333: {
skamonkey@3333: return RoundState:GameRules_GetProp("m_iRoundState");
skamonkey@3333: }