• 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] script error

tiddpd

PHP Scripter
Joined
Apr 16, 2008
Messages
331
Reaction score
0
For this script it wanted to make it for when the lever is pulled, a fire will ignite then remove. But it says the item cannot be found, im guessing because there is no delay between doCreateItem and doRemoveItem, so is there a function to put a slight delay between functions? ...this is the code:

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

local statuePos = {x = 314, y = 97, z = 8, stackpos=1}
local statue = getThingfromPos(statuePos)

if item.itemid == 1945 then
doCreateItem(6289,1,statuePos)
doRemoveItem(statuePos.uid,1)
doTransformItem(item.uid,1946)
elseif item.itemid == 1946 then
doTransformItem(item.uid,1945)
end
end
 
For this script it wanted to make it for when the lever is pulled, a fire will ignite then remove. But it says the item cannot be found, im guessing because there is no delay between doCreateItem and doRemoveItem, so is there a function to put a slight delay between functions? ...this is the code:

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

local statuePos = {x = 314, y = 97, z = 8, stackpos=1}
local statue = getThingfromPos(statuePos)

if item.itemid == 1945 then
doCreateItem(6289,1,statuePos)
doRemoveItem(statue.uid,1)
doTransformItem(item.uid,1946)
elseif item.itemid == 1946 then
doTransformItem(item.uid,1945)
end
end

change statuePos.uid to just statue.uid
hope that helps..are you just changing an item? cause if so you could just transform the item at that spot instead of removing/adding
 
what i meant to happen is when the lever is pulled, a fire field will appear then disapear, by only pulling once.

not by pulling it and making it appear, then pulling again and it disapearing. thats why i though i needed a delay between the two functions because when i try to do it in one pull it says the item cannot be found.
 
what i meant to happen is when the lever is pulled, a fire field will appear then disapear, by only pulling once.

not by pulling it and making it appear, then pulling again and it disapearing. thats why i though i needed a delay between the two functions because when i try to do it in one pull it says the item cannot be found.

you need to get the tile information AFTER the fire field is there or else it won't find it
 
I'll post two scripts, animated(more effects) and simple.

Animated:
Code:
-
-- Credits by BinHo®

local config = {
    fireWallPos = { x = 314, y = 97, z = 8, stackpos = 1},
    fireWallId = 6289,
    switch1 = 1945,
    switch2 = 1946,
    switchPos = { x = ?, y = ?, z = ?}
}

function onUse(cid, item, fromPostion, itemEx, toPosition)
    if item.actionid == 4500 and item.itemid == config.switch1 then
        doRemoveItem(getThingFromPos(config.fireWallPos).uid, 1)
        doSendMagicEffect(config.switchPos, 12)
        doSendMagicEffect(config.fireWallPos, 2)
        doPlayerSendTextMessage(cid, 22, "The FireWall was removed.")
    else
        if item.itemid == config.switch2 then
            doCreateItem(config.fireWallId, 1, config.fireWallPos)
            doSendMagicEffect(config.switchPos, 12)
            doSendMagicEffect(config.fireWallPos, 2)
            doPlayerSendTextMessage(cid, 22, "The FireWall was added.")
        end
    end
end


Simple:

Code:
--- Credits by BinHo®

local config = {
    fireWallPos = { x = 314, y = 97, z = 8, stackpos = 1},
    fireWallId = 6289,
    switch1 = 1945,
    switch2 = 1946
}

function onUse(cid, item, fromPostion, itemEx, toPosition)
    if item.actionid == 4500 and item.itemid == config.switch1 then
        doRemoveItem(getThingFromPos(config.fireWallPos).uid, 1)
    else
        if item.itemid == config.switch2 then
            doCreateItem(config.fireWallId, 1, config.fireWallPos)
        end
    end
end
 
Last edited:
Try Binho® script I think it would work just fine.

ofc it will work, but thats not what he is trying to do, he wants the fire field to appear then automatically disappear, just just be made or removed like in the posted scripts

best bet is to add an event that will just remove the fire field after X seconds AddEvent(removeField,2*1000) or something along those lines
 
Back
Top