• 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 [0.4] Deconstruct kit.

elnelson

Lunaria World Dev
Joined
Jun 20, 2009
Messages
579
Solutions
2
Reaction score
58
Location
México
Good afternoon, i was wondering if you guys could help me to script a decontruction kit, like a reverse version of the construction kits.

this scripts set AID 3051 (may be used to avoid abuse trying to deconstruct non-house things)
Lua:
local CONSTRUCTIONS = {
 --[boxed chair] = chair
               [3901] = 1652
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(fromPosition.x == CONTAINER_POSITION) then
        doPlayerSendCancel(cid, "Put the construction kit on the floor first.")
    elseif(not getTileInfo(fromPosition).house) then
        doPlayerSendCancel(cid,"You may construct this only inside a house.")
    elseif(CONSTRUCTIONS[item.itemid] ~= nil) then
        doTransformItem(item.uid, CONSTRUCTIONS[item.itemid]) --i was wondering if this data could be used to read inverted values, so chair (id 3051) id tranformed to boxed chair (id: 3901)
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        doItemSetAttribute(itemEx.uid, "aid", 3051)
    else
        return false
    end

    return true
end
 
aid shouldn't be required.

Just deconstruct the items back into the normal construction kits.
 
Solution
aid shouldn't be required.

Just deconstruct the items back into the normal construction kits.

Well i used it as a security measure, without it can be bugged
built items receive aid 3051
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if itemEx.actionid == 3051 then
    -- if(fromPosition.x == CONTAINER_POSITION) then
    --     doPlayerSendCancel(cid, "Put the construction kit on the floor first.")
    -- elseif(not getTileInfo(fromPosition).house) then
    --     doPlayerSendCancel(cid,"You may construct this only inside a house.")
    -- else
    -- if(CONSTRUCTIONS[itemEx.uid] ~= nil) then
        doTransformItem(itemEx.uid, CONSTRUCTIONS[itemEx.itemid])
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        doItemSetAttribute(itemEx.uid, "aid", 0)
    else
        return false
    end

    return true
end
 
Back
Top