pls Hlp For stop Sounds playing at a certain time
1 reply



18.05.13 09:01:52 am
Hello staff
Today I wanted to know how to use the delay in a sound and moves him to stop playing at a certain time
Today I wanted to know how to use the delay in a sound and moves him to stop playing at a certain time
Lua;
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
sound = {
--[[
['tilex:tiley'] = {
on = false,
during = 100, --during only when you want the sound to stop after X milliseconds (not seconds)
length = 10, --length is the length in milliseconds of the soundfile (not seconds)
file = '\"map/file.extension\"'
},
['tilex2:tiley2'] = {
stop = 'tilex:tiley' --this stops the file
}
--]]
['10:20'] = {
on = false,
during = 10,
length = 3,
file = '\"player/hit1.wav\"'
},
['20:5'] = {
stop = '10:20'
}
}
addhook('movetile', 'movetileHook')
addhook('ms100', 'ms100Hook')
function movetileHook(id, x, y)
local tbl = sound[x..':'..y]
if tbl then
if tbl.on ~= nil then
if tbl.during ~= nil then
sound[x..':'..y].remaining = tbl.during
end
sound[x..':'..y].left, sound[x..':'..y].on = tbl.length, true
elseif tbl.stop then
sound[tbl.stop].remaining, sound[tbl.stop].left, sound[tbl.stop].on = nil, nil, false
end
end
end
function ms100()
for k, v in pairs(sound) do
if sound[k].on ~= false and sound[k].on ~= nil then
sound[k].left = sound[k].left - 1
if sound[k].left == 0 then
parse('sv_sound '..sound[k].file)
sound[k].left = sound[k].length
end
if sound[k].remaining then
sound[k].remaining = sound[k].remaining - 1
if sound[k].remaining == 0 then
sound[k].on = false
end
end
end
end
end
--[[
['tilex:tiley'] = {
on = false,
during = 100, --during only when you want the sound to stop after X milliseconds (not seconds)
length = 10, --length is the length in milliseconds of the soundfile (not seconds)
file = '\"map/file.extension\"'
},
['tilex2:tiley2'] = {
stop = 'tilex:tiley' --this stops the file
}
--]]
['10:20'] = {
on = false,
during = 10,
length = 3,
file = '\"player/hit1.wav\"'
},
['20:5'] = {
stop = '10:20'
}
}
addhook('movetile', 'movetileHook')
addhook('ms100', 'ms100Hook')
function movetileHook(id, x, y)
local tbl = sound[x..':'..y]
if tbl then
if tbl.on ~= nil then
if tbl.during ~= nil then
sound[x..':'..y].remaining = tbl.during
end
sound[x..':'..y].left, sound[x..':'..y].on = tbl.length, true
elseif tbl.stop then
sound[tbl.stop].remaining, sound[tbl.stop].left, sound[tbl.stop].on = nil, nil, false
end
end
end
function ms100()
for k, v in pairs(sound) do
if sound[k].on ~= false and sound[k].on ~= nil then
sound[k].left = sound[k].left - 1
if sound[k].left == 0 then
parse('sv_sound '..sound[k].file)
sound[k].left = sound[k].length
end
if sound[k].remaining then
sound[k].remaining = sound[k].remaining - 1
if sound[k].remaining == 0 then
sound[k].on = false
end
end
end
end
end
edited 1×, last 18.05.13 10:22:30 am



