Encontrei essa action na net e achei muito interessante e espero que gostem.
Primeiramente os créditos vão para slawkens!
Como isto funciona?
Simples, você colocar um firework (Id: 6576) sobre um fire field, e automaticamente começa a contagem,
e depois de 5 segundos "BOOM"...
Vamos trabalhar?!
actions/scripts/fireworks.lua
function onUse(cid, item, fromPosition, itemEx, toPosition)if fromPosition.x ~= CONTAINER_POSITION then
fireWorkRocketBoom(fromPosition)
else
doSendMagicEffect(fromPosition, CONST_ME_HITBYFIRE)
doSendMagicEffect(fromPosition, CONST_ME_EXPLOSIONAREA)
doCreatureSay(cid, "Ouch! Rather place it on the ground next time.", TALKTYPE_ORANGE_1)
doCreatureAddHealth(cid, -10)
end
doRemoveItem(cid, item.uid, 1)
return TRUE
end
Adicione a seguinte tag em actions/actions.xml
<action itemid="6576" script="fireworks.lua" />
Agora vamos para as movements:
movements/script/fireworksrocket.lua
--by slaw--Config
local timeToBoom = 5
local fireFields = {1487, 1488, 1489, 1492, 1493, 1494}
function fireWorkTimer(seconds, pos, itemid)
local tmp = getTileItemById(pos, itemid)
if tmp.uid == FALSE then
return FALSE
end
if seconds == 0 then
fireWorkRocketBoom(pos)
doRemoveItemFromPos(pos, itemid)
return TRUE
end
doSendAnimatedText(pos, seconds, 150)
seconds = seconds - 1
addEvent(fireWorkTimer, 1000, seconds, pos, itemid)
end
function onAddItem(moveitem, tileitem, pos)
pos.stackpos = STACKPOS_TOP_FIELD
if isInArray(fireFields, getThingFromPos(pos).itemid) == TRUE then
fireWorkTimer(timeToBoom, pos, moveitem.itemid)
end
return TRUE
end
Agora em movements.xml adicione a tag:
<!-- FIREROCKET by slawkens --><movevent event="AddItem" itemid="6576" script="fireworksrocket.lua" />
Agora uma das partes mais importantes! Abra seu global.lua ou function.lua e adicione isto! (Tome muito cuidado ao editar esse arquivo e aconcelho vocês a fazer uma copia do mesmo antes de edita-lo!!!)
function fireWorkRocketBoom(fromPosition)local tmpPos = {}
local i = 4
while(i >= 1) do
tmpPos = {x=fromPosition.x - i, y=fromPosition.y - i, z=fromPosition.z, stackpos=0}
if isSightClear(fromPosition, tmpPos, FALSE) == TRUE then
if(hasProperty(getThingFromPos(tmpPos).uid, CONST_PROP_BLOCKINGANDNOTMOVEABLE) ~= TRUE) then
doSendDistanceShoot(fromPosition, tmpPos, 3)
addEvent(doSendMagicEffect, 350, tmpPos, math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
break
end
end
i = i - 1
end
end
Pronto agora só você entrar em seu ot e comemorar o ano novo em grande estilo!
Atenção; para um funcionamento correto você precisa ter a função "doRemoveItemFromPos" e caso você não tenha abra seu global.lua
ou function.lua e adicione o seguinte:
function doRemoveItemFromPos(position, itemid, count)local tmp = count or 1
local item = getTileItemById(position, itemid)
if item.uid ~= FALSE then
return doRemoveItem(item.uid, tmp)
end
return FALSE
end
Feliz ano novo e não esqueçam de comentar!