Ir para conteúdo

Yan Oliveira

Moderador
  • Total de itens

    2187
  • Registro em

  • Última visita

  • Dias Ganhos

    57

Histórico de Reputação

  1. Upvote
    Yan Oliveira recebeu reputação de assinho3k em [10.98] PokeDash Pota v1.0 - TFS 1.2 - Server, Client, Sources, Site, Map editor e Item editor   
    Parece ser muito legal sua base e os sistemas listados são bem interessantes.
     
    Parabéns! E obrigado por compartilhar esse conteúdo para nossa comunidade.
     
    Tópico aprovado!
  2. Upvote
    Yan Oliveira recebeu reputação de 880123 em Event Boss   
    Olá, vá na pasta Data/Globalevents/Scripts e crie um arquivo lua chamado boss e adicione o código dentro:
    ----------------------------------- EVENTO SUMMON BOSS FEITO POR YAN18 ----------------------------------------- local minutos = 20 ---- COLOCA OS MINUTOS AQUI PARA OS BOSS SUMIREM CASO NINGUÉM OS MATE ---- NOME DOS MONTROS ---- local monsters = { [1] = "Magmar" , [2] = "Electabuzz", [3] = "Scizor", } ---- POSIÇÃO DA ARENA ONDE APARECERÁ OS MONSTROS ---- local position_arena = { from_pos = {x= 964, y = 993, z= 7}, -- VARIÁVEL QUE TEM A COORDENADA INICIAL DO LUGAR ONDE VAI APARECER OS MONSTROS to_pos = {x= 978, y = 1009, z= 7}, -- VARIÁVEL QUE TEM A COORDENADA FINAL DO LUGAR ONDE VAI APARECER OS MONSTROS } ---------------------------------- CÓDIGO ---------------------------------------------- function onThink(cid, words, interval, lastExecution) ----- CRIA OS BOSS ----- for i, j in ipairs(monsters) do ----- VARIÁVEL RANDOM_POSITION GERA O SPAWN ALEATÓRIO DOS BOSS ----- local random_position = {x= math.random(position_arena.from_pos.x, position_arena.to_pos.x), y= math.random(position_arena.from_pos.y, position_arena.to_pos.y), z= math.random(position_arena.from_pos.z, position_arena.to_pos.z)} doSummonCreature(j, random_position) end doBroadcastMessage(#monsters == 1 and "A monster have been arrived in this world. Don't arrive near!" or "Some monsters have been arrived in this world. Don't arrive near by them!", 22) ---- VERIFICAÇÃO SE TEM MONSTROS NA ARENA PARA REMOVER ---- addEvent(function() local position = {} for i = position_arena.from_pos.x, position_arena.to_pos.x do for j = position_arena.from_pos.y, position_arena.to_pos.y do position[#position+1] = {x= i, y = j, z= position_arena.from_pos.z, stackpos = 0} end end for i= 1, #position do for j = 0, 255 do position[i].stackpos = j local monster = getTileThingByPos(position[i]) if isMonster(monster.uid) then for d, n in ipairs(monsters) do if getCreatureName(monster.uid) == n then doRemoveCreature(monster.uid) if d == #monsters then doBroadcastMessage(#monsters == 1 and "The monster left this world. But it will return soon...." or "The monsters left this world. But they will return soon....", 22) end end end end end end end, minutos * 60 * 1000) return true end Agora em Data/Globalevents abra o globalevents.xml e adicione a tag:
    <globalevent name="boss" interval="3600" event="script" value="boss.lua"/> <!-- TEMPO EM SEGUNDOS, JÁ DEIXEI 1 HORA --> Explicação: No código, eu criei 3 monstros genéricos para testar, só adicionar o nome deles igual está na tabela, e se quiser só 1 monstro, apague os outros dois e insira o desejado (lembrando de colocar a vírgula no final igual como está).
     
    Na variável minutos já deixei 20 como pediu, mas caso queira trocar, só alterar o valor dela (lembrando que o valor dela tem que ser menor que o intervalo do evento no xml).
     
    E na tabela position_arena, precisa colocar as coordenadas iniciais e finais da arena, já deixei pronto ali também e é só substituir.
     
    Deixei para eles nascerem em posições aleatórias dentro das coordenadas da arena, caso queira spawns fixos, só ir na variável random_position e colocar x, y e z desejados.
     
    Agora na parte do Xml como deixei o comentário na tag, já deixei 1 hora como pediu (3600 segundos), caso queira outro valor só alterar lá, lembrando que ali é em segundos.
     
    Deixei tudo comentado e explicadinho, mas qualquer dúvida só falar. Eu testei muito aqui e deu certo, mas qualquer problema só me dizer.
  3. Upvote
    Yan Oliveira recebeu reputação de willamsxp em AJUDA RME nao aparece spawn em NENHUM mapa   
    Tenta fazer o seguinte procedimento:
     
    Abre o executar (Windows + R) e digita: %appdata%
     
    Depois procure pela pasta do Remere's, apague ela. E por fim, abra o Remere's e importa todos os monstros/npc do seu server e tenta abrir o mapa.
     
    Eu tive esse problema com a versão do remere's, pois nas base de poketibia que eu uso, trabalha com versão extendida ou transparência. Tem que ver seu sua base trabalha com essas versões e se seu remere's tem suporte a elas.
  4. Thanks
    Yan Oliveira recebeu reputação de wenderotpoke em Vault   
    Substitua o código por:
     
    function onUse(cid, item, fromPosition, itemEx, toPosition) local cidMoney = getPlayerMoney(cid) local vaultmoney = getItemAttribute(itemEx.uid, "money") if (getItemAttribute(itemEx.uid, "money") == 0) then doSetItemAttribute(itemEx.uid, "money", cidMoney) if getPlayerMoney(cid) >= 1000000 and getPlayerMoney(cid) < 10000000 then item = doPlayerAddItem(cid, 7896, 1) doItemSetAttribute(item, "money", cidMoney) elseif getPlayerMoney(cid) >= 10000000 and getPlayerMoney(cid) < 100000000 then item = doPlayerAddItem(cid, 7897, 1) doItemSetAttribute(item, "money", cidMoney) elseif getPlayerMoney(cid) >= 100000000 and getPlayerMoney(cid) <= 2000000000 then item2 = doPlayerAddItem(cid, 7898, 1) doItemSetAttribute(item2, "money", cidMoney) end doPlayerRemoveMoney(cid, cidMoney) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Voce depositou "..cidMoney.." dolares!") else item2 = doPlayerAddItem(cid, 7895, 1) doItemSetAttribute(item2, "money", 0) doPlayerAddMoney(cid, vaultmoney) end doPlayerRemoveItem(cid, itemEx, 1) doRemoveItem(itemEx.uid, 1) return true end  
    Otimizei o código, porque tinha muita repetição nos blocos condicionais
  5. Amei
    Yan Oliveira recebeu reputação de wenderotpoke em Bonus de chance de Catch Pokemon   
    Troque o código por este:
     
    local storage_buff_catch = 3133586 -- STORAGE DO BONUS DE CATCH local minutes_buff = 5 -- MINUTOS PARA TER O BUFF DO CATCH local ballcatch = { --id normal, id da ball shiy [2394] = {cr = 1, on = 193, off = 192, ball = {11826}, send = 86, typeee = "poke", boost = "0"}, --alterado v1.9 \/ [2391] = {cr = 2, on = 198, off = 197, ball = {11832}, send = 87, typeee = "great", boost = "0"}, [2393] = {cr = 3, on = 202, off = 201, ball = {11835}, send = 88, typeee = "super", boost = "0"}, [2392] = {cr = 4, on = 200, off = 199, ball = {11829}, send = 89, typeee = "ultra", boost = "0"}, [12617] = {cr = 4, on = 204, off = 203, ball = {12621}, send = 84, typeee = "saffari", boost = "0"}, [12832] = {cr = 100000, on = 23, off = 24, ball = {12826}, send = 85, typeee = "master", boost = "50"}, [15677] = {cr = 6, on = 313, off = 314, ball = {16204}, send = 72, typeee = "magu", boost = "0", type = {"fire", "ground"}}, [15676] = {cr = 6, on = 316, off = 317, ball = {16205}, send = 73, typeee = "sora", boost = "0", type = {"water", "ice"}}, [15678] = {cr = 6, on = 319, off = 320, ball = {16206}, send = 74, typeee = "yume", boost = "0", type = {"fairy", "psychic"}}, [15680] = {cr = 6, on = 322, off = 323, ball = {16207}, send = 75, typeee = "dusk", boost = "0", type = {"ghost", "dark"}}, [15673] = {cr = 6, on = 331, off = 332, ball = {16210}, send = 78, typeee = "tale", boost = "0", type = {"dragon", "flying"}}, [15674] = {cr = 6, on = 334, off = 335, ball = {16211}, send = 79, typeee = "moon", boost = "0", type = {"fighting", "normal"}}, [15675] = {cr = 6, on = 337, off = 338, ball = {16212}, send = 80, typeee = "net", boost = "0", type = {"bug", "poison"}}, [15681] = {cr = 6, on = 346, off = 347, ball = {16215}, send = 83, typeee = "tinker", boost = "0", type = {"electric", "steel"}}, [15679] = {cr = 1, on = 343, off = 344, ball = {16214}, send = 82, typeee = "premier", boost = "0"}, [15682] = {cr = 6, on = 325, off = 326, ball = {16208}, send = 76, typeee = "fast", boost = "0", pokes = {"Pidgeot", "Kadabra", "Rapidash", "Scyther", "Electabuzz", "Manectric", "Persian", "Starmie", "Sneasel", "Dugtrio", "Alakazam", "Sceptile", "Swellow", "Jolteon", "Crobat", "Electrode", "Ninjask", "Raichu", "Dodrio", "Gengar", "Tauros", "Jumpluff", "Espeon", "Shiny Raichu", "Shiny Dodrio", "Shiny Tauros", "Shiny Gengar", "Shiny Espeon"}}, [15672] = {cr = 6, on = 328, off = 329, ball = {16209}, send = 77, typeee = "heavy", boost = "0", pokes = {"Golem", "Gyarados", "Snorlax", "Onix", "Tyranitar", "Metang", "Steelix", "Camerupt", "Lapras", "Mantine", "Hariyama", "Aggron", " Wailord", "Glalie", "Metagross", "Rhyperior", "Shiny Golem", "Shiny Gyarados", "Shiny Snorlax", "Shiny Onix", "Shiny Tyranitar", "Shiny Metang", "Shiny Steelix", "Shiny Camerupt", "Shiny Lapras", "Shiny Mantine", "Shiny Hariyama", "Shiny Aggron", "Shiny Wailord", "Shiny Glalie", "Shiny Metagross", "Shiny Rhyperior"}}, } function onUse(cid, item, frompos, item3, topos) local item2 = getTopCorpse(topos) if item2 == null then return true end if getPlayerStorageValue(cid, 55006) >= 1 then doPlayerSendCancel(cid, "Você não pode capturar nenhum pokémon enquanto está em duel.") return true end if getItemAttribute(item2.uid, "catching") == 1 then return true end local name = string.lower(getItemAttribute(item2.uid, "pokeName")) name = string.gsub(name, "fainted ", "") name = string.gsub(name, "defeated ", "") name = doCorrectPokemonName(name) local storage = newpokedex[name].stoCatch if type(getPlayerStorageValue(cid, storage)) ~= "string" or not string.find(getPlayerStorageValue(cid, storage), "magu") then --alterado v1.9 setPlayerStorageValue(cid, storage, "normal = 0, great = 0, super = 0, ultra = 0, saffari = 0, dark = 0, magu = 0, sora = 0, yume = 0, dusk = 0, tale = 0, moon = 0, net = 0, premier = 0, tinker = 0, fast = 0, heavy = 0;") --alterado v1.9 end local owner = getItemAttribute(item2.uid, "corpseowner") local pOwner = getPlayerByName(owner) local isInParyWithPlayer = false if isInParty(cid) and isInParty(pOwner) then isInParyWithPlayer = isPartyEquals(pOwner, cid) end if owner and isCreature(pOwner) and isPlayer(pOwner) and cid ~= pOwner and not isInParyWithPlayer then doPlayerSendCancel(cid, "Desculpa. Isso não é possivel.") return true end local newidd = isShinyName(name) and ballcatch[item.itemid].ball[2] or ballcatch[item.itemid].ball[1] or false --alterado v1.9 local typeee = ballcatch[item.itemid].typeee local boost = ballcatch[item.itemid].boost local catchBlocks = {"Kabuto", "Kabutops", "Omanyte", "Omastar","Shiny Vileplume", "Shiny Marowak", "Shiny Umbreon", "Shiny Fearow", "Shiny Espeon", "Shiny Flareon", "Shiny Jolteon", "Shiny Vaporeon", "Shiny Salamence", "Shiny Magmortar", "Shiny Electivire", "Shiny Scizor", "Moltres", "Articuno", "Zapdos", "Aerodactyl", "Hitmonlee", "Hitmonchan", "Hitmontop", "Raikou", "Entei", "Suicune", "Lugia", "Ho-oh"} if isInArray(catchBlocks, name) then doSendMsg(cid, "Você não pode capturar este pokemon.") return true end local catchCyber = {"Shiny Dodrio", "Shiny Magneton", "Shiny Espeon", "Shiny Umbreon", "Shiny Rhydon", "Shiny Ninetales", "Shiny Onix", "Shiny Ariados", "Shiny Stantler", "Shiny Politoed"} if isInArray(catchCyber, name) and getPlayerStorageValue(cid, 50926) ~= 1 then doSendMsg(cid, "Você não concluiu a Cyber Quest!") return true end if getPlayerStorageValue(cid, 1654987) >= 1 then doSendMsg(cid, "Você não pode capturar pokémons nesse local.") return true end if typeee == "master" and isShinyName(name) then doSendMsg(cid, "Você não pode capturar pokemon shiny com a master ball.") return true end -- // New's Bag \\ -- if typeee == "poke" then local valor = getPlayerStorageValue(cid, 233200) <= 0 and 1 or getPlayerStorageValue(cid, 233200) setPlayerStorageValue(cid, 233200, valor + 1) elseif typeee == "great" then local valor1 = getPlayerStorageValue(cid, 233201) <= 0 and 1 or getPlayerStorageValue(cid, 233201) setPlayerStorageValue(cid, 233201, valor1 + 1) elseif typeee == "super" then local valor2 = getPlayerStorageValue(cid, 233202) <= 0 and 1 or getPlayerStorageValue(cid, 233202) setPlayerStorageValue(cid, 233202, valor2 + 1) elseif typeee == "ultra" then local valor3= getPlayerStorageValue(cid, 233203) <= 0 and 1 or getPlayerStorageValue(cid, 233203) setPlayerStorageValue(cid, 233203, valor3 + 1) end if getPlayerStorageValue(cid, 233200) >= 100 and getPlayerStorageValue(cid, 232200) ~= 1 then doPlayerAddItem(cid, 12683, 1) setPlayerStorageValue(cid, 233200, 0) elseif getPlayerStorageValue(cid, 233201) >= 250 and getPlayerStorageValue(cid, 232201) ~= 1 then doPlayerAddItem(cid, 12682, 1) setPlayerStorageValue(cid, 233201, 0) elseif getPlayerStorageValue(cid, 233202) >= 500 and getPlayerStorageValue(cid, 232202) ~= 1 then doPlayerAddItem(cid, 12684, 1) setPlayerStorageValue(cid, 233202, 0) elseif getPlayerStorageValue(cid, 233203) >= 1000 and getPlayerStorageValue(cid, 232203) ~= 1 then doPlayerAddItem(cid, 12685, 1) setPlayerStorageValue(cid, 233203, 0) end if getPlayerStorageValue(cid, 244787) >= 1 and typeee ~= "saffari" then doPlayerSendCancel(cid, "Você não pode capturar esse pokémon com essa Pokébola.") return true end if getPlayerStorageValue(cid, 244787) >= 1 and getPlayerItemCount(cid, 12617) <= 1 then --alterado v1.9 setPlayerStorageValue(cid, 244787, -1) doTeleportThing(cid, {x = 925, y = 1535, z = 6}, false) doSendMagicEffect(getThingPos(cid), 21) doPlayerSendTextMessage(cid, 27, "Você não tem mais Saffari Ball!") end --[[ if getPlayerStorageValue(cid, 141416) >= 1 then return true end]]-- local catchinfo = {} if isShinyName(name) then catchinfo.rate = ballcatch[item.itemid].cr + getPlayerSorte() else catchinfo.rate = ballcatch[item.itemid].cr + getPlayerSorteInNormal() end catchinfo.catch = ballcatch[item.itemid].on catchinfo.fail = ballcatch[item.itemid].off catchinfo.newid = newidd catchinfo.name = doCorrectPokemonName(name) catchinfo.topos = topos --catchinfo.chance = x.chance doBrokesCount(cid, newpokedex[doCorrectPokemonName(name)].stoCatch , typeee) doSendDistanceShoot(getThingPos(cid), topos, ballcatch[item.itemid].send) doRemoveItem(item.uid, 1) ---- newsBalls if (ballcatch[item.itemid].type ~= nil or ballcatch[item.itemid].pokes ~= nil) then catchinfo.rate = getBallsRate(catchinfo.name, item.itemid) + getPlayerSorte() end if isGod(cid) or getPlayerStorageValue(cid, 394672) >= 1 then catchinfo.rate = 100000 end if getPlayerStorageValue(cid, storage_buff_catch) <= os.time() then if getPlayerStorageValue(cid, 121212) >= 1 then catchinfo.rate = 1000 setPlayerStorageValue(cid, storage_buff_catch, os.time() + (60 * minutes_buff)) end end local d = getDistanceBetween(getThingPos(cid), topos) setPlayerStorageValue(cid, 141416, 1) addEvent(setPlayerStorageValue, 725, cid, 141416, -1) doItemSetAttribute(item2.uid, "catching", 1) addEvent(doSendPokeBall, d * 70 + 100 - (d * 14) , cid, catchinfo, false, false, typeee, 1.5) addEvent(doSendMagicEffect, (d * 70 + 100 - (d * 14)) - 100, topos, 3) return true end function getPlayerSorte() if math.random(1, 200) >= 199 then ballS = math.random(250, 450) else ballS = math.random(1, 35) end return ballS end function getPlayerSorteInNormal() if math.random(1, 100) >= 95 then ballS = math.random(250, 450) else ballS = math.random(1, 35) end return ballS end function getBallsRate(name, id) if pokes[name] then if isInArray(ballcatch[id].type, pokes[name].type) or isInArray(ballcatch[id].type, pokes[name].type2) or isInArray(ballcatch[id].pokes, name) then return 6 end end return 4 end  
    Nas duas primeiras linhas do código tem uma variável que armazena o valor da storage que irá guardar o tempo para usar o buff novamente e embaixo tem a variável que contém o tempo em minutos para usar o buff, só alterar o tempo, pois eu deixei 5 apenas como valor fictício.
     
    Teste e se der algum problema, me avise.
  6. Amei
    Yan Oliveira recebeu reputação de KaboFlow em Proibido usar item em tal area   
    Para negar entrada de players que carregam certos itens, precisa primeiramente adicionar uniqueid nos tiles da área no Remere's Map Editor. Então, abra o RME, vá na área desejada, e adicione o seguinte uniqueid para os tiles dentro da área: 18848 (certifique-se de que esse uniqueid já não está em uso, senão use outro).
     
    Após fazer isso, vá em Data/Movements/Scripts e crie o arquivo tile_access_item.lua e adicione o código dentro:
    -- ID DOS ITENS QUE VAI NEGAR O ACESSO DO PLAYER SE ELE CARREGAR NA BAG -- local items = { 2160, 2162, 15000, } function onStepIn(cid, item, position, fromPosition) if not isPlayer(cid) then return true end local items_forbidden = {} for _, value in ipairs(items) do if getPlayerItemById(value, true) then table.insert(items_forbidden, value) end end if #items_forbidden > 0 then local items_name = "" for _, value in ipairs(items_forbidden) do items_name = items_name ~= "" and getItemNameById(value) or (items_name .. "\n" .. getItemNameById(value)) end doTeleportThing(cid, fromPosition) doPlayerSendCancel(cid, "You cannot enter here") doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot enter here holding the following itens: " .. items_name .. ".") end return true end  
    Na tabela items coloque todos os id dos itens que se o player carregar ele não terá acesso à área.
     
    Agora abra o movements.xml e adicione a tag:
    <movevent type="StepIn" uniqueid="18848" event="script" value="tile_access_item.lua"/> Tem que colocar o uniqueid que colocou nos tiles no RME.
     
    Agora, sobre Fly/Ride/Surf eu preciso que você coloque seu order.lua da pasta actions para entender como trabalham com essas habilidades no seu servidor, pois, dependendo da base, é diferente a forma como fizeram o script.
  7. Upvote
    Yan Oliveira recebeu reputação de Dilooow em [Resolvido] ajuda converter para 1.2 versao 1098 tibia   
    Cara, mas a versão do seu TFS é 1.2, 0.3.6 ou 0.4?
  8. Thanks
    Yan Oliveira recebeu reputação de rafersiq em [Resolvido] [PEDIDO] Scripts de spawn no mapa   
    Pelo que entendi, você quer que ao derrotar o último pokémon do contador da task, os boss spawnem na posição do último pokémon derrotado. Se é isso, é tranquilo.
     
    Eu refiz o código, porque olhando novamente o código que fiz ano passado, achei que dava para melhorar, e já está com a alteração que você pediu. Substitua todo seu código por esse:
    -- VARIÁVEIS -- local total = 50 -- TOTAL DE POKEMON QUE PRECISA DERROTAR local random_chance = 50 -- PORCENTAGEM QUE TEM DO POKEMON SPAWNAR AO TERMINAR A TASK -- TABELA COM OS POKÉMONS DA TASK QUE PRECISA DERROTAR -- local pokemon_task = { "Charizard", } -- TABELA COM OS POKEMONS QUE APARECERÃO AO DERROTAR A QUANTIDADE DO POKÉMON QUE COLOCOU NA VARIÁVEL pokemon_derrotar -- local pokemons_spawn = { "Mewtwo", "Mew", "Articuno", "Zapdos", "Moltres", } ------------------------------- CÓDIGO ----------------------------- function onKill(cid, target) for _, pokemon in ipairs(pokemon_task) do if getCreatureName(target) == pokemon then if getGlobalStorageValue(storage_task_defeat_count) < 0 then setGlobalStorageValue(storage_task_defeat_count, 1) end setGlobalStorageValue(storage_task_defeat_count, getGlobalStorageValue(storage_task_defeat_count) + 1) -- INCREMENTA O CONTADOR DE POKÉMONS DERROTADOS DA TASK local restante = total - getGlobalStorageValue(storage_task_defeat_count) if restante == 0 then local chance = math.random(100) -- VARIÁVEL QUE GERA VALOR ALEATÓRIO if chance >= random_chance then for _, boss in pairs(pokemons_spawn) do doCreateMonster(boss, getCreaturePosition(target)) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você despertou a fúria de alguns pokémons, fuja para sobreviver!") end setGlobalStorageValue(storage_task_defeat_count, 0) end break end end return true end  
    Vamos as explicações!
     
    Eu alterei um pouco a estrutura do código, então agora está mais otimizado e agora adicionei o pokémon da task em uma tabela, caso queira adicionar mais de um pokémon para contabilizar a task, agora é possível. Porém, se adicionar mais de um pokémon para a task, do jeito que eu fiz, qualquer um pokémon que está dentro da tabela pokemon_task que derrotar, irá contabilizar como o total, e não individualmente, ou seja, por exemplo, o total que defini é 50 (variável total), então, se você adicionar por exemplo dois pokémons, no caso, Charizard e Blastoise, e você matar 25 Charizards e 25  Blastoises, vai ter a chance de nascer os boss se o valor aleatório gerado pela chance estiver na range definida de 50 (se o math.random gerar 50 ou mais). Caso queira que conte individualmente, vou ter que alterar o código. Mas, se quiser só um pokémon, então deixe somente um na tabela, assim como deixei.
     
    Agora, como estamos trabalhando com storage global, vamos criar ela na pasta lib, porque do jeito que eu tinha feito não era a maneira correta, o certo é criar ela de forma global, e não local. Então, vai em Data/Lib e abra o arquivo 100-compat.lua (ou um arquivo de sua preferência) e adicione a seguinte linha no final do arquivo:
    storage_task_defeat_count = 336699  
    Mantive o mesmo valor na storage global, e agora ela está registrada globalmente.
     
    Pronto, está finalizado as alterações! Agora teste e veja se vai dar algum problema.
  9. Amei
    Yan Oliveira recebeu reputação de Dilooow em [Resolvido] ajuda converter para 1.2 versao 1098 tibia   
    Olhando o tópico agora eu entendi, e era o que eu imaginei, precisa somente do onStepIn, e não do onStepOut como você colocou no seu. E você também não copiou o código completo, faltou pegar o começo do arquivo onde contém a função principal onStepIn(cid, item, position, fromPosition).
     
    A questão é, o tile que você vai usar para isso, é exclusivamente só para isso ou você vai usar um tile que já usa em outra parte do mapa? Porque se for usar um tile que já está em uso no mapa, aí vai ter que trabalhar com uniqueid, porque se trabalhar com itemid, toda vez que alguém pisar nesse tile, independente da coordenada no mapa, vai cair na trap. Mas por via das dúvidas, vamos trabalhar com uniqueid.
     
    Primeiramente vai no Remere's Map Editor, e procura esse local onde vão ficar as traps no tile, e adicione o seguinte uniqueid para todos os tiles: 19737 (certifique-se de que esse uniqueid já não está sendo usado, se tiver, coloca outro valor).
     
    Agora, vai em Data/Movements/Scripts e crie o arquivo tile_trap.lua (ou outro nome de sua preferência) e adicione o seguinte código dentro:
    local storage = 14678 -- n mexa local time_summon = 1 -- tempo em minutos local seconds_remove = 30 -- TEMPO EM SEGUNDOS PARA REMOVER O MONSTRO local monsters = { {"cyclops", Position(157, 35, 7)}, {"Demon", Position(161, 38, 7)}, {"Hydra", Position(155, 38, 7)}, {"Dragon", Position(160, 39, 7)}, } function onStepIn(cid, item, position, fromPosition) if not cid or Game.getStorageValue(storage) >= os.time() then return true end local monster_random = math.random(1, #monsters) -- PARA VER QUAL MONSTRO VAI PEGAR DA TABELA ALEATORIAMENTE local monster = Game.createMonster(monsters[monster_random][1], monsters[monster_random][2]) -- CRIA O MONSTRO ALEATÓRIO if not monster then return true end cid:say("Oh my God, it's a trap!") -- REMOVE O MONSTRO -- addEvent(function() if monster then monster:remove() end end, seconds_remove * 1000) Game.setStorageValue(storage, os.time() + time_summon * 60) -- SÓ VAI CONTABILIZAR APÓS O MONSTRO SER DERROTADO OU REMOVIDO return true end  
    Agora abre o movements.xml e adicione a tag:
    <movevent event="StepIn" uniqueid="19737" script="tile_trap.lua" />  
    Está pronto! Só testar.
  10. Amei
    Yan Oliveira recebeu reputação de KaboFlow em Bonus de chance de Catch Pokemon   
    Troque o código por este:
     
    local storage_buff_catch = 3133586 -- STORAGE DO BONUS DE CATCH local minutes_buff = 5 -- MINUTOS PARA TER O BUFF DO CATCH local ballcatch = { --id normal, id da ball shiy [2394] = {cr = 1, on = 193, off = 192, ball = {11826}, send = 86, typeee = "poke", boost = "0"}, --alterado v1.9 \/ [2391] = {cr = 2, on = 198, off = 197, ball = {11832}, send = 87, typeee = "great", boost = "0"}, [2393] = {cr = 3, on = 202, off = 201, ball = {11835}, send = 88, typeee = "super", boost = "0"}, [2392] = {cr = 4, on = 200, off = 199, ball = {11829}, send = 89, typeee = "ultra", boost = "0"}, [12617] = {cr = 4, on = 204, off = 203, ball = {12621}, send = 84, typeee = "saffari", boost = "0"}, [12832] = {cr = 100000, on = 23, off = 24, ball = {12826}, send = 85, typeee = "master", boost = "50"}, [15677] = {cr = 6, on = 313, off = 314, ball = {16204}, send = 72, typeee = "magu", boost = "0", type = {"fire", "ground"}}, [15676] = {cr = 6, on = 316, off = 317, ball = {16205}, send = 73, typeee = "sora", boost = "0", type = {"water", "ice"}}, [15678] = {cr = 6, on = 319, off = 320, ball = {16206}, send = 74, typeee = "yume", boost = "0", type = {"fairy", "psychic"}}, [15680] = {cr = 6, on = 322, off = 323, ball = {16207}, send = 75, typeee = "dusk", boost = "0", type = {"ghost", "dark"}}, [15673] = {cr = 6, on = 331, off = 332, ball = {16210}, send = 78, typeee = "tale", boost = "0", type = {"dragon", "flying"}}, [15674] = {cr = 6, on = 334, off = 335, ball = {16211}, send = 79, typeee = "moon", boost = "0", type = {"fighting", "normal"}}, [15675] = {cr = 6, on = 337, off = 338, ball = {16212}, send = 80, typeee = "net", boost = "0", type = {"bug", "poison"}}, [15681] = {cr = 6, on = 346, off = 347, ball = {16215}, send = 83, typeee = "tinker", boost = "0", type = {"electric", "steel"}}, [15679] = {cr = 1, on = 343, off = 344, ball = {16214}, send = 82, typeee = "premier", boost = "0"}, [15682] = {cr = 6, on = 325, off = 326, ball = {16208}, send = 76, typeee = "fast", boost = "0", pokes = {"Pidgeot", "Kadabra", "Rapidash", "Scyther", "Electabuzz", "Manectric", "Persian", "Starmie", "Sneasel", "Dugtrio", "Alakazam", "Sceptile", "Swellow", "Jolteon", "Crobat", "Electrode", "Ninjask", "Raichu", "Dodrio", "Gengar", "Tauros", "Jumpluff", "Espeon", "Shiny Raichu", "Shiny Dodrio", "Shiny Tauros", "Shiny Gengar", "Shiny Espeon"}}, [15672] = {cr = 6, on = 328, off = 329, ball = {16209}, send = 77, typeee = "heavy", boost = "0", pokes = {"Golem", "Gyarados", "Snorlax", "Onix", "Tyranitar", "Metang", "Steelix", "Camerupt", "Lapras", "Mantine", "Hariyama", "Aggron", " Wailord", "Glalie", "Metagross", "Rhyperior", "Shiny Golem", "Shiny Gyarados", "Shiny Snorlax", "Shiny Onix", "Shiny Tyranitar", "Shiny Metang", "Shiny Steelix", "Shiny Camerupt", "Shiny Lapras", "Shiny Mantine", "Shiny Hariyama", "Shiny Aggron", "Shiny Wailord", "Shiny Glalie", "Shiny Metagross", "Shiny Rhyperior"}}, } function onUse(cid, item, frompos, item3, topos) local item2 = getTopCorpse(topos) if item2 == null then return true end if getPlayerStorageValue(cid, 55006) >= 1 then doPlayerSendCancel(cid, "Você não pode capturar nenhum pokémon enquanto está em duel.") return true end if getItemAttribute(item2.uid, "catching") == 1 then return true end local name = string.lower(getItemAttribute(item2.uid, "pokeName")) name = string.gsub(name, "fainted ", "") name = string.gsub(name, "defeated ", "") name = doCorrectPokemonName(name) local storage = newpokedex[name].stoCatch if type(getPlayerStorageValue(cid, storage)) ~= "string" or not string.find(getPlayerStorageValue(cid, storage), "magu") then --alterado v1.9 setPlayerStorageValue(cid, storage, "normal = 0, great = 0, super = 0, ultra = 0, saffari = 0, dark = 0, magu = 0, sora = 0, yume = 0, dusk = 0, tale = 0, moon = 0, net = 0, premier = 0, tinker = 0, fast = 0, heavy = 0;") --alterado v1.9 end local owner = getItemAttribute(item2.uid, "corpseowner") local pOwner = getPlayerByName(owner) local isInParyWithPlayer = false if isInParty(cid) and isInParty(pOwner) then isInParyWithPlayer = isPartyEquals(pOwner, cid) end if owner and isCreature(pOwner) and isPlayer(pOwner) and cid ~= pOwner and not isInParyWithPlayer then doPlayerSendCancel(cid, "Desculpa. Isso não é possivel.") return true end local newidd = isShinyName(name) and ballcatch[item.itemid].ball[2] or ballcatch[item.itemid].ball[1] or false --alterado v1.9 local typeee = ballcatch[item.itemid].typeee local boost = ballcatch[item.itemid].boost local catchBlocks = {"Kabuto", "Kabutops", "Omanyte", "Omastar","Shiny Vileplume", "Shiny Marowak", "Shiny Umbreon", "Shiny Fearow", "Shiny Espeon", "Shiny Flareon", "Shiny Jolteon", "Shiny Vaporeon", "Shiny Salamence", "Shiny Magmortar", "Shiny Electivire", "Shiny Scizor", "Moltres", "Articuno", "Zapdos", "Aerodactyl", "Hitmonlee", "Hitmonchan", "Hitmontop", "Raikou", "Entei", "Suicune", "Lugia", "Ho-oh"} if isInArray(catchBlocks, name) then doSendMsg(cid, "Você não pode capturar este pokemon.") return true end local catchCyber = {"Shiny Dodrio", "Shiny Magneton", "Shiny Espeon", "Shiny Umbreon", "Shiny Rhydon", "Shiny Ninetales", "Shiny Onix", "Shiny Ariados", "Shiny Stantler", "Shiny Politoed"} if isInArray(catchCyber, name) and getPlayerStorageValue(cid, 50926) ~= 1 then doSendMsg(cid, "Você não concluiu a Cyber Quest!") return true end if getPlayerStorageValue(cid, 1654987) >= 1 then doSendMsg(cid, "Você não pode capturar pokémons nesse local.") return true end if typeee == "master" and isShinyName(name) then doSendMsg(cid, "Você não pode capturar pokemon shiny com a master ball.") return true end -- // New's Bag \\ -- if typeee == "poke" then local valor = getPlayerStorageValue(cid, 233200) <= 0 and 1 or getPlayerStorageValue(cid, 233200) setPlayerStorageValue(cid, 233200, valor + 1) elseif typeee == "great" then local valor1 = getPlayerStorageValue(cid, 233201) <= 0 and 1 or getPlayerStorageValue(cid, 233201) setPlayerStorageValue(cid, 233201, valor1 + 1) elseif typeee == "super" then local valor2 = getPlayerStorageValue(cid, 233202) <= 0 and 1 or getPlayerStorageValue(cid, 233202) setPlayerStorageValue(cid, 233202, valor2 + 1) elseif typeee == "ultra" then local valor3= getPlayerStorageValue(cid, 233203) <= 0 and 1 or getPlayerStorageValue(cid, 233203) setPlayerStorageValue(cid, 233203, valor3 + 1) end if getPlayerStorageValue(cid, 233200) >= 100 and getPlayerStorageValue(cid, 232200) ~= 1 then doPlayerAddItem(cid, 12683, 1) setPlayerStorageValue(cid, 233200, 0) elseif getPlayerStorageValue(cid, 233201) >= 250 and getPlayerStorageValue(cid, 232201) ~= 1 then doPlayerAddItem(cid, 12682, 1) setPlayerStorageValue(cid, 233201, 0) elseif getPlayerStorageValue(cid, 233202) >= 500 and getPlayerStorageValue(cid, 232202) ~= 1 then doPlayerAddItem(cid, 12684, 1) setPlayerStorageValue(cid, 233202, 0) elseif getPlayerStorageValue(cid, 233203) >= 1000 and getPlayerStorageValue(cid, 232203) ~= 1 then doPlayerAddItem(cid, 12685, 1) setPlayerStorageValue(cid, 233203, 0) end if getPlayerStorageValue(cid, 244787) >= 1 and typeee ~= "saffari" then doPlayerSendCancel(cid, "Você não pode capturar esse pokémon com essa Pokébola.") return true end if getPlayerStorageValue(cid, 244787) >= 1 and getPlayerItemCount(cid, 12617) <= 1 then --alterado v1.9 setPlayerStorageValue(cid, 244787, -1) doTeleportThing(cid, {x = 925, y = 1535, z = 6}, false) doSendMagicEffect(getThingPos(cid), 21) doPlayerSendTextMessage(cid, 27, "Você não tem mais Saffari Ball!") end --[[ if getPlayerStorageValue(cid, 141416) >= 1 then return true end]]-- local catchinfo = {} if isShinyName(name) then catchinfo.rate = ballcatch[item.itemid].cr + getPlayerSorte() else catchinfo.rate = ballcatch[item.itemid].cr + getPlayerSorteInNormal() end catchinfo.catch = ballcatch[item.itemid].on catchinfo.fail = ballcatch[item.itemid].off catchinfo.newid = newidd catchinfo.name = doCorrectPokemonName(name) catchinfo.topos = topos --catchinfo.chance = x.chance doBrokesCount(cid, newpokedex[doCorrectPokemonName(name)].stoCatch , typeee) doSendDistanceShoot(getThingPos(cid), topos, ballcatch[item.itemid].send) doRemoveItem(item.uid, 1) ---- newsBalls if (ballcatch[item.itemid].type ~= nil or ballcatch[item.itemid].pokes ~= nil) then catchinfo.rate = getBallsRate(catchinfo.name, item.itemid) + getPlayerSorte() end if isGod(cid) or getPlayerStorageValue(cid, 394672) >= 1 then catchinfo.rate = 100000 end if getPlayerStorageValue(cid, storage_buff_catch) <= os.time() then if getPlayerStorageValue(cid, 121212) >= 1 then catchinfo.rate = 1000 setPlayerStorageValue(cid, storage_buff_catch, os.time() + (60 * minutes_buff)) end end local d = getDistanceBetween(getThingPos(cid), topos) setPlayerStorageValue(cid, 141416, 1) addEvent(setPlayerStorageValue, 725, cid, 141416, -1) doItemSetAttribute(item2.uid, "catching", 1) addEvent(doSendPokeBall, d * 70 + 100 - (d * 14) , cid, catchinfo, false, false, typeee, 1.5) addEvent(doSendMagicEffect, (d * 70 + 100 - (d * 14)) - 100, topos, 3) return true end function getPlayerSorte() if math.random(1, 200) >= 199 then ballS = math.random(250, 450) else ballS = math.random(1, 35) end return ballS end function getPlayerSorteInNormal() if math.random(1, 100) >= 95 then ballS = math.random(250, 450) else ballS = math.random(1, 35) end return ballS end function getBallsRate(name, id) if pokes[name] then if isInArray(ballcatch[id].type, pokes[name].type) or isInArray(ballcatch[id].type, pokes[name].type2) or isInArray(ballcatch[id].pokes, name) then return 6 end end return 4 end  
    Nas duas primeiras linhas do código tem uma variável que armazena o valor da storage que irá guardar o tempo para usar o buff novamente e embaixo tem a variável que contém o tempo em minutos para usar o buff, só alterar o tempo, pois eu deixei 5 apenas como valor fictício.
     
    Teste e se der algum problema, me avise.
  11. Upvote
    Yan Oliveira recebeu reputação de No Face em Executar uma Janela   
    Tutorial explicando e ensinando a como usar diretamente essa janela doShowTextDialog() acho que não tem, mas tem alguns tutoriais ensinando a usar para coisas específicas, como por exemplo, um tutorial meu de colocar todas as quests do servidor nela: https://xtibia.com/forum/topic/251549-quest-log-em-janela/?tab=comments#comment-1759135
     
    Como não sei se você possui algum conhecimento em programação, vou fazer para você, mas se tiver, pode entrar nesse link do meu tutorial e colocar somente os textos desejados.
     
    Vai em Data/Talkactions/Scripts e crie um arquivo chamado rules.lua e adicione o script dentro:
     
    Se seu servidor for TFS 0.x adicione esse script:
     
    -- AVISOS -- local avisos = { [1] = "Não ofender ninguém.", [2] = "Não compartilhar sua conta com nenhuma pessoa.", [3] = "Respeitar todos os jogadores.", } -- DICAS -- local dicas = { [1] = "Se você estiver com algum problema, reporte para a administração utilizando o atalho CTRL+R.", [2] = "Para saber quantos jogadores há online, utilize o comando !online.", } -------------- VARIÁVEIS ------------- local id_icon_item = 2160 -- ID DO ITEM QUE FICARÁ COMO ÍCONE DA JANELA local text = "" -- TEXTO QUE CONCATENARÁ TODAS AS MENSAGENS PARA ADICIONAR NA JANELA ------------------------ CÓDIGO ---------------------------- function onSay(cid, words, param) -- REGRAS -- for index, value in ipairs(avisos) do if index == 1 then text = "\t- REGRAS" text = text .. "\n\n" .. index .. "- " .. value elseif index > 1 and index < #avisos then text = text .. "\n" .. index .. "- " .. value else text = text .. "\n" .. index .. "- " .. value .. "\n\n\n" end end -- DICAS -- for index, value in ipairs(dicas) do if index == 1 then text = text .. "\t- DICAS" text = text .. "\n\n" .. index .. "- " .. value elseif index > 1 and index < #avisos then text = text .. "\n" .. index .. "- " .. value else text = text .. "\n" .. index .. "- " .. value end end return doShowTextDialog(cid, id_icon_item, text) end  
     
    Se for TFS 1.X, adicione esse script:
     
    -- AVISOS -- local avisos = { [1] = "Não ofender ninguém.", [2] = "Não compartilhar sua conta com nenhuma pessoa.", [3] = "Respeitar todos os jogadores.", } -- DICAS -- local dicas = { [1] = "Se você estiver com algum problema, reporte para a administração utilizando o atalho CTRL+R.", [2] = "Para saber quantos jogadores há online, utilize o comando !online.", } -------------- VARIÁVEIS ------------- local id_icon_item = 2160 -- ID DO ITEM QUE FICARÁ COMO ÍCONE DA JANELA local text = "" -- TEXTO QUE CONCATENARÁ TODAS AS MENSAGENS PARA ADICIONAR NA JANELA ------------------------ CÓDIGO ---------------------------- function onSay(player, words, param, channel) -- REGRAS -- for index, value in ipairs(avisos) do if index == 1 then text = "\t- REGRAS" text = text .. "\n\n" .. index .. "- " .. value elseif index > 1 and index < #avisos then text = text .. "\n" .. index .. "- " .. value else text = text .. "\n" .. index .. "- " .. value .. "\n\n\n" end end -- DICAS -- for index, value in ipairs(dicas) do if index == 1 then text = text .. "\t- DICAS" text = text .. "\n\n" .. index .. "- " .. value elseif index > 1 and index < #avisos then text = text .. "\n" .. index .. "- " .. value else text = text .. "\n" .. index .. "- " .. value end end return player:showTextDialog(id_icon_item, text) end  
    Agora vá abra o talkactions.xml e adicione a tag:
     
    <talkaction words="!rules" event="script" value="rules.lua"/> <!-- SE QUISER MUDAR O COMANDO, SÓ MUDAR DENTRO DE words -->  
    As únicas coisas que você precisará mexer é nas tabelas que contém as mensagens, coloquei textos genéricos, e o id do ícone que ficará na janela que está na variável id_icon_item (coloquei um id aleatório).
     
    Eu deixei o comando !rules para executar o comando na tag do xml, então usando o comando, esse será o resultado:
     

  12. Upvote
    Yan Oliveira recebeu reputação de georgelxll em Variável Storage   
    Como assim a variável para usar um comando? Variável é um endereço de memória que armazena valores. E Lua tem tipagem fraca, ou seja,  isso significa que você pode colocar qualquer tipo de valor em uma variável porque a linguagem faz a conversão automaticamente de forma interna. E para usar uma variável, depende muito do script para saber se precisa ou não criar uma variável, pois tem casos que não é necessário.
     
    Se você já tem o script pronto e quer que adicione uma verificação para que somente players com essa storage possam usar um talkaction (comando), poste o código para adicionar essa verificação. Agora, se precisa criar esse script, avisa que eu crio.
  13. Amei
    Yan Oliveira recebeu reputação de Muvuka em [Resolvido] 8.60 Necessito de um NPC Revive   
    Como assim ressuscitar a sqm em que o player morreu? Pode me explicar melhor?
  14. Amei
    Yan Oliveira recebeu reputação de Muvuka em [Resolvido] Auto Loot Para Player Que Tenha Storage VIP No Caso 13545   
    Ficou ambíguo o seu pedido, pois você fala no tópico que free players e vips tenham acesso à esse recurso, porém no título você somente para quem é Vip. Então ficou ambíguo.
     
    Outra coisa, você precisa postar o seu script do autoloot para poder trabalhar com a storage e fazer as verificações para criar esse comando. 
  15. Upvote
    Yan Oliveira recebeu reputação de Vodkart em NPC - Teleport se tiver X horas online   
    Pelo que entendi a partir do momento que o player tiver X horas online ele pode ser teleportado quantas vezes quiser certo? Vamos lá!
     
    Primeiro, vá em Data/Creaturescripts/Scripts e abra o arquivo login.lua e embaixo da função onLogin() coloque essa linha:
     
    setPlayerStorageValue(cid, 777777, os.time())  
    Agora vá em Data/Npc e crie um arquivo XML chamado Teleporter.xml (ou o nome que achar melhor) e adicione o código dentro:
     
    <?xml version="1.0" encoding="UTF-8"?> <npc name="Telep" script="Teleporter.lua" walkinterval="4000" floorchange="0" level="1" maglevel="1"> <health now="150" max="150"/> <look type="1421" head="114" body="119" legs="114" feet="114" corpse="2212"/> <parameters> <parameter key="message_greet" value="Hello |PLAYERNAME|! Would you like to be teleported? Say {help} or {ajuda} for more informations."/> </parameters> </npc>  
    Agora abra a pasta Scripts dentro da pasta NPC e crie um arquivo chamado Teleporter.lua e adicione o código dentro:
     
    local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function GetHourFromSeconds(hour) return 60 * 60 * hour end function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if (not npcHandler:isFocused(cid)) then return false end -- VARIÁVEIS -- msg = string.lower(msg) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local position = {x= 1500, y= 1500, z= 7} -- POSIÇÃO PARA ONDE SERÁ TELEPORTADO local tempo_minimo = 1 -- QUANTIDADE DE HORAS QUE SERÁ NECESSÁRIO ESTAR ONLINE PARA SER TELEPORTADO local local_name = 'Village' -- NOME DO LOCAL OU PARA ONDE SERÁ TELEPORTADO local storage_time = 777777 -- STORAGE QUE ARMAZENA O TEMPO ONLINE DO PLAYER ----------------------------------- [ DIALOGO COM NPC] --------------------------------- if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') then selfSay("If you want to teleport to {" .. local_name .. "} you need to be at least {" .. tempo_minimo .. "} hour(s) online. Are you online the enough time to be teleported?", cid) talkState[talkUser] = 1 elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 1 then if (getPlayerStorageValue(cid, storage_time) + GetHourFromSeconds(tempo_minimo)) <= os.time() then selfSay("Good journey!", cid) doTeleportThing(cid, position) else selfSay("You aren't online enough time to be teleported", cid) end talkState[talkUser] = 0 return true elseif (msgcontains(msg, 'no') or msgcontains(msg, 'não')) and talkState[talkUser] == 1 then selfSay("Ok, goodbye!", cid) talkState[talkUser] = 0 return true else selfSay("I didn't understand what you said", cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())  
    Agora vá na pasta Data/Globalevents/Scripts e crie um arquivo chamado ResetTeleportTime.lua e adicione o código dentro:
     
    local storage = 777777 -- STORAGE QUE ARMAZENA O TEMPO ONLINE DO PLAYER function onTimer() for _, player in pairs(getPlayersOnline()) do if getPlayerStorageValue(player, storage) > 0 then setPlayerStorageValue(player, storage, 0) end end return true end  
    E por fim, volte na pasta Data/Globalevents e abra o arquivo globalevents.xml e adicione o seguinte código dentro:
     
    <globalevent name="reset_teleport" time="00:00" event="script" value="ResetTeleportTime.lua"/>  
    Eu deixei todas as variáveis comentadas, só alterar os valores desejado nelas.
     
    Teste e me avise se der algum problema.
  16. Upvote
    Yan Oliveira recebeu reputação de Vodkart em NPC - Teleport se tiver X horas online   
    De nada! ?
  17. Upvote
    Yan Oliveira recebeu reputação de Vodkart em NPC - Teleport se tiver X horas online   
    Como o CID é um ponteiro, ele vai mudar sim quando o player relogar ou deslogar. Mas por que você precisa ou quer saber essa informação? Essa informação não terá impacto no script que fiz para você, só dependerá do player ficar online.
  18. Upvote
    Yan Oliveira recebeu reputação de Vodkart em NPC - Teleport se tiver X horas online   
    Sim, tanto é que no Login.lua em baixo do onLogin() ele sempre recebe o tempo atual que ele logou pela função os.time():
     
    setPlayerStorageValue(cid, 777777, os.time()) Como pode ver na linha acima, ele seta o tempo atual do login para a storage 777777. Então sempre que o cara logar, vai começar a contar a partir desse momento.
  19. Upvote
    Yan Oliveira recebeu reputação de Vodkart em NPC - Teleport se tiver X horas online   
    Que bom que funcionou!
     
    Tem como sim!
     
    Troque o código do arquivo Teleporter.lua (arquivo lua do NPC) por esse:
    local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function GetHourFromSeconds(hour) return 60 * 60 * hour end function GetTime(time_seconds) local out = {} local dateFormat = { {'hora', time_seconds / 60 / 60}, {'minuto', time_seconds / 60 % 60}, } for k, t in ipairs(dateFormat) do local v = math.floor(t[2]) if (v > -1) then table.insert(out, (k < #dateFormat and '' or ' and ') .. v .. '' .. (v <= 1 and t[1] or t[1].."s")) end end if tonumber(dateFormat[1][2]) == 0 and tonumber(dateFormat[2][2]) == 0 then return "segundos" end return table.concat(out) end function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if (not npcHandler:isFocused(cid)) then return false end -- VARIÁVEIS -- msg = string.lower(msg) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local position = {x= 1500, y= 1500, z= 7} -- POSIÇÃO PARA ONDE SERÁ TELEPORTADO local tempo_minimo = 8 -- QUANTIDADE DE HORAS QUE SERÁ NECESSÁRIO ESTAR ONLINE PARA SER TELEPORTADO local local_name = 'Village' -- NOME DO LOCAL OU PARA ONDE SERÁ TELEPORTADO local storage_time = 777777 -- STORAGE QUE ARMAZENA O TEMPO ONLINE DO PLAYER local level = 100 -- LEVEL MÍNIMO PARA TELEPORTAR local effect = true -- true PARA TER EFEITO E false SEM EFEITO AO TELEPORTAR local effect_id = 25 -- ID DO EFEITO AO TELEPORTAR ----------------------------------- [ DIALOGO COM NPC] --------------------------------- if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') then selfSay("If you want to teleport to {" .. local_name .. "} you need to be at least {" .. tempo_minimo .. "} hour(s) online. Are you online the enough time to be teleported?", cid) talkState[talkUser] = 1 elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 1 then if getPlayerLevel(cid) >= level then if (getPlayerStorageValue(cid, storage_time) + GetHourFromSeconds(tempo_minimo)) <= os.time() then selfSay("Good journey!", cid) doTeleportThing(cid, position) if effect then doSendMagicEffect(getThingPos(cid), effect_id) end else selfSay("Only is possible to teleport if you are online at least " .. tempo_minimo .. " hours. You are online " .. GetTime(getPlayerStorageValue(cid, storage_time)) .. ".", cid) end else selfSay("You need to be at least level " .. level .. " to teleport.", cid) end talkState[talkUser] = 0 return true elseif (msgcontains(msg, 'no') or msgcontains(msg, 'não')) and talkState[talkUser] == 1 then selfSay("Ok, goodbye!", cid) talkState[talkUser] = 0 return true else selfSay("I didn't understand what you said", cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())  
    Na variável level você coloca o nível mínimo, na variável effect mude para false caso não queira efeito ao teleportar e na variável effect_id coloque o id do efeito que quer ao teleportar caso opte pelo efeito. Também precisa ajustar os valores das variáveis que você tinha colocado, no caso da posição e nome do lugar. De resto não precisa alterar mais nada, só colocar o tempo em horas que quer na variável tempo_minimo.
  20. Thanks
    Yan Oliveira recebeu reputação de fearwar em Quest Log em Janela   
    Olá amigos do Xtibia, venho trazer um tutorial simples, mas interessante, que exibe uma caixa de diálogo com texto contendo todas as quests do seu servidor.
     
    Atenção: Testado somente em TFS 0.3/0.4
     
    Vamos lá!
     
    Vá em Data/Talkactions/Scripts e crie um arquivo.lua chamado quest_log.lua e adicione o script:
     
    ---------------- QUEST LOG BY YAN18 ----------------- -- NOME DA QUEST NO ÍNDICE, O NÍVEL E STORAGE NO VALOR -- local quests = { ["Cerulean City"] = {level = 30, storage = 32500}, ["Fire Stone"] = {level = 50, storage = 32501}, ["Boost Machine"] = {level = 100, storage = 32502} } function onSay(cid, words, param) local quest_completada = "- Quests completadas: \n\n" local quest_incompleta = "\n- Quests não completadas: \n\n" for i, _ in pairs (quests) do if (getPlayerLevel(cid) >= quests[i].level) and (getPlayerStorageValue(cid, quests[i].storage) < 1) then quest_incompleta = quest_incompleta .. "* " ..i.. " - Nível: " ..quests[i].level.. " \n" elseif (getPlayerLevel(cid) >= quests[i].level) and (getPlayerStorageValue(cid, quests[i].storage) >= 1) then quest_completada = quest_completada .."* " ..i.. " - Nível: " ..quests[i].level.. " \n" end end if quest_completada == "- Quests completadas: \n\n" then quest_completada = quest_completada .. " Nenhuma quest foi completada ainda. \n\n" elseif quest_incompleta == "\n- Quests não completadas: \n\n" then quest_incompleta = quest_incompleta .. " Todas as quests foram completadas." end local quest = quest_completada .. quest_incompleta return doShowTextDialog(cid, 1811, quest) end  
    Agora abra o talkactions.xml que fica em Data/Talkactions/talkctions.xml e adicione a tag:
    <talkaction words="!quest" event="script" value="quest_log.lua"/> Deixei o comando !quest ali em words na tag xml, mas você pode colocar outro comando de sua preferência.
     
    Explicação: Adicione todas as quests do servidor na tabela quests, colocando o nome dela como índice, o level e storage (preste bem atenção para colocar a storage correta) como valores. Em caso de dúvidas, só seguir o exemplo que fiz. Também fiz verificação para ver se todas as quests do jogo (que você colocar na tabela) foram feitas ou não, e também fiz verificação de nível do jogador por quest, ou seja, os jogadores só verão as quests que eles tem nível para fazer. De resto não tem muito o que mexer, só se quiser reduzir ou aumentar a quantidade de espaço entre as linhas, mas ai é da preferência de cada um. Caso queira retirar a verificação de nível do jogador (pare verem todas as quests) só mudar isso:
     
    for i, _ in pairs (quests) do if (getPlayerLevel(cid) >= quests[i].level) and (getPlayerStorageValue(cid, quests[i].storage) < 1) then quest_incompleta = quest_incompleta .. "* " ..i.. " - Nível: " ..quests[i].level.. " \n" elseif (getPlayerLevel(cid) >= quests[i].level) and (getPlayerStorageValue(cid, quests[i].storage) > 1) quest_completada = quest_completada .."* " ..i.. " - Nível: " ..quests[i].level.. " \n" end end Para isso:
    for i, _ in pairs (quests) do if getPlayerStorageValue(cid, quests[i].storage) < 1 then quest_incompleta = quest_incompleta .. "* " ..i.. " - Nível: " ..quests[i].level.. " \n" else quest_completada = quest_completada .."* " ..i.. " - Nível: " ..quests[i].level.. " \n" end end  
    Se fizer tudo corretamente, é para aparecer essa janela com as informações e nível da(s) quest(s):
     

     
    Essa janela é criada na função doShowTextDialog, e o segundo parâmetro dela é um item que aparece como ícone, geralmente deixam 0 (e recomendo deixar 0 como padrão), mas tem base que o id do item 0 aparece como algum item do jogo (as vezes montanhas ou outros itens de ambiente), então deixei um blackboard, até para ficar mais coerente hehe. Você também pode criar um item para representar essa janela, mas vai da preferência e criatividade de cada um. 
     
    Se você tiver source, pode até criar uma janela com título de "Quests" para ficar mais bonito a interface, mas vai de cada um.
     
    OBS: Em alguns servidores pode ser que dê crash na distro por conta do item passado no segundo parâmetro da função doShowTextDialog(cid, id_item, texto), precisa ficar atento nisso.
     
     
    Qualquer dúvida só perguntar!
     
    Abraços e fiquem com Deus!
  21. Thanks
    Yan Oliveira recebeu reputação de fearwar em NPC - Teleport se tiver X horas online   
    Que bom que funcionou!
     
    Tem como sim!
     
    Troque o código do arquivo Teleporter.lua (arquivo lua do NPC) por esse:
    local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function GetHourFromSeconds(hour) return 60 * 60 * hour end function GetTime(time_seconds) local out = {} local dateFormat = { {'hora', time_seconds / 60 / 60}, {'minuto', time_seconds / 60 % 60}, } for k, t in ipairs(dateFormat) do local v = math.floor(t[2]) if (v > -1) then table.insert(out, (k < #dateFormat and '' or ' and ') .. v .. '' .. (v <= 1 and t[1] or t[1].."s")) end end if tonumber(dateFormat[1][2]) == 0 and tonumber(dateFormat[2][2]) == 0 then return "segundos" end return table.concat(out) end function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if (not npcHandler:isFocused(cid)) then return false end -- VARIÁVEIS -- msg = string.lower(msg) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local position = {x= 1500, y= 1500, z= 7} -- POSIÇÃO PARA ONDE SERÁ TELEPORTADO local tempo_minimo = 8 -- QUANTIDADE DE HORAS QUE SERÁ NECESSÁRIO ESTAR ONLINE PARA SER TELEPORTADO local local_name = 'Village' -- NOME DO LOCAL OU PARA ONDE SERÁ TELEPORTADO local storage_time = 777777 -- STORAGE QUE ARMAZENA O TEMPO ONLINE DO PLAYER local level = 100 -- LEVEL MÍNIMO PARA TELEPORTAR local effect = true -- true PARA TER EFEITO E false SEM EFEITO AO TELEPORTAR local effect_id = 25 -- ID DO EFEITO AO TELEPORTAR ----------------------------------- [ DIALOGO COM NPC] --------------------------------- if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') then selfSay("If you want to teleport to {" .. local_name .. "} you need to be at least {" .. tempo_minimo .. "} hour(s) online. Are you online the enough time to be teleported?", cid) talkState[talkUser] = 1 elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 1 then if getPlayerLevel(cid) >= level then if (getPlayerStorageValue(cid, storage_time) + GetHourFromSeconds(tempo_minimo)) <= os.time() then selfSay("Good journey!", cid) doTeleportThing(cid, position) if effect then doSendMagicEffect(getThingPos(cid), effect_id) end else selfSay("Only is possible to teleport if you are online at least " .. tempo_minimo .. " hours. You are online " .. GetTime(getPlayerStorageValue(cid, storage_time)) .. ".", cid) end else selfSay("You need to be at least level " .. level .. " to teleport.", cid) end talkState[talkUser] = 0 return true elseif (msgcontains(msg, 'no') or msgcontains(msg, 'não')) and talkState[talkUser] == 1 then selfSay("Ok, goodbye!", cid) talkState[talkUser] = 0 return true else selfSay("I didn't understand what you said", cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())  
    Na variável level você coloca o nível mínimo, na variável effect mude para false caso não queira efeito ao teleportar e na variável effect_id coloque o id do efeito que quer ao teleportar caso opte pelo efeito. Também precisa ajustar os valores das variáveis que você tinha colocado, no caso da posição e nome do lugar. De resto não precisa alterar mais nada, só colocar o tempo em horas que quer na variável tempo_minimo.
  22. Thanks
    Yan Oliveira recebeu reputação de fearwar em NPC - Teleport se tiver X horas online   
    Pelo que entendi a partir do momento que o player tiver X horas online ele pode ser teleportado quantas vezes quiser certo? Vamos lá!
     
    Primeiro, vá em Data/Creaturescripts/Scripts e abra o arquivo login.lua e embaixo da função onLogin() coloque essa linha:
     
    setPlayerStorageValue(cid, 777777, os.time())  
    Agora vá em Data/Npc e crie um arquivo XML chamado Teleporter.xml (ou o nome que achar melhor) e adicione o código dentro:
     
    <?xml version="1.0" encoding="UTF-8"?> <npc name="Telep" script="Teleporter.lua" walkinterval="4000" floorchange="0" level="1" maglevel="1"> <health now="150" max="150"/> <look type="1421" head="114" body="119" legs="114" feet="114" corpse="2212"/> <parameters> <parameter key="message_greet" value="Hello |PLAYERNAME|! Would you like to be teleported? Say {help} or {ajuda} for more informations."/> </parameters> </npc>  
    Agora abra a pasta Scripts dentro da pasta NPC e crie um arquivo chamado Teleporter.lua e adicione o código dentro:
     
    local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function GetHourFromSeconds(hour) return 60 * 60 * hour end function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if (not npcHandler:isFocused(cid)) then return false end -- VARIÁVEIS -- msg = string.lower(msg) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local position = {x= 1500, y= 1500, z= 7} -- POSIÇÃO PARA ONDE SERÁ TELEPORTADO local tempo_minimo = 1 -- QUANTIDADE DE HORAS QUE SERÁ NECESSÁRIO ESTAR ONLINE PARA SER TELEPORTADO local local_name = 'Village' -- NOME DO LOCAL OU PARA ONDE SERÁ TELEPORTADO local storage_time = 777777 -- STORAGE QUE ARMAZENA O TEMPO ONLINE DO PLAYER ----------------------------------- [ DIALOGO COM NPC] --------------------------------- if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') then selfSay("If you want to teleport to {" .. local_name .. "} you need to be at least {" .. tempo_minimo .. "} hour(s) online. Are you online the enough time to be teleported?", cid) talkState[talkUser] = 1 elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 1 then if (getPlayerStorageValue(cid, storage_time) + GetHourFromSeconds(tempo_minimo)) <= os.time() then selfSay("Good journey!", cid) doTeleportThing(cid, position) else selfSay("You aren't online enough time to be teleported", cid) end talkState[talkUser] = 0 return true elseif (msgcontains(msg, 'no') or msgcontains(msg, 'não')) and talkState[talkUser] == 1 then selfSay("Ok, goodbye!", cid) talkState[talkUser] = 0 return true else selfSay("I didn't understand what you said", cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())  
    Agora vá na pasta Data/Globalevents/Scripts e crie um arquivo chamado ResetTeleportTime.lua e adicione o código dentro:
     
    local storage = 777777 -- STORAGE QUE ARMAZENA O TEMPO ONLINE DO PLAYER function onTimer() for _, player in pairs(getPlayersOnline()) do if getPlayerStorageValue(player, storage) > 0 then setPlayerStorageValue(player, storage, 0) end end return true end  
    E por fim, volte na pasta Data/Globalevents e abra o arquivo globalevents.xml e adicione o seguinte código dentro:
     
    <globalevent name="reset_teleport" time="00:00" event="script" value="ResetTeleportTime.lua"/>  
    Eu deixei todas as variáveis comentadas, só alterar os valores desejado nelas.
     
    Teste e me avise se der algum problema.
  23. Upvote
    Yan Oliveira recebeu reputação de FlamesAdmin em Event Boss   
    Olá, vá na pasta Data/Globalevents/Scripts e crie um arquivo lua chamado boss e adicione o código dentro:
    ----------------------------------- EVENTO SUMMON BOSS FEITO POR YAN18 ----------------------------------------- local minutos = 20 ---- COLOCA OS MINUTOS AQUI PARA OS BOSS SUMIREM CASO NINGUÉM OS MATE ---- NOME DOS MONTROS ---- local monsters = { [1] = "Magmar" , [2] = "Electabuzz", [3] = "Scizor", } ---- POSIÇÃO DA ARENA ONDE APARECERÁ OS MONSTROS ---- local position_arena = { from_pos = {x= 964, y = 993, z= 7}, -- VARIÁVEL QUE TEM A COORDENADA INICIAL DO LUGAR ONDE VAI APARECER OS MONSTROS to_pos = {x= 978, y = 1009, z= 7}, -- VARIÁVEL QUE TEM A COORDENADA FINAL DO LUGAR ONDE VAI APARECER OS MONSTROS } ---------------------------------- CÓDIGO ---------------------------------------------- function onThink(cid, words, interval, lastExecution) ----- CRIA OS BOSS ----- for i, j in ipairs(monsters) do ----- VARIÁVEL RANDOM_POSITION GERA O SPAWN ALEATÓRIO DOS BOSS ----- local random_position = {x= math.random(position_arena.from_pos.x, position_arena.to_pos.x), y= math.random(position_arena.from_pos.y, position_arena.to_pos.y), z= math.random(position_arena.from_pos.z, position_arena.to_pos.z)} doSummonCreature(j, random_position) end doBroadcastMessage(#monsters == 1 and "A monster have been arrived in this world. Don't arrive near!" or "Some monsters have been arrived in this world. Don't arrive near by them!", 22) ---- VERIFICAÇÃO SE TEM MONSTROS NA ARENA PARA REMOVER ---- addEvent(function() local position = {} for i = position_arena.from_pos.x, position_arena.to_pos.x do for j = position_arena.from_pos.y, position_arena.to_pos.y do position[#position+1] = {x= i, y = j, z= position_arena.from_pos.z, stackpos = 0} end end for i= 1, #position do for j = 0, 255 do position[i].stackpos = j local monster = getTileThingByPos(position[i]) if isMonster(monster.uid) then for d, n in ipairs(monsters) do if getCreatureName(monster.uid) == n then doRemoveCreature(monster.uid) if d == #monsters then doBroadcastMessage(#monsters == 1 and "The monster left this world. But it will return soon...." or "The monsters left this world. But they will return soon....", 22) end end end end end end end, minutos * 60 * 1000) return true end Agora em Data/Globalevents abra o globalevents.xml e adicione a tag:
    <globalevent name="boss" interval="3600" event="script" value="boss.lua"/> <!-- TEMPO EM SEGUNDOS, JÁ DEIXEI 1 HORA --> Explicação: No código, eu criei 3 monstros genéricos para testar, só adicionar o nome deles igual está na tabela, e se quiser só 1 monstro, apague os outros dois e insira o desejado (lembrando de colocar a vírgula no final igual como está).
     
    Na variável minutos já deixei 20 como pediu, mas caso queira trocar, só alterar o valor dela (lembrando que o valor dela tem que ser menor que o intervalo do evento no xml).
     
    E na tabela position_arena, precisa colocar as coordenadas iniciais e finais da arena, já deixei pronto ali também e é só substituir.
     
    Deixei para eles nascerem em posições aleatórias dentro das coordenadas da arena, caso queira spawns fixos, só ir na variável random_position e colocar x, y e z desejados.
     
    Agora na parte do Xml como deixei o comentário na tag, já deixei 1 hora como pediu (3600 segundos), caso queira outro valor só alterar lá, lembrando que ali é em segundos.
     
    Deixei tudo comentado e explicadinho, mas qualquer dúvida só falar. Eu testei muito aqui e deu certo, mas qualquer problema só me dizer.
  24. Amei
    Yan Oliveira recebeu reputação de juliolokao em Event Boss   
    Olá, vá na pasta Data/Globalevents/Scripts e crie um arquivo lua chamado boss e adicione o código dentro:
    ----------------------------------- EVENTO SUMMON BOSS FEITO POR YAN18 ----------------------------------------- local minutos = 20 ---- COLOCA OS MINUTOS AQUI PARA OS BOSS SUMIREM CASO NINGUÉM OS MATE ---- NOME DOS MONTROS ---- local monsters = { [1] = "Magmar" , [2] = "Electabuzz", [3] = "Scizor", } ---- POSIÇÃO DA ARENA ONDE APARECERÁ OS MONSTROS ---- local position_arena = { from_pos = {x= 964, y = 993, z= 7}, -- VARIÁVEL QUE TEM A COORDENADA INICIAL DO LUGAR ONDE VAI APARECER OS MONSTROS to_pos = {x= 978, y = 1009, z= 7}, -- VARIÁVEL QUE TEM A COORDENADA FINAL DO LUGAR ONDE VAI APARECER OS MONSTROS } ---------------------------------- CÓDIGO ---------------------------------------------- function onThink(cid, words, interval, lastExecution) ----- CRIA OS BOSS ----- for i, j in ipairs(monsters) do ----- VARIÁVEL RANDOM_POSITION GERA O SPAWN ALEATÓRIO DOS BOSS ----- local random_position = {x= math.random(position_arena.from_pos.x, position_arena.to_pos.x), y= math.random(position_arena.from_pos.y, position_arena.to_pos.y), z= math.random(position_arena.from_pos.z, position_arena.to_pos.z)} doSummonCreature(j, random_position) end doBroadcastMessage(#monsters == 1 and "A monster have been arrived in this world. Don't arrive near!" or "Some monsters have been arrived in this world. Don't arrive near by them!", 22) ---- VERIFICAÇÃO SE TEM MONSTROS NA ARENA PARA REMOVER ---- addEvent(function() local position = {} for i = position_arena.from_pos.x, position_arena.to_pos.x do for j = position_arena.from_pos.y, position_arena.to_pos.y do position[#position+1] = {x= i, y = j, z= position_arena.from_pos.z, stackpos = 0} end end for i= 1, #position do for j = 0, 255 do position[i].stackpos = j local monster = getTileThingByPos(position[i]) if isMonster(monster.uid) then for d, n in ipairs(monsters) do if getCreatureName(monster.uid) == n then doRemoveCreature(monster.uid) if d == #monsters then doBroadcastMessage(#monsters == 1 and "The monster left this world. But it will return soon...." or "The monsters left this world. But they will return soon....", 22) end end end end end end end, minutos * 60 * 1000) return true end Agora em Data/Globalevents abra o globalevents.xml e adicione a tag:
    <globalevent name="boss" interval="3600" event="script" value="boss.lua"/> <!-- TEMPO EM SEGUNDOS, JÁ DEIXEI 1 HORA --> Explicação: No código, eu criei 3 monstros genéricos para testar, só adicionar o nome deles igual está na tabela, e se quiser só 1 monstro, apague os outros dois e insira o desejado (lembrando de colocar a vírgula no final igual como está).
     
    Na variável minutos já deixei 20 como pediu, mas caso queira trocar, só alterar o valor dela (lembrando que o valor dela tem que ser menor que o intervalo do evento no xml).
     
    E na tabela position_arena, precisa colocar as coordenadas iniciais e finais da arena, já deixei pronto ali também e é só substituir.
     
    Deixei para eles nascerem em posições aleatórias dentro das coordenadas da arena, caso queira spawns fixos, só ir na variável random_position e colocar x, y e z desejados.
     
    Agora na parte do Xml como deixei o comentário na tag, já deixei 1 hora como pediu (3600 segundos), caso queira outro valor só alterar lá, lembrando que ali é em segundos.
     
    Deixei tudo comentado e explicadinho, mas qualquer dúvida só falar. Eu testei muito aqui e deu certo, mas qualquer problema só me dizer.
  25. Upvote
    Yan Oliveira recebeu reputação de spoockk em [Resolvido] [PEDIDO] Scripts de spawn no mapa   
    Sobre a versão, então no seu caso muito provavelmente é 0.3.6, que é a versão atualmente de todos os Poketibia.
     
    Se é evento, provavelmente é um pokémon que não terá em respawn, então não precisa de storage para deixa específica a kill dele (quando não tem storage, em qualquer situação vai contar como kill nesse script que vou fazer, por exemplo matar em respawn)
     
     
    Vai em Data/Creaturescripts/Scripts e crie um arquivo chamado task_event.lua (ou o nome que preferir) e adicione o código dentro:
     
    local pokemon_derrotar = "Charizard" -- NOME DO POKÉMON QUE PRECISA DERROTAR NA TASK local total = 50 -- TOTAL DE POKEMON QUE PRECISA DERROTAR local pokemon_spawn = "Mewtwo" -- NOME DO POKEMON QUE VAI SPAWNAR local position_spawn = {x= 1000, y= 1000, z= 7} -- POSIÇÃO ONDE VAI SPAWNAR O POKEMON local storage = 15879 -- STORAGE PARA VER SE JÁ FEZ A TASK local random_porcentagem = 50 -- PORCENTAGEM QUE TEM DO POKEMON SPAWNAR AO TERMINAR A TASK function onKill(cid, target) local contador = 0 local random_chance = math.random(100) if getCreatureName(target) == pokemon_derrotar then if getPlayerStorageValue(cid, storage) < 1 then if (total - contador) > 0 then contador = contador + 1 end if contador == total then setPlayerStorageValue(cid, storage, 1) if (random_chance >= random_porcentagem) then doSummonCreature(pokemon_spawn, position_spawn) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você despertou a fúria de um pokémon, se prepare para o combate!") return true else return true end end else return true end else return true end end  
    Agora vai em creaturescripts.xml e adicione a tag:
    <event type="kill" name="task_event" script="task_event.lua" />  
    OBS: Caso tenha colocado um arquivo com nome diferente do que sugeri não se esqueça de trocar na tag xml.
     
    E por fim em Data/Creaturescripts/Scripts abra o arquivo login.lua e procura seção de eventos e adiciona o evento:
    registerCreatureEvent(cid, "task_event")  
    Deixei tudo comentado nas variáveis, só vai precisar trocar os valores. Lembrando que na variável random_porcentagem é a chance que vai ter de nascer o pokémon, como eu deixei 50, da tanto para verificar se vai ser maior que 50 ou menor, mas no caso deixei maior ou igual a 50, então qualquer valor acima de 50 gerado pela variável random_chance vai sumonar o pokémon. Se quer que tenha menos de 50% de chance, mude o valor da variável random_porcentagem e nessa verificação:
    if (random_chance >= random_porcentagem) then Mude para o valor desejado menor que 50, mas tem que mudar o if para:
    if (random_chance <= random_porcentagem) then  
    Teste, e se der algum erro ou problema, me avise.
  • Quem Está Navegando   0 membros estão online

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