Orpheu: GameRules Object
Posted: Sun Sep 13, 2026 6:48 am
In half life based games, a portion of the game behaviour related to game rules and events is grouped in objects derived from an object named CGameRules. I've collected virtual functions of it (mod dependent and not) so you can use them out of the box after installing this pack.
A mandatory step of using those functions is retrieving the CGameRules derived object itself.
This hooks the function InstallGameRules that exist on every mod and that creates the object we need. After this, our variable g_pGameRules will contain a reference to the object so we can after that hook and call functions of it. As a side note in TFC the function is a little bit different so I had to named it InstallGameRules_tfc. Take that into account if you are making a plugin that should work in TFC.
Now, hooking a function:
Example GetNextBestWeapon(CBasePlayer *, CBasePlayerItem *)
Now, to call a function:
Example: CanHaveAmmo(CBasePlayer *, char const *, int)
If it sounds complicated or whatever, tell me.
After installing the package the functions will be at "configs\orpheu\virtualFunctions\CGameRul es". Check that folder and each file to know the arguments for each function and in which mod it works.
Supported mods:
Functions list:
Last note: this ended up extensive so I probably made more than one error. If a function doesn't work for you, tell me its name, the mod and the operative system. Bye.
A mandatory step of using those functions is retrieving the CGameRules derived object itself.
Code: Select all
#include <amxmodx>
#include <orpheu>
#include <orpheu_stocks>
new g_pGameRules
public plugin_precache()
{
OrpheuRegisterHook(OrpheuGetFunction("InstallGameRules"),"OnInstallGameRules",OrpheuHookPost)
}
public OnInstallGameRules()
{
g_pGameRules = OrpheuGetReturn()
} Now, hooking a function:
Example GetNextBestWeapon(CBasePlayer *, CBasePlayerItem *)
Code: Select all
public plugin_init()
{
/* GetNextBestWeapon is the name of the function. You can see the name of the function at configs\orpheu\virtualFunctions\CGameRules
CGameRules is the base object and is to be used in every function in the package
OnGetNextBestWeapon is the name of our hook function
*/
OrpheuRegisterHookFromObject(g_pGameRules,"GetNextBestWeapon","CGameRules","OnGetNextBestWeapon")
}
public OnGetNextBestWeapon(gameRules,playerID,weaponID)
{
// Game rules object is always passed as the first argument but we don't need it since we already have it in g_pGameRules
} Example: CanHaveAmmo(CBasePlayer *, char const *, int)
Code: Select all
new OrpheuFunction:CanHaveAmmo = OrpheuGetFunctionFromObject(g_pGameRules,"CanHaveAmmo","CGameRules")
// When you call any of those functions you have to pass g_pGameRules always as the first argument
new result = OrpheuCall(CanHaveAmmo,g_pGameRules,id,"ammo_buckshot",30) After installing the package the functions will be at "configs\orpheu\virtualFunctions\CGameRul es". Check that folder and each file to know the arguments for each function and in which mod it works.
Supported mods:
Code: Select all
cstrike
czero
dod
tfc
ns
ts
SvenCoop
valveCode: Select all
AddToTeamScores
AllowAutoTargetCrosshair
AmmoShouldRespawn
BloodSprite
BloodStream
bodyDamage
Bubbles
BubbleTrails
BuildableBuilt
BuildableKilled
BuildMiniMap
BulletTracers
Camera
CanEntityDoDamageTo
CanHaveAmmo
CanHaveItem
CanHavePlayerItem
ChangeLevel
ChangePlayerTeam
ChangePlayerTeam_dod
CheckMapConditions
CheckWinConditions
CleanUpMap
ClientCommand
ClientCommandDeadOrAlive
ClientCommand_dod
ClientConnected
ClientDisconnected
ClientUserInfoChanged
DeadPlayerAmmo
DeadPlayerWeapons
DeathNotice
DeathNotice_dod
EndMultiplayerGame
Explosion
FAllowFlashlight
FAllowMonsters
FlAmmoRespawnTime
FlHealthChargerRechargeTime
FlHEVChargerRechargeTime
FlItemRespawnTime
FlPlayerFallDamage
FlPlayerSpawnTime
FlWeaponRespawnTime
FlWeaponTryRespawn
FPlayerCanRespawn
FPlayerCanTakeDamage
FShouldSwitchWeapon
gerVoice
GetArePlayersAllowedToJoinImmediately
GetCombatAttackingTeamNumber
GetCountdownStarted
GetGameDescription
GetGameStarted
GetGameTime
GetIndexedTeamName
GetIsClientAuthorizedToPlay
GetIsCombatMode
GetIsHamboneMode
GetIsIronMan
GetIsNSMode
GetIsTournamentMode
GetIsTrainingMode
getMapTime
GetMaxWaveTime
GetNextBestWeapon
GetPlayerSpawnSpot
GetTeamID
GetTeamIndex
getWaveTime
GiveC4
GoToIntermission
Init
InitHUD
IPointsForKill
IsAllowedToSpawn
IsClanMatch
IsClanMatchActive
IsCoOp
IsDeathmatch
IsFreezePeriod
IsMultiplayer
IsRoundFrozen
IsTeamplay
IsValidTeam
ItemShouldRespawn
Pain
PerformHardAuthorization
PlayerGotAmmo
PlayerGotItem
PlayerGotWeapon
PlayerKilled
PlayerKilled_dod
PlayerRelationship
PlayerSpawn
PlayerThink
PlayFootstepSounds
PlayTextureSounds
PopHelmet
ProcessRespawnCostForPlayer
Prone
RecalculateHandicap
RecalculateMapMode
RefreshSkillData
RemoveGuns
RestartRound
ReturnGameRules
RewardPlayerForKill
RoundReset
roundRestartSound
RoundState
ScreenFades
SelectSpawnPoint
SendMOTDToClient
SendTeamScores
ServerDeactivate
SetBloodSprite
SetBloodStream
SetbodyDamage
SetBubbles
SetBubbleTrails
SetBulletTracers
SetCamera
SetClanMatch
SetDefaultPlayerTeam
SetExplosion
SetGameStarted
SetgerVoice
SetMapChangeFromTime
setMapTime
SetPain
SetPopHelmet
SetProne
SetRestartTime
SetRocketTrail
SetRoundReset
SetroundRestartSound
SetRoundState
SetScreenFades
SetShards
SetSmoke
SetSparkShower
SetTeamScores
SetusVoice
setWaveTime
Shards
ShouldAutoAim
Smoke
SparkShower
StartTrail
TeamScores
Think
UpdateGameMode
usVoice
VoteKick
WeaponShouldRespawn