我正在编写一个garrysmod服务器的脚本,我完全忘记了这一点,我以前记得,但现在我记不住了。
我正在使用这段代码,
if ent:IsVehicle() then
if ent:GetModel() ~= { "models/mafia2/shubert_taxi.mdl", "models/mafia2/parry_bus.mdl", "models/mafia2/smith_200_p_pha.mdl" } then
client:Freeze(true)
self.Owner:setAction("Chopping", time, function()
ent:Remove()
nut.item.spawn("carparts", self:GetPos() + Vector(math.Rand(1,20), math.Rand(1,20),20), nil, Angle(0, 0, 0 ))
client:Freeze(false)
self.Owner:notify("You've chopped a car.")
end)
end 最初它是if ent:GetModel() ~= "models/mafia2/shubert_taxi.mdl",工作得很好,但是我想限制3个独立的模型。有人知道怎么做吗?
发布于 2020-05-10 13:23:14
您可以使用table.hasValue函数:
if ent:IsVehicle() then
local models = { "models/mafia2/shubert_taxi.mdl", "models/mafia2/parry_bus.mdl", "models/mafia2/smith_200_p_pha.mdl" }
-- Notice the not keyword.
if not table.hasValue(models, ent:GetModel()) then
....https://stackoverflow.com/questions/61691242
复制相似问题