• How does Playable Piano block chat?
    9 replies, posted
How does Playable Piano Addon block the chat when sitting on it and you can only leave when clicking TAB. [B]Addon:[/B] [url]http://steamcommunity.com/sharedfile...ails/104548572[/url] What does this Addon do that when I click E on the Piano, I can't access to the chat while I am on the piano.
[CODE] function RemoveChat() hook.Add( "HUDShouldDraw", "NoChatBox", function( name ) if name == "CHudChat" then return false end end ) end function BringBackChat() hook.Remove( "HUDShouldDraw", "NoChatBox" ) end [/CODE] should be this. [editline]23rd September 2016[/editline] [url]https://wiki.garrysmod.com/page/Basic_Chatbox[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerBindPress]GM:PlayerBindPress[/url]
[QUOTE=meharryp;51095628][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerBindPress]GM:PlayerBindPress[/url][/QUOTE] [B]This inside gmt_instruments_base\cl_init.lua[/B] [CODE]// Override regular keys hook.Add( "PlayerBindPress", "InstrumentHook", function( ply, bind, pressed ) if IsValid( ply.Instrument ) then return true end end )[/CODE] What should it do, how does it work?
[QUOTE=karl-police;51100608][B]This inside gmt_instruments_base\cl_init.lua[/B] [CODE]// Override regular keys hook.Add( "PlayerBindPress", "InstrumentHook", function( ply, bind, pressed ) if IsValid( ply.Instrument ) then return true end end )[/CODE] What should it do, how does it work?[/QUOTE] Returning true in PlayerBindPress prevents the command that is bound to that key from running. If you wanted to block a specific command, say the chatbox, you'd do [lua] hook.Add( PlayerBindPress", "BlockChat", function(ply, bind, pressed) if bind == "say" or bind == "say_team" then return true end end) [/lua]
[QUOTE=meharryp;51100648]Returning true in PlayerBindPress prevents the command that is bound to that key from running. If you wanted to block a specific command, say the chatbox, you'd do [lua] hook.Add( PlayerBindPress", "BlockChat", function(ply, bind, pressed) if bind == "say" or bind == "say_team" then return true end end) [/lua][/QUOTE] Fine, now on a specific gamemode it doesn't block the chat, why?
There is very likely other code that's overriding it.
[QUOTE=Nookyava;51100745]There is very likely other code that's overriding it.[/QUOTE] So an another code can bypass PlayerBindPress?
[QUOTE=karl-police;51100857]So an another code can bypass PlayerBindPress?[/QUOTE] If it's done poorly, yes.
[QUOTE=Nookyava;51102821]If it's done poorly, yes.[/QUOTE] And where can I find something like "BlockChat" are there other commands like "BlockChat" And why does it add a hook instead of doing an if statement? [B]Edit:[/B]Ah, every gamemode is else, like I don't need to add the hooks anymore just if it does something new.
Sorry, you need to Log In to post a reply to this thread.