Hello there,
So i am editing the source of ET and want to add a cvar.
I followed this:
http://www.splashdamage.com/forums/showthread.php/6095-Adding-New-CVARs
I don’t really get it (it was ussefull i learned some things from it
)
So my idea was to make specterators use voicechat/teamchat
There are 2 parts of code that deal whit this:
g_cmds.c
Line 3395
Till
Line 3420
cg_consolecmds.c
Line 473
Till
Line 520
I followed the above tutorial but how do i actually make the client use the same setting as the server?
(Server admin sets c_advspecchat to 1 or 0)
then the code checks if its 1 or 0:
if (advspecchat.integer == 0)
{
if ( cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR || cgs.clientinfo[cg.clientNum].team == TEAM_FREE )
{
CG_Printf( CG_TranslateString( "Advanced Voice chat is disabled on this server.
" ) );
return;
}
}
else if (advspecchat.integer == 1)
{
trap_Argv( 1, chatCmd, 64 );
trap_SendConsoleCommand( va( "cmd vsay %s
", chatCmd ) );
}
else
{
CG_Printf( CG_TranslateString( "Invalid server configuration. advspecchat MUST be 1 OR 0.
" ) );
}
if ( cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR || cgs.clientinfo[cg.clientNum].team == TEAM_FREE ) {
CG_Printf( CG_TranslateString( "Can't voice chat as a spectator.
" ) );
return;
}
I’m sorry if this code is crappy, I’m still learning and i only know a bit of C++
Everything i try results in the cvar not working ingame or a ton of compiler errors
Regards,
-Rut.
EDIT:
I can see and set the cvar ingame now, however the above code ignores it
also i added the cvar in the server files and when i use it in the server code it says:
Error 1 error C2065: ‘g_advspecchat’ : undeclared identifier
I use this code (above) the client spec chat code i posted above:
const char *info;
qhandle_t g_advspecchat;
info = CG_ConfigString( CS_SERVERINFO );
g_advspecchat = Info_ValueForKey( info, "g_advspecchat" );
Maybe a better description:
I basicly want a cvar so server admins can enable the advanced spec chat
the problem is i don’t know how to make the cvar “info” avivable on server and client
(Only server should set the cvar)
so if g_advspecchat is 1 it must be 1 on client and server
(Also is the above code right for checking a cvar?)

I hope it helps a bit.