Forum

> > CS2D > Scripts > Timer sound and image
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Timer sound and image

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Timer sound and image

D-D3ADxPro
User Off Offline

Zitieren
Im trying to make a script that a timer will count down. I tried placing sv_sound's to make the timer count down each sound. Although theirs no error, but all of the sounds play at the same time before the counter starts to count down

Heres the script:
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("startround","beasttimer")
function beasttimer()
	timer(1000,"parse",'sv_msg "5@C"')
	parse("sv_sound \"Beast_Timer/timer_5.wav\"")
	timer(2000,"parse",'sv_msg "4@C"')
	parse("sv_sound \"Beast_Timer/timer_4.wav\"")
	timer(3000,"parse",'sv_msg "3@C"')
	parse("sv_sound \"Beast_Timer/timer_3.wav\"")
	timer(4000,"parse",'sv_msg "2@C"')
	parse("sv_sound \"Beast_Timer/timer_2.wav\"")
	timer(5000,"parse",'sv_msg "1@C"')
	parse("sv_sound \"Beast_Timer/timer_1.wav\"")
end


And I also need another script that once the timer is done, it will randomly make 1 player a terrorist. Once that player spawns, a random image will be shown on him.

alt Re: Timer sound and image

Yates
Reviewer Off Offline

Zitieren
You didn't place the sound functions in a timer. The fuck, you think it's gonna magically work because you added timers above it?

alt Re: Timer sound and image

Alexsandro
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("startround","beasttimer")
function beasttimer()
     timer(1000,"parse",'sv_msg "5@C"')
     timer(1000,"parse",'sv_sound \"Beast_Timer/timer_5.wav\"')
     timer(2000,"parse",'sv_msg "4@C"')
     timer(2000,"parse",'sv_sound \"Beast_Timer/timer_4.wav\"')
     timer(3000,"parse",'sv_msg "3@C"')
     timer(3000,"parse",'sv_sound \"Beast_Timer/timer_3.wav\"')
     timer(4000,"parse",'sv_msg "2@C"')
     timer(4000,"parse",'sv_sound \"Beast_Timer/timer_2.wav\"')
     timer(5000,"parse",'sv_msg "1@C"')
     timer(5000,"parse",'sv_sound \"Beast_Timer/timer_1.wav\"')
end

if the sounds are long in relation to the time duration, you need to increase the run time to prevent two sounds from curling

Spoiler >


---

And this is the script that will randomly turn a player terrorist

1
2
3
4
5
6
7
8
9
10
11
12
13
14
T = false
function SetTR()
	for a,b in pairs(player(0,"table")) do
		if  a >0 then
			if T == false then
				u = math.random(1,#player(0,"table"))
				if player(u,"exists") and player(u,"team")>0 then
					timer(3000,"parse","maket "..u)
					T = true
				end
			end
		end
	end
end

alt Re: Timer sound and image

useigor
User Off Offline

Zitieren
Use > this.

1.) Add hooks cs2d lua hook startround and cs2d lua hook second.
2.) Change "count_down=15" to "count_down=5"
3.) Change "count_down==-1" to "count_down<1"
4.) Change "0,#player" to "#player"
5.) Put the code under "parse("maket "..t)"
1
parse("spawnplayer "..t.." "..player(t,"x").." "..player(t,"y"))
6.) Put the code above "count_down=count_down-1":
1
timer(0,"parse",'sv_sound "Beast_Timer/timer_'..count_down..'.wav"')

Well, i think "random" images names should have numbers in the name.
Example for "image1-10.jpg" images:
1
2
local rndm=image("gfx/image"..math.random(1,10)..".jpg",0,0,1)
imagepos(rndm,player(t,"x"),player(t,"y"),0)
If you don't that image follow the player then put the code under code from "5.)".

alt Re: Timer sound and image

MikuAuahDark
User Off Offline

Zitieren
Try this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
temp=6

function do_it()
	temp=temp-1
	if temp==0 then
		-- Your Code
	else
		msg(temp.."@C")
		parse("sv_sound \"Beast_Timer/timer_"..temp..".wav\"")
	end
end

-- Put this code below somewhere on your script
if timerEx then
	timerEx(1000,do_it,5)
else
	timer(1000,"do_it","",5)
end
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht