• 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!

TFS 1.X+ RevScriptSys hasLoot

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,530
Solutions
1
Reaction score
83
Location
Portugal
Hey there <3

How can I check if an item inside a table is inside another table?

like:


Lua:
        for i = 1, #loot do
            if loot[i].itemId has rareLoot then
                target:getPosition():sendMagicEffect(CONST_ME_TUTORIALARROW)
                target:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE)
            end
        end

full script:

Lua:
-- test value = 2148
local rareLoot = {2148, 12792, 12794, 12788, 12804, 12805, 12806, 12807, 12808, 12809, 12800, 12801}
local monsterKill = CreatureEvent("monsterKill")

function monsterKill.onKill(creature, target)
    if not target:isMonster() then
        return true
    end

    local player = Player(creature:getGuid())
    local loot = MonsterType(target:getName()):getLoot()

    if target:isMonster() then
        for i = 1, #loot do
            if loot[i].itemId has rareLoot then
                target:getPosition():sendMagicEffect(CONST_ME_TUTORIALARROW)
                target:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE)
            end
        end
    end
   
return true
end

monsterKill:type("kill")
monsterKill:register()

---------------------------------------------------------------------------------------

local monsterKillLogin = CreatureEvent("monsterKillLogin")

function monsterKillLogin.onLogin(player)
    player:registerEvent("monsterKillLogin")
    player:registerEvent("monsterKill")
    return true
end

monsterKillLogin:type("login")
monsterKillLogin:register()
 
Top