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

Open tomb.

ruth

Veteran OT User
Joined
Aug 3, 2009
Messages
670
Solutions
2
Reaction score
380
Hello.

Can somebody add to this shovel.lua script open tomb function? It must use action or unique id assigned to sand.

Sand id = 231
Open hole id = 482

Code:
 function onUse(cid, item, frompos, item2, topos)
 if item2.itemid == 28 then
  return 0
 end
 if item2.itemid == 468 then
  doTransformItem(item2.uid,469)
  doDecayItem(item2.uid)
 elseif item2.itemid == 481 then
  doTransformItem(item2.uid,482)
  doDecayItem(item2.uid)
 elseif item2.itemid == 483 then
  doTransformItem(item2.uid,484)
  doDecayItem(item2.uid)
 elseif item2.itemid == 231 then
  rand = math.random(1,30)
  if rand < 12 then
   doSummonCreature("Scarab", topos)
  elseif rand == 20 then
   doPlayerAddItem(cid,2159,1)
  else
   doSendMagicEffect(topos,2)
  end
 else
  return 0
 end
 return 1
 end

For example:
Code:
itemEx.itemid == 231 and itemEx.uid == 4000) then
            doTransformItem(itemEx.uid, 482)
But i dont know if it working and how to combine these two scripts.
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isInArray({468, 481, 483}, itemEx.itemid) then
		doTransformItem(itemEx.uid, itemEx.itemid + 1)
		doDecayItem(itemEx.uid)
	elseif item2.itemid == 231 then
		local rand = math.random(30)
		if rand < 12 then
			doSummonCreature("Scarab", toPosition)
		elseif rand == 20 then
			doPlayerAddItem(cid, 2159, 1)
		else
			doSendMagicEffect(toPosition, CONST_ME_POFF)
		end
	elseif itemEx.itemid == 231 and itemEx.actionid == 100 then
		doTransformItem(itemEx.uid, 482)
		doDecayItem(itemEx.uid)
	else
		return false
	end
	return true
end
(use actionid 100)
 
Last edited:
If you wanted it to be somewhat random to open the holes, You could do it like this right?
(Correct me if im wrong ^^,)

Change
LUA:
elseif itemEx.itemid == 231 and itemEx.actionid == 100 then
		doTransformItem(itemEx.uid, 482)
		doDecayItem(itemEx.uid)
	else

To
LUA:
elseif itemEx.itemid == 231 and itemEx.actionid == 100 then
		local rand = math.random(30)
		if rand < 12 then
		doTransformItem(itemEx.uid, 482)
		doDecayItem(itemEx.uid)
	else
 
If you wanted it to be somewhat random to open the holes, You could do it like this right?
(Correct me if im wrong ^^,)

Change
LUA:
elseif itemEx.itemid == 231 and itemEx.actionid == 100 then
		doTransformItem(itemEx.uid, 482)
		doDecayItem(itemEx.uid)
	else

To
LUA:
elseif itemEx.itemid == 231 and itemEx.actionid == 100 then
		local rand = math.random(30)
		if rand < 12 then
		doTransformItem(itemEx.uid, 482)
		doDecayItem(itemEx.uid)
	else


Thanks you. Can you add duration 3 min to close hole? and write the final script. It will be nice :)
 
Last edited:
Last question what is wrong here:

Code:
function onUse(cid, item, frompos, item2, topos)
 if item2.itemid == 28 then
  return 0
 end
 if item2.itemid == 468 then
  doTransformItem(item2.uid,469)
  doDecayItem(item2.uid)
 elseif item2.itemid == 481 then
  doTransformItem(item2.uid,482)
  doDecayItem(item2.uid)
 elseif (item2.itemid == 231 and item2.uid == 4000) then
  local rand = math.random(0,30)
  if rand < 12 then
  doTransformItem(item2.uid, 482)
  doDecayItem(item2.uid)
  doSendMagicEffect(topos,2)
 elseif item2.itemid == 483 then
  doTransformItem(item2.uid,484)
  doDecayItem(item2.uid)
 elseif item2.itemid == 231 then
  rand = math.random(1,30)
  if rand == 12 then
   doSummonCreature("Scarab", topos)
  elseif rand == 20 then
   doPlayerAddItem(cid,2159,1)
  else
   doSendMagicEffect(topos,2)
  end
 else
  return 0
 end
 return 1
 end

http://www12.speedy*****malware.localhost/files/24085522/download/1212.bmp
 
I always write it like this then:

LUA:
 		local rand = math.random(0,30)

If you want to get random number from 1 to something, you can use math.random(number), if you want to set MINIMUM number, you have to use math.random(MIN, MAX). :p


If you wanted it to be somewhat random to open the holes, You could do it like this right?
(Correct me if im wrong ^^,)

Change
LUA:
elseif itemEx.itemid == 231 and itemEx.actionid == 100 then
		doTransformItem(itemEx.uid, 482)
		doDecayItem(itemEx.uid)
	else

To
LUA:
elseif itemEx.itemid == 231 and itemEx.actionid == 100 then
		local rand = math.random(30)
		if rand < 12 then
		doTransformItem(itemEx.uid, 482)
		doDecayItem(itemEx.uid)
	else


You miss end, bro.
 
If you want to get random number from 1 to something, you can use math.random(number), if you want to set MINIMUM number, you have to use math.random(MIN, MAX). :p





You miss end, bro.

Not sure where i missed it (Im no where near a good lua scripter ^^,) But if i remember correct; every IF needs an end right?
So the final code should look somewhat like this then

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isInArray({468, 481, 483}, itemEx.itemid) then
		doTransformItem(itemEx.uid, itemEx.itemid + 1)
		doDecayItem(itemEx.uid)
	elseif item2.itemid == 231 then
		local rand = math.random(30)
		if rand < 12 then
			doSummonCreature("Scarab", toPosition)
		elseif rand == 20 then
			doPlayerAddItem(cid, 2159, 1)
		else
			doSendMagicEffect(toPosition, CONST_ME_POFF)
		end
elseif itemEx.itemid == 231 and itemEx.actionid == 100 then
		local rand = math.random(30)
		if rand < 12 then
		doTransformItem(itemEx.uid, 482)
		doDecayItem(itemEx.uid)
	else
		end
		return false
	end
	return true
end
 
Back
Top