How to fix a ban/sound

I’m trying to make it so when someone gets banned on the server it plays a .wav. But i’m having an error I used “siege/jihad.wav” as a test .wav and I got an error. Here’s the error-

[ERROR] LuaCmd:1: unfinished string near ‘<eof>’

  1. unknown - LuaCmd:0

And here’s the code;

local meta = FindMetaTable “Player”
local song = “siege/jihad.wav”

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

", function () end )]] ) This part is useless. Also, why are you running this through lua_run?

This better?

local meta = FindMetaTable “Player”
local song = “siege/jihad.wav”

meta._ban = meta._ban or meta.Ban
meta._kick = meta._kick or meta.Kick

local function playSound ( )
BroadcastLua ( [[sound.PlayURL ( "]] … song … [[, ")
end

function meta:Ban ( minutes, kick )
playSound ( )
self._ban ( minutes, kick )
end

function meta:Kick ( reason )
playSound ( )
self._kick ( reason )
end

Try this; also, use code tags.


local meta = FindMetaTable( "Player" )
local song = "siege/jihad.wav"

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

Put it in lua/autorun/

I’ll try it out, Thanks.

[editline]5th April 2015[/editline]

It never worked code. It doesn’t give me any errors. It just doesn’t do any thing. It’s like it’s not even there. Did I do it right?