• Print

Author Topic: How do I go about doing this...  (Read 5044 times)

0 Members and 1 Guest are viewing this topic.

Offline Omni

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
How do I go about doing this...
« on: August 25, 2015, 03:18:49 pm »
Nevermind
« Last Edit: August 27, 2015, 07:06:11 am by Omni »

Offline SociopathicalMe

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: How do I go about doing this...
« Reply #1 on: August 25, 2015, 05:56:55 pm »
So you would like to make a chat command or accessible through ULX menu?

 

Offline Omni

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: How do I go about doing this...
« Reply #2 on: August 26, 2015, 12:11:37 am »
I'd just like to make a chat command so that it opens the gLogs menu.
Here's the link to the addon - https://github.com/Starfox64/gLogs
In the readme it says
 "To integrate gLogs to your existing gamemode or logging addon you may use the example provided for ULX in 'README.txt'."

I've looked in the readme but it said nothing about integrating things into ulx.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: How do I go about doing this...
« Reply #3 on: August 26, 2015, 04:36:05 am »
From https://github.com/Starfox64/gLogs/blob/master/addons/gLogs/lua/glogs/hooks/README.txt:

-- ULX EXAMPLE --
-- To integrate ULX add the 'gLogs.AddLog' function to the ULX's log function like shown below (ULX/lua/ulx/log.lua)
Code: Lua
  1. function ulx.logString(str,log_to_main)
  2.         gLogs.AddLog("ulx",str,false) -- gLogs AddLog function added to ULX's. Notice that I don't use ULX's timestamp system to have standard timestamps in the logs.
  3.         if not ulx.log_file then return end
  4.  
  5.         local dateStr = os.date("%Y-%m-%d")
  6.         if curDateStr < dateStr then
  7.                 next_log()
  8.         end
  9.  
  10.         if log_to_main then
  11.                 ServerLog("[ULX] " .. str .. "\n")
  12.         end
  13.         local date = os.date("*t")
  14.         ulx.logWriteln(string.format("[%02i:%02i:%02i]",date.hour,date.min,date.sec) ..str)
  15. end
-- You will also need to add the ulx (ULX) type in your control panel!

I posted this without actually checking the code, I haven't looked at the function itself but it needs a few ULX/ULib commands to fully work. Add these under the function:

Code: Lua
  1. local logString = ulx.command( CATEGORY_NAME, "ulx logstring", ulx.logstring, "!logstring" )
  2. logstring:addParam{ type=ULib.cmds.StringArg, hint="string", Lib.cmds.takeRestOfLine }
  3. logstring:defaultAccess( ULib.ACCESS_ADMIN )
  4. logstring:help( "Logs string." )

Make sure to replace CATEGORY_NAME with the name of the category you want.
« Last Edit: August 26, 2015, 04:49:47 am by roastchicken »
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

  • Print