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

Solved DoDecayItemTo is destroying ground field rather than created item!

Extrodus

|| Blazera.net ||
Premium User
Joined
Dec 22, 2008
Messages
2,740
Solutions
7
Reaction score
541
Location
Canada
Hello there guys, I am currently messing around with a pick.lua script that is causing the floor tile to be removed rather than the created hole. Very strange.

Description of what happens: You will pick the hole, it works fine until the 120 second tick counter is up. Then it removes the ground tile, rather than the hole "created itemid" and causes the tile to become un-walkable.

Distro: OTHire released by Ezzz in the downloads section of OTLand.
Link: https://github.com/TwistedScorpio/OTHire/

LUA Action Script for Pick Holes:
Code:
function onUse(cid, item, frompos, item2, topos)

aID = 55556 --Action Id the ground tile must have to turn into a hole.
ticks = 120 --How many seconds the hole will last before turning into a normal tile again
topos = {x=topos.x, y=topos.y, z=topos.z}
GRASS = {4526, 4527, 4528, 4529, 4530, 4531, 4532, 4533, 4534, 4535, 4536, 4537, 4538, 4529, 4540, 4541, 4567, 4568, 4569, 4756}
DIRT = {351, 352, 353, 354, 355}
SNOW = {671, 6683, 6684, 6685, 6686, 7002}
DENY = {383, 384, 385, 392, 418, 469, 470, 482, 484, 485, 489}

if item2.actionid == aID then
   if isInArray(GRASS, item2.itemid) == 1 then
     doTransformItem(item2.uid,470)
     doDecayItemTo(topos, item2.itemid, ticks)
   elseif isInArray(DIRT, item2.itemid) == 1 then
     doTransformItem(item2.uid,383)
     doDecayItemTo(topos, item2.itemid, ticks)
   elseif item2.itemid == 231 then
     doTransformItem(item2.uid,482)
     doDecayItemTo(topos, item2.itemid, ticks)
   elseif isInArray(SNOW, item2.itemid) == 1 then
     doTransformItem(item2.uid,485)
     doDecayItemTo(topos, item2.itemid, ticks)
   elseif isInArray(DENY, item2.itemid) == 1 then
     doPlayerSendTextMessage(cid,23,"Sorry! not possible.")
   else
     doCreateItem(3324, 1, topos)
     doDecayItemTo(topos, 0, ticks)
   end
elseif item2.itemid == 7200 then
   doTransformItem(item2.uid,7236)

elseif item2.actionid == 8090 and item2.itemid == 1304 then
CHANCESTONE = math.random(1,10)
PLAYERHEALTH = math.random(10,67)
   if CHANCESTONE <= 2 then
   doTransformItem(item2.uid,383)
   doSendMagicEffect(topos, 3)
   doCreatureAddHealth(cid, -PLAYERHEALTH)
   else
   doCreatureAddHealth(cid, -PLAYERHEALTH)
   doSendMagicEffect(topos, 2)
   end

end
return true
end

Any help is greatly appreciated and for anyone wondering to replicate for sure test DIRT = {351, 352, 353, 354, 355} as that is what I was testing. Although Im sure it does it for every ground type
 
Try this:

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

local DIRT = {351, 352, 353, 354, 355}

   if (itemEx.uid <= 65531 or itemEx.actionid > 0) and isInArray(DIRT, itemEx.itemid) then
     doTransformItem(itemEx.uid, 392)
     doDecayItem(itemEx.uid)
     doSendMagicEffect(toPosition, CONST_ME_POFF)
   end
   
   return true
end
 
Where do we define the decay timer also its action id 55556 not unique 65531. I'm working on a fix tonight, was just busy earlier so I posted here.
 
Last edited:
Here's the fix if anyone needs it :D Remember, this is for OTHire.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local holes = {468, 481, 483}
dirtID = 55556 --Action Id the ground tile must have to turn into a hole.
ticks = 30 --How many seconds the hole will last before turning into a normal tile again
topos = {x=toPosition.x, y=toPosition.y, z=toPosition.z}
sandrand = math.random(1, 10)
  if itemEx.itemid == 0 then
  return 0
  end
  
   if (itemEx.actionid == dirtID) then
     if itemEx.itemid == 351 or 351 or 353 or 354 or 355 then
  doTransformItem(itemEx.uid,383)
  doDecayItemTo(toPosition, itemEx.itemid, ticks)
  else
  doSendMagicEffect(toPosition,2)
  end
  return 1
  end
  
  return 1
end

Glad I finally figure it out ;D
 
Back
Top