• Print

Author Topic: ULX MOTD disable close button  (Read 4483 times)

0 Members and 1 Guest are viewing this topic.

Offline Lolomat

  • Newbie
  • *
  • Posts: 24
  • Karma: 0
ULX MOTD disable close button
« on: June 18, 2014, 11:33:38 am »
Hello,

i am running a ttt server, and i use a modified motdmenu.lua.
It adds to buttons, one kicks you and the other activates after 5 seconds, so u have to read the rules,
but u can also press the X in right top corner.
So i want to disable this cross.

Regards,
Lolomat

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: ULX MOTD disable close button
« Reply #1 on: June 18, 2014, 11:37:11 am »
As shown here, you can use the function:
Code: Lua
  1. frame:ShowCloseButton( false )
on the Frame in the custom motdmenu code to disable the close button. It's an easy modification, but if you don't know lua, you'll have to post the code for further help.
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline Lolomat

  • Newbie
  • *
  • Posts: 24
  • Karma: 0
Re: ULX MOTD disable close button
« Reply #2 on: June 18, 2014, 12:16:33 pm »
This is the code i use:
Code: Lua
  1. ulx.motdmenu_exists = true
  2. -- DON'T EDIT THAT
  3. local isUrl
  4. local url
  5. -- MOTD BUTTON SETUP
  6. local MainURL = "http://fickschnitzel.weebly.com/regeln.html"                                                                   --Main Motd URL Website, I REALLY recommend to run the motd by url.
  7. local MotdText = "Willkommen!"                                                  --Motd Main Windows Tittle.
  8.  
  9. local AcceptButtonText = "Werbung überspringen (5)"                                                                                                    --Text for Accept rules button
  10. local AcceptButtonTime = 5                                                                                                                      --accept rules button will appear only after "X" seconds.
  11. local AcceptSay = ""                                                                            --Say in chat "X" message when I clic on accept rules button.
  12.  
  13. local DeclineButton = true                                                                                                                      --Spawn Decline Button ?
  14. local DeclineButtonText = "Kick mich"                                                                           --Text for Decline rules button
  15. local DeclineSay = "Kich mich."         --Say in chat "X" message when I clic on decline rules button.
  16. local DeclineKickTime = 5                                                                                                                       --time to kick the player if he decline rules, don't put so low, the script need to run "DeclineSay" before.
  17.  
  18. local WebButtonText = "Öffne Web Menü"                                                                                                --Text to open the Web Menu
  19. local CloseWebButtonText = "Schließe Web Menü"                                                                                        --Text to close the Web Menu
  20. local ReturnButtonText = "Startseite"                                                                                           --Text for Return on Main URL Page button.
  21. local CloseMotdButtonText = "Schließe MOTD Seite"                                                                              --Text for Close Motd Page button.
  22.  
  23. --Website Setup
  24. local Website1ButtonText = "Google"                                                                                                             --Text for 1st Website button.
  25. local Website2ButtonText = "Youtube"                                                                                                            --Text for 2nd Website button.
  26. local Website3ButtonText = "Gmod.org"                                                                                                           --Text for 3nd Website button.
  27. local Website4ButtonText = "FacePunch"                                                                                                  --Text for 4nd Website button.
  28. local Website1URL = "http://www.google.com/"                                                                            --1st Webstie URL
  29. local Website2URL = "http://www.youtube.com/"                                                                           --2nd Website URL
  30. local Website3URL = "http://www.garrysmod.org/"                                                                         --3nd Website URL
  31. local Website4URL = "http://www.facepunch.com/"                                                                         --4nd Website URL
  32.  
  33.  
  34. --------------------------------------------------------------------------------------
  35. -------DON'T EDIT ANYTHING BELLOW, if you know what you do, it's your choice !--------
  36. --------------------------------------------------------------------------------------
  37.  
  38. function ulx.showMotdMenu()
  39.         --creating main windows
  40.         local window = vgui.Create( "DFrame" )
  41.         if ScrW() > 640 then -- Make it larger if we can.
  42.                 window:SetSize( ScrW()*0.9, ScrH()*0.9 )
  43.         else
  44.                 window:SetSize( 640, 480 )
  45.         end
  46.         window:Center()
  47.         window:SetTitle( MotdText )
  48.         window:SetVisible( true )
  49.         window:MakePopup()
  50.  
  51.         --creating windows for html
  52.         local html = vgui.Create( "HTML", window )
  53.        
  54.         --AcceptButton
  55.         local AcceptButton = vgui.Create( "DButton", window )
  56.         if AcceptButtonText == "" then
  57.                         AcceptButton:SetText( "Close" )
  58.                 else
  59.                         AcceptButton:SetText( AcceptButtonText )
  60.                 end
  61.  
  62.         AcceptButton.DoClick = function()
  63.                         if AcceptSay != "" then
  64.                                 RunConsoleCommand("say", AcceptSay)
  65.                         end
  66.                         window:Close()
  67.                         gui.EnableScreenClicker(false) -- Disable the mouse
  68.                 end
  69.  
  70.         AcceptButton:SetSize( 90, 40 )
  71.         if AcceptButtonTime > 0 then
  72.                 AcceptButton:SetDisabled( true )
  73.                         timer.Simple( AcceptButtonTime, function()
  74.                                         AcceptButton:SetDisabled( false )
  75.                         end )
  76.                 end
  77.  
  78.        
  79.         if !DeclineButton then
  80.                         AcceptButton:SetPos( (window:GetWide() - AcceptButton:GetWide()) / 2.5, window:GetTall() - AcceptButton:GetTall() - 10 )
  81.                 else
  82.                         AcceptButton:SetPos( ( window:GetWide() / 4.0 ) - ( AcceptButton:GetWide() / 2 ), window:GetTall() - 57 )
  83.                        
  84.         --DeclineButton
  85.         local DeclineButton = vgui.Create( "DButton", window )
  86.                         DeclineButton:SetSize( 110, 40 )
  87.                         DeclineButton:SetPos( ( window:GetWide() / 3.0 ) - ( DeclineButton:GetWide() / 2 ), window:GetTall() - 57 )
  88.                         if DeclineButtonText == "" then
  89.                                 DeclineButton:SetText( "Decline" )
  90.                         else
  91.                                 DeclineButton:SetText( DeclineButtonText )
  92.                         end
  93.                         DeclineButton:SetVisible( true )
  94.                         DeclineButton.DoClick = function()
  95.                                 if DeclineSay != "" then
  96.                                 RunConsoleCommand("say", DeclineSay)
  97.                                 window:Close()
  98.                                 end
  99.                                 if DeclineKickTime > 0 then
  100.                                                 timer.Simple( DeclineKickTime, function()
  101.                                                         RunConsoleCommand( "disconnect" )
  102.                                                         end )
  103.                                 end
  104.                                
  105.                         end
  106.                 end
  107.                
  108.         --CloseMotd page Button
  109.         local CloseMotdButton = vgui.Create( "DButton", window )
  110.                         CloseMotdButton:SetSize( 110, 40 )
  111.                         CloseMotdButton:SetPos( ( window:GetWide() / 1.1 ) - ( CloseMotdButton:GetWide() / 2 ), window:GetTall() - 57 )
  112.                         if CloseMotdButtonText == "" then
  113.                                 CloseMotdButton:SetText( "Return" )
  114.                         else
  115.                                 CloseMotdButton:SetText( CloseMotdButtonText )
  116.                         end
  117.                         CloseMotdButton:SetVisible( true )
  118.                         CloseMotdButton:SetDisabled( true )
  119.                         CloseMotdButton.DoClick = function()
  120.                                 window:Close()
  121.                         end
  122.        
  123.         --Return on main page Button
  124.         local ReturnButton = vgui.Create( "DButton", window )
  125.                         ReturnButton:SetSize( 100, 40 )
  126.                         ReturnButton:SetPos( ( window:GetWide() / 1.6 ) - ( ReturnButton:GetWide() / 2 ), window:GetTall() - 57 )
  127.                         if ReturnButtonText == "" then
  128.                                 ReturnButton:SetText( "Return" )
  129.                         else
  130.                                 ReturnButton:SetText( ReturnButtonText )
  131.                         end
  132.                         ReturnButton:SetVisible( false )
  133.                         ReturnButton.DoClick = function()
  134.                                 html:OpenURL( MainURL )
  135.                                 CloseMotdButton:SetDisabled( false )
  136.                         end
  137.                        
  138.         --Website1 Button
  139.         local Website1Button = vgui.Create( "DButton", window )
  140.                         Website1Button:SetSize( 100, 40 )
  141.                         Website1Button:SetPos( ( window:GetWide() / 1.4 ) - ( Website1Button:GetWide() / 2 ), window:GetTall() - 45 )
  142.                         if Website1ButtonText == "" then
  143.                                 Website1Button:SetText( "Website1" )
  144.                         else
  145.                                 Website1Button:SetText( Website1ButtonText )
  146.                         end
  147.                         Website1Button:SetVisible( false )
  148.                         Website1Button.DoClick = function()
  149.                                 html:OpenURL( Website1URL )
  150.                                 CloseMotdButton:SetDisabled( false )
  151.                         end
  152.                        
  153.         --Website2 Button
  154.         local Website2Button = vgui.Create( "DButton", window )
  155.                         Website2Button:SetSize( 100, 40 )
  156.                         Website2Button:SetPos( ( window:GetWide() / 1.4 ) - ( Website2Button:GetWide() / 2 ), window:GetTall() - 90 )
  157.                         if Website2ButtonText == "" then
  158.                                 Website2Button:SetText( "Website2" )
  159.                         else
  160.                                 Website2Button:SetText( Website2ButtonText )
  161.                         end
  162.                         Website2Button:SetVisible( false )
  163.                         Website2Button.DoClick = function()
  164.                                 html:OpenURL( Website2URL )
  165.                                 CloseMotdButton:SetDisabled( false )
  166.                         end
  167.                        
  168.         --Website3 Button
  169.         local Website3Button = vgui.Create( "DButton", window )
  170.                         Website3Button:SetSize( 100, 40 )
  171.                         Website3Button:SetPos( ( window:GetWide() / 1.25 ) - ( Website3Button:GetWide() / 2 ), window:GetTall() - 45 )
  172.                         if Website3ButtonText == "" then
  173.                                 Website3Button:SetText( "Website3" )
  174.                         else
  175.                                 Website3Button:SetText( Website3ButtonText )
  176.                         end
  177.                         Website3Button:SetVisible( false )
  178.                         Website3Button.DoClick = function()
  179.                                 html:OpenURL( Website3URL )
  180.                                 CloseMotdButton:SetDisabled( false )
  181.                         end
  182.                        
  183.         --Website4 Button
  184.         local Website4Button = vgui.Create( "DButton", window )
  185.                         Website4Button:SetSize( 100, 40 )
  186.                         Website4Button:SetPos( ( window:GetWide() / 1.25 ) - ( Website4Button:GetWide() / 2 ), window:GetTall() - 90 )
  187.                         if Website4ButtonText == "" then
  188.                                 Website4Button:SetText( "Website4" )
  189.                         else
  190.                                 Website4Button:SetText( Website4ButtonText )
  191.                         end
  192.                         Website4Button:SetVisible( false )
  193.                         Website4Button.DoClick = function()
  194.                                 html:OpenURL( Website4URL )
  195.                                 CloseMotdButton:SetDisabled( false )
  196.                         end
  197.  
  198.         --Open WebButton
  199.         local CloseWebButton = vgui.Create( "DButton", window )
  200.         local WebButton = vgui.Create( "DButton", window )
  201.                         WebButton:SetSize( 100, 40 )
  202.                         WebButton:SetPos( ( window:GetWide() / 1.25 ) - ( WebButton:GetWide() / 2 ), window:GetTall() - 57 )
  203.                         if WebButtonText == "" then
  204.                                 WebButton:SetText( "OpenWebMenu" )
  205.                         else
  206.                                 WebButton:SetText( WebButtonText )
  207.                         end
  208.                         WebButton:SetVisible( true )
  209.                         WebButton:SetDisabled( false )
  210.                         WebButton.DoClick = function()
  211.                         --WebButton Clic
  212.                                 html:SetSize( window:GetWide() - 20, window:GetTall() - AcceptButton:GetTall() - 90 )
  213.                                 WebButton:SetPos( ( window:GetWide() / 1.9 ) - ( WebButton:GetWide() / 2 ), window:GetTall() - 90 )
  214.                                 WebButton:SetDisabled( true )
  215.                                 CloseWebButton:SetVisible( true )
  216.                                 ReturnButton:SetVisible( true )
  217.                                 Website1Button:SetVisible( true )
  218.                                 Website2Button:SetVisible( true )
  219.                                 Website3Button:SetVisible( true )
  220.                                 Website4Button:SetVisible( true )
  221.                                 CloseMotdButton:SetDisabled( false )
  222.                         end
  223.                        
  224.         --CloseWebButton
  225.                         CloseWebButton:SetSize( 100, 40 )
  226.                         CloseWebButton:SetPos( ( window:GetWide() / 1.9 ) - ( WebButton:GetWide() / 2 ), window:GetTall() - 45 )
  227.                         if CloseWebButtonText == "" then
  228.                                 CloseWebButton:SetText( "CloseWebMenu" )
  229.                         else
  230.                                 CloseWebButton:SetText( CloseWebButtonText )
  231.                         end
  232.                         CloseWebButton:SetVisible( false )
  233.                         CloseWebButton.DoClick = function()
  234.                         --CloseWebButton Clic
  235.                                 html:SetSize( window:GetWide() - 20, window:GetTall() - AcceptButton:GetTall() - 50 )
  236.                                 WebButton:SetPos( ( window:GetWide() / 1.25 ) - ( WebButton:GetWide() / 2 ), window:GetTall() - 57 )
  237.                                 WebButton:SetDisabled( false )
  238.                                 CloseWebButton:SetVisible( false )
  239.                                 ReturnButton:SetVisible( false )
  240.                                 Website1Button:SetVisible( false )
  241.                                 Website2Button:SetVisible( false )
  242.                                 Website3Button:SetVisible( false )
  243.                                 Website4Button:SetVisible( false )
  244.                                 CloseMotdButton:SetDisabled( false )
  245.                                
  246.                         end
  247.                        
  248.         --windows for button
  249.         html:SetSize( window:GetWide() - 20, window:GetTall() - AcceptButton:GetTall() - 50 )
  250.         html:SetPos( 10, 30 )
  251.        
  252.  
  253.         --if motd got an url, that will run the url, if false this will run motd.txt
  254.         if not isUrl then
  255.                 html:SetHTML( file.Read( "ulx/motd.txt" ) )
  256.         else
  257.                 html:OpenURL( url )
  258.         end
  259. end
  260.  
  261. --find url
  262. function ulx.rcvMotd( isUrl_, text )
  263.         isUrl = isUrl_
  264.         if not isUrl then
  265.                 file.Write( "ulx/motd.txt", text )
  266.         else
  267.                 if text:find( "://", 1, true ) then
  268.                         url = text
  269.                 else
  270.                         url = "http://" .. text
  271.                 end
  272.         end
  273. end
  274.  
« Last Edit: June 18, 2014, 02:30:02 pm by Stickly Man! »

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: ULX MOTD disable close button
« Reply #3 on: June 18, 2014, 02:32:10 pm »
I added lua code tags to your post to help find line numbers.

Add a line between 48 and 49 so it looks like the following:
Code: Lua
  1.         window:Center()
  2.         window:SetTitle( MotdText )
  3.         window:SetVisible( true )
  4.         window:ShowCloseButton( false )
  5.         window:MakePopup()

Hope that helps!
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline Lolomat

  • Newbie
  • *
  • Posts: 24
  • Karma: 0
Re: ULX MOTD disable close button
« Reply #4 on: June 19, 2014, 03:07:14 am »
That worked fine, thank u a lot <3

  • Print