JH
pedido

Efeito Drop Stone.

Por jhonatanp, 10 de jun. de 2015 em Archived

script
36
10.4k
Developer BergD
11 de junho de 2015 às 21:20
local effect = 169                                   --by brun123    --alterado v1.9 \/
local arrow = {effect, duration}                     --Respectivamente, efeito e duração (segundos).
function sendEffect(pos, time)
    if time < 0 then
        return true
    end
    doSendMagicEffect(pos, arrow[1])
    addEvent(sendEffect, 1000, pos, time - 1)
end
local function func(cid, position, corpseid, effect)
    if not isCreature(cid) then return true end
    local corpse = getTileItemById(position, corpseid).uid
    if corpse <= 1 then return end
    if not isContainer(corpse) then return true end
    for slot = 0, (getContainerSize(corpse)-1) do
        local item = getContainerItem(corpse, slot)
        if item.uid <= 1 then return end
        if isStone(item.itemid) then
            return doSendMagicEffect(getThingPos(cid), effect) and sendEffect(position, arrow[2])
        end
    end
end
function onKill(cid, target, lastHit)
 
    if not ehMonstro(target) then return true end
    local corpse = getMonsterInfo(getCreatureName(target)).lookCorpse
 
    addEvent(func, 5, getCreatureSummons(cid)[1], getThingPos(target), corpse, effect)
    return true
end

Zipter, poderia fazer esse sistema para a base do Kpdo Exaioros ?

jhonatanpJ
12 de junho de 2015 às 11:09

[12/06/2015 11:09:04] [Error - CreatureScript Interface]
[12/06/2015 11:09:04] In a timer event called from:
[12/06/2015 11:09:04] data/creaturescripts/scripts/dropStone.lua:onKill
[12/06/2015 11:09:04] Description:
[12/06/2015 11:09:04] data/creaturescripts/scripts/dropStone.lua:4: attempt to compare nil with number
[12/06/2015 11:09:04] stack traceback:
[12/06/2015 11:09:04] data/creaturescripts/scripts/dropStone.lua:4: in function 'sendEffect'
[12/06/2015 11:09:04] data/creaturescripts/scripts/dropStone.lua:19: in function <data/creaturescripts/scripts/dropStone.lua:10>

Luga03L
12 de junho de 2015 às 12:26

Tenta:

 

 

local effect = 169                                   --by brun123    --alterado v1.9 \/
local arrow = {effect, duration}                     --Respectivamente, efeito e duração (segundos).
function doSendMagicEffect(pos, time)
    if time < 0 then
        return true
    end
    doSendMagicEffect(pos, arrow[1])
    addEvent(sendEffect, 1000, pos, time - 1)
end
local function func(cid, position, corpseid, effect)
    if not isCreature(cid) then return true end
    local corpse = getTileItemById(position, corpseid).uid
    if corpse <= 1 then return end
    if not isContainer(corpse) then return true end
    for slot = 0, (getContainerSize(corpse)-1) do
        local item = getContainerItem(corpse, slot)
        if item.uid <= 1 then return end
        if isStone(item.itemid) then
            return doSendMagicEffect(getThingPos(cid), effect) and sendEffect(position, arrow[2])
        end
    end
end
function onKill(cid, target, lastHit)
 
    if not ehMonstro(target) then return true end
    local corpse = getMonsterInfo(getCreatureName(target)).lookCorpse
 
    addEvent(func, 5, getCreatureSummons(cid)[1], getThingPos(target), corpse, effect)
    return true
end
zipter98Z
12 de junho de 2015 às 15:33

Você provavelmente se esqueceu de configurar a tabela arrow.

@ricardoberg

Desculpe, não conheço a estrutura dos códigos desta base, mas suponho que basta algumas alterações no script que enviei para que funcione.

Editado Junho 12 por zipter98

Developer BergD
12 de junho de 2015 às 16:13

Você provavelmente se esqueceu de configurar a tabela arrow.

@ricardoberg

Desculpe, não conheço a estrutura dos códigos desta base, mas suponho que basta algumas alterações no script que enviei para que funcione.

Zipter, poderia me ajudar a fazer pegar essa script na base do Kpdo/Exaioros ? ou poderia modificar essa script para virar uma script própria ? tipo no meio da script a pessoa colocaria os ids das Stones, e adicionava uma Tag para fazer pegar a script, pq na base que uso n tem a script DropStone.lua

zipter98Z
12 de junho de 2015 às 16:43

Claro.

local effect = 169                                   --by brun123    --alterado v1.9 \/
local arrow = {effect, duration}                     --Respectivamente, efeito e duração (segundos).
local items = {itemid, itemid, itemid, ...}          --Tabela para configurar os items.  
function sendEffect(pos, time)
    if time < 0 then
        return true
    end
    doSendMagicEffect(pos, arrow[1])
    addEvent(sendEffect, 1000, pos, time - 1)
end
local function func(cid, position, corpseid, effect)
    if not isCreature(cid) then return true end
    local corpse = getTileItemById(position, corpseid).uid
    if corpse <= 1 then return end
    if not isContainer(corpse) then return true end
    for slot = 0, (getContainerSize(corpse)-1) do
        local item = getContainerItem(corpse, slot)
        if item.uid <= 1 then return end
        if isInArray(items, item.itemid) then
            return doSendMagicEffect(getThingPos(cid), effect) and sendEffect(position, arrow[2])
        end
    end
end
function onKill(cid, target, lastHit)
 
    if not isMonster(target) then return true end
    local corpse = getMonsterInfo(getCreatureName(target)).lookCorpse
 
    addEvent(func, 5, getCreatureSummons(cid)[1], getThingPos(target), corpse, effect)
    return true
end
Tag:
<event type="kill" name="dropStone" script="nome_do_arquivo.lua"/>
Não se esqueça de registrar o evento em login.lua.

Editado Junho 12 por zipter98

Developer BergD
12 de junho de 2015 às 17:25

 

Claro.

local effect = 169                                   --by brun123    --alterado v1.9 \/
local arrow = {effect, duration}                     --Respectivamente, efeito e duração (segundos).
local items = {itemid, itemid, itemid, ...}          --Tabela para configurar os items.  
function sendEffect(pos, time)
    if time < 0 then
        return true
    end
    doSendMagicEffect(pos, arrow[1])
    addEvent(sendEffect, 1000, pos, time - 1)
end
local function func(cid, position, corpseid, effect)
    if not isCreature(cid) then return true end
    local corpse = getTileItemById(position, corpseid).uid
    if corpse <= 1 then return end
    if not isContainer(corpse) then return true end
    for slot = 0, (getContainerSize(corpse)-1) do
        local item = getContainerItem(corpse, slot)
        if item.uid <= 1 then return end
        if isInArray(items, item.itemid) then
            return doSendMagicEffect(getThingPos(cid), effect) and sendEffect(position, arrow[2])
        end
    end
end
function onKill(cid, target, lastHit)
 
    if not isMonster(target) then return true end
    local corpse = getMonsterInfo(getCreatureName(target)).lookCorpse
 
    addEvent(func, 5, getCreatureSummons(cid)[1], getThingPos(target), corpse, effect)
    return true
end
Tag:
<event type="kill" name="dropStone" script="nome_do_arquivo.lua"/>
Não se esqueça de registrar o evento em login.lua.

 

Poderia mostrar a tag que eu colocaria pra registra no login.lua ? e poderia me dizer como eu configuro essa script ? rsrs

Editado Junho 12 por ricardoberg

BrunoB
12 de junho de 2015 às 17:30

Poderia mostrar a tag que eu colocaria pra registra no login.lua ? e poderia me dizer como eu configuro essa script ? rsrs

registerCreatureEvent(cid, "dropStone")
Developer BergD
12 de junho de 2015 às 18:32
registerCreatureEvent(cid, "dropStone")

Vlws U.u Consegui ^^ Reputado

 

Claro.

local effect = 169                                   --by brun123    --alterado v1.9 \/
local arrow = {effect, duration}                     --Respectivamente, efeito e duração (segundos).
local items = {itemid, itemid, itemid, ...}          --Tabela para configurar os items.  
function sendEffect(pos, time)
    if time < 0 then
        return true
    end
    doSendMagicEffect(pos, arrow[1])
    addEvent(sendEffect, 1000, pos, time - 1)
end
local function func(cid, position, corpseid, effect)
    if not isCreature(cid) then return true end
    local corpse = getTileItemById(position, corpseid).uid
    if corpse <= 1 then return end
    if not isContainer(corpse) then return true end
    for slot = 0, (getContainerSize(corpse)-1) do
        local item = getContainerItem(corpse, slot)
        if item.uid <= 1 then return end
        if isInArray(items, item.itemid) then
            return doSendMagicEffect(getThingPos(cid), effect) and sendEffect(position, arrow[2])
        end
    end
end
function onKill(cid, target, lastHit)
 
    if not isMonster(target) then return true end
    local corpse = getMonsterInfo(getCreatureName(target)).lookCorpse
 
    addEvent(func, 5, getCreatureSummons(cid)[1], getThingPos(target), corpse, effect)
    return true
end
Tag:
<event type="kill" name="dropStone" script="nome_do_arquivo.lua"/>
Não se esqueça de registrar o evento em login.lua.

 

Zipter poderia complementar essa script pfv ? ^^ tipo queria que alem do efeito que fica em cima do corps, queria que aparece-se um nome também tipo " Vc Dropou Tal Stone " e esse nome ficava subindo em cima do corps do monstro e desaparecia e quando subi-se denovo ele vinha com outra cor

Luga03L
12 de junho de 2015 às 18:33

No meu n Funfo ¬¬ alguem poderia adaptar pro?? tipo, ao dropar a stone do pokémon, acontece um efeito encima do corpose do poke, e envia uma mensagem em azul para o player que ele dropou a stone! pfv alguem pode ajudar?

 

 

local effect = 173                                   --by brun123    --alterado v2.9 \/
local function func(cid, position, corpseid, effect)
      if not isCreature(cid) then return true end
      local corpse = getTileItemById(position, corpseid).uid
      if corpse <= 1 then return end
      if not isContainer(corpse) then return true end
      for slot = 0, (getContainerSize(corpse)-1) do
          local item = getContainerItem(corpse, slot)
          if item.uid <= 1 then return end
          if isStone(item.itemid) then
             return doSendMagicEffect(getThingPos(cid), effect)
          end
      end
end
function onKill(cid, target, lastHit)
 
    if not ehMonstro(target) then return true end
    local corpse = getMonsterInfo(getCreatureName(target)).lookCorpse
    
    addEvent(func, 5, getCreatureSummons(cid)[1], getThingPos(target), corpse, effect)
return true
end
zipter98Z
12 de junho de 2015 às 20:11

@ricardoberg

Seria possível fazer algo assim, porém com uma mensagem menor. Se conseguir pensar em outra (ex.: "Stone!"), avise que eu altero o código para você.

@Zet0N0Murmurouu

Por acaso seu servidor tem todas as funções utilizadas neste código?

Luga03L
12 de junho de 2015 às 20:37

@ricardoberg

Seria possível fazer algo assim, porém com uma mensagem menor. Se conseguir pensar em outra (ex.: "Stone!"), avise que eu altero o código para você.

@Zet0N0Murmurouu

Por acaso seu servidor tem todas as funções utilizadas neste código?

Sim

zipter98Z
12 de junho de 2015 às 20:48

Não funcionou absolutamente nada? Você registrou o evento em login.lua? Se sim, use este código e informe o que for imprimido no console:

local effect = 173                                   --by brun123    --alterado v2.9 \/
local function func(cid, position, corpseid, effect)
    print(1)
    if not isCreature(cid) then return true end
    local corpse = getTileItemById(position, corpseid).uid
    if corpse <= 1 then return end
    if not isContainer(corpse) then return true end
    for slot = 0, (getContainerSize(corpse)-1) do
        local item = getContainerItem(corpse, slot)
        if item.uid <= 1 then return end
        if isStone(item.itemid) then
            print(2)
            return doSendMagicEffect(position, effect) and doPlayerSendTextMessage(getCreatureMaster(cid), 27, "You found a "..getItemNameById(item.itemid).."!")
        end
    end
end
function onKill(cid, target, lastHit)
 
    print(0)
    if not ehMonstro(target) then return true end
    local corpse = getMonsterInfo(getCreatureName(target)).lookCorpse
 
    addEvent(func, 5, getCreatureSummons(cid)[1], getThingPos(target), corpse, effect)
    return true
end

Editado Junho 12 por zipter98

Luga03L
12 de junho de 2015 às 21:00

Agora sei, qual era o problema ¬¬ é q n estava com a tag no creaturescript.xml!

 

agr terminei de testar e apareceu isto ao dropar a stone:

 

 

[12/06/2015 20:59:04] 0
[12/06/2015 20:59:04] 1
[12/06/2015 20:59:04] 2
 
[12/06/2015 20:59:04] [Error - CreatureScript Interface] 
[12/06/2015 20:59:04] In a timer event called from: 
[12/06/2015 20:59:04] data/creaturescripts/scripts/dropStone.lua:onKill
[12/06/2015 20:59:04] Description: 
[12/06/2015 20:59:04] (luaDoPlayerSendTextMessage) Player not found
sheptS
12 de junho de 2015 às 21:08

cara posta essa função "isStone()" quero poder alterar as stones nesse caso ..

to querendo por pra tfs 1.2 então preciso dessa função

vlw