Is there a way to disable the generic "player left the game (disconnect by user)" thing? I made my own disconnect message I want to use.
[code]
local function ChatText( pindex, pname, text, mess )
if mess == "joinleave" and text:find( "left the game (" ) then
--Do something
--Block old message
return true
end
end
hook.Add( "ChatText", "Custom Disconnect Message", ChatText )[/code]
pindex is the entindex of the player, and pname is the name of the player when it is a chat message.
So I've tried using that with my code (clientside just does a chat.addtext)
[lua]
util.AddNetworkString( "DoSAIPNotify" )
local function SAIP_DoNotify(t,p)
net.Start("DoSAIPNotify")
net.WriteTable(t)
if p then
net.Send(p)
else
net.Broadcast()
end
end
local CL_WHTE = Color(255,255,255)
local CL_RED = Color(255,105,105)
local function ChatText( pindex, pname, text, mess )
if mess == "joinleave" and text:find( "left the game (" ) then
SAIP_DoNotify({CL_RED, ply:Nick() .. " (" .. ply:SteamID() .. ") ", CL_WHTE, "has disconnected!"})
return true
end
end
hook.Add( "ChatText", "Custom Disconnect Message", ChatText )
[/lua]
But it still displays the original message (and no longer displays mine).
And you are doing this on the client? ChatText is a client hook.
I feel stupid. :suicide:
[editline]10th November 2013[/editline]
Still doesn't work. :downs:
[editline]10th November 2013[/editline]
[lua]
local function ChatText( pindex, pname, text, mess )
if mess == "joinleave" and text:find( "left the game (" ) then
chat.AddText(CL_RED, pname:Nick() .. " (" .. pname:SteamID() .. ") ", CL_WHTE, "has disconnected!")
return true
end
end
hook.Add( "ChatText", "Custom Disconnect Message", ChatText )
[/lua]
[editline]10th November 2013[/editline]
[lua]
[ERROR] lua/autorun/client/cl_steamid.lua:10: unfinished capture
1. find - [C]:-1
2. v - lua/autorun/client/cl_steamid.lua:10
3. unknown - lua/includes/modules/hook.lua:82
[/lua]
[editline]10th November 2013[/editline]
Changed it to this [lua] text:find( "left the game (", 1, true ) [/lua] But nothing shows at all now.
Sorry, you need to Log In to post a reply to this thread.