• player console command play
    3 replies, posted
I'm trying to make a player play a song I forced them to download. on there computer the file is in "[I]Steam\steamapps<username>\garrysmod\garrysmod\downloads\sound\music_player[/I]" on the server the file is in "[I]Gmod13\orangebox\garrysmod\sound\music_player[/I]" if i run "[I]Music_Play[/I]" with the file arg of "[I]music_player/<song>.mp3[/I]" the client console says "[I]Failed to load sound music_player\<song>.mp3", file probably missing from disk/repository[/I]" whats going wrong? Am I making the clients download the sound files wrong or? [lua] --forcedownloads.lua AddDir("sound/music_player") --init.lua function Music_Play(pl, command, args) --Music_Play local File = args[1] print("~Playin: "..File..".mp3") for k, v in pairs(player.GetAll()) do v:ConCommand("play " .. File .. ".mp3") end end concommand.Add( "Music_Play", Music_Play ) [/lua]
Your code looks alright, and your function works ingame, at least for local files. I can see a couple of possible problems here. When using [i]music_play[/i], are you including the .mp3 extension in your filename argument, or is that just a mistake when posting? Seems obvious, but bear in mind that your function adds ".mp3" to the string, so if you're doing that, then you'll be playing [i]<song>.mp3.mp3[/i]. Try having the file locally accessible to a client (as in, copy the file outside of the game) and see if your code then works. If it does, then it is likely the download part that's going wrong.
I believe in the console you have to use a forward slash (/)?
It works if "music_player/<song>.mp3" is in "Steam\steamapps<username>\garrysmod\garrysmod\sound\music_player" but not if "music_player/<song>.mp3" is in "Steam\steamapps<username>\garrysmod\garrysmod\down loads\sound\music_player" How do I make the client download then songs to "Steam\steamapps<username>\garrysmod\garrysmod\sound"?
Sorry, you need to Log In to post a reply to this thread.