• 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+ Boss Reward Fix

Solution
Tested.
data/creaturescripts/scripts/bossReward.lua:
Lua:
function onKill(creature, target)
    local monsterName = "Puppet" --boss name to give reward
    if target:getName() ~= monsterName then --check if killed monster(target) is the boss
        return true --if not, return true
    end
    
    for pid, _ in pairs(target:getDamageMap()) do --get damageMap from target killed
        local attackerPlayer = Player(pid) --get userData of each player that damaged the target
        if attackerPlayer then --if player exist
            attackerPlayer:addItem(26767) --give reward
        end
    end
    return true
end

data/creaturescripts/creaturescripts.xml:
XML:
<event type="kill" name="bossReward"...
getDamageMap
Already trying... and have no i idea for now how to setup this to work...
Code:
function onKill(creature, target)

local monster = "Puppet"
    if not monster then
        return true
    end

    for pid, _ in pairs(monster:getDamageMap()) do
        local attackPlayer = Player(pid)
            if attackPlayer then
                player:addItem(26767)
            end
        end
    end
 
Last edited:
Already trying... and have no i idea for now how to setup this to work...
Code:
function onKill(creature, target)

local monster = "Puppet"
    if not monster then
        return true
    end

    for pid, _ in pairs(monster:getDamageMap()) do
        local attackPlayer = Player(pid)
            if attackPlayer then
                player:addItem(26767)
            end
        end
    end
local attackPlayer = Player(pid)

You want to kill player or monster?
 
Tested.
data/creaturescripts/scripts/bossReward.lua:
Lua:
function onKill(creature, target)
    local monsterName = "Puppet" --boss name to give reward
    if target:getName() ~= monsterName then --check if killed monster(target) is the boss
        return true --if not, return true
    end
    
    for pid, _ in pairs(target:getDamageMap()) do --get damageMap from target killed
        local attackerPlayer = Player(pid) --get userData of each player that damaged the target
        if attackerPlayer then --if player exist
            attackerPlayer:addItem(26767) --give reward
        end
    end
    return true
end

data/creaturescripts/creaturescripts.xml:
XML:
<event type="kill" name="bossReward" script="bossReward.lua"/>

data/creaturescripts/scripts/login.lua:
Above return true, put:
Lua:
player:registerEvent("bossReward")

EDIT:
Commented code
 
Solution
Tested.
data/creaturescripts/scripts/bossReward.lua:
Lua:
function onKill(creature, target)
    local monsterName = "Puppet" --boss name to give reward
    if target:getName() ~= monsterName then --check if killed monster(target) is the boss
        return true --if not, return true
    end
   
    for pid, _ in pairs(target:getDamageMap()) do --get damageMap from target killed
        local attackerPlayer = Player(pid) --get userData of each player that damaged the target
        if attackerPlayer then --if player exist
            attackerPlayer:addItem(26767) --give reward
        end
    end
    return true
end

data/creaturescripts/creaturescripts.xml:
XML:
<event type="kill" name="bossReward" script="bossReward.lua"/>

data/creaturescripts/scripts/login.lua:
Above return true, put:
Lua:
player:registerEvent("bossReward")

EDIT:
Commented code
Already do it in this way
Lua:
function onKill(cid, target)
   local mob = Creature('Puppet')
   local damageMap = mob:getDamageMap()

   for id, damage in pairs(damageMap) do
     local creature = Creature(id)
     creature:addItem(26767)
   end
end
Anyway thanks for you time and ofc i will use aswell you script
 
Back
Top