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

Help with bomberman event!

lSenturion2

Member
Joined
Oct 2, 2019
Messages
40
Reaction score
17
I have this script for Bomberman event...

What I want is that instead of item 9468 (blockID) being destroyed I want it to become item 12372.


Lua:
function getPlayersInRange(position, radiusx, radiusy)
local creaturesList = {}
for x = -radiusx, radiusx do
for y = -radiusy, radiusy do
if not (x == 0 and y == 0) then
local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z})
if creature.type == 1 then
table.insert(creaturesList, creature.uid)
end
end
end
end

local creature = getTopCreature(position)
if creature.type == 1 then
if not(table.find(creaturesList, creature.uid)) then
table.insert(creaturesList, creature.uid)
end
end
return creaturesList
end

function isPositionInArray(haystack, needle)
for i = 1, #haystack do
if haystack[i].x == needle.x and haystack[i].y == needle.y and haystack[i].z == needle.z then
return true
end
end
return false
end

local t = {
from = {x = 19067, y = 19034, z = 7}, --- Zona Num 1
to = {x = 19089, y = 19056, z = 7}, ---- zona Num 8
storage = {
placed = 10001,
max = 10002,
radius = 10003
},
delay = 3000,
bombID = 14993,
effect = CONST_ME_FIREAREA,
blockID = 9468,
blockIK = 2160,
text = "BOMB!",
temple = {x = 19079, y = 19064, z = 7}, --- aqui aparecen cuando pierden
exceptions = {
{x = 19067, y = 19034, z = 7}, --- zona 1
{x = 19068, y = 19034, z = 7}, --- zona 2
{x = 19067, y = 19035, z = 7}, --- zona 3

{x = 19088, y = 19034, z = 7}, --- zona 5
{x = 19089, y = 19034, z = 7}, --- zona 4
{x = 19089, y = 19035, z = 7}, --- zona 6

{x = 19067, y = 19055, z = 7}, --- zona 12
{x = 19067, y = 19056, z = 7}, --- zona 11
{x = 19068, y = 19056, z = 7}, --- zona 10

{x = 19089, y = 19055, z = 7}, --- zona 8
{x = 19089, y = 19056, z = 7}, --- zona 9
{x = 19088, y = 19056, z = 7} --- zona 7
}
}
function reset()
local dummy = doCreateItem(14908, 1, {x = 19078, y = 19045, z = 7}) --- Centro Del Juego
for x = t.from.x, t.to.x do
for y = t.from.y, t.to.y do
local pos = {x=x,y=y,z=t.from.z}
local i1, i2, i3 = getTileItemById(pos, 8304).uid, getTileItemById(pos, 8306).uid, getTileItemById(pos, 8310).uid
if i1 > 0 then
doCreateItem(getTileItemById(pos, 2160).uid)
end
if i2 > 0 then
doCreateItem(getTileItemById(pos, 2160).uid)
end
if i3 > 0 then
doCreateItem(getTileItemById(pos, 2160).uid)
end
if queryTileAddThing(dummy, pos, 4) == RETURNVALUE_NOERROR and not isPositionInArray(t.exceptions, pos) then
doCreateItem(t.blockID, 1, pos)
end
end
end
doCreateItem(getTileItemById(pos, 2160).uid)
end

local function boom(pos, cid)
local v = getTileItemById(pos, t.bombID).uid
if isPlayer(cid) and isInRange(getThingPos(cid), t.from, t.to) then
setPlayerStorageValue(cid, t.storage.placed, getPlayerStorageValue(cid, t.storage.placed) - 1)
doCreatureSay(cid, t.text, TALKTYPE_ORANGE_2, false, nil, pos)
doSendMagicEffect(pos, t.effect)
local c = getTopCreature(pos).uid
if isPlayer(c) and isInRange(getThingPos(c), t.from, t.to) then
doSendMagicEffect(pos, CONST_ME_GIFT_WRAPS)
doTeleportThing(c, t.temple)
doSendMagicEffect(t.temple, CONST_ME_MORTAREA)
local n1, n2 = getPlayerName(c), getPlayerName(cid)
doBroadcastMessage(n1==n2 and n1 .. " killed " .. (getPlayerSex(c) == 0 and "her" or "him") .. "self![Bomberman]" or n1 .. " was killed by " .. n2 .. "![Bomberman]", MESSAGE_STATUS_WARNING)
local a = getPlayersInRange({x = 19078, y = 19045, z = 7}, 7, 5) --- CENTRO Del Juego
if #a < 2 then
doBroadcastMessage(getPlayerName(a[1]) .. " has won the match![Bomberman]", MESSAGE_STATUS_WARNING)
doTeleportThing(a[1], t.temple)
doSendMagicEffect(t.temple, CONST_ME_FIREWORK_RED)
reset()
reset()
end
else
local b = getTileItemById(pos, t.blockID).uid
if b > 0 then
doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
doCreateItem(getTileItemById(pos, 2160).uid)
local r = math.random(10)
if r < 4 then
doCreateItem(r==1 and 8304 or r==2 and 8306 or r==3 and 8310, 1, _pos)
end
end
end
local N, E, W, S, l = 1, 1, 1, 1, getPlayerStorageValue(cid, t.storage.radius)
function loopDir(dir)
local _pos = {x=pos.x+(dir=="E" and E or dir=="W" and -W or 0), y=pos.y+(dir=="N" and -N or dir=="S" and S or 0), z=pos.z}
if queryTileAddThing(v, _pos, 4) == RETURNVALUE_NOERROR or getTileItemById(_pos, t.blockID).uid > 0 then
doSendMagicEffect(_pos, t.effect)
local c = getTopCreature(_pos).uid
if isPlayer(c) and isInRange(getThingPos(c), t.from, t.to) then
doSendMagicEffect(_pos, CONST_ME_GIFT_WRAPS)
doTeleportThing(c, t.temple)
doSendMagicEffect(t.temple, CONST_ME_MORTAREA)
local n1, n2 = getPlayerName(c), getPlayerName(cid)
doBroadcastMessage(n1==n2 and n1 .. " killed " .. (getPlayerSex(c) == 0 and "her" or "him") .. "self! - [Bomberman]" or n1 .. " was killed by " .. n2 .. "! - [Bomberman]", MESSAGE_STATUS_WARNING)
local a = getPlayersInRange({x = 19078, y = 19045, z = 7}, 7, 5) --- CENTRO DEl JUEGO
if #a < 2 then
doBroadcastMessage(getPlayerName(a[1]) .. " has won the match![Bomberman]", MESSAGE_STATUS_WARNING)
doTeleportThing(a[1], t.temple)
doSendMagicEffect(t.temple, CONST_ME_FIREWORK_RED)
reset()
reset()
return "endgame"
end
else
local b = getTileItemById(_pos, t.blockID).uid
if b > 0 then
doSendMagicEffect(_pos, CONST_ME_BLOCKHIT)
doRemoveItem(b)

local r = math.random(10)
if r < 4 then
doCreateItem(r==1 and 8304 or r==2 and 8306 or r==3 and 8310, 1, _pos)
end

return false




end
end
elseif queryTileAddThing(v, _pos, 4) == 3 then
return false
end
return true
end
while N <= l do
local q = loopDir("N")
if q == "endgame" then
return doRemoveItem(v, 1)
elseif not q then
break
else
N = N + 1
end
end
while E <= l do
local q = loopDir("E")
if q == "endgame" then
return doRemoveItem(v, 1)
elseif not q then
break
else
E = E + 1
end
end
while W <= l do
local q = loopDir("W")
if q == "endgame" then
return doRemoveItem(v, 1)
elseif not q then
break
else
W = W + 1
end
end
while S <= l do
local q = loopDir("S")
if q == "endgame" then
return doRemoveItem(v, 1)
elseif not q then
break
else
S = S + 1
end
end
end
doRemoveItem(v, 1)
end
function onSay(cid, words, param, channel)
if isInRange(getThingPos(cid), t.from, t.to) then
setPlayerStorageValue(cid, t.storage.placed, math.max(getPlayerStorageValue(cid, t.storage.placed), 0))
setPlayerStorageValue(cid, t.storage.max, math.max(getPlayerStorageValue(cid, t.storage.max), 1))
setPlayerStorageValue(cid, t.storage.radius, math.max(getPlayerStorageValue(cid, t.storage.radius), 1))
if getPlayerStorageValue(cid, t.storage.placed) < getPlayerStorageValue(cid, t.storage.max) then
doCreateItem(t.bombID, 1, getThingPos(cid))
addEvent(boom, t.delay, getThingPos(cid), cid)
setPlayerStorageValue(cid, t.storage.placed, getPlayerStorageValue(cid, t.storage.placed) + 1)
end
return true
end
end
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,564
Solutions
386
Reaction score
3,688
line 145 is where it's removed.

So you can transform the item instead of removing it.

Lua:
doTransformItem(b, 12372)
 
OP
L

lSenturion2

Member
Joined
Oct 2, 2019
Messages
40
Reaction score
17
It works, but on area the attribute "DecayTo" does not works :s, The item is created successfully but it dont decayto xd.

I have the bomberman event, but it doesnt works 100%, I did my own idea, becaus the barrels they don't reappear once you've destroyed them. So I decided to implement that when they are destroyed by the "bomb" they become another item that I made so that when they have the "decayTo" attribute they become the barrel again after 20 minutes.

Code:
function getPlayersInRange(position, radiusx, radiusy)
   local creaturesList = {}
   for x = -radiusx, radiusx do
      for y = -radiusy, radiusy do
         if not (x == 0 and y == 0) then
            local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z})
            if creature.type == 1 then
               table.insert(creaturesList, creature.uid)
            end
         end
      end
   end

   local creature = getTopCreature(position)
   if creature.type == 1 then
      if not(table.find(creaturesList, creature.uid)) then
         table.insert(creaturesList, creature.uid)
      end
   end
   return creaturesList
end

function isPositionInArray(haystack, needle)
   for i = 1, #haystack do
      if haystack[i].x == needle.x and haystack[i].y == needle.y and haystack[i].z == needle.z then
         return true
      end
   end
   return false
end

local t = {
   from = {x = 19067, y = 19034, z = 7}, --- Zona Num 1
   to = {x = 19089, y = 19056, z = 7}, ---- zona Num 8
   storage = {
      placed = 10001,
      max = 10002,
      radius = 10003
   },
   delay = 3000,
   bombID = 14993,
   effect = CONST_ME_FIREAREA,
   blockID = 9468,
   blockIK = 2160,
   text = "BOMB!",
   temple = {x = 19079, y = 19064, z = 7}, --- aqui aparecen cuando pierden
   exceptions = {
      {x = 19067, y = 19034, z = 7}, --- zona 1
      {x = 19068, y = 19034, z = 7}, --- zona 2
      {x = 19067, y = 19035, z = 7}, --- zona 3

      {x = 19088, y = 19034, z = 7}, --- zona 5
      {x = 19089, y = 19034, z = 7}, --- zona 4
      {x = 19089, y = 19035, z = 7}, --- zona 6

      {x = 19067, y = 19055, z = 7}, --- zona 12
      {x = 19067, y = 19056, z = 7}, --- zona 11
      {x = 19068, y = 19056, z = 7}, --- zona 10

      {x = 19089, y = 19055, z = 7}, --- zona 8
      {x = 19089, y = 19056, z = 7}, --- zona 9
      {x = 19088, y = 19056, z = 7} --- zona 7
   }
}
function reset()
   local dummy = doCreateItem(14908, 1, {x = 19078, y = 19045, z = 7}) --- Centro Del Juego
   for x = t.from.x, t.to.x do
      for y = t.from.y, t.to.y do
         local pos = {x=x,y=y,z=t.from.z}
         local i1, i2, i3 = getTileItemById(pos, 14988).uid, getTileItemById(pos, 14990).uid, getTileItemById(pos, 14989).uid
         if i1 > 0 then
            doCreateItem(getTileItemById(pos, 2160).uid)
         end
         if i2 > 0 then
            doCreateItem(getTileItemById(pos, 2160).uid)
         end
         if i3 > 0 then
            doCreateItem(getTileItemById(pos, 2160).uid)
         end
         if queryTileAddThing(dummy, pos, 4) == RETURNVALUE_NOERROR and not isPositionInArray(t.exceptions, pos) then
            doCreateItem(t.blockID, 1, pos)
         end
      end
   end
   doCreateItem(getTileItemById(pos, 2160).uid)
end

local function boom(pos, cid)
   local v = getTileItemById(pos, t.bombID).uid
   if isPlayer(cid) and isInRange(getThingPos(cid), t.from, t.to) then
      setPlayerStorageValue(cid, t.storage.placed, getPlayerStorageValue(cid, t.storage.placed) - 1)
      doCreatureSay(cid, t.text, TALKTYPE_ORANGE_2, false, nil, pos)
      doSendMagicEffect(pos, t.effect)
      local c = getTopCreature(pos).uid
      if isPlayer(c) and isInRange(getThingPos(c), t.from, t.to) then
         doSendMagicEffect(pos, CONST_ME_GIFT_WRAPS)
         doTeleportThing(c, t.temple)
         doSendMagicEffect(t.temple, CONST_ME_MORTAREA)
         local n1, n2 = getPlayerName(c), getPlayerName(cid)
         doBroadcastMessage(n1==n2 and n1 .. " killed " .. (getPlayerSex(c) == 0 and "her" or "him") .. "self![Bomberman]" or n1 .. " was killed by " .. n2 .. "![Bomberman]", MESSAGE_STATUS_WARNING)
         local a = getPlayersInRange({x = 19078, y = 19045, z = 7}, 7, 5) --- CENTRO Del Juego
         if #a < 2 then
            doBroadcastMessage(getPlayerName(a[1]) .. " has won the match![Bomberman]", MESSAGE_STATUS_WARNING)
            doTeleportThing(a[1], t.temple)
            doSendMagicEffect(t.temple, CONST_ME_FIREWORK_RED)
            reset()
            reset()
         end
      else
         local b = getTileItemById(pos, t.blockID).uid
         if b > 0 then
            doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
            doCreateItem(getTileItemById(pos, 2160).uid)
            local r = math.random(10)
            if r < 4 then
               doCreateItem(r==1 and 14988 or r==2 and 14990 or r==3 and 14989, 1, _pos)
            end
         end
      end
      local N, E, W, S, l = 1, 1, 1, 1, getPlayerStorageValue(cid, t.storage.radius)
      function loopDir(dir)
         local _pos = {x=pos.x+(dir=="E" and E or dir=="W" and -W or 0), y=pos.y+(dir=="N" and -N or dir=="S" and S or 0), z=pos.z}
         if queryTileAddThing(v, _pos, 4) == RETURNVALUE_NOERROR or getTileItemById(_pos, t.blockID).uid > 0 then
            doSendMagicEffect(_pos, t.effect)
            local c = getTopCreature(_pos).uid
            if isPlayer(c) and isInRange(getThingPos(c), t.from, t.to) then
               doSendMagicEffect(_pos, CONST_ME_GIFT_WRAPS)
               doTeleportThing(c, t.temple)
               doSendMagicEffect(t.temple, CONST_ME_MORTAREA)
               local n1, n2 = getPlayerName(c), getPlayerName(cid)
               doBroadcastMessage(n1==n2 and n1 .. " killed " .. (getPlayerSex(c) == 0 and "her" or "him") .. "self! - [Bomberman]" or n1 .. " was killed by " .. n2 .. "! - [Bomberman]", MESSAGE_STATUS_WARNING)
               local a = getPlayersInRange({x = 19078, y = 19045, z = 7}, 7, 5) --- CENTRO DEl JUEGO
               if #a < 2 then
                  doBroadcastMessage(getPlayerName(a[1]) .. " has won the match![Bomberman]", MESSAGE_STATUS_WARNING)
                  doTeleportThing(a[1], t.temple)
                  doSendMagicEffect(t.temple, CONST_ME_FIREWORK_RED)
                  reset()
                  reset()
                  return "endgame"
               end
            else
               local b = getTileItemById(_pos, t.blockID).uid
               if b > 0 then
                  doSendMagicEffect(_pos, CONST_ME_BLOCKHIT)
                  doTransformItem(b, 14998)

                  local r = math.random(10)
                  if r < 4 then
                     doCreateItem(r==1 and 14988 or r==2 and 14990 or r==3 and 14989, 1, _pos)
                  end

                  return false




               end
            end
         elseif queryTileAddThing(v, _pos, 4) == 3 then
            return false
         end
         return true
      end
      while N <= l do
         local q = loopDir("N")
         if q == "endgame" then
            return doRemoveItem(v, 1)
         elseif not q then
            break
         else
            N = N + 1
         end
      end
      while E <= l do
         local q = loopDir("E")
         if q == "endgame" then
            return doRemoveItem(v, 1)
         elseif not q then
            break
         else
            E = E + 1
         end
      end
      while W <= l do
         local q = loopDir("W")
         if q == "endgame" then
            return doRemoveItem(v, 1)
         elseif not q then
            break
         else
            W = W + 1
         end
      end
      while S <= l do
         local q = loopDir("S")
         if q == "endgame" then
            return doRemoveItem(v, 1)
         elseif not q then
            break
         else
            S = S + 1
         end
      end
   end
   doRemoveItem(v, 1)
end
function onSay(cid, words, param, channel)
   if isInRange(getThingPos(cid), t.from, t.to) then
      setPlayerStorageValue(cid, t.storage.placed, math.max(getPlayerStorageValue(cid, t.storage.placed), 0))
      setPlayerStorageValue(cid, t.storage.max, math.max(getPlayerStorageValue(cid, t.storage.max), 1))
      setPlayerStorageValue(cid, t.storage.radius, math.max(getPlayerStorageValue(cid, t.storage.radius), 1))
      if getPlayerStorageValue(cid, t.storage.placed) < getPlayerStorageValue(cid, t.storage.max) then
         doCreateItem(t.bombID, 1, getThingPos(cid))
         addEvent(boom, t.delay, getThingPos(cid), cid)
         setPlayerStorageValue(cid, t.storage.placed, getPlayerStorageValue(cid, t.storage.placed) + 1)
      end
      return true
   end
end
 
Last edited:

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,244
Solutions
71
Reaction score
554
Location
Hell
Format your code before posting.
If you don't know how, use one of the online tools:
 
OP
L

lSenturion2

Member
Joined
Oct 2, 2019
Messages
40
Reaction score
17
Format your code before posting.
If you don't know how, use one of the online tools:
Can u help me with my problem please???
 
Top