Hey,
How i can make a Time played script (in hud) please ?
Thx :)
Printable View
Hey,
How i can make a Time played script (in hud) please ?
Thx :)
Make a script that monitors time played.
Make another script that writes it to hud...
hmmm what do you mean ?
Use: SetTimerUp( <time> ) to count time.
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...)
ahh ok sorry then didn't tested it for now
Make a loop with a wait 1; So every second it will update the time with 1 second
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
I try all but cant make it...
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: ");
I hope, I helped you a bit.PHP Code:
_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);
}
}
Thx rob :)
What i need make for count this time in min ? like 0:00.
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;
Well, settimerup does NOT return an error when using it. It just doesnt start counting.
Note: this was tested on a linux server.
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.
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.