Have a problem about ULX chat

Hello I have a question about ULX chat command.

Such as

http://imageflock.com/img/1312171088.png

when i type @@ Fuck my life , appears like that.

But , As there is no name of admins So they dont know who typed the commands. So i modified the line of Tsay(@@) but seems to not works

\orangebox\garrysmod\addons\ulx\lua\ulx\modules\sh\chat.lua

the line 42

[lua]
------------------------------ Tsay ------------------------------
function ulx.tsay( calling_ply, message )
ULib.tsay( _, message )

if util.tobool( GetConVarNumber( "ulx_logChat" ) ) then
	ulx.logString( string.format( "(tsay from %s) %s : #P", calling_ply:IsValid() and calling_ply:Nick() or "Console", message ) )
end

end
local tsay = ulx.command( CATEGORY_NAME, “ulx tsay”, ulx.tsay, “@@”, true, true )
tsay:addParam{ type=ULib.cmds.StringArg, hint=“message”, ULib.cmds.takeRestOfLine }
tsay:defaultAccess( ULib.ACCESS_ADMIN )
tsay:help( “Send a message to everyone in the chat box.” )
[/lua]

What should i do?

Anyone?

I honestly am not sure. Play around with it… My first guess would be doing

calling_ply:Name() … ": " … ULib.cmds.takeRestOfLine

[lua]

function ulx.tsay( calling_ply, message )
ULib.tsay( _, message )

if util.tobool( GetConVarNumber( "ulx_logChat" ) ) then
	ulx.logString( string.format( "(tsay from %s) %s : #P", calling_ply:IsValid() and calling_ply:Nick() or "Console", message ) )
end

end
local tsay = ulx.command( CATEGORY_NAME, “ulx tsay”, ulx.tsay, “@@”, true, true )
tsay:addParam{ type=ULib.cmds.StringArg, hint=“message”, calling_ply:Name() … ": " … ULib.cmds.takeRestOfLine }
tsay:defaultAccess( ULib.ACCESS_ADMIN )
tsay:help( “Send a message to everyone in the chat box.” )
[/lua]

Is that correct?

yah, try that. No guarantees.

Not worked…

Any errors, anything pop up, I need something to go off…

Not appeared ERROR, If i typed @@ say , It was not worked.

Ugh. Did it not even pop up or did the name just not show???

Yep…I thought…

You’re going about this wrong, that’s just going to add their name to the ULX logs, not the actual chat, if you want their name to appear in chat, you’ll need to edit ULib.tsay

Oh, you’re right… Didn’t think about that.

[lua]
tsay:addParam{ type=ULib.cmds.StringArg, hint=“message”, calling_ply:Name() … ULib.cmds.takeRestOfLine }
[/lua]
i’m pretty sure this would work.

that’s what I thought originally. And then whats his face confused me. But after looking it back over the only part that adds shit to console is

[lua]
if util.tobool( GetConVarNumber( “ulx_logChat” ) ) then
ulx.logString( string.format( “(tsay from %s) %s : #P”, calling_ply:IsValid() and calling_ply:Nick() or “Console”, message ) )
end
[/lua]

So i really don’t know what to say if that’s incorrect.

That will just add the name of the player using tsay to the chat line in the ULX logs (data/ulx_logs), it seemed to me the OP wanted this to appear in the chat.

Here’s what I think you should do (as well?):

ULib/lua/ULib/shared/messages.lua
[lua]
function ULib.tsay( ply, msg, wait, wasValid )
ULib.checkArg( 1, “ULib.tsay”, {“nil”,“Player”,“Entity”}, ply )
ULib.checkArg( 2, “ULib.tsay”, “string”, msg )
ULib.checkArg( 3, “ULib.tsay”, {“nil”,“boolean”}, wait )

if wait then timer.Simple( FrameTime()*0.5, ULib.tsay, ply, msg, false, ply and ply:IsValid() ) return end -- Call next frame

if SERVER and ply and not ply:IsValid() then -- Server console
	if wasValid then -- This means we had a valid player that left, so do nothing
		return
	end		
	Msg( msg .. "

" )
return
end

if CLIENT then
	LocalPlayer():ChatPrint( "(tsay from you) " .. msg  )
	LocalPlayer():EmitSound( Sound( "common/talk.wav" ) )
	return
end

if ply then
	ply:ChatPrint( "(tsay from you) " .. msg )
	umsg.Start( "ulib_sound", ply )
		umsg.String( Sound( "common/talk.wav" ) )
	umsg.End()
else
	local players = player.GetAll()
	for _, player in ipairs( players ) do
		player:ChatPrint( "(tsay from " .. ply:Nick .. ") " .. msg )
	end
	umsg.Start( "ulib_sound" )
		umsg.String( Sound( "common/talk.wav" ) )
	umsg.End()
end

end
[/lua]

[lua]
function ULib.tsay( ply, msg, wait, wasValid )
ULib.checkArg( 1, “ULib.tsay”, {“nil”,“Player”,“Entity”}, ply )
ULib.checkArg( 2, “ULib.tsay”, “string”, msg )
ULib.checkArg( 3, “ULib.tsay”, {“nil”,“boolean”}, wait )

if wait then timer.Simple( FrameTime()*0.5, ULib.tsay, ply, msg, false, ply and ply:IsValid() ) return end -- Call next frame

if SERVER and ply and not ply:IsValid() then -- Server console
    if wasValid then -- This means we had a valid player that left, so do nothing
        return
    end    
    Msg( msg .. "

" )
return
end

if CLIENT then
    LocalPlayer():ChatPrint( "(tsay from you) " .. msg  )
    LocalPlayer():EmitSound( Sound( "common/talk.wav" ) )
    return
end

if ply then
    ply:ChatPrint( "(tsay from you) " .. msg )
    umsg.Start( "ulib_sound", ply )
        umsg.String( Sound( "common/talk.wav" ) )
    umsg.End()
else
    local players = player.GetAll()
    for _, player in ipairs( players ) do
        player:ChatPrint( "(tsay from " .. ply:Nick .. ") " .. msg )
    end
    umsg.Start( "ulib_sound" )
        umsg.String( Sound( "common/talk.wav" ) )
    umsg.End()
end

end
[/lua]

i typed the scripts but still not works…

Did you over-write the existing ULib.tsay function or just add another one to the top/bottom/wherever?

i overwrite that…

[lua]
–[[
Title: Messages

Handles messaging like logging, debug, etc.

]]

–[[
Function: tsay

Prints a message in talk say as well as in the user's consoles.

Parameters:

	ply - The player to print to, set to nil to send to everyone. (Ignores this param if called on client)
	msg - The message to print.
	wait - *(Optional, defaults to false)* Wait one frame before posting. (Useful to use from things like chat hooks)
	wasValid - *(INTERNAL USE ONLY)* This is flagged on waiting if the player *was* valid.

Revisions:

	v2.10 - Initial

]]
function ULib.tsay( ply, msg, wait, wasValid )
ULib.checkArg( 1, “ULib.tsay”, {“nil”,“Player”,“Entity”}, ply )
ULib.checkArg( 2, “ULib.tsay”, “string”, msg )
ULib.checkArg( 3, “ULib.tsay”, {“nil”,“boolean”}, wait )

if wait then timer.Simple( FrameTime()*0.5, ULib.tsay, ply, msg, false, ply and ply:IsValid() ) return end -- Call next frame

if SERVER and ply and not ply:IsValid() then -- Server console
    if wasValid then -- This means we had a valid player that left, so do nothing
        return
    end    
    Msg( msg .. "

" )
return
end

if CLIENT then
    LocalPlayer():ChatPrint( "(tsay from you) " .. msg  )
    LocalPlayer():EmitSound( Sound( "common/talk.wav" ) )
    return
end

if ply then
    ply:ChatPrint( "(tsay from you) " .. msg )
    umsg.Start( "ulib_sound", ply )
        umsg.String( Sound( "common/talk.wav" ) )
    umsg.End()
else
    local players = player.GetAll()
    for _, player in ipairs( players ) do
        player:ChatPrint( "(tsay from " .. ply:Nick .. ") " .. msg )
    end
    umsg.Start( "ulib_sound" )
        umsg.String( Sound( "common/talk.wav" ) )
    umsg.End()
end

end

local serverConsole = {} – Used in the function below to identify the server console (internal use)

local function tsayColorCallback( ply, … )
if CLIENT then
chat.AddText( … )
return
end

if ply and ply ~= serverConsole and not ply:IsValid() then return end -- Player must have left the server

local args = { ... }

if ply == serverConsole then
	for i=2, #args, 2 do
		Msg( args[ i ] )
	end
	Msg( "

" );
return
end

local current_chunk = { size = 0 }
local chunks = { current_chunk }
local max_chunk_size = 240
while #args > 0 do
	local arg = table.remove( args, 1 )
	local typ = type( arg )
	local arg_size = typ == "table" and 4 or #arg + 2 -- Include null in strings, bool in both
	if typ == "string" and current_chunk.size + arg_size > max_chunk_size then -- Split a large string up into multiple messages
		local substr = arg:sub( 1, math.max( 1, max_chunk_size - current_chunk.size - 2 ) )
		if #substr > 0 then
			table.insert( current_chunk, substr )
		end
		table.insert( args, 1, arg:sub( #substr + 1) )

		current_chunk = { size = 0 }
		table.insert( chunks, current_chunk )
	else
		if current_chunk.size + arg_size > max_chunk_size then
			current_chunk = { size = 0 }
			table.insert( chunks, current_chunk )
		end
		current_chunk.size = current_chunk.size + arg_size
		table.insert( current_chunk, arg )
	end
end

for chunk_num=1, #chunks do
	local chunk = chunks[ chunk_num ]
	umsg.Start( "tsayc", ply )
		umsg.Bool( chunk_num == #chunks )
		umsg.Char( #chunk )
		for i=1, #chunk do
			local arg = chunk[ i ]
			if type( arg ) == "string" then
				umsg.Bool( true )
				umsg.String( arg )
			else
				umsg.Bool( false )
				umsg.Char( arg.r - 128 )
				umsg.Char( arg.g - 128 )
				umsg.Char( arg.b - 128 )
			end
		end
	umsg.End()
end

end

if CLIENT then
local accumulator = {}

local function tsayColorHook( um )
local last = um:ReadBool()
local argn = um:ReadChar()
for i=1, argn do
if um:ReadBool() then
table.insert( accumulator, um:ReadString() )
else
table.insert( accumulator, Color( um:ReadChar() + 128, um:ReadChar() + 128, um:ReadChar() + 128) )
end
end

if last then
	chat.AddText( unpack( accumulator ) )
	accumulator = {}
end

end
usermessage.Hook( “tsayc”, tsayColorHook )
end

–[[
Function: tsayColor

Prints a tsay message in color!

Parameters:

	ply - The player to print to, set to nil to send to everyone. (Ignores this param if called on client)
	wait - *(Optional, defaults to false)* Wait one frame before posting. (Useful to use from things like chat hooks)
	... - color arg and text arg ad infinitum, color needs to come before the text it's coloring.

Revisions:

	v2.40 - Initial.

]]
function ULib.tsayColor( ply, wait, … )
if SERVER and ply and not ply:IsValid() then ply = serverConsole end – Mark as server

if wait then ULib.queueFunctionCall( tsayColorCallback, ply, ... ) return end -- Call next frame
tsayColorCallback( ply, ... )

end

–[[
Function: tsayError

Just like tsay, but prints the string in red

Parameters:

	ply - The player to print to, set to nil to send to everyone. (Ignores this param if called on client)
	msg - The message to print.
	wait - *(Optional, defaults to false)* Wait one frame before posting. (Useful to use from things like chat hooks)

Revisions:

	v2.40 - Initial.

]]
function ULib.tsayError( ply, msg, wait )
return ULib.tsayColor( ply, wait, Color( 255, 140, 39 ), msg )
end

–[[
Function: csay

Prints a message in center of the screen as well as in the user's consoles.

Parameters:

	ply - The player to print to, set to nil to send to everyone. (Ignores this param if called on client)
	msg - The message to print.
	color - *(Optional)* The amount of red to use for the text.
	duration - *(Optional)* The amount of time to show the text.
	fade - *(Optional, defaults to 0.5)* The length of fade time

Revisions:

	v2.10 - Added fade parameter. Fixed it sending the message multiple times.
	v2.40 - Changed to use clientRPC.

]]
function ULib.csay( ply, msg, color, duration, fade )
if CLIENT then
ULib.csayDraw( msg, color, duration )
Msg( msg … "
" )
return
end

ULib.clientRPC( ply, "ULib.csayDraw", msg, color, duration, fade )
ULib.console( ply, msg )

end

–[[
Function: console

Prints a message in the user's consoles.

Parameters:

	ply - The player to print to, set to nil to send to everyone. (Ignores this param if called on client)
	msg - The message to print.

]]
function ULib.console( ply, msg )
if CLIENT or (ply and not ply:IsValid()) then
Msg( msg … "
" )
return
end

if ply then
	ply:PrintMessage( HUD_PRINTCONSOLE, msg .. "

" )
else
local players = player.GetAll()
for _, player in ipairs( players ) do
player:PrintMessage( HUD_PRINTCONSOLE, msg … "
" )
end
end
end

–[[
Function: error

Gives an error to console.

Parameters:

	s - The string to use as the error message

]]
function ULib.error( s )
if CLIENT then
Msg( "[LC ULIB ERROR] " … s … "
" )
else
Msg( "[LS ULIB ERROR] " … s … "
" )
end
end

–[[
Function: debugFunctionCall

Prints a function call, very useful for debugging.

Parameters:

	name - The name of the function called.
	... - all arguments to the function.

Revisions:

	v2.40 - Now uses print instead of Msg, since Msg seems to have a low max length.
		Changed how the variable length params work so you can pass nil followed by more params

]]
function ULib.debugFunctionCall( name, … )
local args = { … }

print( "Function '" .. name .. "' called. Parameters:" )
for i=1, #args do
	local value = ULib.serialize( args[ i ] )
	print( "[PARAMETER " .. i .. "]: Type=" .. type( args[ i ] ) .. "	Value=(" .. value .. ")" )
end

end
[/lua]

That’s my addons/ulib/lua/ulib/shared/messages.lua

That’s odd, how doesn’t it work?
Any errors?

@ , @@ , @@@ commands doesn’t works at all.

no errors appeared.