Forum

> > CS2D > Scripts > How to check if the server is playing a sound
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch How to check if the server is playing a sound

30 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Re: How to check if the server is playing a sound

Zeik
User Off Offline

Zitieren
I forgot to change queueSound:
1
2
3
function queueSound(id, queue, sound)
  List.push(queue[id], sound)
end

It should work now:
Mehr >

alt Sound durations

VADemon
User Off Offline

Zitieren
That's a quick and simple way to make a list with sound durations:
Code >

• Download ffmpeg's "ffprobe.exe" and put it to CS2D root folder (ffmpeg package for Linux)
• Put the script to autorun/
• Start in-game server and type this in console: "lua soundtime.export()"
• Wait 2-10 minutes
∗ cs2d/soundtime.lua will contain the sound times

° Some files will not return a duration because ffmpeg thinks they're corrupt

Load this list with:
1
local longtablenamesmakemytaillonger = dofile("soundtime.lua")

The table consists of
["sound path"] = "duration in seconds"

alt Re: How to check if the server is playing a sound

Mami Tomoe
User Off Offline

Zitieren
@user Zeik: One error has left:
1
2
3
4
5
6
LUA ERROR: sys/lua/cool stuff/play.lua:27: attempt to index local 'list' (a nil value)
 -> sys/lua/cool stuff/play.lua:27: in function 'push'
 -> sys/lua/cool stuff/play.lua:61: in function 'queueSound'
 -> sys/lua/cool stuff/main.lua:4: in main chunk
 -> [C]: in function 'dofile'
 -> sys/lua/server.lua:2: in main chunk

I have a question how to call
sv_sound
and how to call
sv_sound2
?
is it
queueSound(0,queue,sound[1])
for all and change 0 to id for one?

I also sometimes get this in console is that normal?
1
FATAL ERROR [UNHANDLED EXCEPTION]: CreateSoundBuffer failed (87)

alt Re: How to check if the server is playing a sound

Zeik
User Off Offline

Zitieren
@user Mami Tomoe: You have to create the queue like this:
1
queue = Array.newLists(32)
Are you doing it that way?



You call queueSound with 0 when the sound is for all:
1
queueSound(0, queue, sounds[1])

And with id when it's private:
1
queueSound(id, queue, sounds[1])

alt Re: How to check if the server is playing a sound

Mami Tomoe
User Off Offline

Zitieren
Yeah I have exactly the code you gave me in that more tag all I changed was the table for sounds

Isn't the list meant to be List?

When I put l
ua queueSound(0,queue,sounds[1])
in console I get this thing:
1
FATAL ERROR [UNHANDLED EXCEPTION]: CreateSoundBuffer failed (87)
And after a few seconds CS2D stops responding
3× editiert, zuletzt 24.01.17 15:28:04

alt Re: How to check if the server is playing a sound

Zeik
User Off Offline

Zitieren
EDIT: Okay I debugged it and found out this:
1
2
3
function killSound(id)
  isSoundRunning[id] = false
end
The timer function was sending a id string and I forgot to convert it to number so it actually never "killed" the sound.

Here's the completely functional script with an example:
Mehr >
2× editiert, zuletzt 24.01.17 18:41:28

alt Re: How to check if the server is playing a sound

Mami Tomoe
User Off Offline

Zitieren
I have fixed a few bugs and now the script works but after a few seconds the script stops working with no errors at all so I did some debugging and I found this:

isSoundRunning[1]
is true even though there is no sound running.
Setting
isSoundRunning[1]
to false manually prints that:
1
FATAL ERROR [UNHANDLED EXCEPTION]: CreateSoundBuffer failed (87)
and will leave the isSoundRunning[1] as true unless I enter it a few more times.

alt Re: How to check if the server is playing a sound

Zeik
User Off Offline

Zitieren
I pointed out the solution in the comment just before yours

I tested it and it works perfectly. So if it doesn't work then you're doing something wrong with it.

PS: If you don't understand how it works or don't mind understanding it, then I'd recommend you to leave it as it is so you don't break anything.
Just modify this with your own sounds:
1
sounds = {{"fun/doublekill.wav",1000}, {"fun/firstblood.wav",1000}}
And then play a sound using only this function call changing the id argument for 0 if its a global sound or with a number between 1 and 32 to play it for a specific player only:
1
queueSound(id, queue, sounds[1])
If you change anything else in the script then you may mess up and it's up to you to fix it.

alt Re: How to check if the server is playing a sound

Mami Tomoe
User Off Offline

Zitieren
Thank you it all works now!
One last problem though is that when both functions are being used then both sounds will play, like the following:

1
2
queueSound(0,queue,sounds[2])
queueSound(id,queue,sounds[3])

In this case
id
will hear both sounds while other players only one
id
should be able to hear both sounds though
1× editiert, zuletzt 25.01.17 14:02:51

alt Re: How to check if the server is playing a sound

Zeik
User Off Offline

Zitieren
If you want it like that then just change queueSound for this:

1
2
3
4
5
6
7
8
9
function queueSound(id, queue, sound)
  if (id ~= 0) then
    List.push(queue[id], sound)
  else
    for i in ipairs(queue) do
      List.push(queue[i], sound)
    end
  end
end
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht