Jump to content

How can i make song play on Log-In


Phoenixx

Recommended Posts

Posted

How do i make some music play when I login/connect to server .. ? :D

~I already have something like : --Playsound "winsound.mp3 (true) or something like that but it doesn't works ..

Posted

Try

Server side

addEventHandler('onPlayerLogin', getRootElement(), 
 function()   
triggerClientEvent('startSound', getRootElement(), 'login')  
 end )  

Client side

local sounds = { 
 ['login'] = 'winsound.mp3' 
 }   
function startSound(sound)  
playSound(sounds[sound], false)  
end  
addEvent('startSound', true)   
addEventHandler('startSound', getRootElement(), startSound) 

Posted

With this example above it will play for ALL players on Server

if you wanna it only for the Player who joined then change this line

triggerClientEvent('startSound', getRootElement(), 'login')

to

triggerClientEvent('startSound', source, 'login')

Posted

--BUILD WINDOW ON RESOURCE START

addEventHandler("onClientResourceStart", resourceRoot,

function ()

build_loginWin()

guiSetVisible(background_front,false)

showLoginWindow(true)

guiSetInputMode("no_binds_when_editing")

--playSound("winsound.mp3")

fadeCamera (true)

setCameraMatrix(1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316)

end

)

Posted

Putting "--" before something comments it out (the code is not executed)

Removing the dashes before playSound should make it work.

Posted

Plain & Simple ((N

Server:

addEventHandler ( "onPlayerLogin", root, function ( ) 
    triggerClientEvent ( source, 'onplayerclientlogin', source ) 
end ) 
  
--client: 
addEvent ( 'onplayerclientlogin', true ) 
addEventHandler ( "onplayerclientlogin", root, function ( ) 
    playSound ( "winsound.mp3" ) 
end ) 

Posted

and the two -- before code play sound (winsound.mp3) when i remove 1 - or 2 -- login breaks and just black screen appears

Thx for help all i'll try this ;)

  • 2 weeks later...
Posted

Ya.... sound plays , ( i got file winsound.mp3 , and it plays the random song) , if i replace my own winsound.mp3 , it still plays random WINSOUND ==

Posted
Ya.... sound plays , ( i got file winsound.mp3 , and it plays the random song) , if i replace my own winsound.mp3 , it still plays random WINSOUND ==

Use this function before using playSound.

setRadioChannel ( 0 ) 

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