Poll

Was this module useful, and helpful?

Yes :)
93 (94.9%)
No :(
5 (5.1%)

Total Members Voted: 0

  • Print

Author Topic: URL Playsound Addon :) [2.28v]  (Read 356254 times)

0 Members and 1 Guest are viewing this topic.

Offline allofmywutsteam

  • Full Member
  • ***
  • Posts: 136
  • Karma: 3
  • MNWO Owner
    • MNWO Discord
Re: URL Playsound Addon :) [2.27v]
« Reply #105 on: March 27, 2015, 11:12:41 am »
Not sure why you didn't know it had to be hosted.
put the url in quotes ulx playsound "your:URL" - though, yes, you may have trouble doing that in console if you don't know how to escape them out.
The original post and few conversations later in thread state that you have to link to a internet URL.
Also, the file link has to end in a supported file extension of .mp3, .ogg, .pls,
Whatever you're trying to use doesn't end in one of those. (Though, it does redirect, I'd guess that Gmod http.Fetch won't allow redirects, nothing the author can do to fix that)

How do I "escape it out" then? because I'm pretty sure I've run:

bind 9 "ulx playurlsound http://monicasnwo.site.nfoservers.com/server/music/swag.mp3"
bind 9 ulx playurlsound "http://monicasnwo.site.nfoservers.com/server/music/swag.mp3"

And neither have worked (I'll double check). When I press the 9 after binding it, it seems to recognize the bind, but it stops at "http:" and doesn't play anything. Keep in mind this is only an issue when trying to bind. The command itself via xgui or say works fine. I've always seen this when trying to bind an http link or when I paste an http via global console. Maybe I'll post a separate post on how to accomplish this?

Anyway, it's hosted, direct link to the sound play file, ends in mp3, and file plays normally via xgui and chat so that's not the issue. It's just console recognizing the URL when the bind is run.

And I understood that it has to be an internet URL. That's not the point I was trying to make.
"Then Jesus said to his disciples, 'Whoever wants to be my disciple must deny themselves and take up their cross and follow me.'" - Matthew 16:24



MNWO: Steam | Discord | Website | Join Server

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: URL Playsound Addon :) [2.27v]
« Reply #106 on: March 27, 2015, 08:46:09 pm »
Hey guys, I am in need of a little help with two things:
1) I am trying to implement an "auto-silence" of all sound being played via !playurl  at the end of the round. While it works, the console is throwing script errors out that say the following:
Code: Text
  1. [ERROR] addons/ulx/lua/ulx/modules/sh/playurl.lua:143: attempt to index global 'umsg' (a nil value)
  2.   1. fn - addons/ulx/lua/ulx/modules/sh/playurl.lua:143
  3.    2. Call - addons/ulib/lua/ulib/shared/hook.lua:105
  4.     3. RoundStateChange - gamemodes/terrortown/gamemode/cl_init.lua:129
  5.      4. func - gamemodes/terrortown/gamemode/cl_init.lua:204
  6.       5. unknown - lua/includes/modules/net.lua:32


These are the lines of code I added starting at line 143
Code: Lua
  1. umsg.Start("ulib_url_stopsound")
  2.         umsg.String(stopurlsound)
  3. umsg.End()
I do not understand why it keep saying that it is a nil value....

2)   I am also trying to implement code to prevent a new song from playing while a song is already playing. (using !stopurl, then !playurl again would be the way to do a new song)

If any of you guys have insight on the matter, feel free to reply to this or email me at stealthycow369@hotmail.com

Thanks

I honestly pretty sure what this was discussed already in somewhere in this thread, try searching
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Stealthycow

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: URL Playsound Addon :) [2.27v]
« Reply #107 on: March 28, 2015, 11:51:55 am »
I honestly pretty sure what this was discussed already in somewhere in this thread, try searching

I went and sifted through all 7 pages of comments and was unable to find the answer to my two questions.  One came close with respect to forcing the music to stop at the end of each round; however, it was not applicable to what I am attempting to accomplish.  I need to be able to globally call stopurlsound without the use of a person calling the !stopurl command.  Whenever I do so , it gives the error message "attempt to index global "umsg" (a nil value) as referenced in my previous comment  :-\

Also, what about keeping a song playing even when someone else tries to start another song? (prevent interruptions)

Thanks :)

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: URL Playsound Addon :) [2.27v]
« Reply #108 on: March 28, 2015, 02:16:27 pm »
I went and sifted through all 7 pages of comments and was unable to find the answer to my two questions.  One came close with respect to forcing the music to stop at the end of each round; however, it was not applicable to what I am attempting to accomplish.  I need to be able to globally call stopurlsound without the use of a person calling the !stopurl command.  Whenever I do so , it gives the error message "attempt to index global "umsg" (a nil value) as referenced in my previous comment  :-\

Also, what about keeping a song playing even when someone else tries to start another song? (prevent interruptions)

Thanks :)

Okay well to answer the first thing

Code: Lua
  1. umsg.Start("ulib_url_stopsound")
  2.         umsg.String(stopurlsound)
  3. umsg.End()

stopurlsound is a variable, so what do you have stopurlsound equaling to ?

Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Stealthycow

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: URL Playsound Addon :) [2.27v]
« Reply #109 on: March 28, 2015, 04:12:40 pm »
It's part of the ulx command
local stopurlsound = ulx.command( CATEGORY_NAME, "ulx stopurlsound", ulx.stopurlsound, "!stopurl" )

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: URL Playsound Addon :) [2.27v]
« Reply #110 on: March 28, 2015, 10:11:36 pm »
Looks like you're trying to send the client the command table.  That will never work, assuming you can even access it from within the command function.  You have to pass an actual string through.  So set a variable equal to what ever URL you need and pass it through there and you should be fine.

Offline Stealthycow

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: URL Playsound Addon :) [2.27v]
« Reply #111 on: March 29, 2015, 10:17:00 am »
Looks like you're trying to send the client the command table.  That will never work, assuming you can even access it from within the command function.  You have to pass an actual string through.  So set a variable equal to what ever URL you need and pass it through there and you should be fine.

The code I have displayed here works, it's what is used to stop the music by typing "!stopurl" (provided you are an admin)  It's not its functionality that I question.  I just do not understand why is will not work without a calling_ply.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: URL Playsound Addon :) [2.27v]
« Reply #112 on: March 29, 2015, 10:35:47 am »
The code I have displayed here works, it's what is used to stop the music by typing "!stopurl" (provided you are an admin)  It's not its functionality that I question.  I just do not understand why is will not work without a calling_ply.
Code: Lua
  1. function ulx.stopurlsound( calling_ply, stopurlsound )
  2.  
  3.         umsg.Start("ulib_url_stopsound")
  4.                 umsg.String(stopurlsound)
  5.         umsg.End()
  6.  
  7.         ulx.fancyLogAdmin( calling_ply, "#A stopped the url song for the server." )
  8. end
  9.  
  10. local stopurlsound = ulx.command( CATEGORY_NAME, "ulx stopurlsound", ulx.stopurlsound, "!stopurl" )
  11. stopurlsound:defaultAccess( ULib.ACCESS_ADMIN )
  12. stopurlsound:help( "Stops a URL song for the server - !stopurl" )

You mean why calling_ply is in the parameter?  All commands run functions that way.  It's so you can see who is running the command.  You don't have to use it.  If you remove calling_ply, then stopurlsound will be equal to the player running the command.


Offline Stealthycow

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: URL Playsound Addon :) [2.27v]
« Reply #113 on: March 29, 2015, 01:52:00 pm »
Code: Lua
  1. function ulx.stopurlsound( calling_ply, stopurlsound )
  2.  
  3.         umsg.Start("ulib_url_stopsound")
  4.                 umsg.String(stopurlsound)
  5.         umsg.End()
  6.  
  7.         ulx.fancyLogAdmin( calling_ply, "#A stopped the url song for the server." )
  8. end
  9.  
  10. local stopurlsound = ulx.command( CATEGORY_NAME, "ulx stopurlsound", ulx.stopurlsound, "!stopurl" )
  11. stopurlsound:defaultAccess( ULib.ACCESS_ADMIN )
  12. stopurlsound:help( "Stops a URL song for the server - !stopurl" )

You mean why calling_ply is in the parameter?  All commands run functions that way.  It's so you can see who is running the command.  You don't have to use it.  If you remove calling_ply, then stopurlsound will be equal to the player running the command.

I understand what you are saying; however, I fixed my predicament by using another method as follows:
Code: Lua
  1. if SERVER then
  2.         local function stopsound()
  3.                 ULib.consoleCommand( "ulx stopurlsound" .. "\n" )
  4.         end
  5.  
  6.  
  7.         hook.Add ( "TTTPrepareRound", "serverstopgents", stopsound )
  8. end

All it does is at the beginning of each round forces the server to run a command on the server console "ulx stopurlsound"
Phew, the "If server then" was also something that i forgot to put in and was throwing more errors then I would have liked.
The code I have just given, if added to the end of playurl.lua will automatically end any song playing at the beginning of the Preparing round in TTT.
Thanks for your guidance Aaron and Apple.  ;D

Offline TeamEnternode

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: URL Playsound Addon :) [2.27v]
« Reply #114 on: March 30, 2015, 05:04:21 am »
So I wanted to bind playing a url to a key, however the URL seems to be required to be encased in quotes.

Thing is, since the command obviously has spaces in it, so does the bind.

That would lead into the seemingly logical bind command being

bind kp_end "ulx playurlsound "http://www.yougetthepoint.com/""

That doesn't work, because the only thing that would be seen is

"ulx playsoundurl "

Is there a workaround for this?

EDIT: Seems something like this was mentioned however I cannot find it's answer
« Last Edit: March 30, 2015, 05:08:40 am by TeamEnternode »

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: URL Playsound Addon :) [2.27v]
« Reply #115 on: March 30, 2015, 06:08:03 am »
So I wanted to bind playing a url to a key, however the URL seems to be required to be encased in quotes.

Thing is, since the command obviously has spaces in it, so does the bind.

That would lead into the seemingly logical bind command being

bind kp_end "ulx playurlsound "http://www.yougetthepoint.com/""

That doesn't work, because the only thing that would be seen is

"ulx playsoundurl "

Is there a workaround for this?

EDIT: Seems something like this was mentioned however I cannot find it's answer
Try using single quotes instead and see if that works?
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline TeamEnternode

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: URL Playsound Addon :) [2.27v]
« Reply #116 on: March 30, 2015, 12:56:09 pm »
I tried that. It doesn't work.

Offline Stealthycow

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: URL Playsound Addon :) [2.27v]
« Reply #117 on: March 30, 2015, 01:06:22 pm »
I tried that. It doesn't work.

bind key "ulx playurlsound soundfile.mp3"

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: URL Playsound Addon :) [2.27v]
« Reply #118 on: March 30, 2015, 03:19:53 pm »
Cow, that won't work, it has to be a URL... http://blah blah

The quotes are only a tiny bit, if at all, of your challenge.
The console is tricky in and of itself, as colon (:) means "start new command on same line".
So, typing say hello : say world in console would end up you saying in chat
<you>: hello
<you>: world

Try, with no guarantees from me;
bind 9 "ulx playurlsound http\://monicasnwo.site.nfoservers.com/server/music/swag.mp3"
That extra \ in front of the colon is an escape sequences in lua, I forget if they work exact same way in Source console.
Escape sequences tell code to not 'interpret' the next character as it normally would.
I forget what can be used in console.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: URL Playsound Addon :) [2.27v]
« Reply #119 on: March 30, 2015, 04:58:34 pm »
Try, with no guarantees from me;
bind 9 "ulx playurlsound http\://monicasnwo.site.nfoservers.com/server/music/swag.mp3"
That extra \ in front of the colon is an escape sequences in lua, I forget if they work exact same way in Source console.
Escape sequences tell code to not 'interpret' the next character as it normally would.
I forget what can be used in console.
I tested earlier with escaping quotes in a bind. No luck. Not sure if other characters are possible.

I tried that. It doesn't work.
I wonder if it's possible for you to use a console alias for this. If the colon is a problem, then this might not even work, but give it a try.
Code: [Select]
alias soundurl "http://www.example.com/example.mp3"
Code: [Select]
bind kp_end "ulx playurlsound soundurl"
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

  • Print