• Print

Author Topic: Using ULib as an all around admin system  (Read 34756 times)

0 Members and 1 Guest are viewing this topic.

Offline aschmack

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
Using ULib as an all around admin system
« on: July 25, 2006, 11:01:21 pm »
Hi, I'm a relatively new Lua coder; generally I do well but this problem has me stumped.

I downloaded the latest ULib and ULX last night from ulyssesmod.net and installed it. I added my admins, with me having A-Z access. On my server, whenever someone says something, I get this Lua error: "[lua] Error calling
'DoEventHook' : 'Line 564: attempt to index field 'authed' (a nil value)'" Sometimes the line numbers vary, but they are all within 564-599, in file ucl.lua(which are functions getAccess and Query)

I tried to add Ulib admin to eSWEP menu by using this code, but it doesn't work at all.

Code: Lua
  1. eSWEP.ucl = ULib.mainUcl
  2. function eSWEP.send(userid)
  3.     if _PlayerInfo(userid, "connected") then
  4.         eSWEP.sendclient(userid)
  5.         if eSWEP.ucl:query(userid, ACCESS_CHAT) then
  6.             eSWEP.sendadmin(userid)
  7.         end
  8.     end
  9. end


If I change ACCESS_CHAT to ACCESS_ALL, then everyone gets the eSWEP admin menu, so at least I know the query is formatted correctly. No errors surface while loading the eSWEP menu or ucl.lua.

Any help would be appreciated greatly.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Using ULib as an all around admin system
« Reply #1 on: July 26, 2006, 07:39:52 am »
Ok, I'm timid to even try to help with this one, as my Lua ability is, well, not that great, but I find I often learn even if I didn't fully help.

The issues you state seem totally separate, at least at first.
Elaborate if not.

1) When anyone says anything on your server, you get the 'DoEventHook' error... yes?
 Does this error happen when you don't have your ESWEP code attempts loaded?
 I'm _guessing_ eventPlayerSay in ulib/say.lua is having issues, not sure where yet though.
Mind pasting the users you have in the bottom of Ulib/users.ini?

2) Once 1 gets fixed, 2 may fall in line.

Does the ESWEP code include any eventplayersay hooks?

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline aschmack

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
Re: Using ULib as an all around admin system
« Reply #2 on: July 26, 2006, 12:19:05 pm »
I commented out the only eventPlayerSay hook in the eSWEP menu, but the error persists.

Here's an image of the errors:
http://img54.imageshack.us/img54/443/errorsnt5.jpg

Here's a mirror of the image, incase you can't get to it like me:
http://i109.photobucket.com/albums/n64/blech568/Errors.jpg

I figured that the issues were similar because the error is occuring in the function that I'm trying to use.
« Last Edit: July 26, 2006, 12:53:23 pm by aschmack »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Using ULib as an all around admin system
« Reply #3 on: July 26, 2006, 12:53:12 pm »
I posted a bug in ULX bugs about the console say, rcon say, and ulx rcon say not working.
Though, it might be related and just not known fully yet.

I'm not sure whats going on with your challenge, as I'm not sure I'm getting any errors when anyone says anything.
I say not sure because yesterday evening I ran my server for a few hours, and I didn't see errors, but this morning in the 5 minutes I had before work to check the computer I did see a hookevent error, but it wasn't constantly after anyone said anything.

Whats the command line options you're using to turn on logging, and display the extra time/date information to the console? I'll try adding it to mine when I get home in about (~3?) hours from now and see if my info is filling in differently.


"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline aschmack

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
Re: Using ULib as an all around admin system
« Reply #4 on: July 26, 2006, 12:54:15 pm »
put +log on in the command line

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Using ULib as an all around admin system
« Reply #5 on: July 26, 2006, 04:09:13 pm »
I can't replicate your error. Speaking works fine for me.
However!!
Not sure this would help you, but I found this while searching for the error that occurs when trying to use console say, rcon say, or ulx rcon say...

Code: [Select]
lua/init/eventhook.lua

-- Developing? Want to see what events are being called?
-- in the HL2 console:
--
-- lua ShowEvents = true;

Perhaps you could use it to assist.
Prepare to have a console full of extraneous info. Doesn't get logged.

Do you have your users.ini set correctly?
As you stated, you got very similar error when you joined, not just chatted. Might be an 'access' comparison problem.
Copying them straight from ulx 1.x won't work, as you may already know, but when adjusting them the first time, I left out an important part. Here's me in my users.ini

"STEAM_0:1:6016299" "" "abcdefghijklmnopqrstuvwxyz" "c" //JamminR
                              /\--- Don't miss that pw spot     /\-- don't forget that 'type'

I originally didn't put in the password column (can be left blank with double quotes ""), but did add the type.

The only other thing I can think of is that you have another conflicting script. Ulib/ULX tries to accomodate, but I'm sure it may not always. Running any other? Prop protect/anti-spam? Anything?




"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline aschmack

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
Re: Using ULib as an all around admin system
« Reply #6 on: July 26, 2006, 10:09:12 pm »
I took out all of the scripts from the init folder and re-added them one by one. Turns out that xstack and vmfloader were conflicting with ULib.

Also, I force resent the Admin menu with the lua command and it worked. I think that it is being called too soon and the user hadn't been probed yet, so they didn't have access. So I added a timer to the function and now it works beautifully. On to the next mod to add admin support to.


Thanks for the help man


UPDATE: Finished with updating all of my mods, if anyone would like to see what I did with the following mods, feel free to PM me:

PropProtector
eSWEP Menu
Entity Command Suite
« Last Edit: July 26, 2006, 11:23:28 pm by aschmack »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Using ULib as an all around admin system
« Reply #7 on: July 27, 2006, 04:52:57 am »
If you could find the time to write a "how to convert for Ulib" for any of the more popular scripts, it would be greatly appreciated.
 Post them in Ulib releases section. (PropProtect would be wonderful!!)
 I'm not sure of the best way to present them. I wouldn't recommend just changing the script and then hosting it somewhere. That wouldn't allow for manual updates later, or see-and-learn for the code writers.
Perhaps post the original function(s), then your function changes (before and after).
 I'd also recommend putting a link to the original FP release (or whever it might be hosted) at the top with a disclaimer stating your non-affiliation with the original (unless of course you are affiliated. (You are an up and coming Ulib/ULX/lua developer, right :D :D )
  All of us Ulib devs would appreciate any contributions you make.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline aschmack

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
Re: Using ULib as an all around admin system
« Reply #8 on: July 27, 2006, 04:45:21 pm »
Before I release it, I want to work out the kinks. I was wondering if you could give me a hand with that too.

Here is what I have so far, but it only works sometimes due to an unkown factor:

Code: Lua
  1. needsmenu = {}
  2. for userid = 1, _MaxPlayers() do
  3.         needsmenu[ userid ] = true
  4. --      ULib.tsay(0,"needsmenu table is set.")
  5. end
  6.  
  7. function setneeds(userid)
  8.         if not needsmenu[userid] then
  9. --              ULib.tsay(0,_PlayerInfo(userid,"name") .. " already has the menu.")
  10.                 return
  11.         end -- If he already got the menu, he doesnt need it again
  12. --              ULib.tsay(0,_PlayerInfo(userid,"name") .. " needs the menu.")
  13.         needsmenu[userid] = true
  14.         giveneeds(userid)
  15.  
  16. end
  17.  
  18. function giveneeds(userid)
  19.         if _PlayerInfo(userid, "connected") then
  20. --              ULib.tsay(0,_PlayerInfo(userid,"name") .. " is being sent the client menu")
  21.                 eSWEP.sendclient(userid)
  22.                 if ULib.mainUcl:query(userid, ACCESS_MENU) then
  23. --                      ULib.tsay(0,_PlayerInfo(userid,"name") .. " has access and is being sent the menu.")
  24.                         eSWEP.sendadmin(userid)
  25.                         needsmenu[userid] = false
  26.                 else
  27. --                      ULib.tsay(0,_PlayerInfo(userid,"name") .. " doesn't have access and isn't getting the menu")
  28.                         needsmenu[userid] = false
  29.                 end    
  30.         end
  31. end
  32.  
  33. function nomoreneeds(name,userid)
  34.         if not _PlayerInfo(userid,"connected") then
  35. --              ULib.tsay(0,name .. " has disconnected, resetting the table for that userid"
  36.                 needsmenu[userid] = true
  37.         end
  38. end
  39. HookEvent("eventPlayerSpawn", setneeds)
  40. HookEvent("eventPlayerDisconnect", nomoreneeds)

A bit more code than before lol.
« Last Edit: July 27, 2006, 04:47:39 pm by aschmack »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Using ULib as an all around admin system
« Reply #9 on: July 27, 2006, 06:20:08 pm »
Call me lazy, but do you mind explaining the symptoms? :P
Even if they're vague, it would be more explanatory than "it only works sometimes", and wouldn't require me to run it several times. (My laziness kicking in here)

Does it not always send on spawn?
Does it send first time every time, but not on reconnect?
Whats it doing or not doing, or only doing/not doing every other something? :)

I'll be looking at the various parts. If I see anything blatantly sticking out, I'll post.

Oh, though I'm helping Megiddo during his pc fast, I didn't assist in developing Ulib, and am reasonably new to Lua. I do have experience with various languages, and pick up pretty fast.
 In other words, I'm not guaranteeing miracles but enjoy doing what I can to help at the same time learning myself. :D

Golden-Death, you've been quiet!! Where are you? You have more lua experience than I do.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline aschmack

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
Re: Using ULib as an all around admin system
« Reply #10 on: July 27, 2006, 07:39:40 pm »
Well, I was able to get myself the weapons by doing a "lua giveneeds(3)", so nothing is apparently wrong with that function. I think that either setNeeds isn't working or the tables aren't resetting properly.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Using ULib as an all around admin system
« Reply #11 on: July 27, 2006, 07:41:00 pm »

Try adding 'else' to setneeds?
Code: [Select]
function setneeds(userid)
if not needsmenu[userid] then
-- ULib.tsay(0,_PlayerInfo(userid,"name") .. " already has the menu.")
return
else  -- If he already got the menu, he doesnt need it again
-- ULib.tsay(0,_PlayerInfo(userid,"name") .. " needs the menu.")
needsmenu[userid] = true
giveneeds(userid)
end
« Last Edit: July 27, 2006, 07:50:35 pm by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Using ULib as an all around admin system
« Reply #12 on: July 27, 2006, 08:02:26 pm »
Might also add a return to nomoreneeds.
I've had various issues with mixing multiple scripts (as you too have experienced), and feel that if several hook the same function, if return isn't used, that it messes up others up someway.

This is a feeling I have, and don't have hard fact
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline aschmack

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
Re: Using ULib as an all around admin system
« Reply #13 on: July 27, 2006, 08:17:30 pm »
That may have sped up the script a little bit, but I found that it is the tables not being reset correctly(I tried rejoining, and it said that I already had the menu) So I took out the "if not connected" bit, since it would just be called on disconnects anyways, and the table gets reset. But, on rejoin I dont have access yet when it does the send so it doesnt work. Ideas?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Using ULib as an all around admin system
« Reply #14 on: July 27, 2006, 08:31:21 pm »
According to the ucl.lua file, the function to query is ULib.ucl:query(userid, access)

Your code has Ulib.mainUcl:query

(yours has a 'main' in it)

You may have that function already remapped and just not in that code sample.
Or my understanding of lua objects is way off. :)
Also, make sure Ulib is loading first. See the readme.txt file for the assert commands to add to top of your code.
Other than that, no other ideas at this time.
I'm working on a small project of my own right now, so will check back in a few. Let me know how it goes.

Edit: Removed two extraneous posts for 'neatness' sake
« Last Edit: July 27, 2006, 08:33:48 pm by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print