swag_k_dog Posted October 11, 2016 Posted October 11, 2016 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 :)?
iPrestege Posted October 11, 2016 Posted October 11, 2016 You can't play sound when player connect because ' playSound ' function is client side function only and onPlayerConnect server side event.
swag_k_dog Posted October 11, 2016 Author Posted October 11, 2016 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?
iPrestege Posted October 11, 2016 Posted October 11, 2016 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.
swag_k_dog Posted October 11, 2016 Author Posted October 11, 2016 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?
iPrestege Posted October 11, 2016 Posted October 11, 2016 You can make it client side with 'onClientResourceStart' Event. PS. It will start after download finish. 1
swag_k_dog Posted October 11, 2016 Author Posted October 11, 2016 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?
iPrestege Posted October 11, 2016 Posted October 11, 2016 1 minute ago, swag_k_dog said: addEventHandler("onClientResourceStart", resourceRoot, function() sound = playSound("music/APB.mp3") end ) like this? Yes this should work.
swag_k_dog Posted October 11, 2016 Author Posted October 11, 2016 (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 October 11, 2016 by swag_k_dog
iPrestege Posted October 11, 2016 Posted October 11, 2016 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 ) 1
swag_k_dog Posted October 11, 2016 Author Posted October 11, 2016 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
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