• Print

Author Topic: ULib.ucl.userAllow trouble.  (Read 6639 times)

0 Members and 1 Guest are viewing this topic.

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
ULib.ucl.userAllow trouble.
« on: February 27, 2017, 08:16:16 pm »
I've been working on a script for the past few days that automatically assigns permissions to certain Steam IDs when the command is issued.
The only issue is that I'm getting some backtalk from ULib.ucl.userAllow

The error is as follows
Quote
[ERROR] lua/autorun/pttt_admin.lua:174: attempt to call field 'userAllow' (a nil value)
  1. unknown - lua/autorun/pttt_admin.lua:174
   2. unknown - lua/includes/modules/concommand.lua:54

And the relevant lines are
Code: Lua
  1.     if table.HasValue( rootadmin_id, ply:SteamID() ) then
  2.         local root = ply:SteamID()
  3.         ULib.ucl.userAllow( root, rootadmin_perms, false )
  4.     else
  5.         return false
  6.     end
  7.  
  8.     if table.HasValue( superadmin_id, ply:SteamID() ) then
  9.         local super = ply:SteamID()
  10.         ULib.ucl.userAllow( super, superadmin_perms, false )
  11.     else
  12.         return false
  13.     end

If you need more from the script then I can provide everything though I don't think the rest is relevant to the isssue. Thanks in advance.
« Last Edit: February 27, 2017, 09:05:07 pm by BlueNova »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULib.ucl.userAllow trouble.
« Reply #1 on: February 27, 2017, 09:11:28 pm »
This is just my guess at this (for me) late hour.
Are you sure this code is loading after ULib?
You place it in Autorun. It might be running too early.
If you're using ULib, to guarantee ULib is loading it's functions, I'd use ULib modules folder to initialize this (or a separate file to initialize your ULib specific code files, like we do for ULX "addons/ulx/lua/ulib/modules/ulx_init.lua"
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: ULib.ucl.userAllow trouble.
« Reply #2 on: February 27, 2017, 09:23:45 pm »
Perhaps it is the location of it.

I'll put it in the ulib modules directory and come back with results.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: ULib.ucl.userAllow trouble.
« Reply #3 on: February 27, 2017, 09:25:03 pm »
ULib modules is where it should go so that it loads after UCL and ULib initialize.

If you just put it in lua/autorun it might try and run/load before ULib and that would cause the errors you are seeing.

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: ULib.ucl.userAllow trouble.
« Reply #4 on: February 27, 2017, 09:53:32 pm »
I placed it in the ulib modules directory and the same error occurred.

Quote
[ERROR] addons/ulx/lua/ulib/modules/pttt_admin.lua:175: attempt to call field 'userAllow' (a nil value)
  1. unknown - addons/ulx/lua/ulib/modules/pttt_admin.lua:175
   2. unknown - lua/includes/modules/concommand.lua:54

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: ULib.ucl.userAllow trouble.
« Reply #5 on: February 28, 2017, 08:05:58 am »
The userAllow method is only available on the server- are you sure that your code is not being run client-side?
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: ULib.ucl.userAllow trouble.
« Reply #6 on: February 28, 2017, 12:22:52 pm »
The command is from a client. I suppose that's the issue now that you mention it Stickly.

Edit:

I wouldn't imagine it would work with RunConsoleCommand would it? Just a theory that came into my head.
« Last Edit: February 28, 2017, 12:29:52 pm by BlueNova »

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: ULib.ucl.userAllow trouble.
« Reply #7 on: February 28, 2017, 12:50:10 pm »
The command is from a client. I suppose that's the issue now that you mention it Stickly.

Edit:

I wouldn't imagine it would work with RunConsoleCommand would it? Just a theory that came into my head.
RunConsoleCommand would only run console commands, as the name would suggest, on the side it is executed on. You could use (AUTHENTICATED) net messages to run a console command on the server, you could just use userAllow with that instead.
bw81@ulysses-forums ~ % whoami
Homepage

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: ULib.ucl.userAllow trouble.
« Reply #8 on: February 28, 2017, 08:19:56 pm »
RunConsoleCommand would only run console commands, as the name would suggest, on the side it is executed on. You could use (AUTHENTICATED) net messages to run a console command on the server, you could just use userAllow with that instead.

I don't follow :P

Could ya explain for me please?

Edit:

So I did some tweaking and now I'm not getting any errors. Nothing returns at all.
« Last Edit: February 28, 2017, 10:26:13 pm by BlueNova »

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: ULib.ucl.userAllow trouble.
« Reply #9 on: March 01, 2017, 07:54:13 am »
If you tweaked some things and nothing returns and no errors, can you post what code you made?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: ULib.ucl.userAllow trouble.
« Reply #10 on: March 01, 2017, 12:53:55 pm »
Code: Lua
  1.                 if table.HasValue( rootadmin_id, ply:SteamID() ) then
  2.                         local root = ply:SteamID()
  3.                         userAllow( root, rootadmin_perms )
  4.                 elseif table.HasValue( superadmin_id, ply:SteamID() ) then
  5.                         local super = ply:SteamID()
  6.                         userAllow( super, superadmin_perms )
  7.                 end
  8.  

I edited userAllow to say just that and the ulx format was lacking so I fixed that. Now nothing returns. What I attempted to do was use user.lua as a reference for userAllow since I was a bit bored.

<I don't have the entire file with me currently. It's saved on my PC and currently don't have access to it.>
« Last Edit: March 03, 2017, 06:35:59 pm by BlueNova »

  • Print