Fawxy Posted June 29, 2010 Share Posted June 29, 2010 I have a script that plays music while in the server, but it doesnt sync up with the other players. Is there something I missed? This command should really be server side anyways. Link to comment
dzek (varez) Posted June 29, 2010 Share Posted June 29, 2010 just trigger event from server to client like: SERVER: function some_function() if (something_happen) then triggerClientEvent(getRootElement(), "playMyMusic", getRootElement()) end end CLIENT: addEvent("playMyMusic",true) addEventHandler("playMyMusic", getRootElement(), function() playSound (parameters, here) --or any other things end) EDIT: afair you can overwrite mta native functions, so write own server side playSound (in the way showed above - but when triggering client event also pass filename parameter - to play correct file on client) search wiki for examples of triggering events Link to comment
[DMC] Posted June 29, 2010 Share Posted June 29, 2010 (edited) i tried and failed, could anyone fix it client addEvent("playMyMusic",true) addEventHandler("playMyMusic", getRootElement(), function() local sound = playSound("mariosong.mp3",false) setSoundVolume(sound, 1.0) end) server function PlayMusic() triggerClientEvent(getRootElement(), "playMyMusic", getRootElement()) end addCommandHandler("play", PlayMusic) Edited June 30, 2010 by Guest Link to comment
dzek (varez) Posted June 29, 2010 Share Posted June 29, 2010 its working if you have added it all right to meta.xml INCLUDING THE SOUND FILE https://wiki.multitheftauto.com/wiki/Meta.xml Link to comment
[DMC] Posted June 30, 2010 Share Posted June 30, 2010 <meta> <info type="script" version="1.0.0" /> <script src="musics.lua" type="server"/> <script src="musicc.lua" type="client"/> <file src="files/song.mp3" /> </meta> Link to comment
dzek (varez) Posted June 30, 2010 Share Posted June 30, 2010 you are loading: files/song.mp3 and want to play: mariosong.mp3 Link to comment
Xierra Posted June 30, 2010 Share Posted June 30, 2010 Yes, the meta must be the same ones as the music's name. Link to comment
[DMC] Posted June 30, 2010 Share Posted June 30, 2010 i changed it and only i hear the music:S Link to comment
dzek (varez) Posted June 30, 2010 Share Posted June 30, 2010 zip your resource and post whole resource. i dont know HOW and WHAT you messed up, but you messed up something for sure o_O Link to comment
dzek (varez) Posted June 30, 2010 Share Posted June 30, 2010 local sound = playSound("mariosong.mp3",false) you are still trying to load sound without specifying full (but relative to resource root of course) in playSound argument... local sound = playSound("files/mariosong.mp3",false) Link to comment
[DMC] Posted July 1, 2010 Share Posted July 1, 2010 lol typo but its not working only i hear the music Link to comment
dzek (varez) Posted July 1, 2010 Share Posted July 1, 2010 you are making me wanna kill myself.. maybe the others are deaf? or they are lying to you? or they have sound turned off? on client side put: addEvent("playMyMusic",true) addEventHandler("playMyMusic", getRootElement(), function() local sound = playSound("files/mariosong.mp3",false) setSoundVolume(sound, 1.0) outputChatBox("this is freaking DEBUG, DEBUG FTW!") end) read this (btw: read whole manual before asking anything) https://wiki.multitheftauto.com/wiki/Debugging and if you are really desperated use this for debug (gift from me): server function PlayMusic() triggerClientEvent(getRootElement(), "playMyMusic", getRootElement()) end addCommandHandler("mario", PlayMusic) addEvent("catchDebug", true) addEventHandler("catchDebug", getRootElement(), function() local name=getPlayerName(source) outputChatBox(name.." should hear the sound - debug don't lie" end) client addEvent("playMyMusic",true) addEventHandler("playMyMusic", getRootElement(), function() local sound = playSound("files/mariosong.mp3",false) setSoundVolume(sound, 1.0) outputChatBox("this is freaking DEBUG, DEBUG FTW!") triggerServerEvent("catchDebug", getLocalPlayer()) end) and.. i gave you a link, again: https://wiki.multitheftauto.com/wiki/Debugging I don't think so you will bother to read but you can read there about debugscript command. Use it to spot errors in your script. Do "/debugscript 3" in chat or "debugscript 3" in console. Link to comment
[DMC] Posted July 1, 2010 Share Posted July 1, 2010 well they are lying i think because they said yours isnt working either i just wait for someone i trust Link to comment
50p Posted July 1, 2010 Share Posted July 1, 2010 Ask them to type the command. They will triggerClientEvent and if you can hear the music after they type the command in, they can hear the music when you type the command in. Link to comment
dzek (varez) Posted July 1, 2010 Share Posted July 1, 2010 they can lie in that case also .. Link to comment
TheRealCow Posted July 2, 2010 Share Posted July 2, 2010 triggerClientEvent(getRootElement(), "playMyMusic", getRootElement()) you are triggering event to local player.. triggerClientEvent("playMyMusic", getRootElement()) maybe lsomething like that ? Link to comment
50p Posted July 2, 2010 Share Posted July 2, 2010 triggerClientEvent(getRootElement(), "playMyMusic", getRootElement()) you are triggering event to local player.. triggerClientEvent("playMyMusic", getRootElement()) maybe lsomething like that ? Do you know what you're talking about? Both of them are correct. There is no local player on server-side. 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