Quake3World.com Forums
     Programming Discussion
        Requesting scores


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Requesting scores

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-07-2013 11:48 AM           Profile Send private message  E-mail  Edit post Reply with quote


I'm a noobie coder. I love Q3 and attempting to make mods.

My question has to do with sending and receiving the scores on the client side.

I've made a mini scoreboard to be printed in console. Works with a bind or if it's typed into console.

My problem has to do with receiving up to date scores.

Checking my code with /developer 1 I see the scoreboard is printed prior to receiving the score.

Using trap_SendClientCommand( "score" ); still shows me I receive the score after the mini scoreboard has been printed.

While using /developer 1 and pressing the tab button I see the score is received before displaying the regular scoreboard.

How can I do this for my mini scoreboard ?

I've tried not displaying the regular scoreboard and sending the trap_SendClientCommand( "score" ); before printing my scoreboard and no luck.

Thanx in advance, I love iD's work, you guys rock.




Last edited by Sheepsquatch on 04-29-2013 05:02 PM, edited 1 time in total.

Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 04-08-2013 01:29 PM           Profile Send private message  E-mail  Edit post Reply with quote


I see there is a delay time of 2 seconds to get the updated scores. To know more search trap_SendClientCommand ("score") in all files.

What I would do is save cg.scoresRequestTime value at the time you want to show the scores in cg.lastScoresRequestTime, and two seconds later (cg.lastScoresRequestTime + 2000) display them, but it would be very slow, two seconds is a lot.

I am surprised that are two seconds, maybe it's because I use the original code. Is this in ioquake faster?




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-08-2013 03:55 PM           Profile Send private message  E-mail  Edit post Reply with quote


Thank very much for replying, I tried the following and it didn't work :

if ( cg.scoresRequestTime + 2000 < cg.time ) {
cg.lastScoresRequestTime = cg.scoresRequestTime;
cg.scoresRequestTime = cg.time;

if (cg.lastScoresRequestTime + 2000 < cg.time)
trap_SendClientCommand( "score" );
}
Or did you mean something else. I'm using the original code also.

Thanx again =).




Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 04-10-2013 09:40 AM           Profile Send private message  E-mail  Edit post Reply with quote


It's something like that. This code in CG_DrawActiveFrame:
Code:
if (( cg.miniBoardRequestTime + 2000 < cg.time ) && cg.showMiniBoard) {
// show yor miniboard;
cg.showMiniBoard=qfalse;
}

And this in your command function:
Code:
cg.miniBoardRequestTime=cg.scoresRequestTime;
cg.showMiniBoard=qtrue;

I changed the name to cg.miniBoardRequestTime to make it more clear.
As CG_DrawActiveFrame runs in each frame, after two seconds of the last scores request it will display your board, and cg.showMiniBoard will cause only be shown once.




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-10-2013 01:10 PM           Profile Send private message  E-mail  Edit post Reply with quote


OK big thanx. I wasn't thinking. I had the key bind in consoldcmds that triggered the CG_MiniScoreboard(); in the scoreboard file. So I wasn't always in CG_DrawActiveFrame or CG_Draw. My mobo burnt out Monday =(. I'm on my laptop and have to copy over my source etc. So I dunno when I can try. I truly appreciate all your help.




Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 04-11-2013 02:59 PM           Profile Send private message  E-mail  Edit post Reply with quote


Ok, let me know if it works :)




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-13-2013 04:54 AM           Profile Send private message  E-mail  Edit post Reply with quote


I'm dying to try this, but I can't on my laptop. Well I can't compile the source on Win7. I've googled and find out what to change to compile .qvms. I could make .dll but didn't test. Ugh I'm in hell without my computer.




Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 04-14-2013 05:12 PM           Profile Send private message  E-mail  Edit post Reply with quote


If you need help to compile .qvms you can take a look at this tutorial.




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-16-2013 04:01 PM           Profile Send private message  E-mail  Edit post Reply with quote


I tried several times yesterday to get the qvms compiled with no luck. I appreciate your link, didn't work. Sadly my motherboard was supposed to arrived today but didn't 'cause the guy shipped yesterday. Gonna have to wait to test your suggestion. Ugh this is hell =(.




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-20-2013 01:12 PM           Profile Send private message  E-mail  Edit post Reply with quote


UglyFoot I was finally able to test your idea. Still didn't work =(. The scores are received after printing the scoreboard.




Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 04-21-2013 10:10 AM           Profile Send private message  E-mail  Edit post Reply with quote


You're right, it doesn't work. I've tried it and I see it is because cg.scoresRequestTime doesn't update while not seeing the scoresboard. In other words: The scores aren't updated when you're not looking at the scoresboard, so cg.scoresRequestTime keeps unchanged.

To display the updated scoresboard you'll have to request it if it wasn't requested in the last two seconds.

It may also happen that in two seconds haven't been updated and you'll have to wait something more like 2.3 or 2.5 seconds. In that case you just have to change the 2000 by 2300 or 2500.

When something doesn't work you have to print key values to understand what is happening.




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-21-2013 12:42 PM           Profile Send private message  E-mail  Edit post Reply with quote


Still no luck.

Even putting trap_SendClientCommand( "score" ); just before printing the scores still doesn't receive the scores before printing.

I think I may have to use cg.showScores = qtrue; but put a check in the scoreboard not to display so I receive the scores first. But I can't now I have to go out, hopefully later.

Maybe you'll have a better idea before I try again.

Truly appreciate your continued help.




Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 04-22-2013 01:16 PM           Profile Send private message  E-mail  Edit post Reply with quote


The problem is that if cg.scoresRequestTime isn't updated (because you're not watching the scoresboard) this code is useless, because the condition is true right after running your command.
Code:
if (( cg.miniBoardRequestTime + 2000 < cg.time ) && cg.showMiniBoard) {
// show yor miniboard;
cg.showMiniBoard=qfalse;
}


It's not enough to request the scores before displaying the mini scoresboard as the scores takes some time to come. I think you have to request scores right after you run the command and set the right value to cg.miniBoardRequestTime to solve the problem.




Last edited by UglyFoot on 05-04-2013 04:43 PM, edited 1 time in total.

Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-26-2013 05:40 AM           Profile Send private message  E-mail  Edit post Reply with quote


Very close the following :

CG_ScoresDown_f();
cg.showScores = qfalse;
CG_PrintMiniScoreboard();

Will send the scores first not display the regular scoreboard. But the miniscoreboard isn't printed unless I press the key bind twice =(.

Scores are received first. Even with cg.showScores = qfalse; commented out ( the scoreboard appears ) but the bind has to be press twice.

Any ideas ? I appreciate all your help and advice Uglyfoot. Thank you.




Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 04-26-2013 12:32 PM           Profile Send private message  E-mail  Edit post Reply with quote


I don't know why you have to press the key twice but try this in your function:
Code:
   if (cg.scoresRequestTime + 2000 < cg.time) cg.miniBoardRequestTime = cg.time;
   else cg.miniBoardRequestTime=cg.scoresRequestTime;
   cg.showMiniBoard=qtrue;

and in CG_DrawActiveFrame:
Code:
if (( cg.miniBoardRequestTime + 2000 < cg.time ) && cg.showMiniBoard) {
// show yor miniboard;
cg.showMiniBoard=qfalse;
}




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-26-2013 12:56 PM           Profile Send private message  E-mail  Edit post Reply with quote


I don't know why I have to press it twice either =(. I'll try your code. Every time I use the cg.miniBoardRequestTime it creates the two second delay. I'll let you know. Thank you.




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-26-2013 02:02 PM           Profile Send private message  E-mail  Edit post Reply with quote


Sadly one you add the requestime the scores are received after printing the miniscoreboard.

Searching the cgame files I found in local.h :

// add commands to the local console as if they were typed in
// for map changing, etc. The command is not executed immediately,
// but will be executed in order the next time console commands
// are processed




Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 04-27-2013 10:13 AM           Profile Send private message  E-mail  Edit post Reply with quote


Mini scoresboard should be printed 2 seconds after you have pressed the key. If they aren't the actual scores then try more than 2 seconds, like 10 seconds, and lower it until it works.




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-27-2013 01:32 PM           Profile Send private message  E-mail  Edit post Reply with quote


Still not working. The key bind needs to be pressed twice.

let me run down what I've done with your advice.

I've added the following to local.h :

int miniBoardRequestTime;
int showMiniBoard;

cg_draw.c in CG_DrawActiveFrame:
if (( cg.miniBoardRequestTime + 2000 < cg.time ) && cg.showMiniBoard) {
// show yor miniboard;
cg.showMiniBoard=qfalse;
}

Finally most importantly in cg_consolecmds.c in my function :

static void CG_MiniScores_f( void ) {

if (cg.scoresRequestTime + 2000 < cg.time)
cg.miniBoardRequestTime = cg.time;
else
cg.miniBoardRequestTime = cg.scoresRequestTime;

cg.showMiniBoard = qtrue;
// @uglyfoot without this your code doesn't do anything
CG_ScoresDown_f();
cg.showScores = qfalse;

CG_PrintMiniScoreboard();
}

Please let me know what you see wrong. Big thanx.




Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 04-27-2013 04:10 PM           Profile Send private message  E-mail  Edit post Reply with quote


Ok, try this:

In local.h:
Code:
   int         miniBoardRequestTime;
   qboolean        showMiniBoard;


In CG_DrawActiveFrame:
Code:
if (( cg.miniBoardRequestTime + 2000 < cg.time ) && cg.showMiniBoard) {
   CG_PrintMiniScoreboard();
cg.showMiniBoard=qfalse;
}


In cg_consolecmds.c:
Code:
static void CG_MiniScores_f( void ) {

   if (cg.scoresRequestTime + 2000 < cg.time)
      cg.miniBoardRequestTime = cg.time;
   else
      cg.miniBoardRequestTime = cg.scoresRequestTime;

   cg.showMiniBoard = qtrue;
}




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44131
PostPosted: 04-28-2013 12:48 AM           Profile   Send private message  E-mail  Edit post Reply with quote


Off-topic comment here, but maybe it's a good idea to change the topic title to something that's more descriptive of the content of the thread. Makes it easier for future readers to find the info again in case they need it. In the Q3W programminb discussion forum, it's fairly obvious that if you have a question, it's about Q3 coding ;) Just a thought :)




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-29-2013 05:02 PM           Profile Send private message  E-mail  Edit post Reply with quote


@Uglyfoot,

WOW Big thanx ! Ugh coding while tired isn't a smart idea. I shoulda realized with qtrue / qfalse I need the qboolean =(.

Really brilliant code. Love how you prevent looping of the scoreboard.

I still had to add

CG_ScoresDown_f();
cg.showScores = qfalse;
before cg.showMiniBoard = qtrue; otherwise the scores aren't updated.

Really appreciate your help.

@Eraser I honestly couldn't think of a proper title when I made the thread. I knew it wasn't descriptive but I really wanted help. Just thought it would pique someone's interest.

Didn't know I could change the title, I'll try now.




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44131
PostPosted: 04-29-2013 09:08 PM           Profile   Send private message  E-mail  Edit post Reply with quote


It wasn't meant as complaint, just a suggestion :)
Glad you found the solution to your problem.




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 04-30-2013 04:21 AM           Profile Send private message  E-mail  Edit post Reply with quote


@Eraser

Hehe it's ok I didn't take it as a complaint. When I made the thread I couldn't think of anything better, and was worried I wouldn't get any help.




Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 04-30-2013 08:08 AM           Profile Send private message  E-mail  Edit post Reply with quote


You're right, I forgot a line:
Code:
static void CG_MiniScores_f( void ) {

   if (cg.scoresRequestTime + 2000 < cg.time) {
      trap_RequestScores;(?) (I don't remember the function name)
      cg.miniBoardRequestTime = cg.time;
   }   
   else
      cg.miniBoardRequestTime = cg.scoresRequestTime;

   cg.showMiniBoard = qtrue;
}


If it still doesn't work look what CG_ScoresDown_f() does and try to fix your function.




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 05-02-2013 09:23 AM           Profile Send private message  E-mail  Edit post Reply with quote


OK I think this is my final question. Before Uglyfoot's help I also had the CG_PrintMiniScoreboard(); function print at intermission just under CG_DrawIntermission(); in the CG_Draw2D function in cg_draw.c file.

Works just fine. Until last night there was a strange anomaly. I was testing in Windowed mode, 'cause if something crashes in full screen Q3 freezes.

So during intermission there were no crashes and I wanted to test in full screen.

Well this time around while in intermission and now in full screen the CG_MiniScoreboard(); didn't print. Toggling between full and windowed mode nothing.

I understand the code you gave will only print once so it makes sense that switching between modes it wouldn't print again.

Adding cg.snap->ps.pm_type == PM_INTERMISSION or cg.predictedPlayerState.pm_type == PM_INTERMISSION didn't help print again.

Hope there's a way to solve, I believe there is but I'm not seeing right now. Overworked / overstressed.

I appreciate all your help, big thanx.




Top
                 

Gibblet
Gibblet
Joined: 03 Apr 2013
Posts: 19
PostPosted: 05-03-2013 09:25 AM           Profile Send private message  E-mail  Edit post Reply with quote


OK I solved it by replacing CG_PrintMiniScoreboard(); with trap_SendConsoleCommand( "miniscores" );




Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.