• 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 [tfs 0.4] [action script]-> 2 items conjure new item onUse

tiag0_bn

Well-Known Member
Joined
Dec 8, 2011
Messages
181
Reaction score
50
Hello, someone to tweak this script, make it work like this.

system function:
1 vip item and 2 aol, onUse vipitem in aol transforms into a new aol with attributes.


SCRIPTHELP.jpg

1.1 -> When using itemid: 6943 in itemid: 2173 -> it will create itemid: 6485 and it will have the attributes of that new item
1.2 -> when dying with itemid: 6485 it will revert to itemid: 6943


my script, no work because my itemid: 6943 is multi use, and need 1.2 too.

Lua:
local t = {
    useOn = 6943,
    newId = 6485
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if doPlayerRemoveItem(cid,2173,1) then
        doRemoveItem(item.uid, 1)
        doPlayerAddItem(cid, 6485, 1)
        doCreatureSay(cid, 'You recharged your ' .. getItemNameById(item.itemid), TALKTYPE_ORANGE_1)

    else
        doCreatureSay(cid, 'You must use it on a ' .. getItemNameById(t.useOn), TALKTYPE_ORANGE_1)
    end
    return true
end
 
Last edited:
Solution
My script work fine.

I test it:
hM5XYUT.png


IK58fHu.gif


XML:
<action itemid="7759" event="script" value="test.lua"/>
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 6943 and itemEx.itemid == 2174 then
        doRemoveItem(item.uid)
        doTransformItem(itemEx.uid, 6485)
        doCreatureSay(cid, 'You recharged your ' .. getItemNameById(item.itemid), TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'You must use it on a ' .. getItemNameById(2174), TALKTYPE_ORANGE_1)
    end
    return true
end
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 6943 and itemEx.itemid == 2174 then
        doRemoveItem(item.uid)
        doTransformItem(itemEx.uid, 6485)
        doCreatureSay(cid, 'You recharged your ' .. getItemNameById(item.itemid), TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'You must use it on a ' .. getItemNameById(2174), TALKTYPE_ORANGE_1)
    end
    return true
end
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 6943 and itemEx.itemid == 2174 then
        doRemoveItem(item.uid)
        doTransformItem(itemEx.uid, 6485)
        doCreatureSay(cid, 'You recharged your ' .. getItemNameById(item.itemid), TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'You must use it on a ' .. getItemNameById(2174), TALKTYPE_ORANGE_1)
    end
    return true
end
no work
 
how is it written in actions.xml?


in the script he sent the itemEx as 2174, but you said it was 2173, change the number and try again, this is probably the error

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 6943 and itemEx.itemid == 2173 then
        doRemoveItem(item.uid)
        doTransformItem(itemEx.uid, 6485)
        doCreatureSay(cid, 'You recharged your ' .. getItemNameById(item.itemid), TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'You must use it on a ' .. getItemNameById(2174), TALKTYPE_ORANGE_1)
    end
    return true
end
 
how is it written in actions.xml?


in the script he sent the itemEx as 2174, but you said it was 2173, change the number and try again, this is probably the error

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 6943 and itemEx.itemid == 2173 then
        doRemoveItem(item.uid)
        doTransformItem(itemEx.uid, 6485)
        doCreatureSay(cid, 'You recharged your ' .. getItemNameById(item.itemid), TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'You must use it on a ' .. getItemNameById(2174), TALKTYPE_ORANGE_1)
    end
    return true
end
i noticed this
When i try to use itemid:6943 in itemid:2173 nothing happens...

Lua:
<action itemid="6943" script="amuletaol.lua"/>


local t = {
    useOn = 6943,
    newId = 6485
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 6943 and itemEx.itemid == 2173 then
        doRemoveItem(item.uid)
        doTransformItem(itemEx.uid, 6485)
        doCreatureSay(cid, 'You recharged your ' .. getItemNameById(item.itemid), TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'You must use it on a ' .. getItemNameById(2173), TALKTYPE_ORANGE_1)
    end
    return true
end
 
i noticed this
When i try to use itemid:6943 in itemid:2173 nothing happens...

Lua:
<action itemid="6943" script="amuletaol.lua"/>


local t = {
    useOn = 6943,
    newId = 6485
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 6943 and itemEx.itemid == 2173 then
        doRemoveItem(item.uid)
        doTransformItem(itemEx.uid, 6485)
        doCreatureSay(cid, 'You recharged your ' .. getItemNameById(item.itemid), TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'You must use it on a ' .. getItemNameById(2173), TALKTYPE_ORANGE_1)
    end
    return true
end

Try this?
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if itemEx.itemid == 2173 then
        doRemoveItem(item.uid)
        doTransformItem(itemEx.uid, 6485)
        doCreatureSay(cid, 'You recharged your ' .. getItemNameById(item.itemid), TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'You must use it on a ' .. getItemNameById(2173), TALKTYPE_ORANGE_1)
    end
    return true
end
 
Try this?
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if itemEx.itemid == 2173 then
        doRemoveItem(item.uid)
        doTransformItem(itemEx.uid, 6485)
        doCreatureSay(cid, 'You recharged your ' .. getItemNameById(item.itemid), TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'You must use it on a ' .. getItemNameById(2173), TALKTYPE_ORANGE_1)
    end
    return true
end

No work, msg : You can not use this object.
 
My script work fine.

I test it:
hM5XYUT.png


IK58fHu.gif


XML:
<action itemid="7759" event="script" value="test.lua"/>
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 6943 and itemEx.itemid == 2174 then
        doRemoveItem(item.uid)
        doTransformItem(itemEx.uid, 6485)
        doCreatureSay(cid, 'You recharged your ' .. getItemNameById(item.itemid), TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'You must use it on a ' .. getItemNameById(2174), TALKTYPE_ORANGE_1)
    end
    return true
end
 
Solution
the script works! thanks

problem was in my item.otb

Need help-> 1.2 -> when dying with itemid: 6485 it will revert to itemid: 6943 and no lose items
 
the script works! thanks

problem was in my item.otb

Need help-> 1.2 -> when dying with itemid: 6485 it will revert to itemid: 6943 and no lose items

if item 6485 prevents items from being lost when you die, try modifying items.xml to look like this

Lua:
<item id="6485" article="an" name="amulet">
        <attribute key="weight" value="420"/>
        <attribute key="slotType" value="necklace"/>
        <attribute key="preventDrop" value="1"/>
        <attribute key="charges" value="1"/>
        <attribute key="decayTo" value="6943"/>
    </item>


In movements.xml:

Lua:
<!-- YOUR AMULET -->
        <movevent type="Equip" itemid="6485" slot="necklace" event="function" value="onEquipItem"/>
        <movevent type="DeEquip" itemid="6485" slot="necklace" event="function" value="onDeEquipItem"/>
 
Last edited:
Back
Top