Gera algum erro?
- Fórum
- OTServ
- Pedidos
- Resolvidos
- [Resolvido] [Pedido] Adaptar script de trap
[Resolvido] [Pedido] Adaptar script de trap
Por LeoTK, 08 de ago. de 2017 em Resolvidos
info
Grupo: Herói
Registrado: 07/03/16
Posts: 1.4k
Reputação: +385
Gênero: Masculino

1 hora atrás, Poccnn disse:Gera algum erro?
então eu testei de várias formas e deu vários erros por colocar em lugares errados eu creio .... então vim pedir ajuda de alguém mais experiente ^^
info
Grupo: Herói
Registrado: 07/03/16
Posts: 1.4k
Reputação: +385
Gênero: Masculino

Quais foram os erros que gerou?
6 horas atrás, Brunds disse:então eu testei de várias formas e deu vários erros por colocar em lugares errados eu creio .... então vim pedir ajuda de alguém mais experiente ^^
Se quiser que mande a mensagem em todas as posições ao redor do target, adicione depois dessa linha
doCreateItem(5750,1,posicao)
Isso:
doShowTimeByPos(cid, posicao, 5, COLOR_RED)
Se quiser só em uma posição que esteja ao redor do target, adicione a mesma linha acima, antes de:
addEvent(function()
Se quiser que o tempo seja mostrado na posição do player, adicione antes da mesma linha acima:
doShowTimeByPos(cid, getPlayerPosition(cid), 5, COLOR_RED)
E claro, não esqueça da função. Melhor escrevê-la assim:
function doShowTimeByPos(uid, pos, duration, type)type = type or 20 for i = 0, (duration - 1) do addEvent(function() if isCreature(uid) then doSendAnimatedText(pos, tostring(duration - i), type) end end, i * 1000) endreturn true
1 hora atrás, Leoxtibia disse:
Se quiser que mande a mensagem em todas as posições ao redor do target, adicione depois dessa linha
doCreateItem(5750,1,posicao)Isso:
doShowTimeByPos(cid, posicao, 5, COLOR_RED)Se quiser só em uma posição que esteja ao redor do target, adicione a mesma linha acima, antes de:
addEvent(function()Se quiser que o tempo seja mostrado na posição do player, adicione antes da mesma linha acima:
doShowTimeByPos(cid, getPlayerPosition(cid), 5, COLOR_RED)E claro, não esqueça da função. Melhor escrevê-la assim:
function doShowTimeByPos(uid, pos, duration, type)type = type or 20 for i = 0, (duration - 1) do addEvent(function() if isCreature(uid) then doSendAnimatedText(pos, tostring(duration - i), type) end end, i * 1000) endreturn true
erro
[08/08/2017 23:53:16] [Error - LuaScriptInterface::loadFile] data/spells/scripts/hashirama/mokuton prision.lua:67: 'end' expected (to close 'function' at line 29) near '<eof>'
[08/08/2017 23:53:16] [Warning - Event::loadScript] Cannot load script (data/spells/scripts/hashirama/mokuton prision.lua)
[08/08/2017 23:53:16] data/spells/scripts/hashirama/mokuton prision.lua:67: 'end' expected (to close 'function' at line 29) near '<eof>'
function isWalkable(pos, creature, pz, proj)if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 thenreturn falseendlocal creature = getTopCreature(pos)if creature.type > 0 thenreturn falseendif getTilePzInfo(pos) and not pz thenreturn falseendlocal n = not proj and 3 or 2for i = 0, 255 dopos.stackpos = ilocal tile = getTileThingByPos(pos)if tile.itemid ~= 0 and not isCreature(tile.uid) thenif hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) thenreturn falseendendendreturn trueendfunction onCastSpell(cid, var)if exhaustion.check(cid, 5750) == TRUE thendoPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Aguarde " .. exhaustion.get(cid, 5750) .. " segundos para usar novamente.")return falseendexhaustion.set(cid, 5750, 8)local pos = getThingPosition(getCreatureTarget(cid))for x = -1,1 dofor y = -1,1 doposicao = {x = pos.x + x, y = pos.y + y, z = pos.z}if isWalkable(posicao) and posicao ~= {x = pos.x,y = pos.y,z = pos.z} thendoCreateItem(5750,1,posicao)function doShowTimeByPos(uid, pos, duration, type)type = type or 20 for i = 0, (duration - 1) do addEvent(function() if isCreature(uid) then doSendAnimatedText(pos, tostring(duration - i), type) end end, i * 1000) endreturn trueendendendaddEvent(function()for x = -1,1 dofor y = -1,1 doposicao = {x = pos.x + x, y = pos.y + y, z = pos.z}if getTileItemById(posicao, 5750).uid > 0 thendoRemoveItem(getTileItemById(posicao, 5750).uid)endendendend,5*1000)return trueend
@Brunds Na hora de escrever, esqueci do end. E não coloque a função dentro da outra. A função abaixo fica fora.
function doShowTimeByPos(uid, pos, duration, type) type = type or 20 for i = 0, (duration - 1) do addEvent(function() if isCreature(uid) then doSendAnimatedText(pos, tostring(duration - i), type) end end, i * 1000) end return true end
Editado Agosto 10 por Leoxtibia
Em 09/08/2017 at 00:56, Leoxtibia disse:@Brunds Na hora de escrever, esqueci do end. E não coloque a função dentro da outra. A função abaixo fica fora.
function doShowTimeByPos(uid, pos, duration, type) type = type or 20 for i = 0, (duration - 1) do addEvent(function() if isCreature(uid) then doSendAnimatedText(pos, tostring(duration - i), type) end end, i * 1000) end return true end
[10/08/2017 21:50:43] data/spells/scripts/hashirama/mokuton prision.lua:onCastSpell
[10/08/2017 21:50:43] Description:
[10/08/2017 21:50:43] data/spells/scripts/hashirama/mokuton prision.lua:43: attempt to call global 'doShowTimeByPos' (a nil value)
[10/08/2017 21:50:43] stack traceback:
[10/08/2017 21:50:43] data/spells/scripts/hashirama/mokuton prision.lua:43: in function <data/spells/scripts/hashirama/mokuton prision.lua:29>
function isWalkable(pos, creature, pz, proj)
if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then
return false
end
local creature = getTopCreature(pos)
if creature.type > 0 then
return false
end
if getTilePzInfo(pos) and not pz then
return false
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
function onCastSpell(cid, var)
if exhaustion.check(cid, 5750) == TRUE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Aguarde " .. exhaustion.get(cid, 5750) .. " segundos para usar novamente.")
return false
end
exhaustion.set(cid, 5750, 8)
local pos = getThingPosition(getCreatureTarget(cid))
for x = -1,1 do
for y = -1,1 do
posicao = {x = pos.x + x, y = pos.y + y, z = pos.z}
if isWalkable(posicao) and posicao ~= {x = pos.x,y = pos.y,z = pos.z} then
doCreateItem(5750,1,posicao)
doShowTimeByPos(cid, posicao, 5, COLOR_RED)
end
end
end
function doShowTimeByPos(uid, pos, duration, type)
type = type or 20
for i = 0, (duration - 1) do
addEvent(function()
if isCreature(uid) then
doSendAnimatedText(pos, tostring(duration - i), type)
end
end, i * 1000)
end
return true
end
addEvent(function()
for x = -1,1 do
for y = -1,1 do
posicao = {x = pos.x + x, y = pos.y + y, z = pos.z}
if getTileItemById(posicao, 5750).uid > 0 then
doRemoveItem(getTileItemById(posicao, 5750).uid)
end
end
end
end,5*1000)
return true
end
Obs: não aparece os segundos e ao usar vai criando um trap por vez
@Brunds Quando eu disse "fora", queria dizer FORA!! kk
function isWalkable(pos, creature, pz, proj) if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end local creature = getTopCreature(pos) if creature.type > 0 then return false end if getTilePzInfo(pos) and not pz then return false 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 function onCastSpell(cid, var) if exhaustion.check(cid, 5750) == TRUE then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Aguarde " .. exhaustion.get(cid, 5750) .. " segundos para usar novamente.") return false end exhaustion.set(cid, 5750, 8) local pos = getThingPosition(getCreatureTarget(cid)) for x = -1,1 do for y = -1,1 do posicao = {x = pos.x + x, y = pos.y + y, z = pos.z} if isWalkable(posicao) and posicao ~= {x = pos.x,y = pos.y,z = pos.z} then doCreateItem(5750,1,posicao) doShowTimeByPos(cid, posicao, 5, COLOR_RED) end end end addEvent(function() for x = -1,1 do for y = -1,1 do posicao = {x = pos.x + x, y = pos.y + y, z = pos.z} if getTileItemById(posicao, 5750).uid > 0 then doRemoveItem(getTileItemById(posicao, 5750).uid) end end end end,5*1000) return true end function doShowTimeByPos(uid, pos, duration, type) type = type or 20 for i = 0, (duration - 1) do addEvent(function() if isCreature(uid) then doSendAnimatedText(pos, tostring(duration - i), type) end end, i * 1000) end return true end
Editado Agosto 11 por Leoxtibia
Valeu mano kkk é que no começo você tira se referido as linhas pensei que era fora delas kkk mas obrigado funcionou direitinho xD

info
Grupo: Herói
Registrado: 07/03/16
Posts: 1.4k
Reputação: +385
Gênero: Masculino

O pedido neste tópico de foi atendido e/ou o autor do tópico resolveu sua duvida. Este tópico está fechado e foi movido para Pedidos - Resolvidos. Se você tiver outros pedidos, crie um novo tópico.




info
Grupo: Marquês
Registrado: 05/12/11
Posts: 1.2k
Reputação: +173
Gênero: Masculino
Fala guys estava vagando pela net e achei esse script que faz com que mostre o tempo que dura o trap e achei muito útil para colocar no meu servidor porém sei muito pouco de script então tentei diversas vezes porém não consegui adaptar o código no meu script então vim até aqui para pedir uma ajuda a quem souber como adaptar esse código para o meu script
o código é esse
o script é esse
A função do código e fazer com que mostre o tempo de duração do trap porém não consegui de forma alguma adaptar o código para o script estou usando source 0.3.6