View Full Version : #ifndef and #if: What does SC use?

08-04-2016, 01:16 AM
In the HL SDK there are ifndef CLIENT_DLL and if ( g_pGameRules->IsMultiplayer() ) thingies.
What does SC use? SP or MP values?

Also, what does #if 0 do?
Example in zombie.cpp

if ((m_Activity == ACT_MELEE_ATTACK1) || (m_Activity == ACT_MELEE_ATTACK1))
#if 0
if (pev->health < 20)
if (m_flNextFlinch >= gpGlobals->time)

Thanks :3

edit: After further research, apparently #if 0 #endif is the same as /* */
"#if 0 always evaluates to false and code in that block is excluded. "

08-04-2016, 03:51 AM
#ifndef CLIENT_DLL is used for code that is included in both the client and server dll, but that shouldn't exist on the client side. You don't really need it since there are no client side scripts.
If you do want to use it, use #if SERVER.

SC uses multiplayer settings, so you can ignore any singleplayer specific stuff.

08-04-2016, 05:37 AM
Alright, thank you! :3

08-04-2016, 01:03 PM
Oh, forgot one:

#if defined( CLIENT_WEAPONS )
flags = FEV_NOTHOST;
flags = 0;

I'm assuming that flags = 0; is the one that should be used, since FEV_NOTHOST isn't in the documentation?
Then again, flags is used in PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usRpg ); which calls the method(?) EV_FireRpg in cl_dlls/ev_hldm.cpp, and it handles the playing of the firing sounds and animations.

void EV_FireRpg( event_args_t *args )
int idx;
vec3_t origin;

idx = args->entindex;
VectorCopy( args->origin, origin );

gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/rocketfire1.wav", 0.9, ATTN_NORM, 0, PITCH_NORM );
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/glauncher.wav", 0.7, ATTN_NORM, 0, PITCH_NORM );

//Only play the weapon anims if I shot it.
if ( EV_IsLocal( idx ) )
gEngfuncs.pEventAPI->EV_WeaponAnimation( RPG_FIRE2, 1 );

V_PunchAxis( 0, -5.0 );

I can't tell if flags is used for anything there though. D;

But I'm assuming that I should just use whatever is in ev_hldm.cpp instead?

08-04-2016, 01:42 PM
If CLIENT_WEAPONS is defined, it means that the game is using client side weapon support. Events are used to trigger client side weapon effects. Scripts can't use events, so just ignore the whole thing and take the client side event code, modify it to work on the server side and hope it doesn't cause too much network usage.

08-04-2016, 02:38 PM
Aight, thanks :3