Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 04-20-2012, 05:11 PM   #1
Cpt_Andrew
 
Join Date: Jan 2009
Reputation: 0
Posts: 11
Question Accessing hl2mp_gamerules from npc_citizen17.cpp

Hi All,

My coding isn't great, so forgive me if my terminology is a bit off. What I'm trying to do is create a gametype whereby you need to defend citizens from combine attacks. So far everything is well, but I need to implement the win conditions in hl2mp_gamerules.cpp.

What I'd like to be able to do is to keep an array of who (of the citizens) is left alive in CHL2MPRules. My problem is in accessing it from the spawn function in npc_citizen17.cpp. (The idea is that each time a citizen spawns, it is assigned an identifer so that the gamerules can update the clients' HUDs with which specific citizens are alive).

Rather than try to outline all the fiddling I've done, can someone suggest in broad terms the best way to go about this, to nudge me in the right direction?

Many Thanks,

Andrew.
Cpt_Andrew is offline  
Reply With Quote
Old 04-21-2012, 03:20 AM   #2
Filip
 
Join Date: Aug 2010
Reputation: 35
Posts: 220
you add this to the includes:
#include "hl2mp_gamerules.cpp"
since hl2mp_gamerules is suposto be shared you should by theory be able to add that include to any file :P (well in the source sdk source code)

but there is a possible chance of failure... alltough i think thats its well codded (as in to include this if its on the client or the server whatever part)
its possible that some of the includes of hl2mp_gamerules wont "want" to get included into npc_citizen17.cpp alltho give it a shot
Filip is offline   Reply With Quote
Old 04-21-2012, 05:38 AM   #3
Cpt_Andrew
 
Join Date: Jan 2009
Reputation: 0
Posts: 11
I presume you mean include the header file? Yes, I did get that far.

I figured it out though: I'd made a mistake when defining my function in hl2mp_gamerules.cpp. I'd got:

int GetNumberObjectives( void )

Instead of:

int CHL2MPRules::GetNumberObjectives( void )

And so was getting "unresolved external" errors when accessing it from npc_citizen17.cpp. Amazing what a little sleep will do. Thanks though!
Cpt_Andrew is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


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



All times are GMT -7. The time now is 05:59 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2012, All Rights Reserved.