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

{help}Lever with timer

fire_shock666

New Member
Joined
Jun 3, 2014
Messages
24
Reaction score
0
Location
Netherlands
hello there
is it possible to add with this script a times that will set the wall back after 10 minutes?

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)

stonepos = {x=884, y=854, z=9, stackpos=1}
getpos = getThingfromPos(stonepos)

if item.uid == 20010 and item.itemid == 1945 and getpos.itemid == 1304 then
doRemoveItem(getpos.uid,1)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 20010 and item.itemid == 1946 and getpos.itemid == 0 then
doCreateItem(1304,1,stonepos)
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry not possible.")
end
return 1
end
 
Code:
local function changeBack(pos, itemid, transformid)
     doTransformItem(getTileItemById(pos, transformid).uid, itemid)
     doCreateItem(1304, 1, stonepos)
     return true
end

addEvent(changeBack, 10 * 60 * 1000, toPosition, item.itemid, 1946)
 
Replace this part
Code:
elseif item.uid == 20010 and item.itemid == 1946 and getpos.itemid == 0 then
    doCreateItem(1304,1,stonepos)
    doTransformItem(item.uid,item.itemid-1)

With this
Code:
addEvent(changeBack, 10 * 60 * 1000, toPosition, item.itemid, 1946)

Add the function under stonepos, since it's using that variable, you can also add the pos instead of stonepos and add the function at the top.
Code:
local function changeBack(pos, itemid, transformid)
     doTransformItem(getTileItemById(pos, transformid).uid, itemid)
     doCreateItem(1304, 1, {x = 884, y = 854, z = 9})
     return true
end
 
Replace this part
Code:
elseif item.uid == 20010 and item.itemid == 1946 and getpos.itemid == 0 then
    doCreateItem(1304,1,stonepos)
    doTransformItem(item.uid,item.itemid-1)

With this
Code:
addEvent(changeBack, 10 * 60 * 1000, toPosition, item.itemid, 1946)

Add the function under stonepos, since it's using that variable, you can also add the pos instead of stonepos and add the function at the top.
Code:
local function changeBack(pos, itemid, transformid)
     doTransformItem(getTileItemById(pos, transformid).uid, itemid)
     doCreateItem(1304, 1, {x = 884, y = 854, z = 9})
     return true
end

so nou i does look like this?
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
stonepos = {x=884, y=854, z=9, stackpos=1}
getpos = getThingfromPos(stonepos)

local function changeBack(pos, itemid, transformid)
     doTransformItem(getTileItemById(pos, transformid).uid, itemid)
     doCreateItem(1304, 1, stonepos)
     return true
end

if item.uid == 20010 and item.itemid == 1945 and getpos.itemid == 1304 then
doRemoveItem(getpos.uid,1)
doTransformItem(item.uid,item.itemid+1)
addEvent(changeBack, 10 * 60 * 1000, toPosition, item.itemid, 1946)
else
doPlayerSendCancel(cid,"Sorry not possible.")
end
return 1
end
 

Similar threads

Back
Top