Stellow
C++/C#/PHP/LUA
I am trying to addapt a script I found on this forum, to send loot message to a player (on kill monsters).
The scripts is working in parts. It send a message when kill a monsters but they do not drop a container(bag), and do not count items, for example:
17:35 Loot of rat: a gold coin, a gold coin (it droped 13, and 28 gold coins respectely)
When a monsters drops a bag I get a luascriptinterface::luagetcontainersice(). container not found
sources> lastest otserv trunk
script:
The scripts is working in parts. It send a message when kill a monsters but they do not drop a container(bag), and do not count items, for example:
17:35 Loot of rat: a gold coin, a gold coin (it droped 13, and 28 gold coins respectely)
When a monsters drops a bag I get a luascriptinterface::luagetcontainersice(). container not found
sources> lastest otserv trunk
script:
function getContentDescription(uid, comma)
local ret, i, containers = '', 0, {}
while i < getContainerSize(uid) do
local v, s = getContainerItem(uid, i), ''
local k = getItemDescriptions(v.itemid)
if k.name ~= '' then
if v.type > 1 and k.stackable and k.showCount then
s = v.type .. ' ' .. getItemDescriptions(v.itemid).plural
else
local article = k.article
s = (article == '' and '' or article .. ' ') .. k.name
end
ret = ret .. (i == 0 and not comma and '' or ', ') .. s
if isContainer(v.uid) and getContainerSize(v.uid) > 0 then
table.insert(containers, v.uid)
end
else
ret = ret .. (i == 0 and not comma and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
end
i = i + 1
end
for i = 1, #containers do
ret = ret .. getContentDescription(containers, true)
end
return ret
end
local function send(cid, pos, name, party)
local corpse = getTileItemByType(pos, ITEM_TYPE_CONTAINER).uid
local ret = isContainer(corpse) and getContentDescription(corpse)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of ' .. name .. ': ' .. (ret ~= '' and ret or 'nothing'))
if party then
for _, pid in ipairs(getPartyMembers(party)) do
doPlayerSendChannelMessage(pid, '', 'Loot of ' .. name .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_W, CHANNEL_PARTY)
end
end
end
function onKill(cid, target, lastHit)
if not isPlayer(target) then
addEvent(send, 0, cid, getThingPos(target), getCreatureName(target), getPartyMembers(cid))
end
return true
end
Last edited: