Code for triggering all players Created 11 years ago2013-02-21 17:26:34 UTC by Zhouy Zhouy

Created 11 years ago2013-02-21 17:26:34 UTC by Zhouy Zhouy

Posted 11 years ago2013-02-21 17:26:34 UTC Post #312723
Hey there, my first post here. Can't really find any active hl1 coding community, all sites like Wavelength seems dead unfortunately :( So thought this site would be the best bet.

Anyway, I'm making a mod where I want the "Half-Life" title to be visible for all players when a certain entity is triggered(the title that shows when you start a new hl game, c0a0, the tram map..). So I made a copy of trigger_relay and changed some code, it looks like this (only showing the 'Use' function as I guess this is the important part):

void CTriggerLogo::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
gDisplayTitle = TRUE;
}

So when this entity gets triggered at my map, the title appears like I want to. Unfortunately, only for 1 player. My question here is what code do I need to make all players see the logo? I would guess something with for the code ( int i = 1; i <= gpGlobals->maxClients; i++ ) but I can't get it right when playing around with the codes. Thanks!
Posted 11 years ago2013-02-21 18:59:23 UTC Post #312725
I don't remember exactly, but you can't use gDisplayTitle. The title is displayed by the client side so you have to tell every client to show it.

void CTriggerLogo::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
MESSAGE_BEGIN( MSG_ONE, gmsgShowGameTitle, NULL, pActivator->pev );
WRITE_BYTE( 0 );
MESSAGE_END();
should show the message to the player who triggers your trigger entity, so if you simply have everyone trigger it everyone should see it.
ChickenFist ChickenFist<Witty Title>
Posted 11 years ago2013-02-21 20:30:35 UTC Post #312726
Thanks for fast answer. Will try it and tell later if it worked :)

Edit: Did as you said, then I made a game_zone_player with both in- and outtarget triggered to the entity. It worked, thanks a bunch:)

Edit2: I found an easier way, without having to use the game_zone_player. Changed to this:
MESSAGE_BEGIN( MSG_ALL, gmsgShowGameTitle ); 
WRITE_BYTE( 0 );
MESSAGE_END();
Cheers!
You must be logged in to post a response.