Minor LUA issue

So to start off with, yes I am fairly new to Lua and I’m trying to learn it by looking at existing scripts and modifying them and then merging ideas together. It’s what works for more more efficently.

Anyway, for my problem, I am trying to make it so that when the admin presses the button within the menu, they are prompted with a box that says ‘Write here…’ and then whatever they write in their gets displayed on all current players’ screens as the @@@ chat function does. However when I am using the code I have written, what happens is instead of the output being


@@@Test

it becomes


@@@" "Test

I’ve tried modifying it as much as I can to my knowledge, so instead I’ve come to these forums. This is the code that is responsible for the output.



function makeAnnouncement()

		local dp = vgui.Create("DFrame")
		dp:SetSize(400,75)
		dp:Center()
		dp:SetTitle("Write your announcement")
		dp:MakePopup()

		local dte = vgui.Create("DTextEntry",dp)
		dte:SetSize(200,30)
		dte:SetPos(30,25)
		dte:CenterHorizontal()
		dte:SetValue("Write here...")
		dte.OnEnter = function(self)
			reason = self:GetValue()
			RunConsoleCommand("say"," @@@", reason)
			dp:Close()
		end

end

You need to concatenate the strings using ‘…’.
eg:


print("This" .. " is " .. "concatenation")

RunConsoleCommand takes variadic arguments. If you concatenate them, it doesn’t work.

It does that to separate arguments, considering say only takes one argument, he needs to concatenate them.

Edit: Also that space in front of @@@ can be removed.

I thought “say” was protected by FCVAR_SERVER_CAN_EXECUTE

Yeah I got it confused with ply:ConCommand.

Fixed! :slight_smile:

Incase anyone is wondering here’s what I did instead


RunConsoleCommand("say","@@@"..reason)

Thanks alot