swethin Posted January 25, 2016 Share Posted January 25, 2016 i want to play music on mtasa anadolu gaming turkey server. /sound placed speaker and pasted url but the song is not playing.what file in server/map/mod/deathmatch/resourses need to be edited? eg meta. sorry bad eng plz help Link to comment
knightscript Posted January 26, 2016 Share Posted January 26, 2016 Show us your code, what are you currently trying to do?. Link to comment
tosfera Posted January 26, 2016 Share Posted January 26, 2016 You can only play songs that are music files, you can't just simply put in a youtube link. I hope you understand that. Link to comment
knightscript Posted January 26, 2016 Share Posted January 26, 2016 (edited) To play a sound to all players on the server, when you type the command /sound: META: <meta> <file src="mysound.mp3" /> <!--Your MP3 File--> <script src="client.lua" type="client" /> <!--REMEMBER to add this client side --> </meta> function playSound () playSound("mysound.mp3") --plays the sound end addCommandHandler("sound", playSound) --adds the command And if you want to disable the music, you can do it with this code by using the command /stopsound function stopsound() stopSound( mysound ) end addCommandHandler ( "stopsound", stopsound ) --using the command 'stopsound' will stop the sound EDIT: I just discovered you CANT have a function name on the commandhandler. Edited January 26, 2016 by Guest Link to comment
ViRuZGamiing Posted January 26, 2016 Share Posted January 26, 2016 Yeah indeed you can't, wouldn't do that anyway Link to comment
swethin Posted January 31, 2016 Author Share Posted January 31, 2016 thx knightscript it worked thx ur great Link to comment
Dealman Posted January 31, 2016 Share Posted January 31, 2016 EDIT: I just discovered you CANT have a function name on the commandhandler. Of course you can. Your issue is that you made an infinite loop. Look at your own code again, use the syntax highlighting on these forums and it'll be even easier to spot. function playSound () playSound("mysound.mp3") --plays the sound end addCommandHandler("sound", playSound) --adds the command Never name your functions the same as the native MTA functions unless your intention is to overwrite them with your own. Your command runs the function playSound, playSound then runs itself. Infinite loop has begun and Skynet will take over. Link to comment
ViRuZGamiing Posted January 31, 2016 Share Posted January 31, 2016 You can only play songs that are music files, you can't just simply put in a youtube link. I hope you understand that. playSound Required Arguments soundPath: the filepath or URL of the sound file you want to play. (Sound specified by filepath has to be predefined in the meta.xml file with tag.) I know it's not like youtube but you can use URL's to play music. I usually listen to german radio and I think their stream works because it's a .mp3 URL. http://stream01.iloveradio.de/iloveradio1.mp3 Link to comment
swethin Posted January 31, 2016 Author Share Posted January 31, 2016 (srry bad eng)thx for the help.the problem is sloved. i just typed in /sound in mtasa and a window poped up .its saying type url and i pasted a music url and its playing and othhers can hear it.i didnt edit meta.xml or not even a single file in mtasa. lol/ (srry bad eng) 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