Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.05 KB | None | 0 0
  1. local holes = {468, 481, 483, 7932, 8579}
  2. local sand = {231, 9059}
  3.  
  4. local config = {
  5.     soul = 1
  6. }
  7.  
  8. local trees = {
  9.     [5410] = {maketime = 75 * 1000, bloomtime = 70*1000, deathtime = 50*1000, makeid = 4008, growid = 4006, MakeMsg = "Your orange tree has grown!", BloomMsg="Your orange tree has fully grown! Harvest it before it withers!", DeathMsg="Your orange tree has withered."};
  10.     [5411] = {maketime = 45 * 1000, bloomtime = 45*1000, deathtime = 30*1000, makeid = 5092, growid = 5094, MakeMsg = "Your banana tree has grown!", BloomMsg="Your banana tree has fully grown! Harvest it before it withers!", DeathMsg="Your banana tree has withered."};
  11.     [5412] = {maketime = 60 * 1000, bloomtime = 60*1000, deathtime = 50*1000, makeid = 2726, growid = 5096, MakeMsg = "Your coconut tree has grown!", BloomMsg="Your coconut tree has fully grown! Harvest it before it withers!", DeathMsg="Your coconut tree has withered."};
  12.     [5413] = {maketime = 30 * 1000, bloomtime = 30*1000, deathtime = 45*1000, makeid = 2786, growid = 2785, MakeMsg = "Your blueberry bush has grown!", BloomMsg="Your blueberry busy has fully grown! Harvest it before it withers!", DeathMsg="Your blueberry bush has withered."};
  13.     [5414] = {maketime = 70 * 1000, bloomtime = 70*1000, deathtime = 50*1000, makeid = 5156, growid = 5157, MakeMsg = "Your mango tree has grown!", BloomMsg="Your mango tree has fully grown! Harvest it before it withers!", DeathMsg="Your mango tree has withered."};
  14. }
  15.  
  16.  
  17. function onUse(cid, item, fromPosition, itemEx, toPosition)
  18.     if(isInArray(holes, itemEx.itemid)) then
  19.         local newId = itemEx.itemid + 1
  20.         if(itemEx.itemid == 8579) then
  21.             newId = 8585
  22.         end
  23.         doTransformItem(itemEx.uid, newId)
  24.         doDecayItem(itemEx.uid)
  25.     elseif(isInArray(sand, itemEx.itemid)) then
  26.         local rand = math.random(1, 100)
  27.         if(itemEx.actionid  == 100 and rand <= 20) then
  28.             doTransformItem(itemEx.uid, 489)
  29.             doDecayItem(itemEx.uid)
  30.         elseif(rand >= 1 and rand <= 5) then
  31.             doCreateItem(2159, 1, toPosition)
  32.         elseif(rand > 85) then
  33.             doCreateMonster("Scarab", toPosition, false)
  34.         end
  35.     elseif(itemEx.itemid == 7732 and itemEx.type == 1) then
  36.         local ground_position = {x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 0}
  37.         local ground_info = getThingfromPos(ground_position)
  38.         if(isInArray(config.aids, ground_info.actionid)) then
  39.             if(ground_info.itemid == 806) then
  40.                 if(getPlayerSoul(cid) >= config.soul) then
  41.                     if(getPlayerItemCount(cid, 7734) >= 1) then
  42.                         if(trees[ground_info.actionid] ~= nil then
  43.                             addEvent(doMakeTree, trees[ground_info.actionid].maketime, toPosition, cid, ground_info.actionid)
  44.                         end
  45.                         doRemoveItem(itemEx.uid, 1)
  46.                         doTransformItem(ground_info.uid, 804)
  47.                         doSendMagicEffect(ground_position, 53)
  48.                         doPlayerAddSoul(cid, -config.soul)
  49.                         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You dug a hole and watered the seeds.")
  50.                     else
  51.                         doPlayerSendCancel(cid, "You need a watering can so you can water the seeds.")
  52.                     end
  53.                 else
  54.                     doPlayerSendCancel(cid, "You don't have enough soul points.")
  55.                 end
  56.             else
  57.                 doPlayerSendCancel(cid, "You need to soil the ground first.")
  58.             end
  59.         else
  60.             doPlayerSendCancel(cid, "Sorry, not possible.")
  61.         end
  62.     else
  63.         local ground_position = {x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 0}
  64.         local ground_info = getThingfromPos(ground_position)
  65.         if(isInArray(config.aids, ground_info.actionid)) then
  66.             if(ground_info.itemid == 806) then
  67.                 if(itemEx.type ~= 1) then
  68.                     doPlayerSendCancel(cid, "You need to place one seed.")
  69.                 end
  70.             else
  71.                 doPlayerSendCancel(cid, "Sorry, not possible.")
  72.             end
  73.         else
  74.             doPlayerSendCancel(cid, "Sorry, not possible.")
  75.         end
  76.     end
  77.     return true
  78. end
  79.  
  80. -- ORANGE --
  81. function doMakeTree(pos, cid, aid)
  82.     local tree = getThingfromPos{x = pos.x, y = pos.y, z = pos.z, stackpos = 1}
  83.     if(tree.itemid ~= trees[aid].makeid) then
  84.         local treePos = {x = pos.x, y = pos.y, z = pos.z}
  85.         doCreateItem(trees[aid].makeid, 1, treePos)
  86.         if(isPlayer(cid)) then
  87.             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, trees[aid].MakeMsg)
  88.             if(isInArea(getPlayerPosition(cid), treePos, treePos)) then
  89.                 doMoveCreature(cid, SOUTH)
  90.             end
  91.         end
  92.         addEvent(doBloomTree, trees[aid].bloomtime, {x = pos.x, y = pos.y, z = pos.z }, cid, aid)
  93.     end
  94. end
  95.  
  96. function doBloomTree(pos, cid, aid)
  97.     local tree = getThingfromPos{x = pos.x, y = pos.y, z = pos.z, stackpos = 1}
  98.     if(tree.itemid == trees[aid].makeid) then
  99.         doTransformItem(tree.uid, trees[aid].growid)
  100.         if(isPlayer(cid)) then
  101.             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, trees[aid].BloomMsg)
  102.         end
  103.         addEvent(doDieTree, trees[aid].deathtime, {x = pos.x, y = pos.y, z = pos.z }, cid, aid)
  104.     end
  105. end
  106.  
  107. function doDieTree(pos, cid, aid)
  108.     local tree = getThingfromPos{x = pos.x, y = pos.y, z = pos.z, stackpos = 1}
  109.     local ground = getThingfromPos{x = pos.x, y = pos.y, z = pos.z, stackpos = 0}
  110.     doRemoveItem(tree.uid)
  111.     doTransformItem(ground.uid, 103)
  112.     if(isPlayer(cid)) then
  113.         doPlayerSendTextMessage(parameter.cid, MESSAGE_INFO_DESCR, trees[aid].DeathMsg)
  114.     end
  115. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement