axel364 Posted May 1, 2006 Share Posted May 1, 2006 Hello, I'm trying to make a new field (column) in the scoreboards. I want to add how many headshots done per players. I do like this : I add PERS_HEADSHOTS in the persEnum_t; table. I copy the AddScore function : void AddScore( gentity_t *ent, vec3_t origin, int score ) { /* if (g_gametype.integer == GT_SIEGE) { //no scoring in this gametype at all. return; } */ if ( !ent->client ) { return; } // no scoring during pre-match warmup if ( level.warmupTime ) { return; } // show score plum //ScorePlum(ent, origin, score); // ent->client->ps.persistant[PERS_SCORE] += score; if ( g_gametype.integer == GT_TEAM && !g_dontPenalizeTeam ) level.teamScores[ ent->client->ps.persistant[PERS_TEAM] ] += score; CalculateRanks(); } I create the AddHeadshots function like this : void AddHeadshots( gentity_t *ent, vec3_t origin, int hs ) { /* if (g_gametype.integer == GT_SIEGE) { //no scoring in this gametype at all. return; } */ if ( !ent->client ) { return; } // no scoring during pre-match warmup if ( level.warmupTime ) { return; } // show score plum //ScorePlum(ent, origin, score); // ent->client->ps.persistant[PERS_HEADSHOTS] += hs; /*if ( g_gametype.integer == GT_TEAM && !g_dontPenalizeTeam ) level.teamScores[ ent->client->ps.persistant[PERS_TEAM] ] += score; CalculateRanks();*/ } When anyone does an headshot, the headshot is added to the scoretable at his name : AddHeadshots( attacker, attacker->client->ps.origin,1); In the file g_cmds.c at the DeathmatchScoreboardMessage function, I add a new '%i' Com_sprintf (entry, sizeof(entry), " %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i" Then I add cl->ps.persistant[PERS_HEADSHOTS]); Then I edit the client side to show the Headshots column... In the score table score_t; I add : int headshots; In the CG_ParseScores function I add : cg.scores.headshots = atoi(CG_Argv(i * 14 + 18)); perfect is 14 + 16 captures is 14 + 17 I think headshots should be 14 + 18. cg.scores[i].perfect = atoi(CG_Argv(i * 14 + 16)); cg.scores[i].captures = atoi(CG_Argv(i * 14 + 17)); cg.scores[i].headshots = atoi(CG_Argv(i * 14 + 18)); Then I define those lines : #define SB_SCORE_X (SB_SCORELINE_X + .45 * SB_SCORELINE_WIDTH) #define SB_PING_X (SB_SCORELINE_X + .60 * SB_SCORELINE_WIDTH) #define SB_TIME_X (SB_SCORELINE_X + .75 * SB_SCORELINE_WIDTH) #define SB_HEADSHOTS_X (SB_SCORELINE_X + .90 * SB_SCORELINE_WIDTH) CG_Text_Paint (SB_PING_X, y, 1.0f * scale, colorWhite, va("%i", score->ping),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_TIME_X, y, 1.0f * scale, colorWhite, va("%i", score->time),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_HEADSHOTS_X, y, 1.0f * scale, colorWhite, va("%i", score->headshots),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); else { CG_Text_Paint (SB_SCORE_X, y, 1.0f * scale, colorWhite, "-",0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_PING_X, y, 1.0f * scale, colorWhite, "-",0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_TIME_X, y, 1.0f * scale, colorWhite, "-",0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_HEADSHOTS_X, y, 1.0f * scale, colorWhite, "-",0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); } Now let's talk about the problem : When I press on the key to show the scoreboard, nothing happens (my Force points and my life and armors points disappears). I make some headshots, when I die, I see the scoreboard, the headshots column works fine but I don't see my name and I see often 2 names highlighted. Can anyone help me please ? Thanks Link to comment Share on other sites More sharing options...
razorace Posted May 1, 2006 Share Posted May 1, 2006 What's the else statement for in that last bit? Link to comment Share on other sites More sharing options...
axel364 Posted May 2, 2006 Author Share Posted May 2, 2006 I'm sorry, I didn't understand, what is a statement please ? Link to comment Share on other sites More sharing options...
razorace Posted May 2, 2006 Share Posted May 2, 2006 if() { } else { } Why is the .... CG_Text_Paint (SB_SCORE_X, y, 1.0f * scale, colorWhite, "-",0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_PING_X, y, 1.0f * scale, colorWhite, "-",0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_TIME_X, y, 1.0f * scale, colorWhite, "-",0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_HEADSHOTS_X, y, 1.0f * scale, colorWhite, "-",0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); ..only inside an else statement? Link to comment Share on other sites More sharing options...
axel364 Posted May 2, 2006 Author Share Posted May 2, 2006 Hello, This is the full statement if ( score->ping != -1 ) { if ( ci->team != TEAM_SPECTATOR || cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL ) { if (cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL) { CG_Text_Paint (SB_SCORE_X, y, 1.0f * scale, colorWhite, va("%i/%i", ci->wins, ci->losses),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); } else { CG_Text_Paint (SB_SCORE_X, y, 1.0f * scale, colorWhite, va("%i", score->score),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); } } CG_Text_Paint (SB_PING_X, y, 1.0f * scale, colorWhite, va("%i", score->ping),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_TIME_X, y, 1.0f * scale, colorWhite, va("%i", score->time),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_HEADSHOTS_X, y, 1.0f * scale, colorWhite, va("%i", score->headshots),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); } else { CG_Text_Paint (SB_SCORE_X, y, 1.0f * scale, colorWhite, "-",0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_PING_X, y, 1.0f * scale, colorWhite, "-",0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_TIME_X, y, 1.0f * scale, colorWhite, "-",0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_HEADSHOTS_X, y, 1.0f * scale, colorWhite, "-",0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); } Link to comment Share on other sites More sharing options...
ck-killa Posted May 4, 2006 Share Posted May 4, 2006 if ( score->ping != -1 ) { if ( ci->team != TEAM_SPECTATOR || cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL ) { if (cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL) { CG_Text_Paint (SB_SCORE_X, y, 1.0f * scale, colorWhite, va("%i/%i", ci->wins, ci->losses),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); } else { CG_Text_Paint (SB_SCORE_X, y, 1.0f * scale, colorWhite, va("%i", score->score),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); } } CG_Text_Paint (SB_PING_X, y, 1.0f * scale, colorWhite, va("%i", score->ping),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_TIME_X, y, 1.0f * scale, colorWhite, va("%i", score->time),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); CG_Text_Paint (SB_HEADSHOTS_X, y, 1.0f * scale, colorWhite, va("%i", score->headshots),0, 0, ITEM_TEXTSTYLE_OUTLINED, FONT_SMALL ); } Try removing CG_Text_Paint (SB_HEADSHOTS_X, y, 1.0f * scale, colorWhite, va from the -1 statement. Hard to connect when the headshots arnt even set yet. Worth a try. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.