Jump to content

Join, Quit, Login, Logout, sounds


Recommended Posts

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

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

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