如果您现在正在阅读此内容,我希望您了解一下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
答案 0 :(得分:0)
----------------------------------------------- ---------- UPDATE --------------------------------------- ------------------
我找到了另一种方法,它起作用了。
现在代码看起来像这样。
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