Forum

> > CS2D > Scripts > Time script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Time script

10 replies
To the start Previous 1 Next To the start

old Time script

Autumn
User Off Offline

Quote
Hi people.I have made time script...
Spoiler >

But I have one problem how to make that time stopped on 0 and did not leave in a minus (-1,-2,-3....)

old Re: Time script

DC
Admin Off Offline

Quote
add "if sample.hudtxt.timer>0 then" to the beginning of the sample.hudtxt.second() function and another "end" to its end.
(btw.: you shouldn't use the sample table for your scripts. it's for samples )

old Re: Time script

Autumn
User Off Offline

Quote
Thanks for the help
But I have 1 more question. How to make that in the beginning of each round the timer was = 60? Because at start of a card the script starts to work for me normally, time reaches to 0 and at a new round the timer is not nulled till 60 seconds. How it to correct?
edited 1×, last 15.10.11 12:46:31 am

old Re: Time script

DC
Admin Off Offline

Quote
you have to use the startround hook.

1
2
3
4
addhook("startround","start")
function start()
	sample.hudtxt.timer=60
end

old Re: Time script

Autumn
User Off Offline

Quote
I already tried it, why that does not work. The timer all the same remains on 0

old Re: Time script

DC
Admin Off Offline

Quote
that's impossible. make sure that there is no typo. see what the console says. add prints to make sure that the function is actually called.

old Re: Time script

Autumn
User Off Offline

Quote
The console does not give out errors. I do not understand where there can be an error. Look please at a script.
Spoiler >

old Re: Time script

DC
Admin Off Offline

Quote
the problem is that you overwrite your function:
1
2
function sample.hudtxt.second()
end
it's a bad idea obviously!
replace the 2 lines above with
1
freehook("second","sample.hudtxt.second")

and also add
1
addhook("second","sample.hudtxt.second")
to the start function!

that should fix your problem.
of course you could also have done it the way I suggested (with the >0 condition). would have been much easier

old Re: Time script

Autumn
User Off Offline

Quote
It should look so?
Spoiler >

That I do not understand that

old Re: Time script

DC
Admin Off Offline

Quote
yeah but you forgot my second instruction. the addhook in start part.

old Thanks

Autumn
User Off Offline

Quote
Everything, I have made a script, now it works нормально.Dc, thanks you big)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview