• 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 Error on Lever Script

Mystera

New Member
Joined
Apr 17, 2015
Messages
9
Reaction score
0
Hello, I hope and can help me, I have an error with a script that I found, the function you should realize is that when using a lever remove one gate .. This works fine, but the gate must return to their place in 1 minute, and throws me this error:
UU10U0j.png

Code:
function onUse(cid, item, frompos, item2, topos)
local gatepos = {x = 1595, y = 959, z = 7, stackpos=1}
local getgate = getThingfromPos(gatepos)
local time = 60

if item.itemid == 1946 then
doRemoveItem(getgate.uid,1)
doTransformItem(item.uid,item.itemid-1)
doPlayerSendTextMessage(cid,25,"The lever is open, you have one minute.")
addEvent(revive, time*1000)
elseif item.id == 1945 then
doTransformItem(item.uid,item.itemid+1)
end

local function revive()
doCreateItem(9533,1,gatepos)
end
return true
end

I use TFS 1.1
 
Last edited:
Try this:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
local gateTile = Tile(X, Y, Z)
local time = 60

if item.itemid == 1945 then
        gateTile:getPosition():sendMagicEffect(CONST_ME_POFF)
        gateTile:getItemById(1515):remove()
        Item(item.uid):transform(1946)
        doPlayerSendTextMessage(cid,25,"The lever is open, you have one minute.")

        addEvent(function(gatePos, lever)
            Game.createItem(9533, 1, gatePos)    
            gatePos:sendMagicEffect(CONST_ME_POFF)
            lever:transform(1945)
        end, time*1000, gateTile:getPosition(), Tile(toPosition):getItemById(1946))
   
    elseif item.itemid == 1946 then
        return false
    end
    return true
end
 
Hello, I hope and can help me, I have an error with a script that I found, the function you should realize is that when using a lever remove one gate .. This works fine, but the gate must return to their place in 1 minute, and throws me this error:
UU10U0j.png

Code:
function onUse(cid, item, frompos, item2, topos)
local gatepos = {x = 1595, y = 959, z = 7, stackpos=1}
local getgate = getThingfromPos(gatepos)
local time = 60

if item.itemid == 1946 then
doRemoveItem(getgate.uid,1)
doTransformItem(item.uid,item.itemid-1)
doPlayerSendTextMessage(cid,25,"The lever is open, you have one minute.")
addEvent(revive, time*1000)
elseif item.id == 1945 then
doTransformItem(item.uid,item.itemid+1)
end

local function revive()
doCreateItem(9533,1,gatepos)
end
return true
end

I use TFS 1.1
callback paramateter should be a function.
callback = something you return
paramateter = variable inside the function, i think, not sure xD i haven't learned the programming from book. I learned from looking other scripts.
function = activator something what has these ( ) at the end of a word.

Your code:
local function
revive()
doCreateItem(9533,1,gatepos)​
end

I dont see any return there?

it should be:
local function revive()
return doCreateItem(9533,1,gatepos)
end
 
I use the script from Techrlz and i got this error :/ :
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
local gateTile = (x = 1595, y = 959, z = 7)
local time = 60

if item.itemid == 1945 then
        gateTile:getPosition():sendMagicEffect(CONST_ME_POFF)
        gateTile:getItemById(9533):remove()
        Item(item.uid):transform(1946)
        doPlayerSendTextMessage(cid,25,"The lever is open, you have one minute.")

        addEvent(function(gatePos, lever)
            Game.createItem(9533, 1, gatePos)    
            gatePos:sendMagicEffect(CONST_ME_POFF)
            lever:transform(1945)
        end, time*1000, gateTile:getPosition(), Tile(toPosition):getItemById(1946))
   
    elseif item.itemid == 1946 then
        return false
    end
    return true
end

FH8VRGk.png
 
Okay, works perfect, the gate removed, and reappears, but in console throw this error:
THIS WORK Only one time, i can´t remove the lever again
dCafJDr.png
 
Add the position and itemid as parameters in addEvent and the function and get the item in the function.
So Tile(toPosition):getItemById(1946) should be inside the function and not as parameter in addEvent.
 
Can you edit my script :/? i don´t understand :(
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local gateTile = Tile(1595, 959, 7)
local time = 60

if item.itemid == 1945 then
        gateTile:getPosition():sendMagicEffect(CONST_ME_POFF)
        gateTile:getItemById(9533):remove()
        Item(item.uid):transform(1946)
        doPlayerSendTextMessage(cid,25,"The lever is open, you have one minute.")

        addEvent(function(gatePos, lever)
            Game.createItem(9533, 1, gatePos)    
            gatePos:sendMagicEffect(CONST_ME_POFF)
            lever:transform(1945)
        end, time*1000, gateTile:getPosition(), Tile(toPosition):getItemById(1946))
   
    elseif item.itemid == 1946 then
        return false
    end
    return true
end
 
Back
Top