Console Command Adding Code Help

What i want to do is this, whenever a user types in “!adminhelp” in console it prints a message saying the user which typed in !adminhelp then after that needs an admin! E.g.e:

Bob: !adminhelp
Bob needs an admin!

-Thanks.

Why console, you can do that upon entering !adminhelp in chat.



function Adminhelp( ply, text)
    if (string.find(text, "!adminhelp") != nil) then
       chat.AddText("Player "..ply:GetName().." asked for admin's help!")
    end
end
hook.Add( "OnPlayerChat", "Adminhelp", Adminhelp )


Thanks! That’s what i meant. Didn’t explain right. Thank you very much. Now how would i make the text show local?

to add a command to be used with console use the contex

concommand.add ( For the OP, if you still need the info )

Where do i put the adminhelp.lua file?

garrysmod/garrysmod/lua/autorun/server
That is the folder you can put it in if it is a server file, if it is a client file put it in here:
garrysmod/garrysmod/lua/autorun/client

Thanks! Now what would i need to do for when the player types !adminhelp a little box comes up with 1. 2. etc where you can press a number for a reason? Then it says in the text the reason which was chose?

This all goes into a shared lua file, one that is run on both the client and the server.
[lua]
local AdminHelp_List = {“There is a spammer!”, “People are harrassing me!”, “I found a bug!”, “d”, “dw”, “wd”, “dwew”, “dwe”, “weefd”, “weed”}

if CLIENT then

function CreateAdminHelpMenu()
    AH_Frame = vgui.Create( "DFrame" )
    AH_Frame:SetSize( ScrW()/2, ScrH()/2 )
    AH_Frame:Center()
    AH_Frame:SetTitle( "Admin help menu" )
    AH_Frame:SetDraggable( false )
    AH_Frame:ShowCloseButton( true )

    AH_Frame.List = vgui.Create( "DPanelList" )
    AH_Frame.List:SetParent( AH_Frame )
    AH_Frame.List:SetPos( 5, 30 )
    AH_Frame.List:SetSize( AH_Frame:GetWide()-10, AH_Frame:GetTall()-35 )
    AH_Frame.List:SetSpacing( 5 )
    AH_Frame.List:SetPadding( 10 )
    AH_Frame.List:EnableHorizontal( false )
    AH_Frame.List:EnableVerticalScrollbar( true )

    AH_Frame.Populate = function()
        AH_Frame.List:Clear()
        for k, v in pairs( AdminHelp_List ) do
            AH_Frame.List[k] = vgui.Create( "DPanel" )
            AH_Frame.List[k]:SetSize( AH_Frame:GetWide()-43, 30 )
            AH_Frame.List[k].Paint = function()
                surface.SetDrawColor( 50, 50, 50, 255 ) 
                surface.DrawRect( 0, 0, AH_Frame.List[k]:GetWide(), AH_Frame.List[k]:GetTall() )
                draw.SimpleText( v, "Default", 5, 15, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
            end
            AH_Frame.List:AddItem( AH_Frame.List[k] )

            AH_Frame.List[k].button = vgui.Create( "DButton", AH_Frame.List[k] )
            AH_Frame.List[k].button:SetSize( 35, 20 )
            AH_Frame.List[k].button:SetPos( AH_Frame.List[k]:GetWide()-40, 5 )
            AH_Frame.List[k].button:SetText( "Go" )
            AH_Frame.List[k].button.DoClick = function( button )
                if !AH_Frame then return end
                if AH_Frame:IsVisible() then
                    AH_Frame:Close()
                end
                RunConsoleCommand("AdminHelp", LocalPlayer():Nick(), k)
            end
        end
    end
    AH_Frame.Open = function()
        AH_Frame:SetVisible( true )
        AH_Frame:Populate()
        RestoreCursorPosition()
        gui.EnableScreenClicker(true)
    end
    AH_Frame.Close = function()
        AH_Frame:SetVisible( false )
        RememberCursorPosition()
        gui.EnableScreenClicker(false)
    end
end

function Adminhelp_ChatFunction( ply, text)
    if string.lower( string.Left(text, 10) ) == "!adminhelp" then
        if !AH_Frame then
            CreateAdminHelpMenu()
            AH_Frame:Open()
        elseif AH_Frame:IsVisible() then
            AH_Frame:Close()
        elseif !AH_Frame:IsVisible() then
            AH_Frame:Open()
        end
    end
end
hook.Add( "OnPlayerChat", "ChatCommand_Adminhelp", Adminhelp_ChatFunction )

else
function InformPeople( pl, cmd, arg )
if !arg[1] then return end
if !arg[2] then return end
local nick = arg[1]
local key = tonumber(arg[2])
if !AdminHelp_List[key] then return end
local Real = false
for k, v in pairs(player.GetAll()) do
if v:Nick() == nick then
Real = true
end
end

    if Real then
        for k, v in pairs(player.GetAll()) do
            v:ChatPrint(nick..": "..AdminHelp_List[key])
        end
    end
end
concommand.Add( "AdminHelp", InformPeople )

end
[/lua]
It’s a little sloppy but works so excuse the code work.

https://dl.dropbox.com/u/30778198/gm_flatgrass0007.jpg

https://dl.dropbox.com/u/30778198/gm_flatgrass0008.jpg

I made it so the server prints out the help message, this way it sticks out more for admins.

All you have to do is change what the text says for each box at the top of the script.

Thanks man!

Where would that last script be placed? Placing it in client forces it to open for the entire server eh?

That doesn’t actually mean much to me, unless you’re telling me to make a shared.lua and place it in autorun, eh?

Okay another question, how would i make it different colours when it says in chat? E.g. “Liam has found a spammer” in the colour red?