PDA

View Full Version : Time played



thOuMta
26th February 2013, 22:35
Hey,

How i can make a Time played script (in hud) please ?

Thx :)

IzNoGoD
26th February 2013, 22:51
Make a script that monitors time played.

Make another script that writes it to hud...

thOuMta
26th February 2013, 23:05
hmmm what do you mean ?

Jeplaa
27th February 2013, 07:33
Use: SetTimerUp( <time> ) to count time.

IzNoGoD
27th February 2013, 08:38
settimerup doesnt work for some reason. Tried it, tried settenthstimerup too, but it seems like IW left it out of cod2... (does NOT give an unknown function error. Just sets the timer on 0:00 and doesnt move...)

Jeplaa
27th February 2013, 09:30
ahh ok sorry then didn't tested it for now

Ni3ls
27th February 2013, 10:02
Make a loop with a wait 1; So every second it will update the time with 1 second

Earliboy
27th February 2013, 10:25
Ye and when the map ends, you get played = 0

Save that stat to an file, update the Server itself every minute and save this to every player. If u wanna give out Hours played just
self.played["hours"] = self.played["minutes"] / 60;
self.played["hours"] = int(self.played["hours"]); //Makes it to a full number, not 1.5 as example

Tally
27th February 2013, 13:35
settimerup doesnt work for some reason. Tried it, tried settenthstimerup too, but it seems like IW left it out of cod2... (does NOT give an unknown function error. Just sets the timer on 0:00 and doesnt move...)

It works in SP. Many functions in COD2 only work in SP - getStance() is the classic one. The MP functionality of many of these functions was only completed with COD4.

thOuMta
12th June 2013, 13:13
I try all but cant make it...

RobsoN
12th June 2013, 13:50
If you want time in seconds hud wont be difficult.

Call this function on playerConnected: ( self thread _countTime() )

and on CallbackStartGametype add:

precacheString(&"Seconds Played: ");



_countTime()
{
self endon("disconnect");

self.seconds_HUD = newClientHudElem(self);
self.seconds_HUD.x = 305;
self.seconds_HUD.y = 140;
self.seconds_HUD.alignX = "center";
self.seconds_HUD.alignY = "middle";
self.seconds_HUD.sort = 1;
self.seconds_HUD.alpha = 1;
self.seconds_HUD.fontScale = 1.3;
self.seconds_HUD.label = &"Seconds Played: ";

self.timeplayed = 0;

while(1)
{
wait 1;
self.timeplayed+= 1;
self.seconds_HUD setValue(self.timeplayed);
}

}


I hope, I helped you a bit.

thOuMta
12th June 2013, 13:57
Thx rob :)

What i need make for count this time in min ? like 0:00.

RobsoN
12th June 2013, 14:09
You need 2 Huds. Just add 1 more hud call it eg. minutes_HUD, then in while(1) loop add: self.minutesplayed += 1/60; and self.minutes_HUD setValue(int(self.minutesplayed));

ah + define the varriable below self.timeplayed = 0; add: self.minutesplayed = 0;

randall
12th June 2013, 14:40
http://www.totalconversion.hu/sub_domain/doc/ScriptFunctions/HUD/settimerup.htm

Tally
12th June 2013, 16:28
http://www.totalconversion.hu/sub_domain/doc/ScriptFunctions/HUD/settimerup.htm

Please read the thread before posting. IznoGod has already pointed out that the setTimerUp() does not work in COD2 MP (although it does in SP).

IzNoGoD
12th June 2013, 17:23
Well, settimerup does NOT return an error when using it. It just doesnt start counting.

Note: this was tested on a linux server.

Tally
12th June 2013, 19:48
Well, settimerup does NOT return an error when using it. It just doesnt start counting.

Note: this was tested on a linux server.

No one said it DOES.

IzNoGoD
12th June 2013, 19:50
What i mean to say is, normally, when trying SP-only functions in MP, you get the "unknown function"-error.
Not with settimerup.

As this is different from all those SP-functions, I pointed it out for the sake of the community. It just might work on windows servers for example.

PatmanSan
12th June 2013, 21:11
It's kinda counter-intuitive, but the time you pass as parameter for setTimerUp and setTenthsTimerUp is the time to wait before it starts ticking. There is no way to set the max, so it just ticks until you kill the hud element. Do a quick test using setTimerUp(10), and you will see it will start ticking after 10 seconds.

randall
12th June 2013, 21:50
Please read the thread before posting. IznoGod has already pointed out that the setTimerUp() does not work in COD2 MP (although it does in SP).

Yes, but IzNoGod's pointing was wrong such as the function description in Docs. The time argument in fact a delay in seconds.