Jump to content

music on connect


swag_k_dog

Recommended Posts

Posted

I want a sound to be played when a player connects..

function playsound1()
local sound = playSound("music/APB.mp3")
end

addEventHandler("onPlayerConnect", getRootElement(), playsound1) 

help :)?

Posted
Just now, FaHaD said:

You can't play sound when player connect because ' playSound ' function is client side function only and onPlayerConnect server side event.

why is there a "client" and "server" side.. why they are not together xD?

Posted
Just now, swag_k_dog said:

why is there a "client" and "server" side.. why they are not together xD?

No some functions are client side functions only the red functions is client side only and the orange is server side only and blue mean's that it's shared.

Posted
1 minute ago, FaHaD said:

No some functions are client side functions only the red functions is client side only and the orange is server side only and blue mean's that it's shared.

then. how do you make this script? with triggerEvent?

Posted
1 minute ago, FaHaD said:

You can make it client side with 'onClientResourceStart' Event.

 

PS. It will start after download finish.

addEventHandler("onClientResourceStart", resourceRoot,
function()
sound = playSound("music/APB.mp3")
end
)

like this?

Posted
1 minute ago, swag_k_dog said:

addEventHandler("onClientResourceStart", resourceRoot,
function()
sound = playSound("music/APB.mp3")
end
)

like this?

Yes this should work.

Posted (edited)
14 minutes ago, FaHaD said:

Yes this should work.

i'll try

14 minutes ago, FaHaD said:

Yes this should work.

addEventHandler("onClientResourceStart", resourceRoot,
function()
sound = playSound("music/APB.mp3")
setTimer(stopSound,50000,1,sound)
end
)

the setTimer does not work for a reason or another.. I want the sound to stop after several seconds.. why doesnt it work? ty

 

EDIT: It works, I just put a too high value

Edited by swag_k_dog
Posted

Try this :

 

addEventHandler ( "onClientResourceStart",resourceRoot,
function   (  )
        sound = playSound( "music/APB.mp3" )
        setTimer (
                function (  )
                    if sound and isElement ( sound ) then
                        destroyElement ( sound )
                        sound = nil
            end
        end,50000,1
    )
end
)

 

  • Like 1
Posted
1 minute ago, FaHaD said:

Try this :

 


addEventHandler ( "onClientResourceStart",resourceRoot,
function   (  )
        sound = playSound( "music/APB.mp3" )
        setTimer (
                function (  )
                    if sound and isElement ( sound ) then
                        destroyElement ( sound )
                        sound = nil
            end
        end,50000,1
    )
end
)

 

thanks

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