ULX

Author Topic: Attempt to call method 'find' a nil value  (Read 2378 times)

0 Members and 1 Guest are viewing this topic.

Offline Sir Klutch

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Attempt to call method 'find' a nil value
« on: April 05, 2017, 07:18:52 PM »
Hello, I am receiving this error from a custom ulx motd menu everytime you join the server.
Code: [Select]
[ERROR] addons/ulx/lua/ulx/modules/cl/motdmenu.lua:78: attempt to call method 'find' (a nil value)
  1. fn - addons/ulx/lua/ulx/modules/cl/motdmenu.lua:78
   2. func - addons/ulib/lua/ulib/client/cl_util.lua:22
    3. unknown - lua/includes/extensions/net.lua:32

The user who wrote this code is MrPresident. The code can be found here;
https://forums.ulyssesmod.net/index.php/topic,6113.msg29952.html#msg29952

The error is within
Code: [Select]
function ulx.rcvMotd( isUrl_, text )
isUrl = isUrl_
if not isUrl then
ULib.fileWrite( "data/ulx_motd.txt", text )
else
if text:find( "://", 1, true ) then
url = text
else
url = "http://" .. text
end
end
end

Help would be greatly appreciated!

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Attempt to call method 'find' a nil value
« Reply #1 on: April 05, 2017, 07:48:14 PM »
This code is 4 years old. It's not surprising that it doesn't work.

What exactly are you trying to do?

Offline Sir Klutch

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Attempt to call method 'find' a nil value
« Reply #2 on: April 05, 2017, 09:08:51 PM »
Fix the error. Everything works as intended to.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Attempt to call method 'find' a nil value
« Reply #3 on: April 05, 2017, 09:37:44 PM »
You fixed it? What did you do to fix it?

Offline Sir Klutch

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Attempt to call method 'find' a nil value
« Reply #4 on: April 05, 2017, 09:39:11 PM »
Lol, sorry if you misunderstood. I did not fix the error, you asked 'What exactly are you trying to do?' and I said fix the error. I could probably gut it and everything would be fine. Also, I could perhaps add a conditional to make sure text exists, is a string, and has a .find method

Code: [Select]
if not ( ( text ) and ( type( text ) == "string" ) and ( text.find) ) then return end
Would most likely fix the error, yes. Although I cannot find where the function is being called.


« Last Edit: April 05, 2017, 09:48:49 PM by Sir Klutch »

Offline Sir Klutch

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Attempt to call method 'find' a nil value
« Reply #5 on: April 05, 2017, 09:56:31 PM »
I went ahead and gutted it.