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

Dor that closes after 5 sec

Joined
Apr 11, 2015
Messages
98
Reaction score
5
Hello guys, im having some problem doing this on my own, so here i am asking for help

I want a script that, when the player opens a door (with actionid), after 5 seconds, the door closes. Simple as that
I was trying to do this, but I keep getting this error:
(luaDoTransformItem) Item not found

Anyway, here's the code that i tried to do alone.

Lua:
function onUse(cid, item, frompos, item2, topos)

if item.actionid == 44100 then
     doTransformItem(item.uid, 5737)
            addEvent(function()
            doTransformItem(item2.uid, 5736)
            end, 6000)

end
    return true
    end

Thanks.
 
Solution
@Snavy @Levi999x

Thx for the help, but both scripts gets me the same error:
(luaDoTransformItem) Item not found

tested in 0.4 3777
Lua:
local config = {
    fromId = 5736,
    toId = 5737
}
function onUse(cid, item, frompos, item2, topos)
    doTransformItem(item.uid, config.toId)
    addEvent(function(pos)
        local itemX = getTileItemById(pos, config.toId)
        if itemX then
            doTransformItem(itemX.uid, config.fromId)
        end
    end, 5000, frompos)
    return true
end
Hello guys, im having some problem doing this on my own, so here i am asking for help

I want a script that, when the player opens a door (with actionid), after 5 seconds, the door closes. Simple as that
I was trying to do this, but I keep getting this error:
(luaDoTransformItem) Item not found

Anyway, here's the code that i tried to do alone.

Lua:
function onUse(cid, item, frompos, item2, topos)

if item.actionid == 44100 then
     doTransformItem(item.uid, 5737)
            addEvent(function()
            doTransformItem(item2.uid, 5736)
            end, 6000)

end
    return true
    end

Thanks.
The error says that It is unable to find item2.
In your case you should use item instead of item2 since item2 parameter is the item on the target tile, for example; using machete on spider web would have the spider web in item2 parameter.

try:
Lua:
function onUse(cid, item, frompos, item2, topos)
    if item.actionid == 44100 then
        doTransformItem(item.uid, 5737)
        addEvent(function(uid)
            doTransformItem(uid, 5736)
        end, 5000, item.uid)
    end
    return true
end
 
Lua:
function onUse(cid, item, frompos, item2, topos)

    if item.actionid == 44100 then
        doTransformItem(item.uid, 5737)
        addEvent(function() doTransformItem(item.uid, 5736) end, 3000)
    end
    return true
end
Post automatically merged:

The error says that It is unable to find item2.
In your case you should use item instead of item2 since item2 parameter is the item on the target tile, for example; using machete on spider web would have the spider web in item2 parameter.

try:
Lua:
function onUse(cid, item, frompos, item2, topos)
    if item.actionid == 44100 then
        doTransformItem(item.uid, 5737)
        addEvent(function(uid)
            doTransformItem(uid, 5736)
        end, 5000, item.uid)
    end
    return true
end

you was faster over again

no lifer no lifer
noob
 
They cannot use temporary identifiers, In these cases it is recommended to do a search in the tile, look for the item with itemID and then work on it
maybe in a few minutes I can help you, if they haven't already
 
@Snavy @Levi999x

Thx for the help, but both scripts gets me the same error:
(luaDoTransformItem) Item not found

tested in 0.4 3777
Lua:
local config = {
    fromId = 5736,
    toId = 5737
}
function onUse(cid, item, frompos, item2, topos)
    doTransformItem(item.uid, config.toId)
    addEvent(function(pos)
        local itemX = getTileItemById(pos, config.toId)
        if itemX then
            doTransformItem(itemX.uid, config.fromId)
        end
    end, 5000, frompos)
    return true
end
 
Solution
They cannot use temporary identifiers, In these cases it is recommended to do a search in the tile, look for the item with itemID and then work on it
maybe in a few minutes I can help you, if they haven't already
@Sarah Wesker
I think this is beyond my script's ability, but i will try here
Post automatically merged:

@Snavy , @Levi999x and @Sarah Wesker
Thank you guys for the help (that was fast tho)
Again, thank you all
Post automatically merged:

@Snavy
Sorry but i found a bug:
If the player tries to close the door when it opens, an error would appear (item not found) causing lag.
I tried to use this to cancel the bug:

if itemid == 5736 then
return false
else

But only delayed the error to when the door closes. I.e, if the player tries to close, and error appears when the door closes itself, after 5 sec
 
Last edited:
@Sarah Wesker
I think this is beyond my script's ability, but i will try here
Post automatically merged:

@Snavy , @Levi999x and @Sarah Wesker
Thank you guys for the help (that was fast tho)
Again, thank you all
Post automatically merged:

@Snavy
Sorry but i found a bug:
If the player tries to close the door when it opens, an error would appear (item not found) causing lag.
I tried to use this to cancel the bug:

if itemid == 5736 then
return false
else

But only delayed the error to when the door closes. I.e, if the player tries to close, and error appears when the door closes itself, after 5 sec

replace
Lua:
if itemX then
with
Lua:
if itemX and itemX.uid > 0 then
 
Back
Top