Forum

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

English script timing

3 replies
To the start Previous 1 Next To the start

old script timing

omg
User Off Offline

Quote
when a part of a script runs like
1
2
3
4
function f(id)
	parse("hudtxtalphafade "..id.." 0 1000 0")--visibility of hudtxt 0 goes to 0% in 1 second
	parse("hudtxtalphafade "..id.." 0 1000 1")--visibility of hudtxt 0 goes to 100% in 1 second
end
does the program wait for the first line to finish running before running the second line, or do they run at the same time? if they run simultaneously, is it possible to delay the second line so that it runs later, without interfering with additional calls to function f?

old Re: script timing

Apache uwu
User Off Offline

Quote
Yeah, you would need to setup a timer.

1
2
3
4
function f(id)
	parse("hudtxtalphafade "..id.." 0 1000 0")--visibility of hudtxt 0 goes to 0% in 1 second
	timer(1000,"parse","hudtxtalphafade "..id.." 0 1000 1")--visibility of hudtxt 0 goes to 100% in 1 second
end

old Re: script timing

omg
User Off Offline

Quote
thats what i thought...but if i use a timer, wont f() get intercepted by the first timer if it runs twice within less than a second of each run? like, the first run's timer will activate partway thru the second run and will cut off the first hudtxtalphafade

old Re: script timing

Apache uwu
User Off Offline

Quote
Then it's up to your script to make sure that that doesn't happen.

It is also possible to use hooks instead like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("ms100","_ms100")

count=0

function f(id)
	parse("hudtxtalphafade "..id.." 0 1000 0") --visibility of hudtxt 0 goes to 0% in 1 second
	count=1000
end

function _ms100()
	count=count-1
	if count==0 then
		parse("hudtxtalphafade "..id.." 0 1000 1")--visibility of hudtxt 0 goes to 100% in 1 second
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview