Jump to content

play sound


Stevenn

Recommended Posts

Posted

hey i want to play a sound when i start the resource, not when a player login or connect only when i restart/start resource

function soundPlay() 
    sound = playSound ("files/mission.mp3",false) 
    setSoundVolume(sound, 1.0) 
end 
addEventHandler("onClientResourceStart", root, soundPlay) 

thanks!

Posted
function soundPlay ( ) 
    sound = playSound ("files/mission.mp3", false ) 
    setSoundVolume ( sound, 1.0 ) 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, soundPlay ) 

Posted
function soundPlay ( ) 
    sound = playSound ("files/mission.mp3", false ) 
    setSoundVolume ( sound, 1.0 ) 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, soundPlay ) 

Yea, i've tried that, the sound is still playing if i reconnect..

Posted
That's because every time you join, you download the client side resources and that triggers "onClientResourceStart".

oh, is it possible to not make it trigger?

Posted (edited)
That's because every time you join, you download the client side resources and that triggers "onClientResourceStart".

oh, is it possible to not make it trigger?

try this:

addEventHandler ( "onClientPlayerJoin", root,function( ) 
    sound = playSound ("files/mission.mp3", false ) 
    setSoundVolume ( sound, 1.0 ) 
end) 

Edited by Guest
Posted
That's because every time you join, you download the client side resources and that triggers "onClientResourceStart".

oh, is it possible to not make it trigger?

try this:

addEventHandler ( "onClientPlayerJoin", root,function( ) 
    sound = playSound ("files/mission.mp3", false ) 
    setSoundVolume ( sound, 1.0 ) 
end) 

wouldn't that specifically play the sound when i join? i want it to only play when i restart the resource.

Posted
wouldn't that specifically play the sound when i join? i want it to only play when i restart the resource.

oh, srry, you could only use it for when the resource start/stop.

Posted (edited)
function soundPlay ( command ) 
    sound = playSound ( "files/mission.mp3", false ) 
    setSoundVolume ( sound, 1.0 ) 
end 
addCommandHandler ( "sound", soundPlay ) -- change the command into whatever you want. 

Edited by Guest
Posted
function soundPlay ( command ) -- Command handlers client side has no player argument. 
    sound = playSound ( "files/mission.mp3", false ) 
    setSoundVolume ( sound, 1.0 ) 
end 
addCommandHandler ( "sound", soundPlay ) -- change the command into whatever you want. 

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...