Ulysses Stuff > Ulysses Release Archives

[BROKEN] UMotd Revived - Motd and OTHER informational screens.

<< < (18/23) > >>

JamminR:

--- Quote from: Reiko on October 01, 2008, 08:43:37 PM ---Great! It's working perfectly now. Thanks so much for all your help!

--- End quote ---

And thank you for the inspiration and practice.
It's been months since I've done any hobby coding I could enjoy.
Now that we've helped each other debug, I'll know what not to do when I incorporate streaming radio into UMotd.

If you ever have ideas or projects you need help with now that you've dabbled in Lua, please feel free to visit our Developer's corner forum.
I personally don't always know the direct answer, but I like learning from our community and my team.

Frostyfrog:
The MOTD on player spawn thing won't work :(
I think somewhere here is the problem:

--- Code: ---function Umotd_help(ply, cmd, argv, args)
         ULib.console(ply, "[Umotd] - The following are available; help(this context), " .. string.Implode( ", ", Ucmds ) )
end
--ULib.concommand( "Umotd", Umotd_help )
ULib.begin_subconcommand( "Umotd", Umotd_help, nil, ULib.ACCESS_ALL  )

  Umotd_content = { }
  for Umotd_cmd, Ufile in pairs( Umotd_command_files ) do
      Umotd_content[Umotd_cmd] = { }
      Umotd_content[Umotd_cmd].cmd_name = Umotd_cmd

      if Ufile:lower():find("http:", 1, true) then
         Umotd_content[Umotd_cmd].path = Ufile -- It's a URL!
      else
         Umotd_content[Umotd_cmd].path = Umotd_LoadDir .. Ufile
      end

      if string.lower( Umotd_cmd ) == "motd" then
        if not Umotd_content[Umotd_cmd].path:lower():find("http:", 1, true) then

           local motdpath = "../" .. GetConVarString( "motdfile" )
           if file.Exists( motdpath )
           and not file.Read( motdpath ):find( "Welcome to Team Fortress 2", 1, true ) then
               Umotd_content[Umotd_cmd] = { path = motdpath } --Use motdfile variable if it exists, otherwise use config.
           end
        end
      end

      if file.Exists( Umotd_content[Umotd_cmd].path ) or Umotd_content[Umotd_cmd].path:lower():find("http:", 1, true) then
         Umotd_funcname = Umotd_cmd
         table.insert( Ucmds, Umotd_cmd )

         function Umotd_funcname(ply)
                 if not ply:IsValid() then
                    ULib.console(ply, "[Umotd] - You can't see the "..Umotd_cmd.." from the console.\n" )
                    return
                 end
                  UshowMotd( ply, Umotd_cmd, Umotd_content[Umotd_cmd].path )
         end
         Umotd_content[Umotd_cmd].func = Umotd_funcname
--print("Created ".. Umotd_cmd .." and passing ".. Umotd_content[Umotd_cmd].path )

         ULib.add_subconcommand( "Umotd", Umotd_cmd, Umotd_funcname, ULib.ACCESS_ALL )
         ULib.addSayCommand( Uchat_prefix .. Umotd_cmd, Umotd_funcname, "Umotd " .. Umotd_cmd )

      else
         Msg("[Umotd] Error - I can't create function \"" .. Umotd_cmd .. "\", file\URL " .. Umotd_content.Umotd_cmd.path .. " couldn't be found/understood.\n" )
         Msg("[Umotd] Error - Function \"" .. Umotd_cmd.. "\" not created\n" )
         --       Don't create functions.
      end
  end

  function UShow_motd(ply)
           if util.tobool( GetConVarString( "ulx_showMotd" ) ) then -- If ULX is loaded, attempt to disable its motd.
              game.ConsoleCommand( "ulx showMotd 0\n" )
           end
           ply:ConCommand("Umotd "..Umotd_SpawnCommand .."\n")
  end

local function Umotdinit()
                 if util.tobool(Umotd_ShowatPlayerSpawn) then
                    hook.Add( "PlayerInitialSpawn", "Umotd_Spawner", UShow_motd)
                 end
                 Umotd_map_starttime = os.time()
        end
hook.Add( "Initialize", "UmotdInitialize", Umotdinit )

--[[ ToDo
--table.HasValue - look it up ]]--

end -- UmotdLoaded
end -- Server
--- End code ---

My configuration file:

--- Code: ---Umotd_LoadDir = "Umotd/"
Uchat_prefix = "!"
Umotd_SpawnCommand = "listaddons"
Umotd_ShowatPlayerSpawn = "true"
Umotd_command_files = {
                    ["motd"] = "motd_template.txt",
                    ["rules"] = "rules.txt",
                    ["helpme"] = "help.txt",
                    ["serverinfo"] = "info_template.txt",
                    ["ulysses"] = "http://www.ulyssesmod.net/",
["donations"] = "donations.txt",
["listaddons"] = "addons.txt",
["website"] = "http://www.pawspubserver.co.uk/",
                      }
Umotd_dynvar = true
Umotd_AddOnSep1 = ", <br>" -- this sets what to use as separator if you use %addon_long%
Umotd_AddOnSep2 = ", " -- this sets what to use as separator if you use %addon_short%

--- End code ---

JamminR:
Any errors at server startup? Any errors when you join your server? When other people join your server?

Frostyfrog:
nope, no errors. then again, not really my server. I'm just the Lua guy for it. When I have this, it works: Umotd_ShowatPlayerSpawn = "false"
I shows the default (which isn't what we want)...

angrykid:

--- Quote from: Frostyfrog on October 10, 2008, 08:39:03 PM ---nope, no errors. then again, not really my server. I'm just the Lua guy for it. When I have this, it works: Umotd_ShowatPlayerSpawn = "false"
I shows the default (which isn't what we want)...

--- End quote ---

It's not showing up for me either. I don't really care, though, since nobody ever visits my server. :P


Oh, non-inline CSS works now! Kickass!
Now all I need for it to do is not lag so badly when trying to make a post on my forums... :P

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version