ULX

Author Topic: How to make motd stay up for certain times??  (Read 2062 times)

0 Members and 2 Guests are viewing this topic.

Offline Lalala

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
How to make motd stay up for certain times??
« on: January 04, 2013, 08:22:58 PM »
I know how to create accept and decline buttons
I can't figure this out would love for someone to post the code I would need soon.
Thanks

Offline krooks

  • Sr. Member
  • ****
  • Posts: 382
  • Karma: 32
  • I don't like video games.
    • Diamond Krooks
Re: How to make motd stay up for certain times??
« Reply #1 on: January 04, 2013, 09:35:14 PM »
I'm not a lua coder by any means, but I ran across this bit of code in the sui scoreboard:

Code: [Select]
timer.Simple( 1.5, function()
--your code
)

Maybe it can help?
My TTT server. Join the fun!

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: How to make motd stay up for certain times??
« Reply #2 on: January 07, 2013, 09:26:00 AM »
to do this you would need to create  a timer based accept button  that gets disabled when crated and starts a timer that reinables it but make sure any code that needs what is ran in the timer to be done first is in the function of the timer as well or it won't work
ps: i don't know gui lua code so take this with a  bag of salt
« Last Edit: January 07, 2013, 09:29:19 AM by nathan736 »
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: How to make motd stay up for certain times??
« Reply #3 on: January 07, 2013, 03:03:29 PM »
Here's how I do it. I don't use the built in ULX MOTD though. This would take some modification to the base ULX code to make this work with their MOTD.

Code: [Select]
/*--------------------------------
---------------TOS----------------
--------------------------------*/
local PANEL = {}

function PANEL:Init()
    self:SetPos((ScrW() / 2) - 400, 30)
    self:SetSize(800, 650)
    self:SetVisible(false)


self.time = SGS.tostime
self.nextthink = CurTime() + 1
self.bdisabled = true

self:DrawFrame()


end

function PANEL:Paint( w, h )

draw.RoundedBoxEx( 16, 0, 0, self:GetWide(), self:GetTall(), Color(80, 80, 80, 150), true, true, true, true )

end

function PANEL:DrawFrame()
HTMLPanel = vgui.Create("DPanel", self)
HTMLPanel:SetPos(8,64)
HTMLPanel:SetSize(782, 500)


HTMLTest = vgui.Create("HTML", HTMLPanel)
HTMLTest:SetPos(0,0)
HTMLTest:Dock( FILL )
HTMLTest:OpenURL("http://www.g4p.org/Stranded/TOS/")

TOSbutton = vgui.Create( "DButton", self )
TOSbutton:SetSize( 120, 40 )
TOSbutton:SetPos( 8, 572 )
TOSbutton:SetText( "Wait: " .. self.time )
TOSbutton:SetDisabled( true )
TOSbutton.DoClick = function( TOSbutton )
if TOSbutton:GetDisabled() then return end
SGS.accepttos = true
RunConsoleCommand("sgs_refreshmodelpanel")
RunConsoleCommand("sgs_tosaccept")
self:Remove()
end

TOSbutton2 = vgui.Create( "DButton", self )
TOSbutton2:SetSize( 120, 40 )
TOSbutton2:SetPos( 136, 572 )
TOSbutton2:SetText( "I DON'T ACCEPT" )
TOSbutton2.DoClick = function( TOSbutton2 )
RunConsoleCommand("disconnect")
end


end


function PANEL:Think()
if CurTime() < self.nextthink then return end
if self.bdisabled then
if self.time > 0 then
self.time = self.time - 1
TOSbutton:SetText( "Wait: " .. self.time )
TOSbutton:SetDisabled( true )
else
TOSbutton:SetText( "I ACCEPT" )
TOSbutton:SetDisabled( false )
self.bdisabled = false
end
end
self.nextthink = CurTime() + 1
end

vgui.Register("sgs_tospanel", PANEL, "Panel")