Author Topic: attempt to index global 'ULib' (a nil value) help please  (Read 9239 times)

0 Members and 2 Guests are viewing this topic.

Offline atomic-cruncher

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
attempt to index global 'ULib' (a nil value) help please
« on: January 12, 2014, 02:34:13 AM »
Someone told me this execute command: ULib.ucl.addUser( ply:SteamID(), nil, nil, "donator" ) but i get this error when running server[ERROR] lua/autorun/donationkeys.lua:15: attempt to index global 'ULib' (a nil value)1. unknown - lua/autorun/donationkeys.lua:15 ulx and ulib is installed anyways so i don't know the clue

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: attempt to index global 'ULib' (a nil value) help please
« Reply #1 on: January 12, 2014, 02:59:26 AM »
Code: [Select]
ULib.ucl.addUser( ply:SteamID(), nil, nil, "donator" )
What're those "nil"s doing there?
Out of the Garry's Mod business.

Offline atomic-cruncher

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: attempt to index global 'ULib' (a nil value) help please
« Reply #2 on: January 12, 2014, 03:21:33 AM »
Code: [Select]
ULib.ucl.addUser( ply:SteamID(), nil, nil, "donator" )
What're those "nil"s doing there?
something for allowed and refused but I don't need those so I just fill in nil

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: attempt to index global 'ULib' (a nil value) help please
« Reply #3 on: January 12, 2014, 07:08:05 AM »
Are you calling module() in donationkeys.lua on an earlier line?

Or are you calling ULib from the global scope, before it has a chance to load?
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: attempt to index global 'ULib' (a nil value) help please
« Reply #4 on: January 12, 2014, 10:24:48 AM »
Easiest quickest way to make sure ULib has loaded first..imo, is not use autorun folder for Ulib needed code.
Use addons\<your_addon>\lua\ulib\modules\<your file>

As the \addons\ulib\lua\ulib\modules\what_is_this.txt states
Quote
This folder is similar to the lua/autorun folder, except all scripts in this folder are loaded after ULib.
Scripts in this directory are shared ( loaded both server and client side ).
Scripts in the client and server sub-folders are loaded only on the client and server respectively.

Same for ULX (if using ulx functions), but replace ulib with ulx in the addon folder path.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline atomic-cruncher

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: attempt to index global 'ULib' (a nil value) help please
« Reply #5 on: January 12, 2014, 01:25:11 PM »
ERROR:

[ULIB] Loading SHARED module: donationkeys.lua

[ERROR] addons/ulib/lua/ulib/modules/donationkeys.lua:15: attempt to index global 'ply' (a nil value)
1. unknown - addons/ulib/lua/ulib/modules/donationkeys.lua:15
2. include - [C]:-1
3. unknown - addons/ulib/lua/ulib/init.lua:68
4. include - [C]:-1
5. unknown - addons/ulib/lua/autorun/ulib_init.lua:3

[ULIB] Loading SHARED module: ulx_init.lua

using this: ULib.ucl.addUser( ply:SteamID(), nil, nil, "donator" )

EDIT: also when trying this execute command: RunConsoleCommand( "ulx", "adduserid", "" .. ply:SteamID() .. "", "vip")
getting same thnig
« Last Edit: January 12, 2014, 01:26:44 PM by atomic-cruncher »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: attempt to index global 'ULib' (a nil value) help please
« Reply #6 on: January 12, 2014, 04:19:12 PM »
Errors are pretty obvious.
During startup, you have the Ulib command running outside of a function...or running before a player is defined in ply.
During run of the command, your not passing the command the right info.
Attach your file for review.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given