-.Paradox.- Posted July 17, 2013 Share Posted July 17, 2013 Hello, it's me again i made this script, but there is some bugs on it function soundonPlayerJoin() sound = playSound("join.wav", false) end addEventHandler("onClientPlayerJoin", getRootElement(), soundonPlayerJoin) function onQuitGame() sound = playSound("quit.wav", false) end addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame ) function onLogin() sound = playSound("login.wav", false) end addEventHandler( "onPlayerLogin", getRootElement(), onLogin ) function onLogout() sound = playSound("logout.wav", false) end addEventHandler( "onPlayerLogout", getRootElement(), onLogout ) The onClientPlayerQuit & onClientPlayerJoin working but the other wont. Link to comment
xXMADEXx Posted July 17, 2013 Share Posted July 17, 2013 Em are you just trying to play the sound for the client or entire server? If just the client use: onClientResourceStart onClientResourceStop otherwise use triggerServerEvent, triggerClientEvent, addEvent, onPlayerJoin, onPlayerQuit Link to comment
codeluaeveryday Posted July 17, 2013 Share Posted July 17, 2013 Client.lua local sounds = { ['join'] = 'join.wav', ['quit'] = 'quit.wav', ['login'] = 'login.wav', ['logout'] = 'logout.wav' } function startSound(sound) playSound(sounds[sound], false) end addEvent('startSound', true) addEventHandler('startSound', getRootElement(), startSound) addEventHandler('onClientPlayerJoin', getRootElement(), function() startSound('join') end ) addEventHandler('onClientPlayerQuit', getRootElement(), function() startSound('logout') end ) Server.lua: addEventHandler('onPlayerLogin', getRootElement(), function() triggerClientEvent('startSound', getRootElement(), 'login') end ) addEventHandler('onPlayerLogout', getRootElement(), function() triggerClientEvent('startSound', getRootElement(), 'logout') end ) Link to comment
-.Paradox.- Posted July 17, 2013 Author Share Posted July 17, 2013 Client.lua local sounds = { ['join'] = 'join.wav', ['quit'] = 'quit.wav', ['login'] = 'login.wav', ['logout'] = 'logout.wav' } function startSound(sound) playSound(sounds[sound], false) end addEvent('startSound', true) addEventHandler('startSound', getRootElement(), startSound) addEventHandler('onClientPlayerJoin', getRootElement(), function() startSound('join') end ) addEventHandler('onClientPlayerQuit', getRootElement(), function() startSound('logout') end ) Server.lua: addEventHandler('onPlayerLogin', getRootElement(), function() triggerClientEvent('startSound', getRootElement(), 'login') end ) addEventHandler('onPlayerLogout', getRootElement(), function() triggerClientEvent('startSound', getRootElement(), 'logout') end ) Thanks csmit working fine Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now