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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

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

lol

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. 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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