Implementing cg_nochatbeep [SOLVED]

The OSP mod has a cg_nochatbeep cvar that eliminates the chat beep when set to 1. I’d like to write a function to implement this in the ioq3 client. What’s the best method to create a new cvar like cg_nochatbeep and where would I intercept the sound file call to drop it? Any help would be appreciated.

I was able to get things working with generous help from `Ishq on IRC. Here’s the code to implement cg_nochatbeep:

cg_local.h

//nochatbeep
extern	vmCvar_t       cg_nochatbeep;
//nochatbeep

cg_main.c

//nochatbeep
vmCvar_t	cg_nochatbeep;
//nochatbeep

cg_main.c

//nochatbeep
{ &cg_nochatbeep, "cg_nochatbeep", "0", CVAR_ARCHIVE}
//nochatbeep

cg_servercmds.c

Replace lines 1021 and 1030 with:

if ( cg_nochatbeep.integer != 1 ) {
	trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
}

You can then add a bind to your .cfg file to toggle nochatbeep on and off.

bind c “toggle cg_nochatbeep”

You’ll still hear an occasional chat beep for special events such as callvotes.

1 Like

If you dont replace line 1030 the team chats will still beep correct?

@Orbital-S2d correct.

also in cg_main

{ &cg_nochatbeep, “cg_nochatbeep”, “0”, CVAR_ARCHIVE}

wouldnt 0 mean its disabled by default?

The cvar defaults to 0, which causes the chat beep to play. Setting the cvar to 1 disables the chat beep.

I would like to share this back :smile: i did it this way so you could have the option of turning one or the other off :slight_smile:
Thanks to zturtleman :wink:

cg_local.h

//chatbeep
extern vmCvar_t cg_chatbeep;
extern vmCvar_t cg_teamchatbeep;
//chatbeep

cg_main.c

//chatbeep
vmCvar_t cg_chatbeep;
vmCvar_t cg_teamchatbeep;
//chatbeep

cg_main.c

//chatbeep
{ &cg_chatbeep, “cg_chatbeep”, “1”, CVAR_ARCHIVE}
{ &cg_teamchatbeep, “cg_teamchatbeep”, “1”, CVAR_ARCHIVE}
//chatbeep

cg_servercmds.c

L1021

     trap_S_StartLocalSound( cgs.media.voteFailed, CHAN_ANNOUNCER );
  } else if ( !Q_stricmpn( cmd, "vote passed", 11 ) || !Q_stricmpn( cmd, "team vote passed", 16 ) ) {
     trap_S_StartLocalSound( cgs.media.votePassed, CHAN_ANNOUNCER );
  }

#endif
return;
}

if ( !strcmp( cmd, “chat” ) ) {
if ( !cg_teamChatsOnly.integer ) {
if ( cg_chatbeep.integer != 0 ) {
trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
}
Q_strncpyz( text, CG_Argv(1), MAX_SAY_TEXT );
CG_RemoveChatEscapeChar( text );
CG_Printf( “%s\n”, text );
}
return;
}

if ( !strcmp( cmd, “tchat” ) ) {
if ( cg_teamchatbeep.integer != 0 ) {
trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
}
Q_strncpyz( text, CG_Argv(1), MAX_SAY_TEXT );