Requesting scores
-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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.
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 Tue Apr 30, 2013 1:02 am, edited 1 time in total.
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?
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?
-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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 =).
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 =).
Re: Q3 coding question
It's something like that. This code in CG_DrawActiveFrame:
And this in your command function:
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.
Code: Select all
if (( cg.miniBoardRequestTime + 2000 < cg.time ) && cg.showMiniBoard) {
// show yor miniboard;
cg.showMiniBoard=qfalse;
}
Code: Select all
cg.miniBoardRequestTime=cg.scoresRequestTime;
cg.showMiniBoard=qtrue;
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.
-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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.
Re: Q3 coding question
Ok, let me know if it works 

-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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.
Re: Q3 coding question
If you need help to compile .qvms you can take a look at this tutorial.
-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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 =(.
-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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.
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.
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.
-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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.
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.
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.
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.
Code: Select all
if (( cg.miniBoardRequestTime + 2000 < cg.time ) && cg.showMiniBoard) {
// show yor miniboard;
cg.showMiniBoard=qfalse;
}
Last edited by UglyFoot on Sun May 05, 2013 12:43 am, edited 1 time in total.
-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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.
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.
Re: Q3 coding question
I don't know why you have to press the key twice but try this in your function:
and in CG_DrawActiveFrame:
Code: Select all
if (cg.scoresRequestTime + 2000 < cg.time) cg.miniBoardRequestTime = cg.time;
else cg.miniBoardRequestTime=cg.scoresRequestTime;
cg.showMiniBoard=qtrue;
Code: Select all
if (( cg.miniBoardRequestTime + 2000 < cg.time ) && cg.showMiniBoard) {
// show yor miniboard;
cg.showMiniBoard=qfalse;
}
-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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.
-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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
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
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.
-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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.
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.
Re: Q3 coding question
Ok, try this:
In local.h:
In CG_DrawActiveFrame:
In cg_consolecmds.c:
In local.h:
Code: Select all
int miniBoardRequestTime;
qboolean showMiniBoard;
Code: Select all
if (( cg.miniBoardRequestTime + 2000 < cg.time ) && cg.showMiniBoard) {
CG_PrintMiniScoreboard();
cg.showMiniBoard=qfalse;
}
Code: Select all
static void CG_MiniScores_f( void ) {
if (cg.scoresRequestTime + 2000 < cg.time)
cg.miniBoardRequestTime = cg.time;
else
cg.miniBoardRequestTime = cg.scoresRequestTime;
cg.showMiniBoard = qtrue;
}
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 


-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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.
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.
Re: Requesting scores
It wasn't meant as complaint, just a suggestion 
Glad you found the solution to your problem.

Glad you found the solution to your problem.
-
- Posts: 19
- Joined: Wed Apr 03, 2013 7:23 pm
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.
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.
Re: Requesting scores
You're right, I forgot a line:
If it still doesn't work look what CG_ScoresDown_f() does and try to fix your function.
Code: Select all
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;
}