Jump to content

[HELP] onPlayerJoin


Recommended Posts

onPlayerJoin is a server-side event. Use onClientResourceStart to properly initialize the sound when the player joins.

addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        local sound = playSound("Sounds/PanelSounds.mp3", false) 
        setSoundVolume(sound, 1.0) 
    end 
) 

Link to comment
onPlayerJoin is a server-side event. Use onClientResourceStart to properly initialize the sound when the player joins.
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        local sound = playSound("Sounds/PanelSounds.mp3", false) 
        setSoundVolume(sound, 1.0) 
    end 
) 

Yeah i know that...but i want the song starts only when the player join...and then stops it when he Login.

Link to comment

Then use this.

Client-side

local sound 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        sound = playSound("Sounds/PanelSounds.mp3", false) 
        setSoundVolume(sound, 1.0) 
    end 
) 
  
addEvent("stopIntro", true) -- Create a custom event in order to stop when player logs in 
addEventHandler("stopIntro", root, -- When the custom event is triggered, execute the function 
    function() 
        if (sound) and (isElement(sound)) then -- If the sound is an element 
            destroyElement(sound) -- Destroy the sound element 
        end 
    end 
) 

Server-side

addEventHandler("onPlayerLogin", root, -- Trigger when a player logs in 
    function() 
        triggerClientEvent(source, "stopIntro", source) -- Trigger a client-side event to stop the music 
    end 
) 

Link to comment
Then use this.

Client-side

local sound 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        sound = playSound("Sounds/PanelSounds.mp3", false) 
        setSoundVolume(sound, 1.0) 
    end 
) 
  
addEvent("stopIntro", true) -- Create a custom event in order to stop when player logs in 
addEventHandler("stopIntro", root, -- When the custom event is triggered, execute the function 
    function() 
        if (sound) and (isElement(sound)) then -- If the sound is an element 
            destroyElement(sound) -- Destroy the sound element 
        end 
    end 
) 

Server-side

addEventHandler("onPlayerLogin", root, -- Trigger when a player logs in 
    function() 
        triggerClientEvent(source, "stopIntro", source) -- Trigger a client-side event to stop the music 
    end 
) 

Works Fine :) Thanks a lot :)

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