solidsnake Posted February 2, 2010 Share Posted February 2, 2010 hi all ... i just wanna ask about how can i add sounds when team (red win) -sound 1 & when team (blue win) -sound2 also sounds when player spawn i read in wiki that (playSound) just only work in client side of script but i cant add it i just can add in Server side under this if team1survivers > team2survivers then local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( redwinsdisplay, thisplayer ) end local teampoints = getElementData ( team1, "Score" ) setElementData ( team1, "Score", teampoints+1 ) end if team2survivers > team1survivers then local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( bluewinsdisplay, thisplayer ) end im really dont know well about lua but it least i tried ... i think i'm a bit confused about funiction & event (eventHandler) i check all client events & function theres nothing such linked(related) with what i want OR maybe need to use more than 1 function & handler idk im dizzy Link to comment
solidsnake Posted February 5, 2010 Author Share Posted February 5, 2010 over 30 viewes & no reply ..... im waiting Link to comment
Gamesnert Posted February 5, 2010 Share Posted February 5, 2010 You can put some functions in a client-side script file to play the sounds. Alternatively, use this: callClientFunction If you paste the function code into a client script file and a server script file, you can call client functions from the server. I'm not exactly sure if it'd be 100% safe though, but it should be safer than callServerFunction. Link to comment
solidsnake Posted March 2, 2010 Author Share Posted March 2, 2010 You can put some functions in a client-side script file to play the sounds.Alternatively, use this: callClientFunction If you paste the function code into a client script file and a server script file, you can call client functions from the server. I'm not exactly sure if it'd be 100% safe though, but it should be safer than callServerFunction. Great so is there any other way like Call : https://wiki.multitheftauto.com/wiki/Call call a function in same resources (client) or in other resources ? i cant understand events things its confused me so i trying to escape from this i just want to play sound if team1survivers > team2survivers then sound 1 = playsound( .... ) if team2survivers > team1survivers then sound 2 = playsound(.....) Link to comment
Aibo Posted March 3, 2010 Share Posted March 3, 2010 callClientFunction is just a custom function which calls client functions through event. if you have that added, then just call playSound from server for every player (near textDisplayAddObserver in your script) with needed file. server: if team1survivers > team2survivers then local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( redwinsdisplay, thisplayer ) callClientFunction(thisplayer, "playSound", "sounds/team1ftw.mp3") end local teampoints = getElementData ( team1, "Score" ) setElementData ( team1, "Score", teampoints+1 ) end if team2survivers > team1survivers then local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( bluewinsdisplay, thisplayer ) callClientFunction(thisplayer, "playSound", "sounds/ohnoes.mp3") end or you can use events: client: addEvent("playSomeSound", true) addEventHandler("playSomeSound", getRootElement(), playSound) server: if team1survivers > team2survivers then triggerClientEvent("playSomeSound", getRootElement(), "sounds/team1ftw.mp3") local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( redwinsdisplay, thisplayer ) end local teampoints = getElementData ( team1, "Score" ) setElementData ( team1, "Score", teampoints+1 ) end if team2survivers > team1survivers then triggerClientEvent("playSomeSound", getRootElement(), "sounds/ohnoes.mp3") local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( bluewinsdisplay, thisplayer ) end Link to comment
solidsnake Posted March 4, 2010 Author Share Posted March 4, 2010 callClientFunction is just a custom function which calls client functions through event.if you have that added, then just call playSound from server for every player (near textDisplayAddObserver in your script) with needed file. server: if team1survivers > team2survivers then local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( redwinsdisplay, thisplayer ) callClientFunction(thisplayer, "playSound", "sounds/team1ftw.mp3") end local teampoints = getElementData ( team1, "Score" ) setElementData ( team1, "Score", teampoints+1 ) end if team2survivers > team1survivers then local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( bluewinsdisplay, thisplayer ) callClientFunction(thisplayer, "playSound", "sounds/ohnoes.mp3") end or you can use events: client: addEvent("playSomeSound", true) addEventHandler("playSomeSound", getRootElement(), playSound) server: if team1survivers > team2survivers then triggerClientEvent("playSomeSound", getRootElement(), "sounds/team1ftw.mp3") local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( redwinsdisplay, thisplayer ) end local teampoints = getElementData ( team1, "Score" ) setElementData ( team1, "Score", teampoints+1 ) end if team2survivers > team1survivers then triggerClientEvent("playSomeSound", getRootElement(), "sounds/ohnoes.mp3") local alltheplayers = getElementsByType("player") for index, thisplayer in ipairs(alltheplayers) do textDisplayAddObserver( bluewinsdisplay, thisplayer ) end man i cant belive this you not only fix the problem you also fix the idea in my head about events very very thanks now i understand events 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