Portside Posted March 1, 2014 Share Posted March 1, 2014 Hi, on my login screen I want to have a song playing until the player selects their character that they want to play as. It half works... the song plays when the player joins the game, logs in and selects their character. But once they select their character, the song continues to play until it's over. Here's what I've inserted; local sound = playSound("login.mp3", 2000.53125, -2767.8525390625, 1.7703918218613, true) setSoundVolume(sound, 100) setSoundMaxDistance(sound, 100) setElementDimension(sound, 0) end Any help? Thanks in advance. Link to comment
WhoAmI Posted March 1, 2014 Share Posted March 1, 2014 local sound = playSound("login.mp3", true) Link to comment
cheez3d Posted March 1, 2014 Share Posted March 1, 2014 use stopSound() or destroyElement() Link to comment
Portside Posted March 1, 2014 Author Share Posted March 1, 2014 Yeah but I only want the element destroyed when the player clicks "select character" So how do I do that? Link to comment
WhoAmI Posted March 1, 2014 Share Posted March 1, 2014 Function added to event onClientGUIClick, and there destroyElement or stopSound. Link to comment
WhoAmI Posted March 1, 2014 Share Posted March 1, 2014 If you created button, add function which will have been done when you click this button. And in this function just stop the sound. Link to comment
Portside Posted March 1, 2014 Author Share Posted March 1, 2014 So something like this? local sound = playSound("music.mp3", 2000.53125, -2767.8525390625, 1.7703918218613, true) setSoundVolume(sound, 100) setSoundMaxDistance(sound, 100) setElementDimension(sound, 0) stopSound(onClientGUIClick "Login", true) end Link to comment
WhoAmI Posted March 1, 2014 Share Posted March 1, 2014 Well, you mean playSound, or playSound3D? Couse your code is strange. Link to comment
Portside Posted March 1, 2014 Author Share Posted March 1, 2014 There's a difference between playSound and playSound3D? Link to comment
Karuzo Posted March 1, 2014 Share Posted March 1, 2014 You should check this : https://wiki.multitheftauto.com/wiki/Scr ... troduction 'Cause your code doesn't really makes sense. Link to comment
Moderators Citizen Posted March 1, 2014 Moderators Share Posted March 1, 2014 First you can remove this: setSoundVolume(sound, 100) -- The volume range is 0.0 to 1.0 (= 100%) and it's already 1.0 by default) setSoundMaxDistance(sound, 100) -- not needed because it's not a 3D sound setElementDimension(sound, 0) -- not a 3D sound too Then do something like this: local welcomeSound function yourFunc() ... welcomeSound = playSound("login.mp3", true) ... end --Call the following function with "onClientGUIClick" event function playerSelected( button ) if button == "left" then -- get the caracter stopSound( welcomeSound ) --stop the sound -- trigger the server here and give the caracter he selected and do your spawn process on severside end end Link to comment
Portside Posted March 1, 2014 Author Share Posted March 1, 2014 Yup... it's definitely playsound3D that needs to be there instead of playSound. But I've changed it to that and it's still not working. Link to comment
Moderators Citizen Posted March 1, 2014 Moderators Share Posted March 1, 2014 Yup... it's definitely playsound3D that needs to be there instead of playSound. But I've changed it to that and it's still not working. NO ! playSound is the function you wanted to use. playSound3D is to play a sound at a specific location in the GTA world like sound engines for example, or explosions. The function yourFunc() must be called when the players join the server (so when the client resource start). You had to remove ... in the function, if not, then you are dumb (sorry, but it would be the truth) The function playerSelected must be an handler of onClientGUIClick for the button or character's image. Show us the whole client side script. Link to comment
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