DI
suporte scripts

Adicionar SetNoMove em spell

Por diarmaint, 15 de fev. de 2019 em Scripts

11
2k
diarmaintD
15 de fevereiro de 2019 às 15:34

Galera, como adiciono essa função na spell 

doCreatureSetNoMove(cid, true)

eu consigo adicionar ela , o problema é que fica sem mover depois que a spell para.

A spell precisa ser tipo

ao usar o personagem não se move, fica healando até eu ativar novamente parando a spell.

Citar

local config = {
cooldown = 5, -- tempo entre uma magia e outra
tempo = 15, -- tempo em segundos que ficarĂ¡ healando
storage = 45382,
}

function onCastSpell(cid, var)
if getPlayerLevel(cid) < 200 then
if os.time() - getPlayerStorageValue(cid, config.storage) >= config.cooldown then
for i = 1, config.tempo do
addEvent(function()
 if isCreature(cid) then
 local lifedraw = 100
 local pos = getPlayerPosition(cid)
              doCreatureAddMana(cid, lifedraw, 1) 
              doSendAnimatedText(pos, "+"..lifedraw , TEXTCOLOR_YELLOW)          
              
local position127 = 
{x=getPlayerPosition(cid).x+1,
 y=getPlayerPosition(cid).y+0,
 z=getPlayerPosition(cid).z}
doSendMagicEffect(position127, 564)

end
end, 1000*i)
end
doPlayerSetStorageValue(cid, config.storage, os.time())
else
doPlayerSendCancel(cid, "Podera usar novamente em "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, config.storage))).." segundos.")
return false
end
else
doPlayerSendCancel(cid, "Somente level menores que 200 podem usar esta magia.")
return false
end
return true
end

 

Editado Fevereiro 15 por diarmaint

RefeR
15 de fevereiro de 2019 às 15:40
local config = {
cooldown = 5, -- tempo entre uma magia e outra
tempo = 60, -- tempo em segundos que ficarĂ¡ healando
storage = 45382,
effect = 564 --- efeito que vai sair

posx = 1, -- mudança de pos, pode ser numero positivo ou negativo 
posy = 1, -- mudança de pos, pode ser numero positivo ou negativo 
posz = 0, -- mudança de andar, pode ser numero positivo ou negativo 
}

function onCastSpell(cid, var)
if getPlayerLevel(cid) < 200 then
if os.time() - getPlayerStorageValue(cid, config.storage) >= config.cooldown then
doCreatureSetNoMove(cid, true)
for i = 1, config.tempo do
addEvent(function()
 if isCreature(cid) then
 local lifedraw = 1000
 local pos = getPlayerPosition(cid)
 local pos = {x = pos.x + posx, y = pos.y+posy, z = pos.z+posz}
              doCreatureAddMana(cid, lifedraw, 1) 
              doSendAnimatedText(pos, "+"..lifedraw , TEXTCOLOR_YELLOW)          
                doSendMagicEffect(pos, config.effect)
                if i == 60 then
					doCreatureSetNoMove(cid, false)
				end
end
end, 1000*i)
end
doPlayerSetStorageValue(cid, config.storage, os.time())
else
doPlayerSendCancel(cid, "Podera usar novamente em "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, config.storage))).." segundos.")
return false
end
else
doPlayerSendCancel(cid, "Somente level menores que 200 podem usar esta magia.")
return false
end
return true
end

Teste ai :)

diarmaintD
15 de fevereiro de 2019 às 15:43

 

2 minutos atrás, Refe disse:

Teste ai :)

[15:42:56.068] [Error - LuaInterface::loadFile] data/spells/scripts/Iniciais/charge.lua:7: '}' expected (to close '{' at line 1) near 'posx'
[15:42:56.068] [Warning - Event::loadScript] Cannot load script (data/spells/scripts/Iniciais/charge.lua)
[15:42:56.076] data/spells/scripts/Iniciais/charge.lua:7: '}' expected (to close '{' at line 1) near 'posx'

 

RefeR
15 de fevereiro de 2019 às 15:45
1 minuto atrás, diarmaint disse:

 

[15:42:56.068] [Error - LuaInterface::loadFile] data/spells/scripts/Iniciais/charge.lua:7: '}' expected (to close '{' at line 1) near 'posx'
[15:42:56.068] [Warning - Event::loadScript] Cannot load script (data/spells/scripts/Iniciais/charge.lua)
[15:42:56.076] data/spells/scripts/Iniciais/charge.lua:7: '}' expected (to close '{' at line 1) near 'posx'

 

local config = {
cooldown = 5, -- tempo entre uma magia e outra
tempo = 60, -- tempo em segundos que ficarĂ¡ healando
storage = 45382,
effect = 564, --- efeito que vai sair

posx = 1, -- mudança de pos, pode ser numero positivo ou negativo 
posy = 1, -- mudança de pos, pode ser numero positivo ou negativo 
posz = 0 -- mudança de andar, pode ser numero positivo ou negativo 
}

function onCastSpell(cid, var)
if getPlayerLevel(cid) < 200 then
if os.time() - getPlayerStorageValue(cid, config.storage) >= config.cooldown then
doCreatureSetNoMove(cid, true)
for i = 1, config.tempo do
addEvent(function()
 if isCreature(cid) then
 local lifedraw = 1000
 local pos = getPlayerPosition(cid)
 local pos = {x = pos.x + posx, y = pos.y+posy, z = pos.z+posz}
              doCreatureAddMana(cid, lifedraw, 1) 
              doSendAnimatedText(pos, "+"..lifedraw , TEXTCOLOR_YELLOW)          
                doSendMagicEffect(pos, config.effect)
                if i == 60 then
					doCreatureSetNoMove(cid, false)
				end
end
end, 1000*i)
end
doPlayerSetStorageValue(cid, config.storage, os.time())
else
doPlayerSendCancel(cid, "Podera usar novamente em "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, config.storage))).." segundos.")
return false
end
else
doPlayerSendCancel(cid, "Somente level menores que 200 podem usar esta magia.")
return false
end
return true
end

 

diarmaintD
15 de fevereiro de 2019 às 15:46
[15:45:34.837] [Error - Spell Interface]
[15:45:34.837] In a timer event called from:
[15:45:34.837] data/spells/scripts/Iniciais/charge.lua:onCastSpell
[15:45:34.837] Description:
[15:45:34.846] data/spells/scripts/Iniciais/charge.lua:21: attempt to perform arithmetic on global 'posx' (a nil value)
[15:45:34.846] stack traceback:
[15:45:34.846]  data/spells/scripts/Iniciais/charge.lua:21: in function <data/spells/scripts/Iniciais/charge.lua:17>

 

RefeR
15 de fevereiro de 2019 às 15:49

Você mexeu em algo ai ?

local config = {
cooldown = 5, -- tempo entre uma magia e outra
tempo = 60, -- tempo em segundos que ficarĂ¡ healando
storage = 45382,
effect = 564, --- efeito que vai sair

posx = 1, -- mudança de pos, pode ser numero positivo ou negativo 
posy = 1, -- mudança de pos, pode ser numero positivo ou negativo 
posz = 0 -- mudança de andar, pode ser numero positivo ou negativo 
}

function onCastSpell(cid, var)
if getPlayerLevel(cid) < 200 then
if os.time() - getPlayerStorageValue(cid, config.storage) >= config.cooldown then
doCreatureSetNoMove(cid, true)
for i = 1, config.tempo do
addEvent(function()
 if isCreature(cid) then
 local lifedraw = 1000
 local pos = {x = getPlayerPosition(cid).x + config.posx, y = getPlayerPosition(cid).y+config.posy, z = getPlayerPosition(cid).z+config.posz}
              doCreatureAddMana(cid, lifedraw, 1) 
              doSendAnimatedText(pos, "+"..lifedraw , TEXTCOLOR_YELLOW)          
                doSendMagicEffect(pos, config.effect)
                if i == 60 then
					doCreatureSetNoMove(cid, false)
				end
end
end, 1000*i)
end
doPlayerSetStorageValue(cid, config.storage, os.time())
else
doPlayerSendCancel(cid, "Podera usar novamente em "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, config.storage))).." segundos.")
return false
end
else
doPlayerSendCancel(cid, "Somente level menores que 200 podem usar esta magia.")
return false
end
return true
end

erro meu, tenta ai

diarmaintD
15 de fevereiro de 2019 às 16:01

Tudo certo, mas tem como deixar ela "infinita" dai se eu usar novamente que ela para ?

se te ajuda, tenho essa como exemplo

Citar

function onCastSpell(cid, var)
local storage = 3340
    if(getPlayerStorageValue(cid, storage) < 1) then
        if(getCreatureCondition(cid, CONDITION_INFIGHT) == false) then
        doPlayerSetStorageValue(cid, storage, 1)
        doPlayerSendCancel(cid, "You start power up.")
        doCreatureSetNoMove(cid, true)
        else
        doPlayerSendCancel(cid, "You have infight ticks.")
        end
    elseif(getPlayerStorageValue(cid, storage) == 1) then
        doPlayerSendCancel(cid, "You stop power up.")
        doPlayerSetStorageValue(cid, storage, 0)
        doCreatureSetNoMove(cid, false)
    end
    return true
end

É o charge do dbko

Editado Fevereiro 15 por diarmaint

RefeR
15 de fevereiro de 2019 às 16:10
local config = {
cooldown = 5, -- tempo entre uma magia e outra
tempo = 60, -- tempo em segundos que ficarĂ¡ healando
storage = 45382,
sendagain = 234322,
effect = 564, --- efeito que vai sair

posx = 1, -- mudança de pos, pode ser numero positivo ou negativo 
posy = 1, -- mudança de pos, pode ser numero positivo ou negativo 
posz = 0 -- mudança de andar, pode ser numero positivo ou negativo 
}

function onCastSpell(cid, var)
if getPlayerLevel(cid) < 200 then
if getPlayerStorageValue(cid, config.sendagain) == 1 then
stopEvent(eventCharge)
doPlayerSetStorageValue(cid, config.sendagain, -1)
end
if os.time() - getPlayerStorageValue(cid, config.storage) >= config.cooldown then
doCreatureSetNoMove(cid, true)
for i = 1, config.tempo do
eventCharge = addEvent(function()
 if isCreature(cid) then
 local lifedraw = 1000
 local pos = {x = getPlayerPosition(cid).x + config.posx, y = getPlayerPosition(cid).y+config.posy, z = getPlayerPosition(cid).z+config.posz}
              doCreatureAddMana(cid, lifedraw, 1) 
              doSendAnimatedText(pos, "+"..lifedraw , TEXTCOLOR_YELLOW)          
                doSendMagicEffect(pos, config.effect)
                if i == 60 then
					doCreatureSetNoMove(cid, false)
				end
end
end, 1000*i)
end
doPlayerSetStorageValue(cid, config.storage, os.time())
doPlayerSetStorageValue(cid, config.sendagain, 1)
else
doPlayerSendCancel(cid, "Podera usar novamente em "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, config.storage))).." segundos.")
return false
end
else
doPlayerSendCancel(cid, "Somente level menores que 200 podem usar esta magia.")
return false
end
return true
end

 

diarmaintD
15 de fevereiro de 2019 às 16:13

Ele usa novamente, duplicando o poder.

e continua não andando quando o poder acaba.

Editado Fevereiro 15 por diarmaint

RefeR
15 de fevereiro de 2019 às 16:20
local config = {
cooldown = 5, -- tempo entre uma magia e outra
tempo = 60, -- tempo em segundos que ficarĂ¡ healando
storage = 45382,
sendagain = 234322,
effect = 564, --- efeito que vai sair

posx = 1, -- mudança de pos, pode ser numero positivo ou negativo 
posy = 1, -- mudança de pos, pode ser numero positivo ou negativo 
posz = 0 -- mudança de andar, pode ser numero positivo ou negativo 
}

function onCastSpell(cid, var)
if getPlayerLevel(cid) < 200 then
if getPlayerStorageValue(cid, config.sendagain) == 1 then
stopEvent(eventCharge)
doCreatureSetNoMove(cid, false)
doPlayerSetStorageValue(cid, config.sendagain, -1)
return true
end
if os.time() - getPlayerStorageValue(cid, config.storage) >= config.cooldown then
doCreatureSetNoMove(cid, true)
for i = 1, config.tempo do
eventCharge = addEvent(function()
 if isCreature(cid) then
 local lifedraw = 1000
 local pos = {x = getPlayerPosition(cid).x + config.posx, y = getPlayerPosition(cid).y+config.posy, z = getPlayerPosition(cid).z+config.posz}
              doCreatureAddMana(cid, lifedraw, 1) 
              doSendAnimatedText(pos, "+"..lifedraw , TEXTCOLOR_YELLOW)          
                doSendMagicEffect(pos, config.effect)
                if i == 60 then
					doCreatureSetNoMove(cid, false)
				end
end
end, 1000*i)
end
doPlayerSetStorageValue(cid, config.storage, os.time())
doPlayerSetStorageValue(cid, config.sendagain, 1)
else
doPlayerSendCancel(cid, "Podera usar novamente em "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, config.storage))).." segundos.")
return false
end
else
doPlayerSendCancel(cid, "Somente level menores que 200 podem usar esta magia.")
return false
end
return true
end

 

diarmaintD
15 de fevereiro de 2019 às 16:27

Quando uso o poder novamente e desativa o  setnomove, ainda fica com o effect e healando.
 

Editado Fevereiro 15 por diarmaint