Tremulous Forum
Mods => Modding Center => Topic started by: Obj-C on January 25, 2010, 02:03:34 am
-
Hey, so I edited gclient and put in 1 extra qboolean, then an admin could change that boolean via a cmd (!decapulate), then in the G_cmds.c I edited G_Say to test if that boolean was true or false. If it was true, then I converted all the text to lower case. Anyways, this worked fine in all the test servers I tried it in, but when I tried it for real, whenever there was 8+ people, the server crashed. Anyone know how to fix this?
-
So I did some more testing, and I know that its a segment fault that is causing it... anyone know what to do?
-
post up the changes?
-
in g_local.h in the clientPersistant_t struct
qboolean decapulated;
in g_admin.h
qboolean G_admin_decapulate( gentity_t *ent, int skiparg );
in g_admin.c
{"capulate", G_admin_decapulate, "0",
"capulate a decapulated player",
"[^3name|slot#^7]"
},
{"decapulate", G_admin_decapulate, "0",
"decapulate a capulated player",
"[^3name|slot#^7]"
},
and then a bit further down in g_admin.c
qboolean G_admin_decapulate( gentity_t *ent, int skiparg )
{
int pids[ MAX_CLIENTS ];
char name[ MAX_NAME_LENGTH ], err[ MAX_STRING_CHARS ];
char command[ MAX_ADMIN_CMD_LEN ], *cmd;
gentity_t *vic;
if( G_SayArgc() < 2 + skiparg )
{
ADMP( "^3!decapulate: ^7usage: !decapulate [name|slot#]\n" );
return qfalse;
}
G_SayArgv( skiparg, command, sizeof( command ) );
cmd = command;
if( cmd && *cmd == '!' )
cmd++;
G_SayArgv( 1 + skiparg, name, sizeof( name ) );
if( G_ClientNumbersFromString( name, pids ) != 1 )
{
G_MatchOnePlayer( pids, err, sizeof( err ) );
ADMP( va( "^3!decapulate: ^7%s\n", err ) );
return qfalse;
}
if( !admin_higher( ent, &g_entities[ pids[ 0 ] ] ) )
{
ADMP( "^3!decapulate: ^7sorry, but your intended victim has a higher admin"
" level than you\n" );
return qfalse;
}
vic = &g_entities[ pids[ 0 ] ];
if( vic->client->pers.decapulated == qtrue )
{
if( !Q_stricmp( cmd, "decapulate" ) )
{
ADMP( "^3!decapulate: ^7player is already decapulated\n" );
return qtrue;
}
vic->client->pers.decapulated = qfalse;
CPx( pids[ 0 ], "cp \"^1You have been capulated\"" );
AP( va( "print \"^3!capulate: ^7%s^7 has been capulated by %s\n\"",
vic->client->pers.netname,
( ent ) ? ent->client->pers.netname : "console" ) );
}
else
{
if( !Q_stricmp( cmd, "capulate" ) )
{
ADMP( "^3!capulate: ^7player is not currently decapulated\n" );
return qtrue;
}
vic->client->pers.decapulated = qtrue;
CPx( pids[ 0 ], "cp \"^1You've been decapulated\"" );
AP( va( "print \"^3!decapulate: ^7%s^7 has been decapulated by ^7%s\n\"",
vic->client->pers.netname,
( ent ) ? ent->client->pers.netname : "console" ) );
}
ClientUserinfoChanged( pids[ 0 ] );
return qtrue;
}
in g_cmds at the top of the function G_Say I added
int i=0;
qboolean usedCaps = FALSE;
and a bit further down, I added
if (!ent->client->pers.decapulated)
Q_strncpyz( text, chatText, sizeof( text ) );
else {
while (i < MAX_SAY_TEXT) {
if (chatText[i]) {
if (chatText[i] <= 90 && chatText[i] >= 41) {
text[i] += 32;
usedCaps = TRUE;
}
else
text[i] = chatText[i];
}
++i;
}
}
if (usedCaps) {
ADMP( "^1You can't use capital letters\n" );
CP("cp \"^1You can't use capital letters\"");
}
A friend who is helping me test says when aliens go near to turrets using this qvm, there is the error: ERROR: Cvar_Update: handle out of range
-
// ps MUST be the first element, because the server expects it
-
That var still is the first var, I put the my variable underneath the qboolean muted var in clientPersistant_t.
-
Make sure that g_main.c has been recompiled after you changed g_local.h; the Makefile should take care of this, but maybe you have some messed up timestamps.
-
I did a make clean, and then remade, still encountering the same issue.