Polarbear72
Member
This is my loot.lua script that ive been trying to get working for a independent loot channel. It doesn't actually show any loot in the channel and it also announces whenever any player joins the channel.
I just want it to show loot in this channel instead of server log and I want it to only show for the player not everyone in channel.
Any help is appreciated
I just want it to show loot in this channel instead of server log and I want it to only show for the player not everyone in channel.
Any help is appreciated
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<channels>
<channel id="2" name="Tutor" script="tutor.lua" />
<channel id="3" name="World Chat" public="1" script="worldchat.lua" />
<channel id="4" name="English Chat" public="1" script="englishchat.lua" />
<channel id="5" name="Advertising" public="1" script="advertising.lua" />
<channel id="6" name="Advertising-Rookgaard" public="1" script="advertising-rook.lua" />
<channel id="7" name="Help" public="1" script="help.lua" />
<channel id="8" name="Gamemaster" script="gamemaster.lua" />
<channel id="9" name="Loot Channel" public="0" script="looter.lua" />
</channels>
Lua:
local ec = EventCallback
ec.onDropLoot = function(self, corpse)
if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
return
end
local player = Player(corpse:getCorpseOwner())
local mType = self:getType()
if not player or player:getStamina() > 840 then
local monsterLoot = mType:getLoot()
for i = 1, #monsterLoot do
local item = corpse:createLootItem(monsterLoot[i])
if not item then
print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
end
end
if player then
local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
local party = player:getParty()
if party then
party:broadcastPartyLoot(text)
for _, member in ipairs(getPartyMembers(player)) do
doPlayerSendChannelMessage(member, player, text, TALKTYPE_CHANNEL_O, 9)
end
end
else
player:sendTextMessage(MESSAGE_INFO_DESCR, text)
sendChannelMessage(9, TALKTYPE_CHANNEL_O, text)
end
end
else
local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
local party = player:getParty()
if party then
party:broadcastPartyLoot(text)
else
sendChannelMessage(9, TALKTYPE_CHANNEL_O, text)
player:sendTextMessage(MESSAGE_INFO_DESCR, text)
end
end
end
ec:register()