如何在lua中的函数返回中返回多个值

时间:2015-01-14 04:10:49

标签: lua

我正在尝试将GetUserGroup返回到多个值但它只返回1我尝试使用for语句但是没有用,我不想做ply:GetUserGroup() == "owner"ply:GetUserGroup() == "superadmin"那个是解决这个问题的唯一方法,但它将是一个很长的路线,而我无法解决这个问题。

这是深色的身份代码:

DarkRP.createEntity("Money printer", {
    ent = "money_printer",
    model = "models/props_c17/consolebox01a.mdl",
    price = 1000,
    cmd = "buymoneyprinter",
    getMax = function(ply) 
    local limitRanks = {"odyssian", "tmod", "dmod", "dadmin", "admin", "superadmin", "co-owner", "owner"}
    return ply:GetUserGroup() == limitRanks and 6 or 3 
    end,
})

1 个答案:

答案 0 :(得分:3)

您需要将limitRanks转换为哈希表,并检查返回语句中是否存在该键:

local limitRanks = {odyssian = true, tmod = true, dmod = true, dadmin = true,
  admin = true, superadmin = true, ["co-owner"] = true, owner = true}
return limitRanks[ply:GetUserGroup()] and 6 or 3