Jump to content

play sound


Stevenn

Recommended Posts

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!

Link to comment
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..

Link to comment
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
Link to comment
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.

Link to comment
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
Link to comment
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. 

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