Jump to content

Play a sound to everyone (not radioshit)


Puma

Recommended Posts

Hi,

I know this has been asked several times already, but I just haven't found what I'm looking for.

I want to script a command which will result in a sound being played for everyone. Now, I've searched quite a lot and I found some topics about the radiostation-script, but that wasn't what I needed: I just want something that manipulates the "playSound"-clientside-function so that the sound is played to all players at the same time.

Is it even possible to script it?

Link to comment

You could script the command server-side and then trigger a client event to play the sound for every player.

This could look like this:

Server-side:

addCommandHandler("sound",
function (player)
triggerClientEvent("onSoundRequest", player)
end
)

Client-side:

addEvent("onSoundRequest", true)
addEventHandler("onSoundRequest", getRootElement(),
function ()
playSound("sounds/mySound.mp3")
end
)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...