Author Topic: how to get an array[playerid] = access ?  (Read 5641 times)

0 Members and 2 Guests are viewing this topic.

Andbusy

  • Guest
how to get an array[playerid] = access ?
« on: October 09, 2006, 01:31:16 PM »
hi all

how can i get an array like the old "gUsers"  ???

gUsers[playerid]=access

cant finde something like this in the new ULib
need it at an AdminImportULX() for some other lua

cant convert something like
...
if (gUsers) then
for k,v in gUsers do
...

n8

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: how to get an array[playerid] = access ?
« Reply #1 on: October 09, 2006, 02:17:51 PM »
ULib has a compatibility layer, so just use "gUsers" (a global variable), like you would in ULX v1.1. You can also use hasAccess and hasAccessSteamid.
Experiencing God's grace one day at a time.

Andbusy

  • Guest
Re: how to get an array[playerid] = access ?
« Reply #2 on: October 10, 2006, 04:37:42 AM »
hi

hasAccess and hasAccessSteamid i can only us if player is online if i understand it correct

i need the array for offline and online admins ;)

if i use something like

if (gUsers) then
...
end

it will go in the if only if there are admins in the users.ini ?
and if it dosent go in the if why if i have admins in the users.ini ?
i havend find a way that it gos in all time false this variable :/
if this is only online admins i must make a timer all minut or something like this to import admins if they are onine -.-

n8

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: how to get an array[playerid] = access ?
« Reply #3 on: October 10, 2006, 09:05:04 AM »
In ULX v1.1, gUsers would contain all users online or off. In ULib, gUsers only contains users who have logged in on this map change (since you can add users by other things than steamid).
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: how to get an array[playerid] = access ?
« Reply #4 on: October 10, 2006, 06:33:49 PM »
Meg, that is what he is asking. What variable stores _all_ admins, logged on or not.

Andbusy...
see ucl_public.lua ... where I found this comment and variable.

Quote from: Megiddo in ucl_public.lua
--[[
   Variable: mainUcl
   
   This holds the default user access list, from the file "lua/ULib/users.ini"
   
   Revisions:
   
      v1 - Changed from mainUcl to ULib.mainUcl
]]
ULib.mainUcl = ULib.ucl:newFromFile( ULib.DEFAULT_UCL_FILE )

I believe the answer you're looking for is ULb.mainUcl
However, you'll need to use ULib functions to query individual members from the table.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: how to get an array[playerid] = access ?
« Reply #5 on: October 10, 2006, 07:01:18 PM »
He'd be better off using gUsers... the ucl contains all sorts of other things besides steamids (ips, clantags, etc)
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: how to get an array[playerid] = access ?
« Reply #6 on: October 10, 2006, 08:11:43 PM »
True, but he's wanting offline players too.
He could use ULib.isInTable to check whatever he's searching for.
I've not really looked at the format of the table to know how its all stored.

Andbusy, I just thought about it....why are you wanting offline too?
It can be done, it just makes it more difficult, messy, like Megiddo said :)



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

Andbusy

  • Guest
Re: how to get an array[playerid] = access ?
« Reply #7 on: October 10, 2006, 10:28:47 PM »
hi

@Megiddo she ;)

ULib.mainUcl sores some more stuff making an funktion to geht the array (= ...

ähm i want offline user too cause of removing admin righs (only spezial flags) or add or edit adinrights online (so u can look what admins has which rights, not only if they are online)
and some other lua's need this variable because they load ther admins only on init and i dont want change code at 20 or more places if there is an existing ULX import admin funktion that dos work only with old ulx and nor with new ulib ;)

i've found a way to get the variable, ill post it later @17pm if i remember...  now 7am and i have to work =( ^^

n8

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: how to get an array[playerid] = access ?
« Reply #8 on: October 11, 2006, 03:53:22 PM »
ACK!  :-[  ::)
 How presumptuous of us. Megiddo and I just presumed you were he.
Our apologies. It seems rare we find coders of the feminine persuasion among our ranks very often.
(Shame too. What few I've worked with in my career are/have been top notch)
Good luck with you're project.

If we can be of further assistance, please ask.  :)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: how to get an array[playerid] = access ?
« Reply #9 on: October 11, 2006, 08:03:19 PM »
It seems rare we find coders of the feminine persuasion among our ranks very often.

That same presumptous thought crossd my very philosophical mind as well. (In keeping with the fancy language).

But anyyway, Good luck with that, nate (assuming thats your name)!


Andbusy

  • Guest
Re: how to get an array[playerid] = access ?
« Reply #10 on: October 16, 2006, 08:45:34 AM »
moin moin

Code: [Select]

function ecsulx.teams.importUlxUser (loop)
        local count = 0

        if _file.Exists ("lua/ULib/init.lua") then -- Import from ULib
                if ULib ~= nil then
                        splitArgs = ULib.splitArgs
                        for steamid in ULib.mainUcl["steamids"] do
                                if (ecsulx.teams.config.members[steamid] == nil) then
                                        ecsulx.teams.config.members[steamid]  = ULib.mainUcl["steamids"][steamid]["access_flags"]
                                        count = count + 1
                                end
                        end
                elseif loop == nil then
                        --_Msg ("xxx-ecsulx [ULib] Initiating ...\n")
                        _OpenScript ("lua/ULib/init.lua")
                        --_Msg ("xxx-ecsulx [ULib] ... done\n")
                        count = ecsulx.teams.importUlxUser (true)
                end
        elseif _file.Exists ("lua/init/ulx_init.lua") then -- Import from ULX
                if gUsers ~= nil then
                        for k, v in gUsers do
                                -- temp = string.upper (string.gsub (k, " ", ""))
                                temp = string.upper (k)
                                if (ecsulx.teams.config.members[temp] == nil) then
                                        ecsulx.teams.config.members[temp] = v
                                        count = count + 1
                                end
                        end
                elseif loop == nil then
                        --_Msg ("xxx-ecsulx [ULX] Initiating ...\n")
                        _OpenScript ("lua/init/ulx_init.lua")
                        --_Msg ("xxx-ecsulx [ULX] ... done\n")
                        count = ecsulx.teams.importUlxUser (true)
                end
        else
                _Msg ("//  ULX -> ECS user import   // - ecsulx Can not find ULib / ULX.\n")
        end
        return count
end

thats the funktion i use now. the name says it (to import users to ECS)

i call it in the orginal funktion like

Code: [Select]
_Msg ("//  ULX -> ECS user import   // - ".. ecsulx.teams.importUlxUser() .. " user imported\n");

now all ULX admins whis the flack (in ECS config) are Admins in ECS   =)

have fun with it ;)

n8

Offline fackelkind

  • Newbie
  • *
  • Posts: 24
  • Karma: 4
Re: how to get an array[playerid] = access ?
« Reply #11 on: October 16, 2006, 10:41:46 AM »
moin moin

Code: [Select]

function ecsulx.teams.importUlxUser (loop)
        local count = 0

        if _file.Exists ("lua/ULib/init.lua") then -- Import from ULib
                if ULib ~= nil then
                        splitArgs = ULib.splitArgs
                        for steamid in ULib.mainUcl["steamids"] do
                                if (ecsulx.teams.config.members[steamid] == nil) then
                                        ecsulx.teams.config.members[steamid]  = ULib.mainUcl["steamids"][steamid]["access_flags"]
                                        count = count + 1
                                end
                        end
                elseif loop == nil then
                        --_Msg ("xxx-ecsulx [ULib] Initiating ...\n")
                        _OpenScript ("lua/ULib/init.lua")
                        --_Msg ("xxx-ecsulx [ULib] ... done\n")
                        count = ecsulx.teams.importUlxUser (true)
                end
        elseif _file.Exists ("lua/init/ulx_init.lua") then -- Import from ULX
                if gUsers ~= nil then
                        for k, v in gUsers do
                                -- temp = string.upper (string.gsub (k, " ", ""))
                                temp = string.upper (k)
                                if (ecsulx.teams.config.members[temp] == nil) then
                                        ecsulx.teams.config.members[temp] = v
                                        count = count + 1
                                end
                        end
                elseif loop == nil then
                        --_Msg ("xxx-ecsulx [ULX] Initiating ...\n")
                        _OpenScript ("lua/init/ulx_init.lua")
                        --_Msg ("xxx-ecsulx [ULX] ... done\n")
                        count = ecsulx.teams.importUlxUser (true)
                end
        else
                _Msg ("//  ULX -> ECS user import   // - ecsulx Can not find ULib / ULX.\n")
        end
        return count
end

thats the funktion i use now. the name says it (to import users to ECS)

i call it in the orginal funktion like

Code: [Select]
_Msg ("//  ULX -> ECS user import   // - ".. ecsulx.teams.importUlxUser() .. " user imported\n");

now all ULX admins whis the flack (in ECS config) are Admins in ECS   =)

have fun with it ;)

n8

This function looks very familiar to me :D

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: how to get an array[playerid] = access ?
« Reply #12 on: October 16, 2006, 11:29:36 PM »
....funktion.....


....funktion....

Thats funky.


Hatred

  • Guest
Re: how to get an array[playerid] = access ?
« Reply #13 on: October 27, 2006, 08:44:36 PM »
Can you explain how you put this exactly into ecs, please.