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

Problem with plastic bomb

Zorinhi

New Member
Joined
Apr 29, 2009
Messages
53
Reaction score
1
What can be bad in this script or what can i do? because when i use it. Its says that i cant use it in pz but im not in pz ._.'


Code:
local PLANTING_DELAY = 5 --seconds
local EXPLOSION_DELAY = 5000 --milliseconds
local MAX_HIT = 500
local MIN_HIT = 100
local PVP = true -- true for PVP, false for Non-PVP
local PLAYERS = {}

function isInArray2(table, valor)
  for i,j in pairs(table) do
    if (j == valor) then
      return i
    end
  end
  return 0
end

function explosion(info)
   area = {
        {0,0,0,0,0},
        {0,1,1,1,0},
        {0,1,1,1,0},
        {0,1,1,1,0},
        {0,0,0,0,0},
       }
    hitpos = {x=info.pos.x, y=info.pos.y, z=info.pos.z, stackpos=253}
    center = {}
    center.y = math.floor(table.getn(area)/2)+1
    for i in ipairs(area) do
        center.x = math.floor(table.getn(area[i])/2)+1
        for j, v in ipairs(area[i]) do
            if (v == 1) then
            hitpos.x = info.pos.x + (j - center.x)
            hitpos.y = info.pos.y + (i - center.y)
            if (getTilePzInfo(hitpos) == false) then
                effect = 4
                if ((j == center.x) and (i == center.y)) then
                    doSendAnimatedText(hitpos,"KABOOOOOM",TEXTCOLOR_RED)
                    hitpoints = MAX_HIT
                    effect = 5
                else
                    hitpoints = math.random(MIN_HIT,MAX_HIT)
                end
                if isPlayer(victim.uid) then
                    if PVP then
                        doPlayerSendTextMessage(victim.uid,20,'You have lost '..hitpoints..' hitpoints by '..getCreatureName(info.player)..'\'s plastic bomb.')
                    else
                        hitpoints = 0
                    end
                end
                if isCreature(victim.uid) then
                    doCreatureAddHealth(victim.uid,-hitpoints)
                end
                doSendMagicEffect(hitpos,effect)
                end
            end
        end
    end
    PLAYERS[isInArray2(PLAYERS, info.player)] = 0
  return true
end

function planting(info)
  if info.num == PLANTING_DELAY then
    doPlayerSendTextMessage(info.player,22,'Plastic Bomb successfully planted!')
    doCreatureSetNoMove(info.player, false)
    addEvent(explosion,EXPLOSION_DELAY,info)
  else
    info.num = info.num + 1
    doPlayerSendTextMessage(info.player,22,info.num ..'...')
    addEvent(planting,1000,info)
  end
  return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
  position = getThingPos(item.uid)
  if (getTilePzInfo(position) == 0) then
       if (isInArray2(PLAYERS, cid) == 0) then    
        table.insert(PLAYERS, cid)
        doSendMagicEffect(frompos,3)
        info = {player = cid, pos = position, num = 1}
        doPlayerSendTextMessage(cid,22,'Planting the bomb...')
        doPlayerSendTextMessage(cid,22,'1...')
        doCreatureSetNoMove(cid, true)
        doRemoveItem(item.uid,1)
        addEvent(planting,1000,info)
    else
        doPlayerSendCancel(cid,'You can only plant one bomb at the same time.')
    end
  else
    doPlayerSendCancel(cid,'You can not plant this bomb in a PZ!')
  end    
  return true
end
 
Back
Top