Ir para conteúdo

Yan Oliveira

Moderador
  • Total de itens

    2221
  • Registro em

  • Última visita

  • Dias Ganhos

    60

Tudo que Yan Oliveira postou

  1. Yan Oliveira

    Pokemon Inicial

    Conseguiu resolver o problema?
  2. Qual erro gerou?
  3. Que bom que funcionou. Obrigado ?.
  4. Primeiramente, obrigado pelo elogio, procuro sempre deixar os scripts de maneira fácil, para que qualquer um entenda. Sobre não teleportar, eu não tinha visto que seu TFS é 1.3, achei que era 0.4. O 1.3 é mais fácil ainda de fazer, troque o script por esse: local item_id = 1945 -- ID DA ALAVANCA local action_id = 8756 -- ACTION ID QUE COLOCOU NA ALAVANCA NO REMERES -- POSIÇÃO QUE OS PLAYERS TEM QUE ESTAR AO CLICAR NA ALAVANCA -- local position_players = { Position(1082, 1050, 7), Position(1082, 1051, 7), Position(1082, 1052, 7), Position(1082, 1053, 7), Position(1082, 1054, 7) } -- TABELA DOS MONSTROS E SUAS RESPECTIVAS POSIÇÕES DE ACORDO COM A QUANTIDADE DE PLAYERS TELEPORTADOS local monsters = { {nome = "Rat", pos = Position(1208, 960, 7)}, -- MONSTRO QUE VAI NASCER SE SÓ 1 PLAYER FOR TELEPORTADO {nome = "Centipede", pos = Position(1208, 960, 7)}, -- MONSTRO QUE VAI NASCER SE 2 PLAYERS FOR TELEPORTADO {nome = "Cockroach", pos = Position(1208, 960, 7)}, -- MONSTRO QUE VAI NASCER SE 3 PLAYERS FOR TELEPORTADO {nome = "spider", pos = Position(1208, 960, 7)}, -- MONSTRO QUE VAI NASCER SE 4 PLAYERS FOR TELEPORTADO {nome = "Paterson macion", pos = Position(1208, 960, 7)} -- MONSTRO QUE VAI NASCER SE 5 PLAYERS FOR TELEPORTADO } local position_destino = Position(1202, 960, 7) -- POSIÇÃO ONDE OS PLAYERS SERÃO TELEPORTADOS storage_global_quest = 89578 -- STORAGE GLOBAL, NÃO PODE SER USADO ESSE VALOR PARA OUTRA STORAGE E NEM PARA PLAYER local cooldown_alavanca = 3 -- TEMPO EM MINUTOS PARA O COOLDOWN DA ALAVANCA Game.setStorageValue(storage_global_quest, os.time()) -- COMEÇA SETANDO A VARIÁVEL GLOBAL COM HORÁRIO PARA NÃO FICAR VALOR NIL NA VARIÁVEL(POIS NÃO FOI SETADA ANTES) -- NÃO MEXER, SÃO VARIÁVEIS PARA PEGAR O RADIUS E VERIFICAR TODOS OS PLAYERS DENTRO DO RAIO NA FUNÇÃO GETSPECTATOR -- local y_inicial = 1050 -- TILE INICIAL (RADIUS Y INICIAL) local y_final = 1054 -- TILE FINAL (RADIUS Y FINAL) local center = Position(1082, 1052, 7) -- COORDENADA ONDE PEGA O TILE QUE FICA NO CENTRO DA DISTÂNCIA TOTAL RADIUS X,Y MIN E MAX local y = math.floor((y_final + y_inicial) / 2) -- MÉDIA DO RADIUS (PARA IR ATÉ AS DISTÂNCIAS A PARTIR DA MÉDIA) ----------------------------------------- CÓDIGO ----------------------------------------- function onUse(cid, item, fromPos, itemEx, toPos) if (item.itemid == item_id) and (item.actionid == action_id) then if Game.getStorageValue(storage_global_quest) <= os.time() then local players = Game.getSpectators(center, false, true, 1, 1, y, y) count_players = #players for _, player in pairs (players) do player:teleportTo(position_destino) end if #players ==1 then Game.createMonster(monsters[1].nome, monsters[1].pos) elseif #players ==2 then Game.createMonster(monsters[2].nome, monsters[2].pos) elseif #players ==3 then Game.createMonster(monsters[3].nome, monsters[3].pos) elseif #players ==4 then Game.createMonster(monsters[4].nome, monsters[4].pos) elseif #players ==5 then Game.createMonster(monsters[5].nome, monsters[5].pos) end for _, player in pairs (players) do player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Good lucky!") end Game.setStorageValue(storage_global_quest, os.time() + (60 * cooldown_alavanca)) return true else return cid:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "The switch is in cooldown. You need to wait.") end end end Já arrumei o valor das variáveis, das coordenadas e o nome dos mosntros para você. Testei aqui e funcionou.
  5. Yan Oliveira

    (BUG) Revive

    Então cara, é estranho, porque olhei o revive em bases diferentes e todas usa o mesmo script de revive, que é o mesmo que o seu. Tem que ver se você não mexeu na tabela global pokeballs.
  6. Mas, de qual maneira quer pegar a vida de outro jogador? Sobre o doSendMagicEffect(), é só na source para mexer nele. Mas, essa função executa o efeito das suas sprites, então se quer uma sprite longa, coloque animações maiores.
  7. Obrigado pelo elogio. Então, não uso não, eu faço de cabeça mesmo. Mas, se é algum script parecido com algum que já fiz, eu adapto para poupar tempo.
  8. Foi, por que?
  9. Você já tinha criado esse mesmo tópico em outra seção (apesar de essa ser a correta para o seu caso). Não fique spamando tópicos, aguarde ser respondido. Eu fiz o script no outro tópico.
  10. Yan Oliveira

    (BUG) Revive

    Qual é a base do seu servidor? É PDA ou DXP?
  11. Vai em Data/Actions/Scripts e crie o arquivo quest_alavanca.lua (ou um nome que preferir), e adicione o código: local id_alavanca = 1945 -- ID DA ALAVANCA local action_id = 6542 -- ACTION ID QUE COLOCOU NA ALAVANCA NO REMERES -- POSIÇÃO QUE OS PLAYERS TEM QUE ESTAR AO CLICAR NA ALAVANCA -- local position_players = { {x= 1000, y= 1000, z=7}, {x= 1001, y= 1001, z=7}, {x= 1002, y= 1002, z=7}, {x= 1003, y= 1003, z=7}, {x= 1004, y= 1004, z=7} } -- TABELA DOS MONSTROS E SUAS RESPECTIVAS POSIÇÕES DE ACORDO COM A QUANTIDADE DE PLAYERS TELEPORTADOS local monsters = { {nome = "Ferumbras", pos = {x= 1500, y= 1050, z=7}}, -- MONSTRO QUE VAI NASCER SE SÓ 1 PLAYER FOR TELEPORTADO {nome = "Goblins", pos = {x= 1500, y= 1050, z=7}}, -- MONSTRO QUE VAI NASCER SE 2 PLAYERS FOR TELEPORTADO {nome = "Medusa", pos = {x= 1500, y= 1050, z=7}}, -- MONSTRO QUE VAI NASCER SE 3 PLAYERS FOR TELEPORTADO {nome = "Mage", pos = {x= 1500, y= 1050, z=7}}, -- MONSTRO QUE VAI NASCER SE 4 PLAYERS FOR TELEPORTADO {nome = "Skull", pos = {x= 1500, y= 1050, z=7}} -- MONSTRO QUE VAI NASCER SE 5 PLAYERS FOR TELEPORTADO } local position_destino = {x= 1500, y= 1020, z= 7} -- POSIÇÃO ONDE OS PLAYERS SERÃO TELEPORTADOS storage_global_quest = 87898 -- STORAGE GLOBAL, NÃO PODE SER USADO ESSE VALOR PARA OUTRA STORAGE E NEM PARA PLAYER local cooldown_alavanca = 3 -- TEMPO EM MINUTOS PARA O COOLDOWN DA ALAVANCA ----------------------------------------- CÓDIGO ----------------------------------------- function onUse(cid, item, fromPos, itemEx, toPos) local player = nil local count_players = 0 if (item.itemid == id_alavanca) and (item.actionid == action_id) then if getGlobalStorageValue(storage_global_quest) <= os.time() then for i = 1, #position_players do player = getTileThingByPos(position_players[i]) if isPlayer(player.uid) then doTeleportThing(player.uid, position_destino) count_players = count_players + 1 end if (i == #position_players) and (count_players == 0) then return true end end if count_players == 1 then doCreateMonster(monsters[1].nome, monsters[1].pos) elseif count_players == 2 then doCreateMonster(monsters[2].nome, monsters[2].pos) elseif count_players == 3 then doCreateMonster(monsters[3].nome, monsters[3].pos) elseif count_players == 4 then doCreateMonster(monsters[4].nome, monsters[4].pos) elseif count_players == 5 then doCreateMonster(monsters[5].nome, monsters[5].pos) end doPlayerSendTextMessage(player.uid, MESSAGE_STATUS_CONSOLE_BLUE, "Good lucky!") setGlobalStorageValue(storage_global_quest, os.time() + (60 * cooldown_alavanca)) return true else return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The switch is in cooldown. You need to wait.") end end end Deixei tudo comentado, então está bem fácil de identificar, coloquei variável para determinar tempo de cooldown em minutos da alavanca ao clicar novamente (lembrando que tem que colocar uma storage ali que não foi usada ainda, e nem pode ser usada para outra coisa, pois, ela é global). Você também precisa arrumar as coordenadas das posições e o nome dos monstros (igual está no xml dele). Agora abre o actions.xml e adicione a tag: <action actionid="6542" event="script" value="quest_alavanca.lua"/> Coloquei verificação por actionid porque provavelmente essa alavanca deve ser usada em outras quests, então, você tem que colocar uma actionid (ou a mesma que coloquei ali de exemplo, caso não esteja em uso) nessa alavanca no Remere's (mapa). Após colocar no mapa, arrume o id da action na tag xml e na variável action_id no script.lua. Então, o script vai criar os monstros de acordo com a quantidade de players, deixei o limite de 5, e não esqueça de arrumar as coordenadas, deixei tudo genérico. Teste e fale se der algum erro.
  12. Que bom que deu certo! De nada.
  13. Tinha esquecido de adicionar a nova tabela no array, pois, como criei uma tabela nova, ai faltou passar para o isInArray. local STORAGE_SKILL_LEVEL = 10009 local STORAGE_SKILL_TRY = 10007 local config = { levels = { {level = {0,9}, quant = {1,1}, percent = 5}, {level = {10,19}, quant = {1,1}, percent = 10}, {level = {20,29}, quant = {1,1}, percent = 15}, {level = {30,39}, quant = {1,1}, percent = 20}, {level = {40,49}, quant = {1,1}, percent = 25}, {level = {50,59}, quant = {1,1}, percent = 30}, {level = {60,69}, quant = {1,1}, percent = 30}, {level = {70,79}, quant = {1,1}, percent = 35}, {level = {80,89}, quant = {1,1}, percent = 35}, {level = {90,99}, quant = {1,1}, percent = 40}, {level = {100}, quant = {1,1}, percent = 50} }, -- Rocks = Id das rochas que podem ser quebradas || -- Stone = Modelo {rock_id, rock_id} -- stones = { {rock = 5092, ore = 5097}, {rock = 5093, ore = 5099}, {rock = 5094, ore = 5100}, {rock = 5095, ore = 5098}, } rock_delay = 60, -- Tempo de volta da rocha (Em segundos) bonus_chance = 3, -- Chance (em porcentagem) de se conseguir um bonus de exp bonus_exp = 1 -- Bonus extra } ------------------------------------ -- END Configurations --- ------------------------------------ function getCuttingLevel(cid) return getPlayerStorageValue(cid, STORAGE_SKILL_LEVEL) end function setPlayerCuttingLevel(cid, n) setPlayerStorageValue(cid, STORAGE_SKILL_LEVEL, n) end function addCuttingLevel(cid, n) setPlayerCuttingLevel(cid, getCuttingLevel(cid) + (isNumber(n) and n or 1)) setCuttingTry(cid, 0) end function getCuttingInfo(cid) for i = 1, #config.levels do min = config.levels[i].level[1]; max = config.levels[i].level[2] if (getCuttingLevel(cid) >= min and getCuttingLevel(cid) <= max) then return {quantity = {min = config.levels[i].quant[1], max = config.levels[i].quant[2]}, chance = config.levels[i].percent} end end end -- RETORNA O MINÉRIO DE ACORDO COM A ROCHA DESTRUIDA -- function getOreByRock(rock_target) for i = 1, #config.stones do if config.stones[i].rock == rock_target then return config.stones[i].ore end end end function getCuttingTries(cid) return getPlayerStorageValue(cid, STORAGE_SKILL_TRY) end function setCuttingTry(cid, n) setPlayerStorageValue(cid, STORAGE_SKILL_TRY, n) end function addCuttingTry(cid, bonus) setCuttingTry(cid, getCuttingTries(cid) + 1 + (bonus and config.bonus_exp or 0)) if (getCuttingTries(cid) >= getCuttingExpTo(getCuttingLevel(cid))) then -- Up doPlayerSendTextMessage(cid, 22, "You advanced from level " .. getCuttingLevel(cid) .. " to level ".. (getCuttingLevel(cid) + 1) .." in miner.") if ((getCuttingLevel(cid)+1) == getCuttingMaxLevel()) then doPlayerSendTextMessage(cid, 22, "Max level reached in miner.") end addCuttingLevel(cid) doSendMagicEffect(getCreaturePosition(cid), math.random(28,30)) setCuttingTry(cid, 0) end end function getCuttingExpTo(level) return ((level*1.5)+((level+1)*7)) end function getCuttingMaxLevel() return config.levels[#config.levels].level[#config.levels[#config.levels].level] end ------------------------------------------------------------------------------------------------------ function onUse(cid, item, fromPosition, itemEx, toPosition) local rock = { id = itemEx.itemid, uid = itemEx.uid, position = toPosition } local player = { position = getCreaturePosition(cid) } if (getCuttingLevel(cid) < 0) then setPlayerCuttingLevel(cid, 0) end if isInArray({config.stones[1].rock, config.stones[2].rock, config.stones[3].rock, config.stones[4].rock}, rock.id) then addCuttingTry(cid) if (math.random(1,100) <= getCuttingInfo(cid).chance) then local collected = math.random(getCuttingInfo(cid).quantity.min, getCuttingInfo(cid).quantity.max) doPlayerAddItem(cid, getOreByRock(rock.id), collected) doSendAnimatedText(getThingPos(cid), collected .. " ore", math.random(1, 255)) doPlayerSendTextMessage(cid, 22, "You got " .. collected .. " brass" .. (collected > 1 and "s" or "") .. " ore.") if (math.random(1,100) <= config.bonus_chance) then -- Bonus calc addCuttingTry(cid, true) doSendAnimatedText(player.position, "Bonus!", COLOR_ORANGE) end event_rockCut(rock) else if (math.random(0,100) <= (0-getCuttingInfo(cid).chance/0)) then doPlayerSendTextMessage(cid, 22, "You got nothing.") event_rockCut(rock) else doSendMagicEffect(rock.position, 3) doSendAnimatedText(rock.position, "Poff!", COLOR_GREEN) end end else doPlayerSendCancel(cid, "This can't be cut.") end end function event_rockCut(rock) addEvent(event_rockGrow, config.rock_delay * 1000, rock.position, rock.id) doTransformItem(rock.uid, 5104) doSendMagicEffect(rock.position, 3) doSendAnimatedText(rock.position, "Tack!", COLOR_GREEN) doItemSetAttribute(rock.uid, "name", "A trunk of " .. getItemNameById(rock.id)) end function event_rockGrow(rockPos, old_id) local rock = getThingFromPos(rockPos).uid doTransformItem(rock, old_id) doItemSetAttribute(rock, "name", getItemNameById(old_id)) doSendMagicEffect(rockPos, 3) end Teste e veja se continuo com erro.
  14. Eu refiz a função que você fez, e também criei uma tabela com a rocha destruída e o minério equivalente que vem de acordo com tal rocha, para ficar mais fácil de verificar. Substitua o código por: local STORAGE_SKILL_LEVEL = 10009 local STORAGE_SKILL_TRY = 10007 local config = { levels = { {level = {0,9}, quant = {1,1}, percent = 5}, {level = {10,19}, quant = {1,1}, percent = 10}, {level = {20,29}, quant = {1,1}, percent = 15}, {level = {30,39}, quant = {1,1}, percent = 20}, {level = {40,49}, quant = {1,1}, percent = 25}, {level = {50,59}, quant = {1,1}, percent = 30}, {level = {60,69}, quant = {1,1}, percent = 30}, {level = {70,79}, quant = {1,1}, percent = 35}, {level = {80,89}, quant = {1,1}, percent = 35}, {level = {90,99}, quant = {1,1}, percent = 40}, {level = {100}, quant = {1,1}, percent = 50} }, -- Rocks = Id das rochas que podem ser quebradas || -- Stone = Modelo {rock_id, rock_id} -- stones = { {rock = 5092, ore = 5097}, {rock = 5093, ore = 5099}, {rock = 5094, ore = 5100}, {rock = 5095, ore = 5098}, } rock_delay = 60, -- Tempo de volta da rocha (Em segundos) bonus_chance = 3, -- Chance (em porcentagem) de se conseguir um bonus de exp bonus_exp = 1 -- Bonus extra } ------------------------------------ -- END Configurations --- ------------------------------------ function getCuttingLevel(cid) return getPlayerStorageValue(cid, STORAGE_SKILL_LEVEL) end function setPlayerCuttingLevel(cid, n) setPlayerStorageValue(cid, STORAGE_SKILL_LEVEL, n) end function addCuttingLevel(cid, n) setPlayerCuttingLevel(cid, getCuttingLevel(cid) + (isNumber(n) and n or 1)) setCuttingTry(cid, 0) end function getCuttingInfo(cid) for i = 1, #config.levels do min = config.levels[i].level[1]; max = config.levels[i].level[2] if (getCuttingLevel(cid) >= min and getCuttingLevel(cid) <= max) then return {quantity = {min = config.levels[i].quant[1], max = config.levels[i].quant[2]}, chance = config.levels[i].percent} end end end -- RETORNA O MINÉRIO DE ACORDO COM A ROCHA DESTRUIDA -- function getOreByRock(rock_target) for i = 1, #config.stones do if config.stones.rock[i] == rock_target then return config.stones.ore[i] end end end function getCuttingTries(cid) return getPlayerStorageValue(cid, STORAGE_SKILL_TRY) end function setCuttingTry(cid, n) setPlayerStorageValue(cid, STORAGE_SKILL_TRY, n) end function addCuttingTry(cid, bonus) setCuttingTry(cid, getCuttingTries(cid) + 1 + (bonus and config.bonus_exp or 0)) if (getCuttingTries(cid) >= getCuttingExpTo(getCuttingLevel(cid))) then -- Up doPlayerSendTextMessage(cid, 22, "You advanced from level " .. getCuttingLevel(cid) .. " to level ".. (getCuttingLevel(cid) + 1) .." in miner.") if ((getCuttingLevel(cid)+1) == getCuttingMaxLevel()) then doPlayerSendTextMessage(cid, 22, "Max level reached in miner.") end addCuttingLevel(cid) doSendMagicEffect(getCreaturePosition(cid), math.random(28,30)) setCuttingTry(cid, 0) end end function getCuttingExpTo(level) return ((level*1.5)+((level+1)*7)) end function getCuttingMaxLevel() return config.levels[#config.levels].level[#config.levels[#config.levels].level] end ------------------------------------------------------------------------------------------------------ function onUse(cid, item, fromPosition, itemEx, toPosition) local rock = { id = itemEx.itemid, uid = itemEx.uid, position = toPosition } local player = { position = getCreaturePosition(cid) } if (getCuttingLevel(cid) < 0) then setPlayerCuttingLevel(cid, 0) end if (isInArray(config.rocks, rocks2, rocks3, rocks4, rock.id, rock.id2, rock.id3, rock.id4)) then addCuttingTry(cid) if (math.random(1,100) <= getCuttingInfo(cid).chance) then local collected = math.random(getCuttingInfo(cid).quantity.min, getCuttingInfo(cid).quantity.max) doPlayerAddItem(cid, getOreByRock(rock.id), collected) doSendAnimatedText(getThingPos(cid), collected .. " ore", math.random(1, 255)) doPlayerSendTextMessage(cid, 22, "You got " .. collected .. " brass" .. (collected > 1 and "s" or "") .. " ore.") if (math.random(1,100) <= config.bonus_chance) then -- Bonus calc addCuttingTry(cid, true) doSendAnimatedText(player.position, "Bonus!", COLOR_ORANGE) end event_rockCut(rock) else if (math.random(0,100) <= (0-getCuttingInfo(cid).chance/0)) then doPlayerSendTextMessage(cid, 22, "You got nothing.") event_rockCut(rock) else doSendMagicEffect(rock.position, 3) doSendAnimatedText(rock.position, "Poff!", COLOR_GREEN) end end else doPlayerSendCancel(cid, "This can't be cut.") end end function event_rockCut(rock) addEvent(event_rockGrow, config.rock_delay * 1000, rock.position, rock.id) doTransformItem(rock.uid, 5104) doSendMagicEffect(rock.position, 3) doSendAnimatedText(rock.position, "Tack!", COLOR_GREEN) doItemSetAttribute(rock.uid, "name", "A trunk of " .. getItemNameById(rock.id)) end function event_rockGrow(rockPos, old_id) local rock = getThingFromPos(rockPos).uid doTransformItem(rock, old_id) doItemSetAttribute(rock, "name", getItemNameById(old_id)) doSendMagicEffect(rockPos, 3) end Coloquei um mensagem com efeito (animated text) falando a quantidade de ore que recebeu, caso não queira só remover a linha: doSendAnimatedText(getThingPos(cid), collected .. " ore", math.random(1, 255)) Teste e veja se da algum erro.
  15. Dá algum erro na distro? O pokémon tem que estar fora da ball?
  16. Se ele é item equipável (colocar no set de roupas do inventário) tem que registrar no movements no Equip e DeEquipe.
  17. Yan Oliveira

    (Bug) NPC

    O erro acontece quando o player tenta comprar qualquer backpack?
  18. Os id dos minérios já estão no script? E quer que saia qual minério para cada pedra quebrada?
  19. Como esses pontos são armazenados no banco? Vi que tem uma função própria doPlayerAddPoints, e o valor (pontos) passados para essa função é salvo no banco na tabela de itens ou de players?
  20. Não acho que é isso que ele quer. Pelo que ele disse, ele quer um script que aumente a vida máxima do player, e não a vida atual.
  21. Esse não é o problema dele, ele não está com problemas em relação a logar mais de um personagem na mesma conta, e sim de, mais de uma personagem da mesma conta poder ganhar os pontos.
  22. local pos = {x=1411, y=1287, z=5} local need_lv = 300 function onUse(cid, item, frompos, item2, topos) if isPremium(cid) then if getPlayerLevel(cid) >= need_lv then doTeleportThing(cid, pos) doSendMagicEffect(pos, CONST_ME_TELEPORT) return true else return doPlayerSendCancel(cid, "Você precisa ser level "..need_lv.." para passar por esta porta.") end else doPlayerSendCancel(cid, "Você precisa ser level "..need_lv.." para passar por esta porta.") doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você precisa ser premium account para passar por esta porta.") doTeleportThing(cid, frompos) return true end end
  23. Yan Oliveira

    erro na potion

    Eu refiz o seu código, pois a estrutura dele não estava legal. Não fazia sentido você setar a storage com tempo do os.time() sem nenhum acréscimo além dele, pois seria a mesma coisa que nada. E também não é bom fazer uma função dentro do onUse, é sempre bom fazer fora, como boas práticas. Substitua seu código por: ---------------------------- FUNÇÃO DE HEALAR ----------------------------- local function doRegeneration(cid, health, effect, count) if count > 0 then doCreatureAddHealth(cid, math.floor(health)) doSendMagicEffect(getCreaturePosition(cid), effect) addEvent(doRegeneration, 1000, cid, health, effect, count - 1) end end --------------------------------------------------------------------------- local storage = 11148 -- STORAGE PARA ARMAZENAR UM TEMPO DE COOLDOWN PARA USAR A POTION NOVAMENTE ------------------------------ CÓDIGO -------------------------------------- function onUse(cid, item, fromPos, itemEx, toPos) local tempo = 30 -- TEMPO EM SEGUNDOS QUE A POTION VAI HEALAR (ESSE MESMO TEMPO É ADICIONADO A STORAGE PARA FAZER UM EXHAUST E O PLAYER NÃO USAR MAIS DE UMA POTION DE UMA VEZ) local health = 15 -- TANTO DE VIDA QUE O PLAYER VAI RECUPERAR local effect = CONST_ME_MAGIC_GREEN -- EFEITO QUE VAI SAIR NO PLAYER QUANDO USAR A POTION if getCreatureHealth(cid) == getCreatureMaxHealth(cid) then -- VERIFICA SE O PLAYER JÁ ESTÁ COM A VIDA TOTALMENTE CHEIA return doPlayerSendCancel(cid, "Your health already is full.") end if not isPlayer(cid) then -- VERIFICA SE O PLAYER ESTÁ USANDO A POTION EM OUTRA CRIATURA doPlayerSendCancel(cid, "You only can use the potion in you.") return false end -- CONDIÇÃO PARA VER SE A POTION AINDA ESTÁ SENDO USADA NO PLAYER, PARA NÃO USAR MAIS DE UMA CORRENDO RISCO DE GASTAR POTION ATOA -- if getPlayerStorageValue(cid, storage) <= os.time() then doRegeneration(cid, health, effect, tempo) doChangeTypeItem(item.uid, item.type - 1) setPlayerStorageValue(cid, storage, os.time() + tempo) return true else doPlayerSendCancel(cid, "You are still being recovering.") doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are still being recovering.") return true end end Deixei tudo comentado para você entender, e também adicionei algumas verificações, como se o player já estiver com a vida totalmente cheia e se ele está tentando usar a potion em outra criatura. Também fiz para setar a storage com o tempo (definido na storage tempo) para setar mais o tempo do os.time() (momento que o player usa a potion), é bom isso porque não corre risco do player usar a potion duas vezes ou mais seguidas sem querer e também não gastar potion atoa, caso a primeira já encha a vida totalmente. Também mudei o tempo do addEvent para 1 segundo, pois estava 2 segundos e meio. Testa e me fala se der algum erro.
  24. Pelo visto seu servidor não tem Blessings, que parece ser uma tabela global.
  25. Não está correto seu script e essa linha não faz sentido local tp = name[getCreatureName(cid)] Vamos lá! Substitua seu código por esse: local monster_name = "Ferumbras" -- NOME DO MONSTRO (TEM QUE SER IGUAL O NOME QUE ESTÁ NO ARQUIVO XML) local storage = 29111 -- STORAGE local storage_points_increment = 15 -- VALOR QUE SERÁ INCREMENTADO NA STORAGE (PONTOS) -- COORDENADAS DA ÁREA -- local position_area = { start_position = {x= 1092, y= 1073, z= 6}, end_position = {x= 1093, y= 1075, z= 6} } local message = true -- SE FOR EXIBIR MENSAGEM PARA OS PLAYERS QUE GANHAREM PONTOS SE ESTIVER DENTRO DA ÁREA DEIXE TRUE, CASO NÃO QUEIRA, MUDE PARA FALSE ------------------------------------------------- CÓDIGO ------------------------------------------------- function onDeath(cid) local check_position = {} for i = position_area.start_position.x, position_area.end_position.x do for j = position_area.start_position.y, position_area.end_position.y do for k = position_area.start_position.z, position_area.end_position.z do check_position[#check_position + 1] = {x= i, y= j, z= k, stackpos = 253} end end end if (isMonster(cid)) and (getCreatureName(cid) == monster_name) then for i = 1, #check_position do local player = getTileThingByPos(check_position[i]) if isInArea(check_position[i], position_area.start_position, position_area.end_position) then if isPlayer(player.uid) then setPlayerStorageValue(player.uid, storage, storage + storage_points_increment) doSendAnimatedText(getThingPos(player.uid), storage_points_increment.. " points", math.random(1, 255), player.uid) if message then doPlayerSendTextMessage(player.uid, MESSAGE_STATUS_CONSOLE_BLUE, "You gained " ..storage_points_increment.. " points for killing " ..monster_name.. ".") end return true end end end else return true end end Lembrando que o nome do monstro na variável monster_name tem que ser igual a nomenclatura do monstro no arquivo xml, se não vai dar erro. E deixei para exibir mensagem para o player, caso não queira, mude a variável message para false. Teste e veja se dá algum erro.
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...