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
LUA:在if-not-then语句中使用多个变量?_Lua_Garrys Mod - Fatal编程技术网

LUA:在if-not-then语句中使用多个变量?

LUA:在if-not-then语句中使用多个变量?,lua,garrys-mod,Lua,Garrys Mod,我正在为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)

我正在为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 
最初它是
如果ent:GetModel()~=“models/mafia2/shubert_taxi.mdl”
并且运行良好,但是我想限制3个单独的模型。有人知道怎么做吗?

您可以使用以下功能:

如果ent:IsVehicle()则
本地模型={“models/mafia2/shubert_taxi.mdl”、“models/mafia2/parry_bus.mdl”、“models/mafia2/smith_200_p_pha.mdl”}
--注意not关键字。
如果不是table.hasValue(models,ent:GetModel()),那么
....