Ulysses Stuff > General Chat & Help and Support

ULib.hasAccess()

(1/2) > >>

fackelkind:
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?

Megiddo:
You use this callback.

fackelkind:
Hey Megiddo, thanks for reply. So it should be something like this?


--- Code: ---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
--- End code ---

Note that I will support ULX1 and 2
this is the addon so far:

--- Code: ---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
--- End code ---

fackelkind:
Ahh crap no!
I think i see what you mean. Well need to rewrite the script then.
Lemme try this.

fackelkind:
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?

Navigation

[0] Message Index

[#] Next page

Go to full version