PDA

View Full Version : GameRules Prop Hax


psychonic
04-04-2011, 13:11
GameRules Prop Hax

Note: Currently requires an SM 1.4.0-dev snapshot >= hg3157 or later.
(if there's enough interest in this, I can later make it able to work on SM 1.3.x releases/snapshots)

This extension allows you to directly get or set property values on the GameRules class, rather than only having access to the GameRules proxy (which will have delayed or plain incorrect values).

You can currently get or set the actual value of any property that exists on the proxy entity. I'll probably also add natives for using your own offset so that non-networked data can also be accessed.

/*
* Gets or Sets a GameRules prop.
* size is auto-detected. paramter is only used if auto-detection fails
* element is element number in array if prop is array
* changeState when setting will propagate change over net to clients
*/
native GameRules_GetProp(const String:prop[], size=4, element=0);
native Float:GameRules_GetPropFloat(const String:prop[], element=0);

native GameRules_SetProp(const String:prop[], value, size=4, element=0, bool:changeState=false);
native GameRules_SetPropFloat(const String:prop[], Float:value, element=0, bool:changeState=false);

The natives work similar to GetEntProp/SetEntProp, with the exceptions of 1) being able to specify the element# if the property is an array, and 2) being able mark the property as changed (like SetEntData), so that the new value is sent to clients.

Some included stocks for games utilizing the TeamplayRoundBased class (ex. TF2).
stock RoundState:GameRules_GetRoundState()

stock Float:GameRules_GetTimeUntilRndReset()

stock Float:GameRules_GetTimeBetweenSpawns(team)
stock GameRules_SetTimeBetweenSpawns(team, Float:time)

stock Float:GameRules_GetNextSpawnTime(team)
stock GameRules_SetNextSpawnTime(team, Float:time)

Click here (http://hg.nicholashastings.com/gamerules/files/tip/sourcemod/scripting/include/gamerules.inc) to view the full include.


Some examples of useful, game-specific properties that can be accessed:
TF2m_bInWaitingForPlayers
m_iWinningTeam
m_bInOvertime
m_bInSetup
m_bSwitchedTeamsThisRound
m_bStopWatch
m_bMultipleTrains
m_nGameType
m_nStopWatchState
m_nHudType

CS:Sm_iRoundTime
m_bMapHasBombTarget
m_bMapHasRescueZone

DOD:Sm_bAlliesAreBombing
m_bAxisAreBombing
m_AlliesRespawnQueue
m_AxisRespawnQueue
m_iAlliesRespawnHead
m_iAlliesRespawnTail
m_iAxisRespawnHead
m_iAxisRespawnTail

L4D2m_iSurvivorScore
m_iCampaignScore
m_iScavengeTeamScore
m_iScavengeMatchScore
m_flTeamRoundTime
m_iVersusDistancePerSurvivor
m_iVersusSurvivorDeathDistance
m_iVersusSurvivalMultiplier
m_iVersusDefibsUsed
m_bInIntro
m_iServerRank
m_flTeamBestRoundTime
m_nScavengeItemsRemaining
m_bAreTeamsFlipped
m_bInSecondHalfOfRound
m_bIsTransitioningToNextMap
For a full list, use sm_dump_netprops and look for the game's specific gamerules proxy entry.

Binary support is included for all games/engines that SM supports. To enable support for specific games not already included, you need only add the netclass name of the gamerules proxy to the gamedata file.

Source code attached.

Samantha
04-04-2011, 14:37
Nice work, very useful!

ProdigySim
04-04-2011, 20:38
You solved at least 20 problems for me.

bl4nk
04-07-2011, 16:30
Yay. I finally just got back around to installing MSVC and IDA to get something like this done, just to find out you beat me to it. :3

noodleboy347
05-01-2011, 15:51
This doesn't work anymore, it says

[SM] Extension gamerules.ext.so failed to load: Could not find interface: ISourceMod

psychonic
05-01-2011, 15:55
This doesn't work anymore, it says

[SM] Extension gamerules.ext.so failed to load: Could not find interface: ISourceMod


Note: Currently requires an SM 1.4.0-dev snapshot >= hg3157 or later.

Though it does still need a recompile on linux for other reasons.

noodleboy347
05-01-2011, 23:09
Okay.

psychonic
05-01-2011, 23:51
Okay.

The zip on the first post is now updated. Only change is that the ep2v bins are recompiled against the newer sdk.

klausenbusk
05-04-2011, 04:15
psychonic, are m_iRoundTime the round timer at the bottom of the screen? if yes, do you know a method, so i when the bomb are planted, the round timer not disappear?

klausenbusk
07-02-2011, 11:07
I am interested in a version for sm 1.3.x :D

psychonic
07-02-2011, 11:14
I am interested in a version for sm 1.3.x :D

Probably not going to happen at this point, but it may get integrated into SDK Tools for SM 1.4.

psychonic
07-09-2011, 15:08
but it may get integrated into SDK Tools for SM 1.4.

This has since been done. The capability is in the current 1.4 snapshots.

klausenbusk
07-10-2011, 07:12
Have you some idea about when sourcemod 1.4.0 will be released?

disawar1
08-31-2012, 23:41
Full l4d & l4d2 GameRules prop dump is here Cvar/Cmd list & Offset (http://forums.alliedmods.net/showthread.php?p=1707897#post1707897)