• 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 Monster onDeath give storage id to party

Schlangemann

New Member
Joined
May 1, 2017
Messages
7
Reaction score
1
Location
Space
TFS 1.4

Hi!

I am trying to make a boss give storage id to all party members who have damaged it when it dies.

I am using a variation of Slavi's code from this post Lua - onKill players on party sharing xp to get task counted (https://otland.net/threads/onkill-players-on-party-sharing-xp-to-get-task-counted.233557/) as it seemed to fit what i need.

I can kill the boss without party and it gives the storage ID to the player, so that works as intended.
But when the boss gets killed in a party it gives the storage ID twice to the player dealing the highest damage, but not to the other party members.

Been searching for a solution for this on this forum but cannot find one. if there already is a solution to this problem i would love a link to that forum page and if so i apologize in advance that i did not find it.

Any help is greatly appreciated!

In data/creaturescripts/creaturescripts.xml i have this code

XML:
    <event type="death" name="TheUndeadMage" script="theundeadmage.lua" />

in creaturescripts/scripts/theundeadmage.lua i have this code

Lua:
function onDeath(creature, target, player)

local bossStorage = 43100
local players
local party = player:getParty()
if party ~= nil then
    players = party:getMembers() -- all members of the party
    players[#players + 1] = party:getLeader() -- don't forget the leader
else
    players = { player } -- no party? then just the player
end

for _, member in ipairs(players) do
    player:setStorageValue(bossStorage, os.time() + 36000)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You slayed The Undead Mage and lifted the curse of the tomb.")
    end
end
 
Solution
B
Your looping through the players, but still just setting storageValue to "player" and not "member"
Lua:
for _, member in ipairs(players) do
    member:setStorageValue(bossStorage, os.time() + 36000)
    member:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You slayed The Undead Mage and lifted the curse of the tomb.")
    end
end

It's also probably best to check if the member is valid and alive before you start to set the storage value
Your looping through the players, but still just setting storageValue to "player" and not "member"
Lua:
for _, member in ipairs(players) do
    member:setStorageValue(bossStorage, os.time() + 36000)
    member:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You slayed The Undead Mage and lifted the curse of the tomb.")
    end
end

It's also probably best to check if the member is valid and alive before you start to set the storage value
 
Solution
Your looping through the players, but still just setting storageValue to "player" and not "member"
Lua:
for _, member in ipairs(players) do
    member:setStorageValue(bossStorage, os.time() + 36000)
    member:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You slayed The Undead Mage and lifted the curse of the tomb.")
    end
end

It's also probably best to check if the member is valid and alive before you start to set the storage value

Ah ofcourse! Thank you!
I get storage value for all party members now.

As it is now if anyone in the party dies or the party is disbanded only the last hitter of the boss gets the storage value if the boss is killed.
Which means that the players who died can enter the boss dungeon to try again without a timer. I can see how this could be an issue.
 
Back
Top