• Print

Author Topic: ULX v1.* compatible authentication  (Read 11951 times)

0 Members and 1 Guest are viewing this topic.

Paintcan

  • Guest
ULX v1.* compatible authentication
« on: August 22, 2006, 06:42:16 pm »
This script should make ULX v1.* compatible scripts compatible with ULib! Now you can get the benefit of the new security and features of ULib with ULX v1 backwards compatibility :D

To use this, just put the code in a file in the lua/init folder (I named mine ulx1compat.lua). The file can be named anything, as long as it has a .lua extension.

Here's the code:
Code: Lua
  1. --[[
  2. ULib->ULX v1.* compatibility script
  3. This script should make ULib compatible with any scripts that relied on the ULX v1.* authentication method!
  4. ]]
  5.  
  6. assert( _file.Exists( "lua/ULib/init.lua" ), "ULX needs ULib to run!" )
  7. _OpenScript( "ULib/init.lua" )
  8. assert( ULib.ULIB_VERSION >= 1, "ULX requires ULib version 1 or higher to run!" )
  9.  
  10. gUsers = {}
  11. local ucl = ULib.mainUcl -- change this if you're using a different UCL
  12.  
  13. function hasAccess( userid, access )
  14.         return ucl:query( userid, access )
  15. end
  16.  
  17. function hasAccessSteamid( steamid, access )
  18.         local player
  19.         for player = 1, _MaxPlayers() do
  20.                 if _PlayerInfo( userid, "networkid" ) == steamid then
  21.                         break
  22.                 end
  23.         end
  24.        
  25.         if not player then return false end
  26.         return ucl:query( player, access )
  27. end
  28.  
  29. function getAccess( userid )
  30.         if ucl.authed[ userid ] then
  31.                 return ucl.authed[ userid ].access_flags
  32.         end
  33.         return nil
  34. end
  35.  
  36. local function updateUsers()
  37.         gUsers = {}
  38.         for k, v in pairs( ucl.authed ) do
  39.                 gUsers[ v.steamid ] = v.access_flags
  40.         end
  41. end
  42. AddTimer( 29, 0, updateUsers )
  43.  

Have fun folks!

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX v1.* compatible authentication
« Reply #1 on: August 27, 2006, 05:30:50 pm »
Thanks!
Bah!
If you'd posted this as a registered user, I would have given compliment points!
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print