• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua How can i reduce this check?

  • Thread starter Thread starter Deleted member 141899
  • Start date Start date
D

Deleted member 141899

Guest
Hello everyone.

I have a script that have a big "if" with so many items to check.. i was looking for any other way to execute that check, tried with
Code:
local items = {items here}, for i = i, #items do -> if player:getItemCount(items[i])
, but doesn't works..

Someone have other way? thanks in advance..

Code:
function onStepIn(player, item, position, fromPosition)
    if item.actionid == 40086 then
        if player:getStorageValue(48100) >= 1 then
            //BIG CHECK HERE
            if player:getItemCount(2195) >= 1 or player:getItemCount(2206) >= 1 or player:getItemCount(2169) >= 1 or player:getItemCount(7457) >= 1 or player:getItemCount(8908) >= 1 or player:getItemCount(8905) >= 1 or player:getItemCount(9956) >= 1 or player:getItemCount(11301) >= 1 or player:getItemCount(11303) >= 1 or player:getItemCount(11374) >= 1 or player:getItemCount(12541) >= 1 or player:getItemCount(12607) >= 1 or player:getItemCount(12646) >= 1 or player:getItemCount(15410) >= 1 or player:getItemCount(15490) >= 1 or player:getItemCount(18404) >= 1 or player:getItemCount(18406) >= 1 or player:getItemCount(21691) >= 1 or player:getItemCount(23539) >= 1 or player:getItemCount(24261) >= 1 or player:getItemCount(24637) >= 1 or player:getItemCount(24742) >= 1 then
                player:sendTextMessage(19, "You can't enter the event with items that have speed attribute.")
                player:teleportTo(fromPosition)
                return false
            else
                player:teleportTo({x = 32261, y = 32213, z = 10})
                player:getPosition():sendMagicEffect(11)
            end
        else
            player:sendTextMessage(19, "You need to do something...")
            player:teleportTo(fromPosition)
        end
    end

    return true
end
 
LUA:
local items = {2195, 2206}
-- below is inside onStepIn
for slot = 1, 10 do
    local item = player:getSlotItem(slot)
    if item then
        if isInArray(items, item:getId()) then -- if you are using 1.3, use table.contains(array, value) instead of isInArray(array, value)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can't enter the event with items that have speed attribute.")
            player:teleportTo(fromPosition)
            return false
        end
    end
end
 
Back
Top