Forum

> > CS2D > Scripts > A code won't work
Forums overviewCS2D overview Scripts overviewLog in to reply

English A code won't work

4 replies
To the start Previous 1 Next To the start

old A code won't work

Xirot
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
addhook('kill','kill')
function kill()
        local number=math.random(1,3)
        if number == 1 then
                parse('sv_sound [Scream]/Scream1')
        elseif number==2 then
                parse('sv_sound [Scream]/Scream2')
        elseif number==3 then
                parse('sv_sound [Scream]/Scream2')
        end
end
I made this code , the lua work (no errors in console) how ever the sounds are not started.

old Re: A code won't work

Gajos
BANNED Off Offline

Quote
user Infinite Rain is right. You must use .wav or .ogg
This is better:
1
2
3
4
5
6
7
cs = {}

addhook('kill','cs.kill')
cs.kill = function()
	local number = math.random(1,3)
	parse('sv_sound [Scream]/Scream'..number..'.wav')
end

old Re: A code won't work

Alistaire
User Off Offline

Quote
user Gajos has written
1
2
3
4
5
6
7
cs = {}

addhook('kill','cs.kill')
cs.kill = function()
	local number = math.random(1,3)
	parse('sv_sound [Scream]/Scream'..number..'.wav')
end


Why such a useless cs table, and declaration of number if it's gonna be used once anyways.

1
2
3
4
5
addhook('kill', 'killHook')

function killHook()
	parse('sv_sound \"[Scream]/Scream'..math.random(1, 3)..'.wav\" ')
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview