Jump to content

[Adding sounds to login screen]


Portside

Recommended Posts

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

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
  • Moderators

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
  • Moderators
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

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