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

TFS 0.X Problem with convert script with event.

OTcreator

Active Member
Joined
Feb 14, 2022
Messages
425
Solutions
1
Reaction score
44
Hello!
I try change scripts from 0.3.7 to 1.4.2 and i work hard.
But i have problem with this one. @Evil Puncker can you help me please <3

Lua:
local transformToItem = 3338
local previousItem = 2797

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if itemEx.actionid == 2718 and getPlayerStorageValue(cid, 1494) < 1 then
        setPlayerStorageValue(cid,1494,1)
        doRemoveItem(item.uid)
        doCreatureSay(cid, "Stones crash...", TALKTYPE_ORANGE_1, false, cid)
        doTransformItem(itemEx.uid, transformToItem)
        addEvent(
            function()
                doTransformItem(getThingfromPos(toPosition).uid, previousItem)
            end,
            30 * 1000
        )
        elseif itemEx.actionid == 2718 and getPlayerStorageValue(cid, 1494) >= 1 then
            doCreatureSay(cid, "You already crash that stones!", TALKTYPE_ORANGE_1, false, cid)
        else
        doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    end
    return true
end
 
something like this:
Lua:
local transformToItem = 3338
local previousItem = 2797

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target.actionid == 2718 and player:getStorageValue(1494) < 1 then
        player:setStorageValue(1494, 1)
        item:remove(1)
        player:say("Stones crash...", TALKTYPE_MONSTER_SAY)
        local i = Item(target.uid) return i and i:transform(transformToItem)
        addEvent(
            function()
                doTransformItem(getThingfromPos(toPosition).uid, previousItem)
            end,
            30 * 1000
        )
        elseif target.actionid == 2718 and player:getStorageValue(1494) >= 1 then
            player:say("You already crash that stones!", TALKTYPE_MONSTER_SAY)
        else
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    end
    return true
end
 
something like this:
Lua:
local transformToItem = 3338
local previousItem = 2797

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target.actionid == 2718 and player:getStorageValue(1494) < 1 then
        player:setStorageValue(1494, 1)
        item:remove(1)
        player:say("Stones crash...", TALKTYPE_MONSTER_SAY)
        local i = Item(target.uid) return i and i:transform(transformToItem)
        addEvent(
            function()
                doTransformItem(getThingfromPos(toPosition).uid, previousItem)
            end,
            30 * 1000
        )
        elseif target.actionid == 2718 and player:getStorageValue(1494) >= 1 then
            player:say("You already crash that stones!", TALKTYPE_MONSTER_SAY)
        else
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    end
    return true
end

[Warning - Event::checkScript] Can not load script: scripts/custom/quests/stone_crash.lua
data/actions/scripts/custom/quests/stone_crash.lua:11: 'end' expected (to close 'if' at line 5) near 'addEvent'
 
[Warning - Event::checkScript] Can not load script: scripts/custom/quests/stone_crash.lua
data/actions/scripts/custom/quests/stone_crash.lua:11: 'end' expected (to close 'if' at line 5) near 'addEvent'
Lua:
local transformToItem = 3338
local previousItem = 2797

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target.actionid == 2718 and player:getStorageValue(1494) < 1 then
        player:setStorageValue(1494, 1)
        item:remove(1)
        player:say("Stones crash...", TALKTYPE_MONSTER_SAY)
        
        local i = Item(target.uid)
        if i then
            i:transform(transformToItem)
        end
        
        addEvent(
            function()
                doTransformItem(getThingfromPos(toPosition).uid, previousItem)
            end,
            30 * 1000
        )
    elseif target.actionid == 2718 and player:getStorageValue(1494) >= 1 then
        player:say("You already crashed those stones!", TALKTYPE_MONSTER_SAY)
    else
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    end
    return true
end
 
Lua:
local transformToItem = 3338
local previousItem = 2797

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target.actionid == 2718 and player:getStorageValue(1494) < 1 then
        player:setStorageValue(1494, 1)
        item:remove(1)
        player:say("Stones crash...", TALKTYPE_MONSTER_SAY)
      
        local i = Item(target.uid)
        if i then
            i:transform(transformToItem)
        end
      
        addEvent(
            function()
                doTransformItem(getThingfromPos(toPosition).uid, previousItem)
            end,
            30 * 1000
        )
    elseif target.actionid == 2718 and player:getStorageValue(1494) >= 1 then
        player:say("You already crashed those stones!", TALKTYPE_MONSTER_SAY)
    else
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    end
    return true
end

Thanks! But have one problem.
If ID2797 transform to item 3338 - all it's OK/
When ID 3338 transform to previous item 2797 (not transform, but create new in this place.
On one stack I have 3338 and 2798. Why?

(this is not transform ID previous)
 
Last edited:
Lua:
local transformToItem = 3338
local previousItem = 2797

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target.actionid == 2718 and player:getStorageValue(1494) < 1 then
        player:setStorageValue(1494, 1)
        item:remove(1)
        player:say("Stones crash...", TALKTYPE_MONSTER_SAY)
        
        local i = Item(target.uid)
        if i then
            local targetItemId = i:getId()
            if targetItemId == previousItem then
                i:transform(transformToItem)
            else
                i:remove(1)
                Game.createItem(previousItem, 1, toPosition)
            end
        end
        
        addEvent(
            function()
                local thing = getThingfromPos(toPosition)
                if thing.itemid == transformToItem then
                    doTransformItem(thing.uid, previousItem)
                end
            end,
            30 * 1000
        )
    elseif target.actionid == 2718 and player:getStorageValue(1494) >= 1 then
        player:say("You already crashed those stones!", TALKTYPE_MONSTER_SAY)
    else
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    end
    return true
end
 
Back
Top