Fawxy Posted June 29, 2010 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.
dzek (varez) Posted June 29, 2010 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 Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
[DMC] Posted June 29, 2010 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
dzek (varez) Posted June 29, 2010 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 Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
[DMC] Posted June 30, 2010 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>
dzek (varez) Posted June 30, 2010 Posted June 30, 2010 you are loading: files/song.mp3 and want to play: mariosong.mp3 Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
Xierra Posted June 30, 2010 Posted June 30, 2010 Yes, the meta must be the same ones as the music's name. XX3 is gone. This is my new name. :3
dzek (varez) Posted June 30, 2010 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 Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
dzek (varez) Posted June 30, 2010 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) Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
dzek (varez) Posted July 1, 2010 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. Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
[DMC] Posted July 1, 2010 Posted July 1, 2010 well they are lying i think because they said yours isnt working either i just wait for someone i trust
50p Posted July 1, 2010 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
dzek (varez) Posted July 1, 2010 Posted July 1, 2010 they can lie in that case also .. Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
TheRealCow Posted July 2, 2010 Posted July 2, 2010 triggerClientEvent(getRootElement(), "playMyMusic", getRootElement()) you are triggering event to local player.. triggerClientEvent("playMyMusic", getRootElement()) maybe lsomething like that ? Server Name: mR|Team Clan Race Server Server IP: 84.82.81.225:22004
50p Posted July 2, 2010 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
TheRealCow Posted July 2, 2010 Posted July 2, 2010 ops Server Name: mR|Team Clan Race Server Server IP: 84.82.81.225:22004
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