-
Total de itens
2221 -
Registro em
-
Última visita
-
Dias Ganhos
60
Tudo que Yan Oliveira postou
-
Potion de Pokemon que cura metade da vida do pokémon
pergunta respondeu ao KaboFlow de Yan Oliveira em Scripts
Adicione esse script no seu arquivo.lua de potions: local function HealHealthPercent(cid, percent, effect) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end percent = percent / 100 doCreatureAddHealth(cid, health > 0 and math.floor(health * getCreatureHealth(cid)) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Heal") end --- TABELA COM O ID DAS POTIONS, TANTO DE PORCENTAGEM QUE CURA BASEADO NA VIDA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {percent = 25, effect = 13}, -- full restore [12348] = {percent = 50, effect = 13}, -- hyper potion [12346] = {percent = 75, effect = 13}, -- ultra potion [12345] = {percent = 100, effect = 13}, -- super potion } ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealHealthPercent(pokemon, potions[item.itemid].percent, potions[item.itemid].effect) doRemoveItem(item.uid, 1) return true end E na tabela de potions mude o Id no índice da tabela, e a porcentagem e efeito nos campos da tabela. -
(Pedido) Script de teletransporte em membros da party
pergunta respondeu ao Sugismundo de Yan Oliveira em Scripts
Tem algum motivo plausível para você querer como uma spell? Por que não pode ser por talkaction? -
Sobre a fala se repetir apenas uma vez, sem problemas! Troque o código por esse: local function HealPerTurn(cid, health, effect, time, seconds) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) local storage_say = 78787 -- STORAGE PARA NÃO REPETIR A FALA if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if time <= 0 then return true else if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end doCreatureAddHealth(cid, health > 0 and math.floor(health) or 1) doSendMagicEffect(getThingPos(cid), effect) if getPlayerStorageValue(cid, storage_say) < 1 then doCreatureSay(cid, "Healing") setPlayerStorageValue(cid, storage_say, 1) end addEvent(HealPerTurn, duration, cid, health, effect, time - 1, seconds) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {health = 1000, effect = 13}, -- full restore [12348] = {health = 3500, effect = 13}, -- hyper potion [12346] = {health = 5000, effect = 13}, -- ultra potion [12345] = {health = 8000, effect = 13}, -- super potion } local vezes_repete = 10 -- QUANTAS VEZES VAI REPETIR O EFEITO local segundos = 1 -- TEMPO EM SEGUNDOS PARA REPETIR O EFEITO ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealPerTurn(pokemon, potions[item.itemid].health, potions[item.itemid].effect, vezes_repete, segundos) doRemoveItem(item.uid, 1) return true end Sobre esse outro script que você quer, vai ter que criar um tópico novo para isso. Cria que eu te ajudo.
-
Deixei a fala apenas por enfeite, mas é bem simples, troque o código por esse: local function HealPerTurn(cid, health, effect, time, seconds) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if time <= 0 then return true else if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end doCreatureAddHealth(cid, health > 0 and math.floor(health) or 1) doSendMagicEffect(getThingPos(cid), effect) addEvent(HealPerTurn, duration, cid, health, effect, time - 1, seconds) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {health = 1000, effect = 13}, -- full restore [12348] = {health = 3500, effect = 13}, -- hyper potion [12346] = {health = 5000, effect = 13}, -- ultra potion [12345] = {health = 8000, effect = 13}, -- super potion } local vezes_repete = 10 -- QUANTAS VEZES VAI REPETIR O EFEITO local segundos = 1 -- TEMPO EM SEGUNDOS PARA REPETIR O EFEITO ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealPerTurn(pokemon, potions[item.itemid].health, potions[item.itemid].effect, vezes_repete, segundos) doRemoveItem(item.uid, 1) return true end
-
Você precisa explicar melhor, pois quando falou que está usando infinito, eu entendi que a cura estava sendo infinita, e não o uso. E sim, realmente esqueci de remover o item. Sobre esse erro, nos testes que fiz aqui não deu. Você está usando em summon ou player? Arrumei e agora está removendo o item: local function HealPerTurn(cid, health, effect, time, seconds) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if time <= 0 then return true else if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end doCreatureAddHealth(cid, health > 0 and math.floor(health) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Healing...") addEvent(HealPerTurn, duration, cid, health, effect, time - 1, seconds) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {health = 1000, effect = 13}, -- full restore [12348] = {health = 3500, effect = 13}, -- hyper potion [12346] = {health = 5000, effect = 13}, -- ultra potion [12345] = {health = 8000, effect = 13}, -- super potion } local vezes_repete = 10 -- QUANTAS VEZES VAI REPETIR O EFEITO local segundos = 1 -- TEMPO EM SEGUNDOS PARA REPETIR O EFEITO ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealPerTurn(pokemon, potions[item.itemid].health, potions[item.itemid].effect, vezes_repete, segundos) doRemoveItem(item.uid, 1) return true end
-
Sim, eu entendi o que você quer. É estranho, pois eu testei aqui e está funcionando normal. Troque o código por esse: local function HealPerTurn(cid, health, effect, time, seconds) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if time <= 0 then return true else if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end doCreatureAddHealth(cid, health > 0 and math.floor(health) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Healing...") addEvent(HealPerTurn, duration, cid, health, effect, time - 1, seconds) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12347] = {health = 1000, effect = 13}, -- full restore [12348] = {health = 3500, effect = 13}, -- hyper potion [12346] = {health = 5000, effect = 13}, -- ultra potion [12345] = {health = 8000, effect = 13}, -- super potion } local vezes_repete = 10 -- QUANTAS VEZES VAI REPETIR O EFEITO local segundos = 1 -- TEMPO EM SEGUNDOS PARA REPETIR O EFEITO ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealPerTurn(pokemon, potions[item.itemid].health, potions[item.itemid].effect, vezes_repete, segundos) return true end Já está configurado para curar o tanto de health que tem em cada potion na tabela das potions por 10 segundos.
-
Sobre erro, é porque eu escrevi errado o nome da função, digitei uma letra errada, troque o código por esse: local function HealPerTurn(cid, health, effect, seconds, time) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if time <= 0 then return true else if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end doCreatureAddHealth(cid, health > 0 and math.floor(health) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSay(cid, "Healing...") addEvent(HealPerTurn, duration, cid, health, effect, seconds, time - 1) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12343] = {health = 1000, effect = 14}, -- full restore [12345] = {health = 3500, effect = 14}, -- hyper potion [12346] = {health = 5000, effect = 12}, -- ultra potion [12347] = {health = 8000, effect = 13}, -- super potion [12348] = {health = 10000, effect = 13}, -- great potion } local vezes_repete = 10 -- QUANTAS VEZES VAI REPETIR O EFEITO local segundos = 1 -- TEMPO EM SEGUNDOS PARA REPETIR O EFEITO ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealPerTurn(pokemon, potions[item.itemid].health, potions[item.itemid].effect, vezes_repete, segundos) return true end E sobre só curar uma vez, foi erro meu, eu havia esquecido de fazer recursão.
-
Esqueci de colocar o campo health da tabela das potions no parâmetro health da função. Troque o código por esse: local function HealPerTurn(cid, health, effect, time, seconds) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if time <= 0 then return true else if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end doCreatureAddHealth(cid, health > 0 and math.floor(health) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSau(cid, "Healing...") addEvent(HealPerTurn, duration, cid, health, effect, time, seconds) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12343] = {health = 1000, effect = 14}, -- full restore [12345] = {health = 3500, effect = 14}, -- hyper potion [12346] = {health = 5000, effect = 12}, -- ultra potion [12347] = {health = 8000, effect = 13}, -- super potion [12348] = {health = 10000, effect = 13}, -- great potion } local vezes_repete = 10 -- QUANTAS VEZES VAI REPETIR O EFEITO local segundos = 1 -- TEMPO EM SEGUNDOS PARA REPETIR O EFEITO ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealPerTurn(pokemon, potions[item.itemid].health, potions[item.itemid].effect, vezes_repete, segundos) return true end
-
De nada, que bom que deu certo ?.
-
Se tivesse explicado isso desde o começo, teria sido mais fácil rsrs. Pois, não precisaria de todos esses scripts. Do jeito que você quer é mais fácil do que eu pensei. Eu pensei em falar para você excluir os scripts que tinha feito, mas deixa caso queira usar em outra coisa, como loteria, quests ou recompensa por exemplo. Vá em Data/Talkactions/Scripts e crie o arquivo chamado add_points.lua e adicione o código: local item_id = 2160 -- ID DOS POINTS local effect = false -- SE QUISER COM EFEITO AO RECEBER O ITEM MUDE PARA TRUE local effect_id = 27 -- EFEITO DO ID AO RECEBER O ITEM local level_acess = 4 -- ACESSO DO PLAYER (PLAYER - TUTOR - GM - CM - ADM), DEIXE 4 OU MAIS PARA STAFF E 6 PARA ADM function onSay(cid, words, param) local command = string.explode(param, ",") local name = string.lower(command[1]) -- SCRIPT SOMENTE PARA STAFF -- if getPlayerAccess(cid) < level_acess then return true end if param == nil or param == "" then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você precisa informar o nome do player para receber os pontos.") elseif string.len(param) < 3 then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você precisa informar um nome válido do player para receber os pontos.") elseif tonumber(command[2]) == nil or tonumber(command[2]) <= 0 then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você precisa informar uma quantia válida de pontos.") else if #getPlayersOnline() > 1 then for index, player in pairs(getPlayersOnline()) do local player_name = string.lower(getCreatureName(player)) if name == player_name then local points = tonumber(command[2]) local message = "" if points > 1 then message = "Obrigado por ter donatado! Como recompensa, você recebeu " .. points .. " points." -- MENSAGEM QUE O PLAYER VAI RECEBER NO CHAT elseif points == 1 then message = "Obrigado por ter donatado! Como recompensa, você recebeu " .. points .. " point." -- MENSAGEM QUE O PLAYER VAI RECEBER NO CHAT end doPlayerAddItem(player, item_id, points) doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_BLUE, message) -- VERIFICA SE VAI RECEBER EFEITO -- if effect then doSendMagicEffect(getThingPos(player), effect_id) end return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "O player " .. command[1] .. " recebeu a recompensa.") end if index == #getPlayersOnline() and name ~= player_name then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "O player " .. command[1] .. " não está online.") end end else return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Não há jogadores online!") end end end Agora abra o talkactions.xml e adicione a tag: <talkaction words="!addpoints" acess="6" event="script" value="add_points.lua"/> Continua via comando (talkaction), e para utilizar, funciona assim, você precisa digitar o comando !addpoints nome do player, quantidade de points: !addpoints Administrador, 50 E todas as variáveis estão comentadas, e segue o mesmo padrão do script antigo, porém a mensagem do player está dentro do for, então se quiser mudar está lá. Só mudar o id do item na primeira variável e lembrando que coloquei restrição de acesso, ou seja, somente membros da staff pode usar, no caso deixei nível de acesso 4, então GM, CM e ADM conseguiram usar o comando, se quiser só ADM, mude para 6 a variável level_acess. Eu testei aqui e está funcionando certinho, só não esqueça de comentar a tag xml da talkaction antiga se não for usar, pois esqueci de fazer verificação de acesso nela e qualquer player consegue usar. E fica seu critério excluir o script da box na pasta Actions também.
-
Entendi, então por exemplo, se o player donatar 20 reais ele ganha pontos, que no caso vem 20 moedas ou diamantes, é isso? Então é um item só que muda a quantidade apenas?
-
Você não entendeu, não estou falando da box, estou falando dos itens que o player tira ao clicar na box, igual eu fiz no script.
-
Então, foi como te falei, eu te dei duas sugestões, uma é por box e outro por tabela. Pensei em fazer assim, quando for usar a talkaction, você usa um parâmetro numérico que vão ser os pontos, e de acordo com o parâmetro, o player vai receber X quantidade de itens. Você quer que receba de forma aleatória ou por ordem que os itens ficam na tabela?
-
Agora entendi perfeitamente, mas assim, agora que entendi melhor, eu acho que isso pode ser problemático, porque se o cara donatar valores altos vai ter que dar itens de acordo com a quantidade, e chega uma hora que fica complicado isso. Recomendo tabelar isso. Mas nesse caso, no script que eu fiz, você tem duas alternativas, tabelar por quantidade na tabela de itens no script da pasta Actions ou por parâmetro no comando talkaction que entrega a box colocar quantas box ele recebe, e se você quiser o segundo caso, recomendo colocar o item da box como agrupável, porque se não vai ocupar muito espaço na bag do player.
-
É uma vírgula extra, devo ter inserido sem querer e nem percebi. Troca o código por esse: local function HealPerTurn(cid, health, effect, time, seconds) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if time <= 0 then return true else if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end doCreatureAddHealth(cid, health > 0 and math.floor(health) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSau(cid, "Healing...") addEvent(HealPerTurn, duration, cid, health, effect, time, seconds) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12343] = {health = 1000, effect = 14}, -- full restore [12345] = {health = 3500, effect = 14}, -- hyper potion [12346] = {health = 5000, effect = 12}, -- ultra potion [12347] = {health = 8000, effect = 13}, -- super potion [12348] = {health = 10000, effect = 13}, -- great potion } local vezes_repete = 10 -- QUANTAS VEZES VAI REPETIR O EFEITO local segundos = 1 -- TEMPO EM SEGUNDOS PARA REPETIR O EFEITO ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealPerTurn(pokemon, potions[item.itemid], potions[item.itemid].effect, vezes_repete, segundos) return true end
-
No caso seria 10x box certo?
-
local function HealPerTurn(cid, health, effect, time, seconds) local duration = seconds > 0 and math.floor(1000 * seconds) or math.floor(1000 * 1) -- EQUIVALENTE A 1 SEGUNDO (MILISSEGUNDOS) if not cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used only in creatures.") return true end if time <= 0 then return true else if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then return doPlayerSendCancel(cid, "Your health is full.") end doCreatureAddHealth(cid, health > 0 and math.floor(health) or 1) doSendMagicEffect(getThingPos(cid), effect) doCreatureSau(cid, "Healing..."), addEvent(HealPerTurn, duration, cid, health, effect, time, seconds) end end --- TABELA COM O ID DAS POTIONS, TANTO DE VIDA QUE CURA CADA UMA E EFEITO AO USAR A POÇÃO --- local potions = { [12343] = {health = 1000, effect = 14}, -- full restore [12345] = {health = 3500, effect = 14}, -- hyper potion [12346] = {health = 5000, effect = 12}, -- ultra potion [12347] = {health = 8000, effect = 13}, -- super potion [12348] = {health = 10000, effect = 13}, -- great potion } local vezes_repete = 10 -- QUANTAS VEZES VAI REPETIR O EFEITO local segundos = 1 -- TEMPO EM SEGUNDOS PARA REPETIR O EFEITO ---------------------------- CÓDIGO -------------------------------- function onUse(cid, item, toPos, itemEx, FromPos) local pokemon = getCreatureSummons(cid)[1] -- PEGA O PRIMEIRO SUMMON DO PLAYER (POKEMON) if not pokemon then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Potions can be used in a pokémon.") return true end if not isSummon(pokemon) or getCreatureMaster(pokemon) ~= cid then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use potion only in your own pokémon.") return doPlayerSendCancel(cid, "You can use potion only in your pokémon.") end if getPlayerStorageValue(cid, 52481) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't do that while a duel.") return doPlayerSendCancel(cid, "You can't do that while a duel.") end if getPlayerStorageValue(cid, 990) >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't use potion during gym battles.") return doPlayerSendCancel(cid, "You can't use potion during gym battles.") end HealPerTurn(pokemon, potions[item.itemid], potions[item.itemid].effect, vezes_repete, segundos) return true end Substitua o código por esse e mude os id das potions na tabela e as respectivas vida e efeito de cada potion. Deixei todas as variáveis comentadas, só mudar os valores na tabela de potions que está tudo pronto.
-
Sobre a box não sumir foi erro meu, esqueci de remover. Sabia que estava esquecendo algo haha. Troque o código da pasta actions por esse: -- TABELA COM O ID DOS ITENS E A QUANTIDADE -- local items = { {id = 2152, quantidade = 1000}, {id = 2160, quantidade = 100}, {id = 13250, quantidade = 1}, {id = 13255, quantidade = 5}, {id = 13260, quantidade = 10}, } local effect = false -- COLOQUE TRUE SE QUER QUE O PLAYER RECEBA EFEITO AO ABRIR A BOX local effect_id = 30 -- ID DO EFEITO AO RECEBER A BOX local table_random = false -- SE QUISER QUE RECEBE ITENS ALEATÓRIOS MUDE PARA TRUE OU DEIXE FALSE PARA O PLAYER RECEBER TODOS OS ITENS -------------------------------------------- CÓDIGO ------------------------------------------ function onUse(cid, item, fromPosition, itemEx, toPosition) if table_random then local random_item = math.random(1, #items) -- PEGA UM ÍNDICE ALEATÓRIO DA TABELA PARA DAR O ITEM DE FORMA ALEATÓRIA doPlayerAddItem(cid, items[random_item].id, items[random_item].quantidade) if items[random_item].quantidade > 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você recebeu " .. "x" .. items[random_item].quantidade .. " " .. getItemNameById(items[random_item].id) .. ".") elseif items[random_item].quantidade == 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você recebeu " .. getItemNameById(items[random_item].id) .. ".") else return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Houve um problema ao receber o item, por favor report o problema.") end if effect then doSendMagicEffect(getThingPos(cid), effect_id) end doRemoveItem(item.uid, 1) return true else for i = 1, #items do doPlayerAddItem(cid, items[i].id, items[i].quantidade) if items[i].quantidade > 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você recebeu " .. "x" .. items[i].quantidade .. " " .. getItemNameById(items[i].id) .. ".") elseif items[i].quantidade == 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você recebeu " .. getItemNameById(items[i].id) .. ".") else return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Houve um problema ao receber o item, por favor report o problema.") end -- SE ESTÁ TRUE RECEBE O EFEITO AO ABRIR A BOX -- if effect then doSendMagicEffect(getThingPos(cid), effect_id) end doRemoveItem(item.uid, 1) end return true end end Sobre sua pergunta, de o player donatar mais, eu não entendi muito bem o que você quis dizer. No caso os pontos seria itens da recompensa ou você fala da quantidade de box?
-
Entendi, vamos lá! Não sei se você já tem a sprite no seu cliente de uma box ou se tem algum item em mente para usar, mas estou te facilitando a vida já te mandando a sprite em PNG e OBD, só adicionar no cliente caso queira, peguei de um pokétibia que tenho aqui. Tem algumas maneiras do player receber a box, pode ser de maneira mais direta ou automatizada. Pensei na direta, porque a automatizada que tive em mente teria que fazer mais coisas e não sei se no seu caso compensa, pois você parece querer ter esse controle de entregar para player, então vamos fazer por talkaction! Primeiramente vá em Data/Talkactions/Scripts e crie um arquivo.lua chamado player_vip_box_item.lua ou o nome que você quiser e adicione o código dentro: local item_id = 13258 -- ID DO ITEM DA BOX local quantidade = 1 -- QUANTIDADE DE BOX QUE O PLAYER VAI RECEBER local message = "Obrigado por ter donatado! Como recompensa, você receberá uma box com um item surpresa." -- MENSAGEM QUE O PLAYER VAI RECEBER NO CHAT local effect = false -- SE QUISER COM EFEITO AO RECEBER O ITEM MUDE PARA TRUE local effect_id = 27 -- EFEITO DO ID AO RECEBER O ITEM function onSay(cid, words, param) local name = string.lower(param) if param == nil or param == "" then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você precisa informar o nome do player para receber o item vip.") elseif string.len(param) < 3 then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você precisa informar um nome válido do player para receber o item vip.") else if #getPlayersOnline() > 1 then for index, player in pairs(getPlayersOnline()) do local player_name = string.lower(getCreatureName(player)) if name == player_name then doPlayerAddItem(player, item_id, quantidade) doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_BLUE, message) -- VERIFICA SE VAI RECEBER EFEITO -- if effect then doSendMagicEffect(getThingPos(player), effect_id) end return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "O player " .. param .. " recebeu a recompensa.") end if index == #getPlayersOnline() and name ~= player_name then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "O player " .. param .. " não está online.") end end else return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Não há jogadores online!") end end end E agora volte um diretório na pasta de Talkactions e abra o arquivo talkactions.xml e adicione a tag: <talkaction words="!vipitem" acess="6" event="script" value="player_vip_box_item.lua"/> Agora vá em Data/Actions/Scripts e crie o arquivo vip_box_item.lua ou o nome que quiser e adicione o código dentro: -- TABELA COM O ID DOS ITENS E A QUANTIDADE -- local items = { {id = 2152, quantidade = 1000}, {id = 2160, quantidade = 100}, {id = 13250, quantidade = 1}, {id = 13255, quantidade = 5}, {id = 13260, quantidade = 10}, } local effect = false -- COLOQUE TRUE SE QUER QUE O PLAYER RECEBA EFEITO AO ABRIR A BOX local effect_id = 30 -- ID DO EFEITO AO RECEBER A BOX local table_random = false -- SE QUISER QUE RECEBE ITENS ALEATÓRIOS MUDE PARA TRUE OU DEIXE FALSE PARA O PLAYER RECEBER TODOS OS ITENS -------------------------------------------- CÓDIGO ------------------------------------------ function onUse(cid, item, fromPosition, itemEx, toPosition) if table_random then local random_item = math.random(1, #items) -- PEGA UM ÍNDICE ALEATÓRIO DA TABELA PARA DAR O ITEM DE FORMA ALEATÓRIA doPlayerAddItem(cid, items[random_item].id, items[random_item].quantidade) if items[random_item].quantidade > 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você recebeu " .. "x" .. items[random_item].quantidade .. " " .. getItemNameById(items[random_item].id) .. ".") elseif items[random_item].quantidade == 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você recebeu " .. getItemNameById(items[random_item].id) .. ".") else return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Houve um problema ao receber o item, por favor report o problema.") end if effect then doSendMagicEffect(getThingPos(cid), effect_id) end return true else for i = 1, #items do doPlayerAddItem(cid, items[i].id, items[i].quantidade) if items[i].quantidade > 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você recebeu " .. "x" .. items[i].quantidade .. " " .. getItemNameById(items[i].id) .. ".") elseif items[i].quantidade == 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você recebeu " .. getItemNameById(items[i].id) .. ".") else return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Houve um problema ao receber o item, por favor report o problema.") end -- SE ESTÁ TRUE RECEBE O EFEITO AO ABRIR A BOX -- if effect then doSendMagicEffect(getThingPos(cid), effect_id) end end return true end end Por fim na pasta Actions volte um diretório e abra o arquivo actions.xml e adicione a tag: <action itemid="XXXX" event="script" value="vip_box_item.lua"/> <!-- COLOQUE O ID DO ITEM ONDE ESTÁ XXXX --> Onde está XXXX você coloca o id do item (até deixei comentado no fim da tag xml. --------- EXPLICAÇÃO -------- O script vai funcionar da seguinte maneira: Você irá dar ao player a box via comando talkactions e só funciona se o player estiver online. A talkaction é: !vipitem Nome Então com o comando !vipitem mais o nome do player irá adicionar o item se ele estiver online. No código ele converte o nome do player para minúsculo, então se tiver players com nome iguais mais com o tamanho do caractere diferente, vai dar ruim e vai adicionar para os dois, para quem tiver online ou para nenhum. Tem mensagens para todo tipo de situação, se o player está offline, se você digitar nome do player com menos de 3 caracteres ou se não digitar o nome. Eu fiz variáveis booleana que se você quiser que tenha efeito ao player receber a box ou abrir só mudar para true no código a variável effect. E no arquivo da pasta actions tem a tabela com os itens, só colocar o id e a quantidade de cada item. Se quiser dar só um item é só deixar a tabela com um item. E a variável table_random é para caso sorteie um item aleatório quando o player abrir a box (clicar), e nesse caso ele vai receber um item só! Agora se quiser que receba todos da tabela, deixe a variável table_random como false, se quiser aleatório coloque true. Eu deixei tudo comentado e está bem intuitivo, e eu testei somente o código do talkactions, pois o do actions é bem fácil e eu fiz de cabeça, mas analisei certinho e não é para dar problema. Qualquer erro ou problema, me avise. box_item.rar
-
Certo, e para os players comprarem vip estão comprando pelo site ou em contato direto com você?
-
Posta esse script moveItem.lua
-
poketibia [Resolvido] Mudar Itens iniciais Base Psoul
pergunta respondeu ao manojl de Yan Oliveira em Resolvidos
Vai na pasta Data/Actions/Script e veja se tem o arquivo starter.lua ou inicias.lua e se tiver, posta ele. Mas, basicamente, nesses arquivos tem a função: doPlayerAddItem(id, quantidade) Nessa função você adiciona os itens, só mudar id e colocar quantidade. Mas, caso não consiga, poste o script. -
Seu servidor tem shop ou site?
-
Amigo, independente se for por site ou por script via servidor, as informações do jogo e do player vão para o banco. Tudo no jogo é salvo no banco, então de qualquer forma você terá que fazer script. Eu acho mais fácil fazer como falei porque é muito fácil fazer esse script em lua, o player vai receber na bag e não vai ter trabalho de ter que clicar em baú, fora que por ser aleatório (no caso da box), da sempre a sensação do cara ganhar itens bons, por mais que seja itens fixo. E fora que por site você vai ter que mexer com PHP e os sites que já vem nas bases de Open Tibia foram mal feitos e mal estruturado. Mas, veja como quer fazer e vemos um jeito de te ajudar.
-
Se são itens, o melhor jeito é fazer por box igual eu te falei. Você vai gastar espaço no mapa para uma coisa muito específica que não é uma quest, task ou evento. Eu acho que vale a pena fazer por box igual poketibia como comentei. Mas, vai de você! Eu acho que seria bem legal o player receber uma box porque da sensação que ele sempre pode receber um item bom, já por baú da a sensação de receber sempre o mesmo item. Mas, veja como quer e penso uma maneira de te ajudar.
-
Quem Está Navegando 0 membros estão online
- Nenhum usuário registrado visualizando esta página.