kotz
New Member
- Joined
- Nov 11, 2010
- Messages
- 17
- Reaction score
- 1
I Have one bomberman system, and i did on chain reaction explosion, but he call the event passing 1 milesecond to starter, and the after event start in 5 seconds, if you drop a bomb in this time the bomb explodes
in the time it left.
Ex. Drop bomb 1 ( 5 seconds)
Drop bomb 2 on the same line in 2 seconds left to first bomb explodes (5 seconds)
In 2 seconds the two bombs explodes in same time, but the second event is dispared in 3 seconds left ;s
Anyone have any idea how to solve??
in the time it left.
Ex. Drop bomb 1 ( 5 seconds)
Drop bomb 2 on the same line in 2 seconds left to first bomb explodes (5 seconds)
In 2 seconds the two bombs explodes in same time, but the second event is dispared in 3 seconds left ;s
Anyone have any idea how to solve??
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=1, y=1, z=7},
to = {x=2905, y=2525, z=7},
storage = {placed = 10001, max = 10002, radius = 10003},
delay = 5000, bombID = 386, effect = CONST_ME_FIREAREA, blockID = 436, text = "BOOM!",
temple = {x = 1023, y = 1024, z = 7}
}
local function boom(pos, cid)
local v = getTileItemById(pos, t.bombID).uid
if v > 0 then
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, 17)
doTeleportThing(c, t.temple)
doSendMagicEffect(t.temple, 10)
local n1, n2 = getPlayerName(c), getPlayerName(cid)
doBroadcastMessage(n1==n2 and n1 .. " killed " .. (getPlayerSex(c) == 0 and "her" or "him") .. "self!" or n1 .. " was killed by " .. n2 .. "!", MESSAGE_STATUS_WARNING)
--local a = getPlayersInRange({x=497, y=500, z=9}, 7, 5)
--if #a < 2 then
--doBroadcastMessage(getPlayerName(a[1]) .. " has won the match!", MESSAGE_STATUS_WARNING)
--doPlayerAddLevel(a[1], 1)
--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)
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
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 and v > 1 then
doSendMagicEffect(_pos, t.effect)
local c = getTopCreature(_pos).uid
if isPlayer(c) and isInRange(getThingPos(c), t.from, t.to) then
doSendMagicEffect(_pos, 17)
doTeleportThing(c, t.temple)
doSendMagicEffect(t.temple, 10)
local n1, n2 = getPlayerName(c), getPlayerName(cid)
doBroadcastMessage(n1==n2 and n1 .. " killed " .. (getPlayerSex(c) == 0 and "her" or "him") .. "self!" or n1 .. " was killed by " .. n2 .. "!", MESSAGE_STATUS_WARNING)
--local a = getPlayersInRange({x=497, y=500, z=9}, 7, 5)
--if #a < 2 then
--doBroadcastMessage(getPlayerName(a[1]) .. " has won the match!", MESSAGE_STATUS_WARNING)
--doPlayerAddLevel(a[1], 1)
--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) == RETURNVALUE_NOERROR or getTileItemById(_pos, t.bombID).uid > 0 then
addEvent(boom, 1, getThingPos(getTileItemById(_pos, t.bombID).uid), cid)
return true
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
end
function onSay(cid, words, param, channel)
local b = getTileItemById(getThingPos(cid), t.bombID).uid
if b > 1 then
--doCreatureSay(cid, "Ja tem uma bomba aqui", TALKTYPE_ORANGE_2, false, nil, getThingPos(cid)) -- FALAR QUE JA TEM UMA BOMBA
return true
else
setPlayerStorageValue(cid, t.storage.placed, 0) --ARRUMAR O STRAGE QUAND BUGA
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), 5))
--doCreatureSay(cid, getPlayerStorageValue(cid, t.storage.placed), TALKTYPE_ORANGE_2, false, nil, getThingPos(cid)) SABER O VALOR DO STORAGE
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