• Print

Author Topic: Re: Adverts not working  (Read 8 times)

0 Members and 1 Guest are viewing this topic.

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Adverts not working
« on: February 09, 2011, 12:44:00 am »
This is in reference to this thread: /index.php/topic,5173.0.html
Since Megiddo isn't online I thought I'd describe my discoveries here before I forget--

So I updated my gmod server/client and joined and immediately saw this error:
Code: [Select]
ERROR: Hook 'ULXInitPlayer' Failed: [@addons\ulx\lua\ulx\lib.lua:70] bad argument #2 to 'format' (number expected, got nil)
Removing Hook 'ULXInitPlayer'
ERROR: Hook 'ULXWelcome' Failed: [@addons\ulx\lua\ulx\lib.lua:70] bad argument #2 to 'format' (number expected, got nil)
Removing Hook 'ULXWelcome'
..Followed by this error when any adverts were supposed to go off:
Code: [Select]
Timer Error: [@addons\ulx\lua\ulx\lib.lua:70] bad argument #2 to 'format' (number expected, got nil)
The bit of code in question was this:
Code: [Select]
r = tonumber( string.Explode( "\n", file.Read( "../lua/ulx/.svn/entries" ) )[ 4 ] ) -- Get revision from entries file. Hackish I know, but who cares?
version = string.format( "<SVN> revision %i", r )

As it turns out, doing a small little test in my server console revealed this:
Code: [Select]
lua_run print( string.Explode("\n",file.Read("../lua/ulx/.svn/entries"))[4])
> print( string.Explode("\n",file.Read("../lua/ulx/.svn/entries"))[4])...
http://ulyssesmod.net/ulx/trunk/lua/ulx
lua_run print( string.Explode("\n",file.Read("../lua/ulx/.svn/entries"))[3])
> print( string.Explode("\n",file.Read("../lua/ulx/.svn/entries"))[3])...
154

So somehow the line to grab the SVN version number got offset by one? That doesn't make much sense to me considering this was supposedly the fault of a gmod update. I changed the code to this:
Code: [Select]
r = tonumber( string.Explode( "\n", file.Read( "../lua/ulx/.svn/entries" ) )[ 3 ] ) -- Get revision from entries file. Hackish I know, but who cares?
version = string.format( "<SVN> revision %i", r )
--Then I committed to the SVN after testing on my server in hopes that it would solve the OP's problem.


Any thoughts Megiddo? The origin of the problem has me slightly baffled and I hope that my solution doesn't cause more issues because the problem I discovered was the fault of a bad entries file on our dropbox sync. (unlikely?)

I give you full poking permissions for a single day during the summer if I cause any troubles with this :P
« Last Edit: February 09, 2011, 12:45:38 am by Stickly Man! »
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Re: Adverts not working
« Reply #1 on: February 09, 2011, 04:32:22 am »
It's possible that garry changed how files with binary data are read, which would cause this problem. I'll check to see how Wire, which took this code from us, solved the problem. :P

EDIT: Hmm, Wire's still doing it the same way. And they removed the mention that they figured out how to do this from ULX. Oh well, just one line of code, not exactly hard to come up.

Code: Lua
  1.         if (file.Exists("lua/wire/.svn/entries", true)) then
  2.                 version = string_Asplode("\n", file.Read( "lua/wire/.svn/entries", true) or "")[4]
  3.                 exported = false
  4.                 plainversion = version
  5.         elseif (file.Exists("wire_version.txt")) then -- Try getting the version by reading the text file:
  6.                 plainversion = file.Read("wire_version.txt")
  7.                 version = plainversion .. " (EXPORTED)"
  8.         end
  9.        
  10.         return version, tonumber(plainversion), exported
« Last Edit: February 09, 2011, 04:36:19 am by Megiddo »
Experiencing God's grace one day at a time.

  • Print