• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lever create item X seconds

freddzor11

Member
Joined
May 25, 2009
Messages
695
Reaction score
5
I have tried all lever scripts I found at Otland and none works for me

I want a script that if you pull lever with UID then create stone x seconds
I use 0.3.6

Kind regards,
freddzor11
 
Code:
local config = {
   pos = {x=92,y=119,z=7},
   stoneid = 1285,
   time = 20 -- time in seconds to remove the stone
}

local function removeStone()
   local stone = getTileItemById(config.pos,config.stoneid).uid
   if(stone > 0) then
     doRemoveItem(stone,1)
     doSendMagicEffect(config.pos, CONST_ME_MAGIC_RED)
   end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local stone = getTileItemById(config.pos,config.stoneid).uid
   if(stone < 1) then
     doCreateItem(config.stoneid, 1, config.pos)
     doSendMagicEffect(config.pos, CONST_ME_MAGIC_GREEN)
     addEvent(removeStone, config.time * 1000)
     doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
   else
     doPlayerSendCancel(cid, "The stone ia already created.")
   end
   return true
end
 
Code:
local config = {
   pos = {x=92,y=119,z=7},
   stoneid = 1285,
   time = 20 -- time in seconds to remove the stone
}

local function removeStone()
   local stone = getTileItemById(config.pos,config.stoneid).uid
   if(stone > 0) then
     doRemoveItem(stone,1)
     doSendMagicEffect(config.pos, CONST_ME_MAGIC_RED)
   end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local stone = getTileItemById(config.pos,config.stoneid).uid
   if(stone < 1) then
     doCreateItem(config.stoneid, 1, config.pos)
     doSendMagicEffect(config.pos, CONST_ME_MAGIC_GREEN)
     addEvent(removeStone, config.time * 1000)
     doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
   else
     doPlayerSendCancel(cid, "The stone ia already created.")
   end
   return true
end
Sorry that I told you wrong, I need a script that removes stone in X seconds haha
 
Code:
local config = {
     pos = {x=92,y=119,z=7},
     stoneid = 1285,
     time = 20 -- time in seconds to create the stone
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
     local stone = getTileItemById(config.pos,config.stoneid).uid
     if(stone > 0) then
       doRemoveItem(stone,1)
       doSendMagicEffect(config.pos, CONST_ME_MAGIC_RED)
       addEvent(doCreateItem, config.time * 1000, config.stoneid, 1, config.pos)
       doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
     else
       doPlayerSendCancel(cid, "The stone is already gone.")
     end
     return true
end
 
Code:
local config = {
     pos = {x=92,y=119,z=7},
     stoneid = 1285,
     time = 20 -- time in seconds to create the stone
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
     local stone = getTileItemById(config.pos,config.stoneid).uid
     if(stone > 0) then
       doRemoveItem(stone,1)
       doSendMagicEffect(config.pos, CONST_ME_MAGIC_RED)
       addEvent(doCreateItem, config.time * 1000, config.stoneid, 1, config.pos)
       doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
     else
       doPlayerSendCancel(cid, "The stone is already gone.")
     end
     return true
end
Thank you! could you do so it's a orange text that says the stones is gone in X minutes
 
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The stone is removed, it will be back in 20 seconds.")
 
Btw if you are looking for different kind of message types, you can find them in data/lib/000-constant.lua.
Code:
MESSAGE_FIRST = 18
MESSAGE_STATUS_CONSOLE_RED = MESSAGE_FIRST
MESSAGE_EVENT_ORANGE = 19
MESSAGE_STATUS_CONSOLE_ORANGE = 20
MESSAGE_STATUS_WARNING = 21
MESSAGE_EVENT_ADVANCE = 22
MESSAGE_EVENT_DEFAULT = 23
MESSAGE_STATUS_DEFAULT = 24
MESSAGE_INFO_DESCR = 25
MESSAGE_STATUS_SMALL = 26
MESSAGE_STATUS_CONSOLE_BLUE = 27
MESSAGE_LAST = MESSAGE_STATUS_CONSOLE_BLUE
 
bump Can't get this work
Code:
local config = {
     pos = {x=1112,y=822,z=10},
     stoneid = 1285,
     time = 20 -- time in seconds to create the stone
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
     local stone = getTileItemById(config.pos,config.stoneid).uid
     if(stone > 0) then
       doRemoveItem(stone,1)
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The stone is removed, it will be back in 20 seconds.")
       doSendMagicEffect(config.pos, CONST_ME_MAGIC_RED)
       addEvent(doCreateItem, config.time * 1000, config.stoneid, 1, config.pos)
       doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
     else
       doPlayerSendCancel(cid, "The stone is already gone.")
     end
     return true
end
 
Back
Top