• Print

Author Topic: ULX Logging Jailbreak Rounds  (Read 4806 times)

0 Members and 1 Guest are viewing this topic.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
ULX Logging Jailbreak Rounds
« on: September 17, 2015, 01:40:13 pm »
Hi,

I'm trying to add the logging of rounds in Excl's jailbreak to ULX. I've looked through the log.lua file and it seems that the function is just ulx.logWriteLn( string ). However when I try to call this function in a hook, ULX seems to freak out and stop function. When the server first starts or the map changes it spams console with about 10 "invalid command" messages. The other error I've noticed is that fancyLogAdmin is nil, making most commands not work. This error only appears when you try to run a command the uses the fancyLog function.

It's even stranger because just commenting out the lines won't fix it. I've needed to completely delete the file and restart the server for ULX to start functioning again. My full code is below, if anyone has any idea as to why this might be happening please do share. This is going in garrysmod/addons/customulxcommands/lua/ulx/log.lua

Code: Lua
  1. hook.Add( "JailbreakRoundStart", "ULXLogJBRoundStart", function( gamemode, rounds )
  2.   ulx.logWriteLn( string.format( "Round %i is starting.", rounds ) )
  3. end )
  4. hook.Add( "JailbreakRoundEnd", "ULXLogJBRoundEnd", function( gamemode, rounds )
  5.   ulx.logWriteLn( string.format( "Round %i is ending.", rounds ) )
  6. end )

And this might be helpful, here are the hook.Call functions for each of those hooks:

Code: Lua
  1. hook.Call("JailBreakRoundStart",JB.Gamemode,JB.RoundsPassed)
  2. hook.Call("JailBreakRoundEnd",JB.Gamemode,JB.RoundsPassed);

JB.RoundsPassed is a non-zero positive integer, and JB.Gamemode is just a master table of sorts for the gamemode.
« Last Edit: September 17, 2015, 01:45:40 pm 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.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: ULX Logging Jailbreak Rounds
« Reply #1 on: September 17, 2015, 01:55:15 pm »
I'm taking a guess here... Try sticking it in addonfolder/lua/ulx/modules/jb_log.lua

It seems like the error is happening maybe because ULX hasn't fully loaded yet or isn't loading because of two identical file names.  Try naming it different, although that might not be necessary with the relocation.
« Last Edit: September 17, 2015, 01:58:07 pm by Aaron113 »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX Logging Jailbreak Rounds
« Reply #2 on: September 17, 2015, 07:45:27 pm »
Additionally, we have a hook that calls when ULib and, I think, ULX, have loaded.
Think Stickly Man requested that for XGUI long before he joined the team 'officially'
I'm not in a spot to look for it right now, but if I remember later, will do.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: ULX Logging Jailbreak Rounds
« Reply #3 on: September 18, 2015, 04:12:55 am »
I was under the assumption that ULX loads other addons in this format of addon/lua/ulx/, so it would automatically be loaded after ULX. If not, then I have no idea why my lua file is being run because it isn't in autorun and it isn't being run from anywhere.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: ULX Logging Jailbreak Rounds
« Reply #4 on: September 18, 2015, 05:07:53 am »
I was under the assumption that ULX loads other addons in this format of addon/lua/ulx/, so it would automatically be loaded after ULX. If not, then I have no idea why my lua file is being run because it isn't in autorun and it isn't being run from anywhere.
ULX modules would go under /lua/ulx/modules/, with the appropriate prefixes for clientside and shared modules IIRC. Your addon is a module, therefore its files should appear in /addons/your_addon/lua/ulx/modules/.
bw81@ulysses-forums ~ % whoami
Homepage

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: ULX Logging Jailbreak Rounds
« Reply #5 on: September 18, 2015, 08:39:35 am »
I thought you just had to copy the structure of the ULX addon folder. log.lua goes in addons/ulx/lua/ulx/, so I assumed I could put my log.lua in the same place in my folder. I'll try moving it to the modules folder.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: ULX Logging Jailbreak Rounds
« Reply #6 on: September 18, 2015, 12:44:50 pm »
I thought you just had to copy the structure of the ULX addon folder. log.lua goes in addons/ulx/lua/ulx/, so I assumed I could put my log.lua in the same place in my folder. I'll try moving it to the modules folder.
That would work if you weren't dependent on ULX for your script.  Since you rely on functions ULX gives you,  you should place it in the modules folder so it is loaded after ULX is fully loaded.  Everything is loaded in a certain order.

  • Print