Author Topic: MOTD to Whatever menu. Help?  (Read 4012 times)

0 Members and 1 Guest are viewing this topic.

Offline Frostyfrog

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
MOTD to Whatever menu. Help?
« on: September 23, 2008, 04:56:28 PM »
Hi, I was just wondering if you guys could help me turn the MOTD menu into my own menu. I'm kind of new to lua yet I want to add some of my own menus to to a few servers that I'm the lua scripter for. Please help me. :)

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: MOTD to Whatever menu. Help?
« Reply #1 on: September 23, 2008, 04:57:28 PM »
I don't understand what you're seeking?
Experiencing God's grace one day at a time.

Offline Frostyfrog

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: MOTD to Whatever menu. Help?
« Reply #2 on: September 23, 2008, 05:10:15 PM »
I am trying to get something similar to the MOTD script, but keep it separate. I'm currently trying to make a donator menu (I would do the HTML for it). It would work just like the MOTD. (I haven't tried links yet though).
The file I am trying to make a copy of and edit is: \addons\ULX\lua\ulx\modules\cl\motdmenu.lua
I Have no idea how to make this thing work :(

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: MOTD to Whatever menu. Help?
« Reply #3 on: September 23, 2008, 06:16:20 PM »
Do you mean display different HTML pages depending on what command was used?
Or do you mean an actual GUI menu in game, like "ulx menu" or "!menu"?

We, well, I, am totally lost as to what you are looking for.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Frostyfrog

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: MOTD to Whatever menu. Help?
« Reply #4 on: September 23, 2008, 06:37:45 PM »
Something like this (my script):
Code: [Select]
local HTML = {}

function HTML:StatusChanged( text )
end

function HTML:ProgressChanged( progress )
end

function HTML:FinishedURL( url )
end

function HTML:OpeningURL( url, target )
end

vgui.Register( "frostyDonator", HTML, "HTML" )



function frosty.showDonatorMenu()
local window = vgui.Create( "DFrame" )
if ScrW() > 640 then -- Make it larger if we can.
window:SetSize( ScrW()*0.9, ScrH()*0.9 )
else
window:SetSize( 640, 480 )
end
window:Center()
window:SetTitle( "Donation Menu" )
window:SetVisible( true )
window:MakePopup()

local html = vgui.Create( "frostyDonator", window )

local button = vgui.Create( "DButton", window )
button:SetText( "Close" )
button.DoClick = function() window:Close() end
button:SetSize( 100, 40 )
button:SetPos( (window:GetWide() - button:GetWide()) / 2, window:GetTall() - button:GetTall() - 10 )

html:SetSize( window:GetWide() - 20, window:GetTall() - button:GetTall() - 50 )
html:SetPos( 10, 30 )
html:SetHTML( file.Read( "Frostymod/Donator.txt" ) )
end
usermessage.Hook( "SendDonatorMenu", frosty.showDonatorMenu )

function frosty.rcvDonatorStart( um )
frosty.DonatorContent = ""
end
usermessage.Hook( "frostyDonatorStart", frosty.rcvDonatorStart )

function frosty.rcvDonatorEnd( um )
file.Write( "frosty/Donator.txt", frosty.DonatorContent )
frosty.DonatorContent = nil
end
usermessage.Hook( "frostyDonatorEnd", frosty.rcvDonatorEnd )

function frosty.rcvDonatorText( um )
frosty.DonatorContent = frosty.DonatorContent .. um:ReadString()
end
usermessage.Hook( "frostyDonatorText", frosty.rcvDonatorText )

CreateConVar( "frostydonation_opentype", "F4", FCVAR_ARCHIVE )
local function CheckKeys()
if ( menu:IsVisible() ) then return end

// If the chat's open we don't want anything triggering when we type.
if ( chatOpen ) then
if ( frostydonation.KEY && ( frostydonation.KEY < KEY_F1 || frostydonation.KEY > KEY_F12 ) ) then return end
end

RunString( "frostydonation.KEY = KEY_" .. string.upper( GetConVarString( "frostydonation_opentype" ) ) )
if ( input.IsKeyDown( frostydonation.KEY or KEY_F4 ) ) then
RunConsoleCommand( "frostydonation" )
return
end
end
MOTD File:
Code: [Select]
local HTML = {}

function HTML:StatusChanged( text )
end

function HTML:ProgressChanged( progress )
end

function HTML:FinishedURL( url )
end

function HTML:OpeningURL( url, target )
end

vgui.Register( "ULXMotd", HTML, "HTML" )



function ulx.showMotdMenu()
local window = vgui.Create( "DFrame" )
if ScrW() > 640 then -- Make it larger if we can.
window:SetSize( ScrW()*0.9, ScrH()*0.9 )
else
window:SetSize( 640, 480 )
end
window:Center()
window:SetTitle( "ULX MOTD" )
window:SetVisible( true )
window:MakePopup()

local html = vgui.Create( "ULXMotd", window )

local button = vgui.Create( "DButton", window )
button:SetText( "Close" )
button.DoClick = function() window:Close() end
button:SetSize( 100, 40 )
button:SetPos( (window:GetWide() - button:GetWide()) / 2, window:GetTall() - button:GetTall() - 10 )

html:SetSize( window:GetWide() - 20, window:GetTall() - button:GetTall() - 50 )
html:SetPos( 10, 30 )
html:SetHTML( file.Read( "ulx/motd.txt" ) )
end
usermessage.Hook( "SendMotdMenu", ulx.showMotdMenu )

function ulx.rcvMotdStart( um )
ulx.motdContent = ""
end
usermessage.Hook( "ULXMotdStart", ulx.rcvMotdStart )

function ulx.rcvMotdEnd( um )
file.Write( "ulx/motd.txt", ulx.motdContent )
ulx.motdContent = nil
end
usermessage.Hook( "ULXMotdEnd", ulx.rcvMotdEnd )

function ulx.rcvMotdText( um )
ulx.motdContent = ulx.motdContent .. um:ReadString()
end
usermessage.Hook( "ULXMotdText", ulx.rcvMotdText )

addons\ULX\lua\ulx\modules\menus.lua:
Code: [Select]
if file.Exists( "../lua/ulx/modules/cl/motdmenu.lua" ) then
CreateConVar( "motdfile", "ulx_motd.txt" )
function ulx.cc_motd( ply, command, argv, args )
if not ply:IsValid() then
Msg( "You can't see the motd from the console.\n" )
return
end

if not file.Exists( "../" .. GetConVarString( "motdfile" ) ) then return end -- Invalid
umsg.Start( "SendMotdMenu", ply )
umsg.End()
end
ulx.concommand( "motd", ulx.cc_motd, " - Shows you the message of the day.", ULib.ACCESS_ALL, "!motd", _, ulx.ID_HELP )

local function showMotd( ply )
if not util.tobool( GetConVarString( "ulx_showMotd" ) ) then return end
if not ply:IsValid() then return end -- They left, doh!

if not file.Exists( "../" .. GetConVarString( "motdfile" ) ) then return end -- Invalid
local f = file.Read( "../" .. GetConVarString( "motdfile" ) )

umsg.Start( "ULXMotdStart", ply )
umsg.End()

while f:len() > 0 do
umsg.Start( "ULXMotdText", ply )
umsg.String( f:sub( 1, 240 ) )
umsg.End()
f = f:sub( 241 )
end

umsg.Start( "ULXMotdEnd", ply )
umsg.End()

umsg.Start( "SendMotdMenu", ply )
umsg.End()
end
hook.Add( "ULibPlayerULibLoaded", "showMotd", showMotd )
ulx.convar( "showMotd", "1", " - Shows the motd to clients on startup.", ULib.ACCESS_ADMIN )
end
« Last Edit: September 23, 2008, 06:43:55 PM by Frostyfrog »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: MOTD to Whatever menu. Help?
« Reply #5 on: September 23, 2008, 06:56:51 PM »
See our releases section, UMotd
It does what you want, allows you to create any html page besides (or including) a MOTD.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming