Adde Posted April 4, 2013 Posted April 4, 2013 Hello, I made a script that play a sound on join and then stop it on login. The problem is that the sound don´t start, what´s wrong? Thankfull for answears function playSoundOnJoin() local sound = playSound("scary.mp3") setSoundVolume(sound, 1) end addEventHandler("onPlayerJoin", root, playSoundOnJoin) function stopSoundOnLogin() stopSound(scary) end addEvent("stop", true) addEventHandler("onPlayerLogin", root, stopSoundOnLogin) btw, nothing in debug My ingame nickname is: Mr.Snus
Castillo Posted April 4, 2013 Posted April 4, 2013 playSound is only client side, and your script is server side. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
iPrestege Posted April 4, 2013 Posted April 4, 2013 Use : onClientResourceStart will be fine with this .
Adde Posted April 4, 2013 Author Posted April 4, 2013 I using it as client.. Okay, so like this? client addEventHandler( "onClientResourceStart", root, function () local sound = playSound("scary.mp3") setSoundVolume(sound, 1) end ) function stopSoundOnLogin() stopSound(sound) end addEvent("stop", true) addEventHandler("onPlayerLogin", root, stopSoundOnLogin) My ingame nickname is: Mr.Snus
Sasu Posted April 4, 2013 Posted April 4, 2013 Event 'onPlayerLogin' is only server side. You must use triggerClientEvent. State: Inactive
MR.S3D Posted April 4, 2013 Posted April 4, 2013 -- Server function stopSoundOnLogin() triggerClientEvent(source,"stop",source) end addEventHandler("onPlayerLogin", root, stopSoundOnLogin) - Client local sound addEventHandler( "onClientResourceStart", resourceRoot, function () sound = playSound("scary.mp3") setSoundVolume(sound, 1) end ) function stopSoundOnLogin() if isElement(sound) then stopSound(sound) end end addEvent("stop", true) addEventHandler("stop", root, stopSoundOnLogin) Welcom to my server Q.5 Current game type in my server Drift my Email : [email protected] Programming level: 90%
DJ_Shocker Posted March 22, 2014 Posted March 22, 2014 I know this topic is almost a year old, but my problem is similar to this (at least I searched before posting a new topic?) Anyways, I'm completely new to Lua and am playing around with making a new RP server from scratch. You actually taught me how to create and trigger events. Thanks! I tried using what you have pasted and it does play, however, where you have: addEventHandler("onPlayerLogin", root, stopSoundOnLogin) Mine is: addEventHandler("spawnCharacter", root, stopSoundOnLogin) And it continues to play. I'm having trouble understanding this "addEventHandler" and such. I cannot count how many times i've read the wiki on this and it's like I'm reading Spanish. If someone could explain this and maybe explain the difference of you putting root rather than getRootElement() or some of the others I see in the Wiki? I have discovered that theirs no popcorn in popcorn chicken. I guess there’s no point in bothering with hash browns then.
Castillo Posted March 22, 2014 Posted March 22, 2014 root is just a shortcut for getRootElement ( ). San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now