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

Creating an item with actionid

Zazeros

Member
Joined
Feb 13, 2012
Messages
67
Reaction score
17
0.4

Ok, its not that simple. I'm trying to make the following idea. Player clicks in an item, the item breaks and after some time, the script create the same item and set an actionid
2 things that I'm having trouble with:
How to destroy an item but the script will remember where it was (using doTransformItem ?)
and
How to creates another one using addevent that also puts actionid on it
Thanks
 
Solution
Try this:
Lua:
local recreateItemTimeSeconds = 60

local function recreateItem(itemPosition, itemId, actionId)
    local itemUid = doCreateItem(itemId, 1, itemPosition)
    if itemUid then
        doItemSetAttribute(itemUid, "aid", actionId)
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local itemPosition = getThingPos(item.uid)
    local itemId = item.itemid
    local actionId = item.actionid

    doSendMagicEffect(itemPosition, CONST_ME_MAGIC_RED)
    doRemoveItem(item.uid)

    addEvent(recreateItem, recreateItemTimeSeconds * 1000, itemPosition, itemId, actionId)

    return true
end
Try this:
Lua:
local recreateItemTimeSeconds = 60

local function recreateItem(itemPosition, itemId, actionId)
    local itemUid = doCreateItem(itemId, 1, itemPosition)
    if itemUid then
        doItemSetAttribute(itemUid, "aid", actionId)
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local itemPosition = getThingPos(item.uid)
    local itemId = item.itemid
    local actionId = item.actionid

    doSendMagicEffect(itemPosition, CONST_ME_MAGIC_RED)
    doRemoveItem(item.uid)

    addEvent(recreateItem, recreateItemTimeSeconds * 1000, itemPosition, itemId, actionId)

    return true
end
 
Solution
Back
Top