Quake3World.com
https://www.quake3world.com/forum/

Requesting scores
https://www.quake3world.com/forum/viewtopic.php?f=16&t=49023
Page 1 of 1

Author:  Sheepsquatch [ 04-07-2013 11:48 AM ]
Post subject:  Requesting scores

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.

Author:  UglyFoot [ 04-08-2013 01:29 PM ]
Post subject:  Re: Q3 coding question

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?

Author:  Sheepsquatch [ 04-08-2013 03:55 PM ]
Post subject:  Re: Q3 coding question

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 =).

Author:  UglyFoot [ 04-10-2013 09:40 AM ]
Post subject:  Re: Q3 coding question

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.

Author:  Sheepsquatch [ 04-10-2013 01:10 PM ]
Post subject:  Re: Q3 coding question

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.

Author:  UglyFoot [ 04-11-2013 02:59 PM ]
Post subject:  Re: Q3 coding question

Ok, let me know if it works :)

Author:  Sheepsquatch [ 04-13-2013 04:54 AM ]
Post subject:  Re: Q3 coding question

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.

Author:  UglyFoot [ 04-14-2013 05:12 PM ]
Post subject:  Re: Q3 coding question

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

Author:  Sheepsquatch [ 04-16-2013 04:01 PM ]
Post subject:  Re: Q3 coding question

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 =(.

Author:  Sheepsquatch [ 04-20-2013 01:12 PM ]
Post subject:  Re: Q3 coding question

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

Author:  UglyFoot [ 04-21-2013 10:10 AM ]
Post subject:  Re: Q3 coding question

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.

Author:  Sheepsquatch [ 04-21-2013 12:42 PM ]
Post subject:  Re: Q3 coding question

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.

Author:  UglyFoot [ 04-22-2013 01:16 PM ]
Post subject:  Re: Q3 coding question

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.

Author:  Sheepsquatch [ 04-26-2013 05:40 AM ]
Post subject:  Re: Q3 coding question

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.

Author:  UglyFoot [ 04-26-2013 12:32 PM ]
Post subject:  Re: Q3 coding question

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;
}

Author:  Sheepsquatch [ 04-26-2013 12:56 PM ]
Post subject:  Re: Q3 coding question

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.

Author:  Sheepsquatch [ 04-26-2013 02:02 PM ]
Post subject:  Re: Q3 coding question

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

Author:  UglyFoot [ 04-27-2013 10:13 AM ]
Post subject:  Re: Q3 coding question

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.

Author:  Sheepsquatch [ 04-27-2013 01:32 PM ]
Post subject:  Re: Q3 coding question

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.

Author:  UglyFoot [ 04-27-2013 04:10 PM ]
Post subject:  Re: Q3 coding question

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;
}

Author:  Eraser [ 04-28-2013 12:48 AM ]
Post subject:  Re: Q3 coding question

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 :)

Author:  Sheepsquatch [ 04-29-2013 05:02 PM ]
Post subject:  Re: Q3 coding question

@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.

Author:  Eraser [ 04-29-2013 09:08 PM ]
Post subject:  Re: Requesting scores

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

Author:  Sheepsquatch [ 04-30-2013 04:21 AM ]
Post subject:  Re: Requesting scores

@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.

Author:  UglyFoot [ 04-30-2013 08:08 AM ]
Post subject:  Re: Requesting scores

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.

Author:  Sheepsquatch [ 05-02-2013 09:23 AM ]
Post subject:  Re: Requesting scores

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.

Author:  Sheepsquatch [ 05-03-2013 09:25 AM ]
Post subject:  Re: Requesting scores

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

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/