Raised This Month: $32 Target: $400
 8% 

Orpheu: GameRules Object


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-07-2010 , 11:12   Orpheu: GameRules Object
Reply With Quote #1

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.
PHP Code:
#include <amxmodx>
#include <orpheu>
#include <orpheu_stocks>

new g_pGameRules

public plugin_precache()
{
    
OrpheuRegisterHook(OrpheuGetFunction("InstallGameRules"),"OnInstallGameRules",OrpheuHookPost)
}
public 
OnInstallGameRules()
{
    
g_pGameRules OrpheuGetReturn() 

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 *)

PHP Code:
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

Now, to call a function:
Example: CanHaveAmmo(CBasePlayer *, char const *, int)
PHP Code:
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
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:
Code:
cstrike
czero
dod
tfc
ns
ts
SvenCoop
valve
Functions list:

Code:
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
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.
Attached Files
File Type: zip gamerules.zip (60.6 KB, 1046 views)
__________________

Last edited by joaquimandrade; 04-07-2010 at 11:40.
joaquimandrade is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-07-2010 , 11:15   Re: Orpheu: GameRules Object
Reply With Quote #2

Wow! This is amazing!
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 04-07-2010 , 19:29   Re: Orpheu: GameRules Object
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
Wow! This is amazing!
Seta00 is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 04-07-2010 , 21:05   Re: Orpheu: GameRules Object
Reply With Quote #4

Joaquim, thank you for sharing this with us.
__________________
stupok is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 04-08-2010 , 17:29   Re: Orpheu: GameRules Object
Reply With Quote #5

Excellent - Ill test the dod stuff asap. Thank you!
__________________
Dr.G is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-08-2010 , 19:14   Re: Orpheu: GameRules Object
Reply With Quote #6

Dear friends, if you want to thank me for this, just fucking use it. Thanks in advance.
__________________
joaquimandrade is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 04-08-2010 , 22:08   Re: Orpheu: GameRules Object
Reply With Quote #7

This reduce many codes in many many plugins
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-08-2010 , 22:51   Re: Orpheu: GameRules Object
Reply With Quote #8

Where can you find the source of these functions?

EDIT:

Nevermind.

multiplay_gamerules.cpp
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 04-08-2010 at 23:13.
Exolent[jNr] is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-14-2010 , 19:32   Re: Orpheu: GameRules Object
Reply With Quote #9

It would be nice if someone could filter properly the functions available by game. Right now all is mixed and it's a pain to find something you can use. Joaquim won't do nothing since it's a motherfucher and lazy guy.
__________________
Arkshine is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 04-15-2010 , 05:52   Re: Orpheu: GameRules Object
Reply With Quote #10

Quote:
Originally Posted by Arkshine View Post
Joaquim won't do nothing since it's a motherfucher and lazy guy.
I wouldn't call him lazy lol.
__________________
I am out of order!
grimvh2 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode