Ulysses

Ulysses Stuff => General Chat & Help and Support => Topic started by: fackelkind on October 20, 2006, 10:02:01 AM

Title: ULib.hasAccess()
Post by: fackelkind on October 20, 2006, 10:02:01 AM
Okay, I have the following problem and don't know to fix it.
For my new TeamSuite I added an addon for ULib /ULX Supoort.
This addon adds a hook to initialspawn.
It seems like ULib initiates a player with a hook on initialspawn too,
however my addon is hooked first and that for the function hasAccess (userid, flag, true) will always return false.

So the question: How can I initiate a player to ulib manualy?
Title: Re: ULib.hasAccess()
Post by: Megiddo on October 20, 2006, 10:30:52 AM
You use this callback (http://ulyssesmod.net/docs/files/ucl_public-lua.html#obj:addAccessCallback).
Title: Re: ULib.hasAccess()
Post by: fackelkind on October 20, 2006, 10:43:08 AM
Hey Megiddo, thanks for reply. So it should be something like this?

Code: [Select]
if not ULib and not hasAccess then
                if _file.Exists ("lua/ULib/init.lua") then
                        fkk.teams:debug ("[Addon] ULib/ULX: Initiating ULib")
                        _OpenScript ("lua/ULib/init.lua")
                        ULIb.addAccessCallback ("hasAccess")
                elseif _file.Exists ("lua/init/ulx_init.lua") then
                        fkk.teams:debug ("[Addon] ULib/ULX: Initiating ULX")
                        _OpenScript ("lua/init/ulx_init.lua")
                else
                        fkk.teams:debug ("[Addon] ULib/ULX: cannot initiate script. script not found.")
                end
        end

Note that I will support ULX1 and 2
this is the addon so far:
Code: [Select]
if true then -- Addon enabled
        if not ULib and not hasAccess then
                if _file.Exists ("lua/ULib/init.lua") then
                        fkk.teams:debug ("[Addon] ULib/ULX: Initiating ULib")
                        _OpenScript ("lua/ULib/init.lua")
                elseif _file.Exists ("lua/init/ulx_init.lua") then
                        fkk.teams:debug ("[Addon] ULib/ULX: Initiating ULX")
                        _OpenScript ("lua/init/ulx_init.lua")
                else
                        fkk.teams:debug ("[Addon] ULib/ULX: cannot initiate script. script not found.")
                end
        end

        fkk.teams.addon["flag"] = {
                default         = "",
                type            = "teamchange",
                func            = function (iUserid)
                        local playersteam = fkk.teams:getPlayersTeam (iUserid)
                        if not hasAccess then
                                return false
                        end
                        if playersteam ~= false then -- is a team set for this player?
                                return false
                        end
                        for team, _ in fkk.teams.cfg.teams do
                                if is_string (fkk.teams.cfg.teams[team].flag) and not fkk.lib.empty (fkk.teams.cfg.teams[team].flag) then
                                        if _PlayerInfo (iUserid, "team") ~= team and hasAccess (iUserid, fkk.teams.cfg.teams[team].flag, true) then
                                                _PlayerChangeTeam (iUserid, team)
                                                fkk.teams:debug ("[Addon] ULib/ULX: moved \"" .. _PlayerInfo (iUserid, "name") .. "\" to \"" .. fkk.teams:getTeamName (team) .. "\".")
                                                return true
                                        end
                                end
                        end
                        fkk.teams:debug ("[Addon] ULib/ULX: \"" .. _PlayerInfo (iUserid, "name") .. "\" has no valid teamflag.")
                        return false
                end
        }
        if hasAccess then
                fkk.teams.isAdmin = function (userid)
                        if hasAccess (userid, "t", true) then
                                return true
                        end
                        userid = fkk.teams:getPlayersId (userid)
                        return fkk.lib.table.in_table (userid, fkk.teams.config.admins)
                end
        end
end
Title: Re: ULib.hasAccess()
Post by: fackelkind on October 20, 2006, 10:47:06 AM
Ahh crap no!
I think i see what you mean. Well need to rewrite the script then.
Lemme try this.
Title: Re: ULib.hasAccess()
Post by: fackelkind on October 20, 2006, 10:54:27 AM
Okay, because of my function returns a value, I can not take this way (to add it as a callback)
Is there another way I just can call ULib.initiatePlayer (userid) or something?
Title: Re: ULib.hasAccess()
Post by: Megiddo on October 20, 2006, 01:42:37 PM
Yes... you can call ucl_obj:probe( userid ), but it will not work if they need a password, and I do not recommend it.
Title: Re: ULib.hasAccess()
Post by: fackelkind on October 20, 2006, 02:06:41 PM
Thank you man.
I will just use that callback thing, it wont be nice then, but it'll work :D

So far