Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GMOD LUA:限制对作业的有线支持_Lua_Garrys Mod - Fatal编程技术网

GMOD LUA:限制对作业的有线支持

GMOD LUA:限制对作业的有线支持,lua,garrys-mod,Lua,Garrys Mod,如果您现在正在阅读本文,我希望您了解lua和Gmod是如何协同工作的。我正在用有线支持在DarkRP Gmod服务器上记录一个褪色门插件。我在将有线支持限制为特定的DarkRP作业时遇到问题。为了让自己轻松,我开始试着把它限制在团队工作中。这是我更改的代码位 local function customCheck(pl) return table.HasValue({TEAM_GANG}, pl:Team()) end local function dooEet(pl, Ent, stu

如果您现在正在阅读本文,我希望您了解lua和Gmod是如何协同工作的。我正在用有线支持在DarkRP Gmod服务器上记录一个褪色门插件。我在将有线支持限制为特定的DarkRP作业时遇到问题。为了让自己轻松,我开始试着把它限制在团队工作中。这是我更改的代码位

local function customCheck(pl)
    return table.HasValue({TEAM_GANG}, pl:Team())
end

local function dooEet(pl, Ent, stuff)
    if Ent.isFadingDoor then
        if Ent.fadeDeactivate then Ent:fadeDeactivate() end
        RemoveKeys(Ent)
    else
        Ent.isFadingDoor = true
        Ent.fadeActivate = fadeActivate
        Ent.fadeDeactivate = fadeDeactivate
        Ent.fadeToggleActive = fadeToggleActive
        Ent:CallOnRemove("Fading Doors", RemoveKeys)
        if WireLib and customCheck(pl) then
            doWireInputs(Ent)
            doWireOutputs(Ent)
            Ent.fadeTriggerInput = Ent.fadeTriggerInput or Ent.TriggerInput
            Ent.TriggerInput = TriggerInput
            if !Ent.IsWire then
                if !Ent.fadePreEntityCopy and Ent.PreEntityCopy then Ent.fadePreEntityCopy = Ent.PreEntityCopy end
                Ent.PreEntityCopy = PreEntityCopy
                if !Ent.fadePostEntityPaste and Ent.PreEntityCopy then Ent.fadePostEntityPaste = Ent.PostEntityPaste end
                Ent.PostEntityPaste = PostEntityPaste
            end
        end
    end
    Ent.fadeUpNum = numpad.OnUp(pl, stuff.key, "Fading Door onUp", Ent)
    Ent.fadeDownNum = numpad.OnDown(pl, stuff.key, "Fading Door onDown", Ent)
    Ent.fadeToggle = stuff.toggle
    Ent.fadeReversed = stuff.reversed
    Ent.fadeKey = stuff.key
    Ent.fadeCanDisableMotion = stuff.CanDisableMotion
    Ent.fadeDoorMaterial = stuff.DoorMaterial
    Ent.fadeDoorOpenSound = stuff.DoorOpenSound
    Ent.fadeDoorLoopSound = stuff.DoorLoopSound
    Ent.fadeDoorCloseSound = stuff.DoorCloseSound
    if stuff.reversed then Ent:fadeActivate() end
    duplicator.StoreEntityModifier(Ent, "Fading Door", stuff)
    return true
end
我只添加了customCheck功能

local function customCheck(pl)
    return table.HasValue({TEAM_GANG}, pl:Team())
end
并在这里为团队检查

if WireLib and customCheck(pl) then
这将从所有作业中删除访问权限,并且也没有授予对团队作业的访问权限。我不明白为什么这不起作用,我也找不到另一种方法,所以我有点被卡住了


如果你想要完整的代码,我会把它粘贴到一个粘贴箱中。链接:

------------------------------------更新---------------------------------------------------------

我找到了另一种方法,并且成功了

代码现在看起来像这样

local function dooEet(pl, Ent, stuff)
    if Ent.isFadingDoor then
        if Ent.fadeDeactivate then Ent:fadeDeactivate() end
        RemoveKeys(Ent)
    else
        Ent.isFadingDoor = true
        Ent.fadeActivate = fadeActivate
        Ent.fadeDeactivate = fadeDeactivate
        Ent.fadeToggleActive = fadeToggleActive
        Ent:CallOnRemove("Fading Doors", RemoveKeys)
        if WireLib then
            if (team.GetName(pl:Team()) == "Gangster") then
                doWireInputs(Ent)
                doWireOutputs(Ent)
                Ent.fadeTriggerInput = Ent.fadeTriggerInput or Ent.TriggerInput
                Ent.TriggerInput = TriggerInput
                if !Ent.IsWire then
                    if !Ent.fadePreEntityCopy and Ent.PreEntityCopy then Ent.fadePreEntityCopy = Ent.PreEntityCopy end
                    Ent.PreEntityCopy = PreEntityCopy
                    if !Ent.fadePostEntityPaste and Ent.PreEntityCopy then Ent.fadePostEntityPaste = Ent.PostEntityPaste end
                    Ent.PostEntityPaste = PostEntityPaste
                end
            end
        end
    end
    Ent.fadeUpNum = numpad.OnUp(pl, stuff.key, "Fading Door onUp", Ent)
    Ent.fadeDownNum = numpad.OnDown(pl, stuff.key, "Fading Door onDown", Ent)
    Ent.fadeToggle = stuff.toggle
    Ent.fadeReversed = stuff.reversed
    Ent.fadeKey = stuff.key
    Ent.fadeCanDisableMotion = stuff.CanDisableMotion
    Ent.fadeDoorMaterial = stuff.DoorMaterial
    Ent.fadeDoorOpenSound = stuff.DoorOpenSound
    Ent.fadeDoorLoopSound = stuff.DoorLoopSound
    Ent.fadeDoorCloseSound = stuff.DoorCloseSound
    if stuff.reversed then Ent:fadeActivate() end
    duplicator.StoreEntityModifier(Ent, "Fading Door", stuff)
    return true
end