1. Post #1
    my_hat_stinks's Avatar
    April 2011
    267 Posts
    I've been having trouble disabling the default chatbox text for a while now, and since I've made no progress at all, I've decided it's time to ask publicly for help

    I know you can use hook.Add with StartChat then return true, but until the player hits Y I'm stuck with this:

    (That's default chatbox on the left, lua chatbox on the right)

    I can't RunConsoleCommand, because the "messagemode" command only works when it's bound to a key (I have no idea why, there's no other console commands that act like that, other than "messagemode2")
    ] bind y
    "y" = "messagemode"
    ] messagemode
    Unknown command "messagemode"
    As far as I'm aware, there's no way to emulate a key press through lua, and even if there was how would I find which key is bound to chat?

    hook.Call("StartChat") doesn't work, it runs the code properly but doesn't hide the default chatbox
    GAMEMODE:StartChat() also doesn't work, it doesn't run the hook
    Same issues for the FinishChat hook

    The problem exists in both the current version of Garry's Mod, and the beta


    So, my question is this: Does anyone know of another workaround, or another way to hide chat?

  2. Post #2
    Can someone give me a dayz copy?
    gonzalolog's Avatar
    April 2011
    624 Posts
    hook.Add("PlayerChat","HIDING",function(ply,text)
    return false end)

    It should hide the chat's text...

  3. Post #3
    my_hat_stinks's Avatar
    April 2011
    267 Posts
    hook.Add("PlayerChat","HIDING",function(ply,text)
    return false end)

    It should hide the chat's text...
    You misunderstand, I want to make the default chatbox disappear as it does when returning true to "StartChat" or "FinishChat" hooks

    Compare the above screenshot to this one, after the player hits Y:


    You can see, the only difference is that the default chatbox is hidden
    I want a way to do that through code, so I don't get the two overlapping chatboxes when a player first joins

  4. Post #4
    my_hat_stinks's Avatar
    April 2011
    267 Posts
    Bump!
    Is it possible?

  5. Post #5
    DylanWilson's Avatar
    January 2010
    251 Posts
    hook.Add("PlayerBindPress", "NoChatBox" function(ply, bind, pressed)
    if string.find(bind, "messagemode") then return true end
    end)
    
    yes, the string.find is neccesary because otherwise you can do "alias penis messagemode" and get into it anyways, also this way covers both messagemodes

  6. Post #6
    my_hat_stinks's Avatar
    April 2011
    267 Posts
    hook.Add("PlayerBindPress", "NoChatBox" function(ply, bind, pressed)
    if string.find(bind, "messagemode") then return true end
    end)
    
    yes, the string.find is neccesary because otherwise you can do "alias penis messagemode" and get into it anyways, also this way covers both messagemodes
    Would that not prevent messagemode from being run, simply making the problem worse?
    I think you've misread the issue

  7. Post #7
    Gold Member
    BlackAwps's Avatar
    July 2011
    726 Posts
    hook.Add( "HUDShouldDraw", "Chatbox - Hide", function ( x )
    	if ( x == "CHudChat" ) then
    		return false
    	end
    end )
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Winner Winner x 2Lua Helper Lua Helper x 1 (list)

  8. Post #8
    my_hat_stinks's Avatar
    April 2011
    267 Posts
    hook.Add( "HUDShouldDraw", "Chatbox - Hide", function ( x )
    	if ( x == "CHudChat" ) then
    		return false
    	end
    end )
    Works perfectly, thanks!