1

How I can check table for string.find?

My code:

WEAPON_TABLE = { -- I need check this weaponclass of sweps
    "swep_1",
    "swep_2",
    "swep_3"
}

if string.find(v:GetWeaponClass(), ???) then
    --
end

1 Answers1

2

Try this:

WEAPON_TABLE = {
    ["swep_1"]=true,
    ["swep_2"]=true,
    ["swep_3"]=true,
}

if WEAPON_TABLE[v:GetWeaponClass()] then
lhf
  • 70,581
  • 9
  • 108
  • 149
  • 1
    See also https://stackoverflow.com/questions/7925090/lua-find-a-key-from-a-value – lhf Feb 06 '21 at 00:55