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

Drop all items on floor via LUA-Script

skywalker16

New Member
Joined
Nov 5, 2008
Messages
250
Reaction score
1
Location
Switzerland
Is it possible to handle the loss of items direct via lua scripting?

Situation: PVP Arena - The player will not die but getting teleported. I would like to make the player lose all his items and drop them (if possible in a container) on the floor @ his last position in the arena. Since I think the "death-action" is based in the source codes of tfs I am not sure about how to do this actually... could anyone please help me?
 

I got this script... but somehow it wont work :/

Error Msg:
[4/1/2013 12:37:7] [Error - CreatureScript Interface]
[4/1/2013 12:37:7] data/creaturescripts/scripts/arena_death.lua:onPrepareDeath
[4/1/2013 12:37:7] Description:
[4/1/2013 12:37:7] (luaDoCreateItem) Item not found

function getAllItemsById(cid, id)
containers = {}
items = {}

for i = CONST_SLOT_FIRST, CONST_SLOT_LAST do
local sitem = getPlayerSlotItem(cid, i)
if sitem.uid > 0 then
if isContainer(sitem.uid) then
table.insert(containers, sitem.uid)
elseif not(id) or id == sitem.itemid then
table.insert(items, sitem)
end
end
end

while #containers > 0 do
for k = (getContainerSize(containers[1]) - 1), 0, -1 do
local tmp = getContainerItem(containers[1], k)
if isContainer(tmp.uid) then
table.insert(containers, tmp.uid)
elseif not(id) or id == tmp.itemid then
table.insert(items, tmp)
end
end
table.remove(containers, 1)
end


return items
end


function onPrepareDeath(cid)

item_drop_pos = getCreaturePosition(cid)
dead_player_tp_pos = {x=50 , y=50 , z=14 }

doTeleportThing(cid, dead_player_tp_pos)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have lost the match.")
doSendMagicEffect(item_drop_pos, CONST_ME_STUN)

getAllItemsById(cid)

for i = 1, #items do
doCreateItem(items, item_drop_pos)
end

for i = 1, #containers do
doCreateItem(contairs, item_drop_pos)
end

return true
end
 
Last edited:
Back
Top