Ir para conteúdo

[Encerrado] PDA Heal pisando no Tile


otavio101

Posts Recomendados

Queria uma script para PDA com Level, quando o player pisar no tile todos os pokemons são curados e ter que esperar 1 minuto para pisar novamente.

 

Heal da Nurse

 

local posis = { --[storage da city] = {pos da nurse na city},
[897530] = {x = 1053, y = 1046, z = 7}, --saffron --alterado v2.9 TUDO!! \/
[897531] = {x = 1060, y = 900, z = 7}, --cerulean
[897532] = {x = 1204, y = 1042, z = 7}, --lavender
[897533] = {x = 1213, y = 1321, z = 7}, --fuchsia
[897534] = {x = 862, y = 1094, z = 6}, --celadon
[897535] = {x = 705, y = 1086, z = 7}, --viridian
[897536] = {x = 1075, y = 1233, z = 7}, --vermilion
[897537] = {x = 723, y = 847, z = 7}, --pewter
[897538] = {x = 850, y = 1396, z = 7}, --cinnabar
[897539] = {x = 1429, y = 1597, z = 6}, --snow
[897540] = {x = 542, y = 675, z = 7}, --golden
}

function onThingMove(creature, thing, oldpos, oldstackpos)
end

function onCreatureAppear(creature)
end

function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye sir!')
focus = 0
talk_start = 0
end
end

function onCreatureTurn(creature)
end

function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end

function onCreatureSay(cid, type, msg)
local msg = string.lower(msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

for a, b in pairs(gobackmsgs) do
local gm = string.gsub(b.go, "doka!", "")
local bm = string.gsub(b.back, "doka!", "")
if string.find(string.lower(msg), string.lower(gm)) or string.find(string.lower(msg), string.lower(bm)) then
return true
end
end

if((msgcontains(msg, 'hi') or msgcontains(msg, 'heal') or msgcontains(msg, 'help')) and (getDistanceToCreature(cid) <= 3)) then

if exhaustion.get(cid, 9211) then
selfSay('Please wait a few moment before asking me to heal your pokemons again!')
return true
end

if not getTileInfo(getThingPos(cid)).protection and nurseHealsOnlyInPZ then
selfSay("Please, get inside the pokémon center to heal your pokemons!")
return true
end

if getPlayerStorageValue(cid, 52480) >= 1 then
selfSay("You can't do that while in a Duel!")
return true
end

for e, f in pairs(posis) do
local pos = getThingPos(getNpcCid())
if isPosEqual(pos, f) then
if getPlayerStorageValue(cid, e) <= -1 then
setPlayerStorageValue(cid, e, 1)
end
end
end

exhaustion.set(cid, 9211, 5)

doCreatureAddHealth(cid, getCreatureMaxHealth(cid)-getCreatureHealth(cid))
doCureStatus(cid, "all", true)
doSendMagicEffect(getThingPos(cid), 132)

local mypb = getPlayerSlotItem(cid, 8)

if #getCreatureSummons(cid) >= 1 then

if not nurseHealsPokemonOut then
selfSay("Please, return your pokemon to his ball!")
return true
end

local s = getCreatureSummons(cid)[1]
doCreatureAddHealth(s, getCreatureMaxHealth(s))
doSendMagicEffect(getThingPos(s), 13)
doCureStatus(s, "all", false)
if getPlayerStorageValue(s, 1008) < baseNurseryHappiness then
setPlayerStorageValue(s, 1008, baseNurseryHappiness)
end
if getPlayerStorageValue(s, 1009) > baseNurseryHunger then
setPlayerStorageValue(s, 1009, baseNurseryHunger)
end
else
if mypb.itemid ~= 0 and isPokeball(mypb.itemid) then
doItemSetAttribute(mypb.uid, "hp", 1)
if getItemAttribute(mypb.uid, "hunger") and getItemAttribute(mypb.uid, "hunger") > baseNurseryHunger then
doItemSetAttribute(mypb.uid, "hunger", baseNurseryHunger)
end
for c = 1, 15 do
local str = "move"..c
setCD(mypb.uid, str, 0)
end
if getItemAttribute(mypb.uid, "happy") and getItemAttribute(mypb.uid, "happy") < baseNurseryHappiness then
doItemSetAttribute(mypb.uid, "happy", baseNurseryHappiness)
end
if getPlayerStorageValue(cid, 17000) <= 0 and getPlayerStorageValue(cid, 17001) <= 0 and getPlayerStorageValue(cid, 63215) <= 0 then
for a, b in pairs (pokeballs) do
if isInArray(b.all, mypb.itemid) then
doTransformItem(mypb.uid, b.on)
end
end
end
end
end

local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)

local balls = getPokeballsInContainer(bp.uid)
if #balls >= 1 then
for _, uid in ipairs(balls) do
doItemSetAttribute(uid, "hp", 1)
for c = 1, 15 do
local str = "move"..c
setCD(uid, str, 0)
end
if getItemAttribute(uid, "hunger") and getItemAttribute(uid, "hunger") > baseNurseryHunger then
doItemSetAttribute(uid, "hunger", baseNurseryHunger)
end
if getItemAttribute(uid, "happy") and getItemAttribute(uid, "happy") < baseNurseryHappiness then
doItemSetAttribute(uid, "happy", baseNurseryHappiness)
end
local this = getThing(uid)
for a, b in pairs (pokeballs) do
if isInArray(b.all, this.itemid) then
doTransformItem(uid, b.on)
end
end
end
end
selfSay('There you go! You and your pokemons are healthy again.')
if useKpdoDlls then
doUpdateMoves(cid)
end
end
end

 

Editado por otaviogfl
Link para o comentário
Compartilhar em outros sites

 

 

function onStepIn(cid, item, pos)
local tempo = 1*60*60 -- Em segundos
if os.time()-getPlayerStorageValue(cid, 69413) > tempo then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)-getCreatureHealth(cid))
doCureStatus(cid, "all", true)
doSendMagicEffect(getThingPos(cid), 132)

local mypb = getPlayerSlotItem(cid, 8)

if #getCreatureSummons(cid) >= 1 then

if not nurseHealsPokemonOut then
selfSay("Please, return your pokemon to his ball!")
return true
end

local s = getCreatureSummons(cid)[1]
doCreatureAddHealth(s, getCreatureMaxHealth(s))
doSendMagicEffect(getThingPos(s), 13)
doCureStatus(s, "all", false)
if getPlayerStorageValue(s, 1008) < baseNurseryHappiness then
setPlayerStorageValue(s, 1008, baseNurseryHappiness)
end
if getPlayerStorageValue(s, 1009) > baseNurseryHunger then
setPlayerStorageValue(s, 1009, baseNurseryHunger)
end
else
if mypb.itemid ~= 0 and isPokeball(mypb.itemid) then
doItemSetAttribute(mypb.uid, "hp", 1)
if getItemAttribute(mypb.uid, "hunger") and getItemAttribute(mypb.uid, "hunger") > baseNurseryHunger then
doItemSetAttribute(mypb.uid, "hunger", baseNurseryHunger)
end
for c = 1, 15 do
local str = "move"..c
setCD(mypb.uid, str, 0)
end
if getItemAttribute(mypb.uid, "happy") and getItemAttribute(mypb.uid, "happy") < baseNurseryHappiness then
doItemSetAttribute(mypb.uid, "happy", baseNurseryHappiness)
end
if getPlayerStorageValue(cid, 17000) <= 0 and getPlayerStorageValue(cid, 17001) <= 0 and getPlayerStorageValue(cid, 63215) <= 0 then
for a, b in pairs (pokeballs) do
if isInArray(b.all, mypb.itemid) then
doTransformItem(mypb.uid, b.on)
end
end
end
end
end

local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)

local balls = getPokeballsInContainer(bp.uid)
if #balls >= 1 then
for _, uid in ipairs(balls) do
doItemSetAttribute(uid, "hp", 1)
for c = 1, 15 do
local str = "move"..c
setCD(uid, str, 0)
end
if getItemAttribute(uid, "hunger") and getItemAttribute(uid, "hunger") > baseNurseryHunger then
doItemSetAttribute(uid, "hunger", baseNurseryHunger)
end
if getItemAttribute(uid, "happy") and getItemAttribute(uid, "happy") < baseNurseryHappiness then
doItemSetAttribute(uid, "happy", baseNurseryHappiness)
end
local this = getThing(uid)
for a, b in pairs (pokeballs) do
if isInArray(b.all, this.itemid) then
doTransformItem(uid, b.on)
Set(uid, b.on)
else
return doPlayerSendCancel(cid, "Voce precisa esperar 1 minuto para curar seus pokemons.")
end
end
end
end

 

 

tenta esse

Link para o comentário
Compartilhar em outros sites

Aqui está, testei, e está funcionando perfeitamente.

Crie um arquivo .lua em data/movements/scripts com o nome tileheal, e adicione nele o seguinte conteúdo:

 

function onStepIn(cid, item, position, fromPosition)

if not isPlayer(cid) then return true end
if getPlayerStorageValue(cid, 100211) > os.time () then
doPlayerSendCancel(cid, "Aguarde "..getPlayerStorageValue(cid, 100211) - os.time().." segundo(s) para pisar aqui novamente.")
doTeleportThing(cid, fromPosition)
return true
end
if #getCreatureSummons(cid) >= 1 then
doPlayerSendCancel(cid, "Retorne seu pokémon para a pokeball.")
doTeleportThing(cid, fromPosition)
return true
end
local mypb = getPlayerSlotItem(cid, 8)
local s = getCreatureSummons(cid)[1]
doCreatureAddHealth(cid, getCreatureMaxHealth(cid)-getCreatureHealth(cid))
setPlayerStorageValue(cid, 100211, os.time () + 60)
doCureStatus(cid, "all", true)
doSendMagicEffect(getThingPos(cid), 14)
doPlayerSendTextMessage(cid, 27, "Suas energias foram recuperadas!")
if #getCreatureSummons(cid) >= 1 then
doCreatureAddHealth(s, getCreatureMaxHealth(s))
doSendMagicEffect(getThingPos(s), 13)
doCureStatus(s, "all", false)
end
if mypb.itemid ~= 0 and isPokeball(mypb.itemid) then
doItemSetAttribute(mypb.uid, "hp", 1)
end
for c = 1, 15 do
local str = "move"..c
setCD(mypb.uid, str, 0)
end
if getPlayerStorageValue(cid, 17000) <= 0 and getPlayerStorageValue(cid, 17001) <= 0 and getPlayerStorageValue(cid, 63215) <= 0 then
for a, b in pairs (pokeballs) do
if isInArray(b.all, mypb.itemid) then
doTransformItem(mypb.uid, b.on)
end
end
end
local bp = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)
local balls = getPokeballsInContainer(bp.uid)
if #balls >= 1 then
for _, uid in ipairs(balls) do
doItemSetAttribute(uid, "hp", 1)
for c = 1, 15 do
local str = "move"..c
setCD(uid, str, 0)
end
local this = getThing(uid)
for a, b in pairs (pokeballs) do
if isInArray(b.all, this.itemid) then
doTransformItem(uid, b.on)
end
end
end
end
if useKpdoDlls then
doUpdateMoves(cid)
end
return true
end

Depois, em data/movements, coloque a seguinte tag em movements.xml.
<movevent type="StepIn" actionid="coloque um action id que não esteja em uso no seu servidor" event="script" value="tileheal.lua"/>
Depois, basta configurar o tile no map editor.
Link para o comentário
Compartilhar em outros sites

 

Koell

Faltaram 2 "end" na linha 76 e 77 coloquei ai apareceu apenas esse erro:

 

 

[19/11/2013 23:02:48] [Error - MoveEvents Interface]

[19/11/2013 23:02:48] data/movements/scripts/healtile.lua:onStepIn

[19/11/2013 23:02:49] Description:

[19/11/2013 23:02:49] data/movements/scripts/healtile.lua:70: attempt to call global 'Set' (a nil value)

[19/11/2013 23:02:49] stack traceback:

[19/11/2013 23:02:49] data/movements/scripts/healtile.lua:70: in function

 

 

 

O pokemon que está no slot cura os da backpack não.

 

Mas vlw.

 

 

 

Zipter98

 

 

VLW mais uma vez me ajudou, funcionou perfeitamente.

Editado por otaviogfl
Link para o comentário
Compartilhar em outros sites

  • 4 years later...
A questão neste tópico de suporte foi encerrada por falta de respostas. Este tópico está fechado e foi movido para Suporte - Tópicos Sem Resposta.

+ Caso a dúvida não tenha sido resolvida você poderá criar outro tópico solicitando ajuda.
* Lembre-se que é permitido dar UP no tópico a cada 24 horas para assim o destacar e manter movimentado.
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...