From fac45098669b7516a26f7460d5ac4b9514423ee8 Mon Sep 17 00:00:00 2001 From: Mikko Tiusanen Date: Thu, 16 Oct 2014 23:57:28 +0300 Subject: Fixed the cvar set issue after client disconnect. Added support for setting player score through score_info. --- src/game/g_admin.c | 33 +++++++++++++++++++++++++-------- src/qcommon/q_shared.h | 2 +- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/game/g_admin.c b/src/game/g_admin.c index d1ff924..5d11ac4 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -222,7 +222,7 @@ g_admin_cmd_t g_admin_cmds[ ] = {"score_info", G_admin_score_info, qtrue, "score_info", "display information about player's accumulated score", - "(^7name|slot#^7)" + "(^7name|slot#^7) [^7newscore^7]" }, {"setlevel", G_admin_setlevel, qfalse, "setlevel", @@ -3414,10 +3414,10 @@ qboolean G_admin_namelog( gentity_t *ent ) qboolean G_admin_score_info( gentity_t *ent ) { - int pid; - char name[ MAX_NAME_LENGTH ]; + char name[ MAX_NAME_LENGTH ]; g_admin_admin_t *target; - namelog_t *match; + namelog_t *match; + int newscore; if( trap_Argc() < 2 ) { @@ -3425,6 +3425,11 @@ qboolean G_admin_score_info( gentity_t *ent ) return qfalse; } + if( trap_Argc() > 2 ){ + trap_Argv( 2, name, sizeof( name ) ); + newscore = atoi( name ); + } + trap_Argv( 1, name, sizeof( name ) ); if( !( match = G_NamelogFromString( ent, name ) ) ) @@ -3439,10 +3444,22 @@ qboolean G_admin_score_info( gentity_t *ent ) return qfalse; } - ADMP( va( "score: ^7%s^7 level: %d score: %d\n", - match->name[match->nameOffset], - target->level, - target->score ) ); + if( trap_Argc() > 2 ) { + target->score = newscore; + admin_writeconfig(); + + admin_log( va("print \"^3score set: ^7%s^7 %d.\n\"", + target->guid, target->score ) ); + ADMP( va( "score set: ^7%s^7 level: %d score: %d\n", + match->name[match->nameOffset], + target->level, + target->score ) ); + } else { + ADMP( va( "score: ^7%s^7 level: %d score: %d\n", + match->name[match->nameOffset], + target->level, + target->score ) ); + } return qtrue; } diff --git a/src/qcommon/q_shared.h b/src/qcommon/q_shared.h index a93b630..cfbc586 100644 --- a/src/qcommon/q_shared.h +++ b/src/qcommon/q_shared.h @@ -1091,7 +1091,7 @@ typedef struct { // bit field limits #define MAX_STATS 16 -#define MAX_PERSISTANT 16 +#define MAX_PERSISTANT 24 #define MAX_MISC 16 #define MAX_WEAPONS 16 -- cgit