• Help Please
    12 replies, posted
As I am totally useless at LUA... ...I was wondering is it possible to make it so that a chat command would trigger a small text box like a VGUI to pop up , I want to use this so that I can inform players of certain commands they can use, Thanks, Scott.
This is all client-side of course. [lua] local command = "!help" hook.Add( "OnPlayerChat", "", function( pl, text ) if ( pl ~= LocalPlayer( ) ) then return end if ( text ~= command ) then return end -- your vgui here end ) [/lua] [url]http://wiki.garrysmod.com/?title=Gamemode.OnPlayerChat[/url] [url]http://wiki.garrysmod.com/?title=Derma[/url]
Ok thanks, but Could you help me on how to make the VGUI , I havnt a clue lol
[QUOTE=~ScottyDo~;18194644]Ok thanks, but Could you help me on how to make the VGUI , I havnt a clue lol[/QUOTE] I guess it would help knowing what exactly it should look like, how big with how much text.. any buttons?
Ermm like just a small box don't know the exact dimensions , could you just put any odd dimensions and leave me to edit it, I don't care what it looks like so long as it contains the text lol...Just an OK button to close it, thanks
[lua]function MenuOfAwesome() local frame = vgui.Create("DFrame") frame:SetSize(300,200) frame:Center() frame:MakePopup() frame:SetTitle("Menu of Awesome") local button = vgui.Create("DButton",frame) button:SetSize(75,25) button:SetPos(frame:GetWide()/2 - button:GetWide()/2,frame:GetTall()/2 - button:GetTall()/2) button:SetText("Close") button.DoClick = function() frame:Close() end end [/lua] Like that?
I think so , Where do I specify the text to be contained in the box?
Right now it's just text on the button, but you can use a [url=http://wiki.garrysmod.com/?title=DLabel][b]DLabel[/b][/url] to make text appear wherever you want.
How I make the text come up inside a small box with the close button to close the box, and incorporate this into the chat command thing Salads was talking about.
Well, I would just try using the function I gave you for the menu. In Salads' function, he uses a hook called "OnPlayerChat", which means the function is run every time a player talks. Where he says "-- put vgui here", put everything in the function I gave you.
Ok thanks vm, I take it this goes into cl_init?
Sure. It could go in any script that runs clientside.
Ok thanks for your help.. will let you know how it goes
Sorry, you need to Log In to post a reply to this thread.