-1

如果你现在正在阅读这篇文章,我希望你对 lua 和 Gmod 如何协同工作有所了解。我正在在 DarkRP Gmod 服务器上重新编码一个带有电线支持的褪色门插件。我在将有线支持限制为特定的 DarkRP 作业时遇到问题。为了让自己更轻松,我开始尝试将其限制在 TEAM_GANG 工作中。这是我更改的代码。

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

这删除了所有作业的访问权限,也没有授予对 TEAM_GANG 作业的访问权限。我不明白为什么这不起作用,我找不到另一种方法来做到这一点,所以我有点卡住了。

如果你想要整个代码,我把它粘贴到一个 pastebin 中。链接:https ://pastebin.com/UrkyK8e2

4

1 回答 1

0

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

我找到了另一种方法,它奏效了。

代码现在看起来像这样。

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
于 2017-07-11T15:50:05.593 回答