Search code examples
luagarrys-mod

Chek table for string.find


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

Solution

  • Try this:

    WEAPON_TABLE = {
        ["swep_1"]=true,
        ["swep_2"]=true,
        ["swep_3"]=true,
    }
    
    if WEAPON_TABLE[v:GetWeaponClass()] then