Forum

> > CS2D > Scripts > 2 codes of script.
Forums overviewCS2D overview Scripts overviewLog in to reply

English 2 codes of script.

6 replies
To the start Previous 1 Next To the start

old 2 codes of script.

Unnamed404
BANNED Off Offline

Quote
The 1st : If the player die the song1 , song2 or song3 in my sfx folder start .
The second : I want behind every palm (obj) a wall.

old Re: 2 codes of script.

RebornDuck
User Off Offline

Quote
This is for the first code. Untested but I think it works.

1
2
3
4
5
6
addhook("die","playDie")
function playDie()
	if player(id,"health") == 0 then
		parse("sv_sound2 "..id.." song1")
	end
end

old Re: 2 codes of script.

Dynamite07
User Off Offline

Quote
user RebornDuck has written
This is for the first code. Untested but I think it works.

1
2
3
4
5
6
addhook("die","playDie")
function playDie()
	if player(id,"health") == 0 then
		parse("sv_sound2 "..id.." song1")
	end
end


You should add a math random, i think he mean that.

old Re: 2 codes of script.

Avo
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
songs = 	{
				--// paths to all available sounds (separated with comma, as in example below)
				"song1.wav",
				"song2.wav",
				"song3.wav"
			}
addhook("die", "onDie")
onDie = function(id)
	parse("sv_sound2 "..id.." '"..songs[math.random(1, # songs)].."'")
end
@user RebornDuck: When player dies, his/her HP equals zero, so...

And more important mistake you made it's no "id" parameter in function "playDie", where you use it in "parse" command.

old Re: 2 codes of script.

Alistaire
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
for x = 0, map('xsize') do
	for y = 0, map('ysize') do
		if entity(x, y, 'exists') then
			if entity(x, y, 'int0') == 0 then
				--create a wall on the x and y
			end
		end
	end
end

Idk what wall you mean, nor how to spawn a dynwall on a location.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview