• Sounds to bans.
    3 replies, posted
So, I want to make it so when I ban someone on my TTT server. It plays a MP3 or a .Wav. Any Idea on how this is done?
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/sound/PlayURL]sound.PlayURL[/url]
Untested, but should do what you are asking for. [lua]local meta = FindMetaTable "Player" local song = "url-to-song" meta._ban = meta._ban or meta.Ban meta._kick = meta._kick or meta.Kick local function playSound ( ) BroadcastLua ( [[sound.PlayURL ( "]] .. song .. [[, "", function () end )]] ) end function meta:Ban ( minutes, kick ) playSound ( ) self._ban ( minutes, kick ) end function meta:Kick ( reason ) playSound ( ) self._kick ( reason ) end[/lua] For you people who are going to complain about the use of SendLua / BroadcastLua instead of net, this is not exploitable in any way possible, and is just a simplified way of doing it since I couldn't be bothered.
This does get put in at "Ulx/lua/ulx/vgui/bans.lua?" [editline]5th April 2015[/editline] [QUOTE=Author.;47464745]Untested, but should do what you are asking for. [lua]local meta = FindMetaTable "Player" local song = "url-to-song" meta._ban = meta._ban or meta.Ban meta._kick = meta._kick or meta.Kick local function playSound ( ) BroadcastLua ( [[sound.PlayURL ( "]] .. song .. [[", "", function ( ) end]] ) end function meta:Ban ( minutes, kick ) playSound ( ) self._ban ( minutes, kick ) end function meta:Kick ( reason ) playSound ( ) self._kick ( reason ) end[/lua] For you people who are going to complain about the use of SendLua / BroadcastLua instead of net, this is not exploitable in any way possible, and is just a simplified way of doing it since I couldn't be bothered.[/QUOTE] Sorry, I'm new to LUA and stuff. I'm unsure where you put this code at. And where I put the URL. I can see it says Player/Url-to-song/and Song. Do I put the URL in the local song = "(URL Goes HERE)" And put the URL Here to? local function playSound ( ) BroadcastLua ( [[sound.PlayURL ( "URL HERE", "", function ( ) end]] )
Sorry, you need to Log In to post a reply to this thread.