Help: displaying 'Time left in Game'
Moderator: InsideQC Admins
10 posts
• Page 1 of 1
Help: displaying 'Time left in Game'
Hi all,
OBJECTIVE: To have a timer on the screen showing the minutes and seconds left till the end of the game.
SHORT VERSION:
How can I output the result of the above timer without having it instantly overwrite every string the game sprints and bprints?
LONG VERSION:
The current 'solution' is to only display the timer if a new variable .timerclear is less than or equal to time.
The main function only outputs the timer if .timerclear 's value is less than or equal to time, as follows:
This works with centerprints because I can insert a call to TimerClear (and set players .timer_clear to time+3), BUT I can't do this in sprint, because sprint is a builtin!
defs.qc has the following functions that also print stuff to the screen:
I was told that you can't put a wrapper on a builtin [EDIT: I mean builtin as above - w unspecified arguments], so apart from modifing the engine(which I'm too newbie to even contemplate) ...
... what are my options?
thanks in advance,
OneManClan
ps, Reminder, I'm still a newb, so please don't hesitate to dumb down your responses
OBJECTIVE: To have a timer on the screen showing the minutes and seconds left till the end of the game.
SHORT VERSION:
How can I output the result of the above timer without having it instantly overwrite every string the game sprints and bprints?
LONG VERSION:
The current 'solution' is to only display the timer if a new variable .timerclear is less than or equal to time.
- Code: Select all
// this is called every time a player gets printed something
// it pauses the display of the timer by 3 seconds
void(entity pl) TimerClear =
{
pl.timer_clear = time + 3;
};
The main function only outputs the timer if .timerclear 's value is less than or equal to time, as follows:
- Code: Select all
// output the results to the players
while (n < 32)
{
n = n+1;
e = nextent(e);
// an entitys .timer_clear gets set to time+3 every time the game prints something on screen
if(e.timer_clear <= time)
centerprint(e, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n Time left: ", stminutes, ":", sttens, stones);
}
};
This works with centerprints because I can insert a call to TimerClear (and set players .timer_clear to time+3), BUT I can't do this in sprint, because sprint is a builtin!
defs.qc has the following functions that also print stuff to the screen:
- Code: Select all
//void(entity client, string s) sprint = #24;
void(...) nqw_bprint = #23;
void(...) nqw_sprint = #24;
// used for QW compatibility
void(...) bprint = #23;
void(...) sprint = #24;
void(...) bprint2 = #23;
void(...) sprint2 = #24;
.
.
.
I was told that you can't put a wrapper on a builtin [EDIT: I mean builtin as above - w unspecified arguments], so apart from modifing the engine(which I'm too newbie to even contemplate) ...
... what are my options?
thanks in advance,
OneManClan
ps, Reminder, I'm still a newb, so please don't hesitate to dumb down your responses
Last edited by OneManClan on Tue Jan 18, 2011 4:10 pm, edited 1 time in total.
- OneManClan
- Posts: 243
- Joined: Sat Feb 28, 2009 2:38 pm
In defs.qc, find this:
and change to:
Now, at the top of defs.qc, add your centerprint() function, like this:
- Code: Select all
void(entity client, string s) centerprint = #73; // sprint, but in middle
and change to:
- Code: Select all
void(entity client, string s) __centerprint = #73; // sprint, but in middle
Now, at the top of defs.qc, add your centerprint() function, like this:
- Code: Select all
void (entity client, string s) centerprint =
{
// put your code here
// (...)
// and finally...
__centerprint (client, s);
}
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
frag.machine wrote:In defs.qc....
Thanks frag.machine. I was able to do this (make a wrapper) for centreprint, but the issue here is trying to wrap functions w unspecified arguments, specifically:
void(...) bprint = #23;
void(...) sprint = #24;
I'm told this is NOT possible
1. The sprint, bprint, centreprint etc outputs
2. Hitting 'tab' brings up the menu bar, but you can *still* see the above messages continue to appear.
3. Death messages (fading in and out).
4. A display of how fast you are moving
So there must be another method...
OneManClan
ps. I'd use CSQC but most players are still using ezquake/fuhquake.
- OneManClan
- Posts: 243
- Joined: Sat Feb 28, 2009 2:38 pm
Some engines such as ezQuake support this feature engine side.
Couldn't you use a variable for the unspecified arguments?
Couldn't you use a variable for the unspecified arguments?
- Team Xlink
- Posts: 368
- Joined: Thu Jun 25, 2009 4:45 am
- Location: Michigan
Team Xlink wrote:Some engines such as ezQuake support this feature engine side.
Not sure what you mean.. Is there an alternative, client specific way to output the timer? Please explain.
Team Xlink wrote: Couldn't you use a variable for the unspecified arguments?
Well fteqw.qc does contain some code which looks like it receives '(...)', and I recall someone saying that a function can return a function... Otoh, someone else suggested that outputting the timer every frame, for every client will slow down the server, so I don't know if I need a completely different implementation concept, or just put the idea in the 'too hard' basket.
- OneManClan
- Posts: 243
- Joined: Sat Feb 28, 2009 2:38 pm
OMC that was me suggesting you use a timer or time compare to only send down the centerprint stuff when needed. Sending a centerprint to client on everyframe can be a bottle neck and wasteful.
Might suggest an alternative in using the monster kill count / total monsters count that is displayed on the left bottom of the quake client status bar. Don't know if those are disabled during regular tf play or not since they are not really used. You could use the total monsters killed count as your minutes and total monster count as your seconds. Since you would use the writebyte / writelong code options to update them, you would broadcast it to all clients in one pass. Again I would use some timer function or time compare send this stuff down the line to clients. No sense of sending things when not necessary.
Might suggest an alternative in using the monster kill count / total monsters count that is displayed on the left bottom of the quake client status bar. Don't know if those are disabled during regular tf play or not since they are not really used. You could use the total monsters killed count as your minutes and total monster count as your seconds. Since you would use the writebyte / writelong code options to update them, you would broadcast it to all clients in one pass. Again I would use some timer function or time compare send this stuff down the line to clients. No sense of sending things when not necessary.
- ratbert
- Posts: 37
- Joined: Thu Nov 19, 2009 3:47 pm
ratbert wrote:OMC that was me suggesting you use a timer or time compare to only send down the centerprint stuff when needed.
Thanks Ratbert, yes I did save your comments (via screenshot) and will look over them carefully tomorrow when I have more time. Btw I avoid mentioning the names of Gurus when I'm hoping they're wrong (I don't want to appear disrespectful), and as a newb, there's a good chance I've misunderstood what they meant anyway..
ratbert wrote:Sending a centerprint to client on everyframe can be a bottle neck and wasteful.
Well I got the method from the Mission Timer tutorial (inside3d). What if the server only sent the 'timeleft' once every second? (I'll try it when I get home). Though this would still overwrite all the sprints - unless..:
ratbert wrote:Might suggest an alternative in using the monster kill count / total monsters count that is displayed on the left bottom of the quake client status bar. Don't know if those are disabled during regular tf play or not since they are not really used. You could use the total monsters killed count as your minutes and total monster count as your seconds. Since you would use the writebyte / writelong code options to update them, you would broadcast it to all clients in one pass. Again I would use some timer function or time compare send this stuff down the line to clients. No sense of sending things when not necessary.
Brilliant! Using ezquake (single-player mode), holding down 'tab' shows monsters, secrets and time since game began. TF-mode (customtf) shows only the time since the game began..
Can these displays be modifid via QuakeC...?
Can they be made to show *without* hitting 'tab'?
Where can I get more info?
- OneManClan
- Posts: 243
- Joined: Sat Feb 28, 2009 2:38 pm
OneManClan wrote:frag.machine wrote:In defs.qc....
Thanks frag.machine. I was able to do this (make a wrapper) for centreprint, but the issue here is trying to wrap functions w unspecified arguments, specifically:
void(...) bprint = #23;
void(...) sprint = #24;
I'm told this is NOT possible.. and I'm currently looking for another solution. I can't help noticing that the Quake engine *can* display multiple text at the same time, eg when using ezquake, I can simultaneously see:
1. The sprint, bprint, centreprint etc outputs
2. Hitting 'tab' brings up the menu bar, but you can *still* see the above messages continue to appear.
3. Death messages (fading in and out).
4. A display of how fast you are moving
So there must be another method...
OneManClan
ps. I'd use CSQC but most players are still using ezquake/fuhquake.
If by "(...)" you mean variable number of parms, then you can do this:
- Code: Select all
void(string s1) bprint = #23;
void(string s1, string s2) bprint2 = #23;
void(string s1, string s2, string s3) bprint3 = #23;
(...)
You can repeat it up to 7 input parameters (this is a vanilla Quake limitation, don't know if it aplies for DP or FTEQW).
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
10 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
