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

DoRemoveItem & DoTransformItem [30 sec cooldown]

Montee

New Member
Joined
Apr 21, 2016
Messages
5
Reaction score
0
Hello.

I am seeking scripts when i click on the wall it takes me items in backpack and changing to other wall, and after 30 seconds, returns to its previous state.

I working on TFS [1.1]

Thanks for help.
 
actions.xml
Code:
<action uniqueid="3000" script="other/wall.lua"/>

wall.lua
Code:
local function doChangeWallBack(pos, currentid, oldid)
     local newItem = Tile(pos):getItemById(currentid)
     if newItem then
         newItem:transform(oldid)
         pos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
     end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  
     if item.itemid == 1026 then
         item:transform(6281)
         player:addItem(2112, 1)
         player:sendTextMessage(MESSAGE_INFO_DESCR, "You found some item in the wall.")
         fromPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
         addEvent(doChangeWallBack, 30 * 1000, fromPosition, 6281, 1026)
     end
     return true
end
 
Can you give the IDs of the items? How exactly should it work, should it only transform if a player has these items?
 
Code:
local function doChangeWallBack(pos, currentid, oldid)
     local newItem = Tile(pos):getItemById(currentid)
     if newItem then
         newItem:transform(oldid)
         pos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
     end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   
     if item.itemid == 1026 then
         if player:removeItem(5901, 1) then
             item:transform(6281)
             player:sendTextMessage(MESSAGE_INFO_DESCR, "You lost some wood.")
             fromPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
             addEvent(doChangeWallBack, 30 * 1000, fromPosition, 6281, 1026)
         else
             player:sendTextMessage(MESSAGE_INFO_DESCR, "You can't do this.")
         end
     end
     return true
end
 
Back
Top