Jump to content

[SOLVED] Sound problem


cheez3d

Recommended Posts

I have created a custom client side event that will be triggered with a server side script when a player joins the server.

Client side:

dayzLoginSong = "login/logintheme_dayz.mp3" 
  
addEvent("playDayzLoginTheme",true) 
addEventHandler("playDayzLoginTheme",root,function () 
playSound(dayzLoginSong,true) 
setSoundVolume(dayzLoginSong,0.2) 
end) 

Server side:

function moveDayzLoginCameraToStart() 
triggerClientEvent(getRootElement(),"playDayzLoginTheme",source) 
fadeCamera(source, true, 1) 
setCameraMatrix(source,227.3,2611.5,25,12,0,142) 
end 
addEventHandler("onPlayerJoin", getRootElement(), moveDayzLoginCameraToStart) 

Whenever i join the game the music does not play.

In the debuscript console i receive this:

WARNING: DayZ/login/login_music.lua:6: Bad 'sound/player' @ 'setSoundVolume'(1)

what could be the problem. i cant figure out..

Edited by Guest
Link to comment

1ºst - Is better to play the sound in a "onClientResourceStart" event handler instead. The sound will be played when the resource starts in client-side (when player join to the server)

2ºnd - the first argument of setSoundVolume, is the sound element, not a string.

client-side

  
dayzLoginSong = "login/logintheme_dayz.mp3"; 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
    function ()  
        fadeCamera(true, 1) 
        setCameraMatrix(227.3,2611.5,25,12,0,142) 
        local sound = playSound(dayzLoginSong,true); -- play the sound. 
        -- sound will be the sound element 
       setSoundVolume(sound, 0.2);  
    end);  
  

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