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

Lua BossReward TFS 1.3

Kuantikum

Member
Joined
Jul 3, 2015
Messages
219
Solutions
1
Reaction score
20
Hello :p:p:p


The script is working normally, but what happens is that it only gives the loot to those who kill the boss. Is it possible to get everyone who attacks the boss to receive the REWARD? 🤔🤔🤔


Lua:
local config = {
    ["[Boss] Curselich"] = {
        loot = {{302,100,1},{2157,20,10},{8900,5,1},{5958,10,1},{2471,12,1},{6132,18,1}},
        message = "Congratulations for defeating [Boss] Curselich, Your reward is now in your backpack",
        BagId = 9774
    },
    ["[Boss] Taintstrike"] = {
        loot = {{302,100,2},{2157,20,20},{8902,5,1},{11240,6,1},{9999,12,1},{6132,18,1}},
        message = "Congratulations for defeating [Boss] Taintstrike, Your reward is now in your backpack",
        BagId = 9774
    },
    ["[Boss] Terrorfreak"] = {
        loot = {{302,100,3},{2157,20,30},{8904,5,1},{11304,6,1},{2349,10,1},{6132,18,1}},
        message = "Congratulations for defeating [Boss] Terrorfreak, Your reward is now in your backpack",
        BagId = 9774
    },
    ["[Boss] Vamphag"] = {
        loot = {{302,100,4},{2157,20,40},{8918,5,1},{11302,3,1},{7760,7,1},{7761,6,1},{6574,10,1},{8303,8,1}},
        message = "Congratulations for defeating [Boss] Vamphag, Your reward is now in your backpack",
        BagId = 9774
    },
    ["Gazharagoth"] = {
        loot = {{302,100,5},{302,10,5},{2157,20,50},{8918,5,1},{8303,8,1},{7760,7,1},{7761,6,1},{6574,9,1},{11242,4,1},{3939,2,1},{11302,3,1}},
        message = "Congratulations for defeating Gazharagoth, Your reward is now in your backpack",
        BagId = 10518
    },
    ["Cartpis"] = {
        loot = {{11400,100,1},{302,10,5}},
        message = "Congratulations for defeating Cartpis, Your reward is now in your backpack",
        BagId = 1998
    },
    ["Latryus"] = {
        loot = {{11400,100,1},{302,10,5}},
        message = "Congratulations for defeating Latryus, Your reward is now in your backpack",
        BagId = 1998
    },
    ["Palwosis"] = {
        loot = {{11400,100,1},{302,10,5}},
        message = "Congratulations for defeating Palwosis, Your reward is now in your backpack",
        BagId = 1998
    },
    ["Yatris"] = {
        loot = {{11400,100,1},{302,10,5}},
        message = "Congratulations for defeating Yatris, Your reward is now in your backpack",
        BagId = 1998
    },
    ["Zargotex"] = {
        loot = {{11400,100,1},{302,10,5}},
        message = "Congratulations for defeating Zargotex, Your reward is now in your backpack",
        BagId = 1998
    },
    ["Aspdex"] = {
        loot = {{2157,50,50},{2157,50,50},{302,10,5},{611,0.,1},{603,1,1},{607,1,1}},
        message = "Congratulations for defeating Aspdex, Your reward is now in your backpack",
        BagId = 5801
    },
    ["Farfit"] = {
        loot = {{2157,50,50},{2157,50,50},{302,10,5},{619,1,1},{615,1,1},{623,1,1}},
        message = "Congratulations for defeating Farfit, Your reward is now in your backpack",
        BagId = 5801
    },
    ["Qatro"] = {
        loot = {{2157,50,50},{2157,50,50},{302,10,5},{631,1,1},{627,1,1},{635,1,1}},
        message = "Congratulations for defeating Qatro, Your reward is now in your backpack",
        BagId = 5801
    },
    ["The Many"] = {
        loot = {{2157,100,50},{302,100,5},{7450,1,1},{7455,1,1},{7420,1,1},{7367,1,1},{7387,1,1},{7429,1,1},{11400,1,1}},
        message = "Congratulations for defeating The Many, Your reward is now in your backpack",
        BagId = 5926
    },
    ["Zulazza the Corruptor"] = {
        loot = {{2157,50,50},{302,10,5},{7450,1,1},{7455,1,1},{7420,1,1},{7367,1,1},{7387,1,1},{7429,1,1},{11400,1,1}},
        message = "Congratulations for defeating Zulazza the Corruptor, Your reward is now in your backpack",
        BagId = 5926
    }
}
--[[
["NameOfMonster"] = {
  loot = {{itemid,chance,count},{itemid,chance,count}},
  message = "Message produced when you kill the boss",
  BagId = dont need explanation
  }
]]

function onKill(player, target)
    if player:isPlayer() and target:isMonster() then
        local monster = config[Creature(target):getName()]
        local bag = player:addItem(monster.BagId, 1)
       
        if monster then
            for i = 1,#monster.loot do
                if monster.loot[i][2] >= math.random(1,100) then
                    bag:addItem(monster.loot[i][1], monster.loot[i][3], INDEX_WHEREEVER, FLAG_NOLIMIT)
                end
            end
           
            player:sendTextMessage(22, monster.message)
        end
    end
    return true
end


I'm very grateful 😍😘🥰🦁
 
Never tested it in a multiplayer setting (yet) but using onDeath(...) and getting all players through the damagemap should allow you to reward everyone.
 
Lua:
for i, damage in pairs(target:getDamageMap()) do
    local p = Player(i)
    if p then
        --do something & don’t break the script
    end
end
 
Lua:
local config = {
    ["nightmare"] = {
        loot = {{302,100,1},{2157,20,10},{8900,5,1},{5958,10,1},{2471,12,1},{6132,18,1}},
        message = "Congratulations for defeating [Boss] Curselich, Your reward is now in your backpack",
        BagId = 9774
    },
    ["[Boss] Taintstrike"] = {
        loot = {{302,100,2},{2157,20,20},{8902,5,1},{11240,6,1},{9999,12,1},{6132,18,1}},
        message = "Congratulations for defeating [Boss] Taintstrike, Your reward is now in your backpack",
        BagId = 9774
    },
}
--[[
["NameOfMonster"] = {
  loot = {{itemid,chance,count},{itemid,chance,count}},
  message = "Message produced when you kill the boss",
  BagId = dont need explanation
  }
]]

function onKill(player, target)
    if player:isPlayer() and target:isMonster() then
        local monster = config[Creature(target):getName():lower()]
           local p = Player(pid)
        local bag = player:addItem(monster.BagId, 1)
        if monster then
            for i = 1,#monster.loot do
                if monster.loot[i][2] >= math.random(1,100) then
                    for pid, damage in pairs(target:getDamageMap()) do
                        bag:addItem(monster.loot[i][1], monster.loot[i][3], INDEX_WHEREEVER, FLAG_NOLIMIT)
                    end
                end
                player:sendTextMessage(22, monster.message)
            end
        end
    end
    return true
end
 
Last edited:
Lua:
local config = {
    ["Nightmare"] = {
        loot = {{302,100,1},{2157,20,10},{8900,5,1},{5958,10,1},{2471,12,1},{6132,18,1}},
        message = "Congratulations for defeating [Boss] Curselich, Your reward is now in your backpack",
        BagId = 9774
    },
    ["[Boss] Taintstrike"] = {
        loot = {{302,100,2},{2157,20,20},{8902,5,1},{11240,6,1},{9999,12,1},{6132,18,1}},
        message = "Congratulations for defeating [Boss] Taintstrike, Your reward is now in your backpack",
        BagId = 9774
    },
}
--[[
["NameOfMonster"] = {
  loot = {{itemid,chance,count},{itemid,chance,count}},
  message = "Message produced when you kill the boss",
  BagId = dont need explanation
  }
]]

function onKill(player, target)
    if target:isMonster() then
        local monster = config[Creature(target):getName()]
        local bag = player:addItem(monster.BagId, 1)
        local damageMap = target:getDamageMap()
       
        if damageMap[target:getId()] then
            if monster then
                for i = 1,#monster.loot do
                    if monster.loot[i][2] >= math.random(1,100) then
                        bag:addItem(monster.loot[i][1], monster.loot[i][3], INDEX_WHEREEVER, FLAG_NOLIMIT)
                        player:sendTextMessage(22, monster.message)
                    end
                end
            end
        end
    end
    return true
end
Ty mate ill try it when i get home
 
Back
Top