Ir para conteúdo

Featured Replies

Postado

este é um script que cria itens em aréa, onde os itens vão ficar depende da configuração do script. O problema é que os itens podem ser criados encima da água, ou até em lugares sem tile (como no print). Oque eu quero é que se o lugar onde o item for criado tiver água embaixo, ou não tiver algum tile o item não seja criado nesse local mas todos os outros seriam criados normalmente se não tivesse água ou nenhum tile embaixo do local, quem poder ajudar agradeço desde já.

 

Script:

Spoiler


local cfg = {
    items_area = {
        {
            itemid = 11497,
            area = {
                {0,0,0,0,0,0,0},
                {0,1,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,2,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,1,0,0},
                {0,0,0,0,0,0,0}
            }
        },
        {
            itemid = 11498,
            area = {
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,2,0,0,1},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,1,0,0,0}
            }
        },
        {
            itemid = 11499,
            area = {
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,2,0,0,0},
                {0,1,0,0,0,0,0},
                {0,0,0,0,0,0,1},
                {0,0,0,0,0,0,0}
            }
        },
        {
            itemid = 11500,
            area = {
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {1,0,0,2,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0}
            }
        },
        {
            itemid = 11501,
            area = {
                {0,0,0,0,0,0,0},
                {0,0,0,0,1,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,2,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,1,0,0,0,0},
                {0,0,0,0,0,0,0}
            }    
        }
    },
    remove_time = 10, -- tempo em segundos para remover
    onuse_message = "Uma area foi atingida pelo Genjutsu de %s" -- message ao usar
}

local combats = {}
for i, t in ipairs(cfg.items_area) do
    combats = createCombatObject()
    setCombatArea(combats, createCombatArea(t.area))
    function onTargetTile(cid, position)
        doCreateItem(t.itemid, 1, position)
        addEvent(function()
            local thing = getTileItemById(position, t.itemid).uid
            if(thing ~= 0) then
                doRemoveItem(thing)
            end
        end, cfg.remove_time * 1000)
    end
    setCombatCallback(combats, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
end

function onCastSpell(cid, var)

local outfit = {lookType = 90, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}
local time1 = 4000 -- segundos que ficará com a outfit
local position = {x=getCreaturePosition(cid).x+1, y=getCreaturePosition(cid).y+1, z=getCreaturePosition(cid).z}

    for i = 1, #combats do
        doCombat(cid, combats, var)
        doSetCreatureOutfit(cid, outfit, time1)
        doSendMagicEffect(position, 193)
    end

    doBroadcastMessage(cfg.onuse_message:format(getCreatureName(cid)), MESSAGE_STATUS_WARNING)
    return true
end

123996435_fuckfuckfuckfuckfuck.PNG.c1e1fd152cf2c35579b34fc989894dd7.PNG

646313217_fuckmylife.PNG.9e035539da195853ecdcca69eafb30b6.PNG

Editado por Mark Charlotte (veja o histórico de edições)

  • Respostas 9
  • Visualizações 1.2k
  • Created
  • Última resposta

Top Posters In This Topic

Posted Images

Postado

@Mark Charlotte 

Spoiler

local cfg = {
    items_area = {
        {
            itemid = 11497,
            area = {
                {0,0,0,0,0,0,0},
                {0,1,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,2,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,1,0,0},
                {0,0,0,0,0,0,0}
            }
        },
        {
            itemid = 11498,
            area = {
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,2,0,0,1},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,1,0,0,0}
            }
        },
        {
            itemid = 11499,
            area = {
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,2,0,0,0},
                {0,1,0,0,0,0,0},
                {0,0,0,0,0,0,1},
                {0,0,0,0,0,0,0}
            }
        },
        {
            itemid = 11500,
            area = {
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {1,0,0,2,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0}
            }
        },
        {
            itemid = 11501,
            area = {
                {0,0,0,0,0,0,0},
                {0,0,0,0,1,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,2,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,1,0,0,0,0},
                {0,0,0,0,0,0,0}
            }    
        }
    },
    remove_time = 10, -- tempo em segundos para remover
    onuse_message = "Uma area foi atingida pelo Genjutsu de %s" -- message ao usar
}

function isWalkable(pos, creature, proj, pz)-- by Nord
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
    if getTopCreature(pos).uid > 0 and creature then return false end
    if getTileInfo(pos).protection and pz then return false, true end
    local n = not proj and 3 or 2
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end  

local combats = {}
for i, t in ipairs(cfg.items_area) do
    combats = createCombatObject()
    setCombatArea(combats, createCombatArea(t.area))
    function onTargetTile(cid, position)
        if isWalkable(position, true, true, true) then
            doCreateItem(t.itemid, 1, position)
            addEvent(function()
                local thing = getTileItemById(position, t.itemid).uid
                if(thing ~= 0) then
                    doRemoveItem(thing)
                end
            end, cfg.remove_time * 1000)
        end
    end
    setCombatCallback(combats, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
end

function onCastSpell(cid, var)

local outfit = {lookType = 90, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}
local time1 = 4000 -- segundos que ficará com a outfit
local position = {x=getCreaturePosition(cid).x+1, y=getCreaturePosition(cid).y+1, z=getCreaturePosition(cid).z}

    for i = 1, #combats do
        doCombat(cid, combats, var)
        doSetCreatureOutfit(cid, outfit, time1)
        doSendMagicEffect(position, 193)
    end

    doBroadcastMessage(cfg.onuse_message:format(getCreatureName(cid)), MESSAGE_STATUS_WARNING)
    return true
end

 

 

Postado
  • Autor

@KotZletY [29/12/2018 09:37:20] [Error - Spell Interface] 
[29/12/2018 09:37:20] data/spells/scripts/itachi/genjutsu.lua:onCastSpell
[29/12/2018 09:37:20] Description: 
[29/12/2018 09:37:20] data/spells/scripts/itachi/genjutsu.lua:110: attempt to get length of upvalue 'combats' (a number value)
[29/12/2018 09:37:20] stack traceback:
[29/12/2018 09:37:20]     data/spells/scripts/itachi/genjutsu.lua:110: in function <data/spells/scripts/itachi/genjutsu.lua:104>

  • 2 weeks later...
Postado
Spoiler

local cfg = {
    items_area = {
        {
            itemid = 11497,
            area = {
                {0,0,0,0,0,0,0},
                {0,1,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,2,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,1,0,0},
                {0,0,0,0,0,0,0}
            }
        },
        {
            itemid = 11498,
            area = {
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,2,0,0,1},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,1,0,0,0}
            }
        },
        {
            itemid = 11499,
            area = {
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,2,0,0,0},
                {0,1,0,0,0,0,0},
                {0,0,0,0,0,0,1},
                {0,0,0,0,0,0,0}
            }
        },
        {
            itemid = 11500,
            area = {
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {1,0,0,2,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,0,0,0,0}
            }
        },
        {
            itemid = 11501,
            area = {
                {0,0,0,0,0,0,0},
                {0,0,0,0,1,0,0},
                {0,0,0,0,0,0,0},
                {0,0,0,2,0,0,0},
                {0,0,0,0,0,0,0},
                {0,0,1,0,0,0,0},
                {0,0,0,0,0,0,0}
            }    
        }
    },
    remove_time = 10, -- tempo em segundos para remover
    onuse_message = "Uma area foi atingida pelo Genjutsu de %s" -- message ao usar
}

function isWalkable(pos) -- by Yan Liima
	local tile = getThingfromPos(pos)
	if hasProperty(tile.uid, 0) == true or hasProperty(tile.uid, 3) == true then 
    	return false
	end
	return true
end

local combats = {}
local pos = {x=math.random(fromPos.x,toPos.x), y=math.random(fromPos.y,toPos.y), z=math.random(fromPos.z,toPos.z)}
for i, t in ipairs(cfg.items_area) do
    combats = createCombatObject()
    setCombatArea(combats, createCombatArea(t.area))
    function onTargetTile(cid, position)
	if isWalkable(pos) then
        doCreateItem(t.itemid, 1, position)
        addEvent(function()
            local thing = getTileItemById(position, t.itemid).uid
            if(thing ~= 0) then
                doRemoveItem(thing)
            end
        end, cfg.remove_time * 1000)
    end
end	
    setCombatCallback(combats, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
end

function onCastSpell(cid, var)
local combats = {}
local outfit = {lookType = 90, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}
local time1 = 4000 -- segundos que ficará com a outfit
local position = {x=getCreaturePosition(cid).x+1, y=getCreaturePosition(cid).y+1, z=getCreaturePosition(cid).z}

    for i = 1, #combats do
        doCombat(cid, combats, var)
        doSetCreatureOutfit(cid, outfit, time1)
        doSendMagicEffect(position, 193)
    end

    doBroadcastMessage(cfg.onuse_message:format(getCreatureName(cid)), MESSAGE_STATUS_WARNING)
    return true
end

 

 

Postado
  • Autor

@Yan Liima 

[12/01/2019 11:45:58] [Error - Spell Interface] 
[12/01/2019 11:45:58] data/spells/scripts/itachi/genjutsu.lua
[12/01/2019 11:45:58] Description: 
[12/01/2019 11:45:58] data/spells/scripts/itachi/genjutsu.lua:78: attempt to index global 'fromPos' (a nil value)
[12/01/2019 11:45:58] [Warning - Event::loadScript] Cannot load script (data/spells/scripts/itachi/genjutsu.lua)

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo