Jump to content

Scripting Script Tfs1.3 Chest Chance


Go to solution Solved by Alumoz,

Recommended Posts

.Qual servidor ou website você utiliza como base? 

Znote

Qual o motivo deste tópico? 

Script

 

 

 

Ola pessoal,

estou procurando um script tfs 1.3,

um baú tem 10% de chance de saquear um item (como 10 itens no total, aleatório com chance)
Se eu obtiver, por exemplo, um item, aumentarei 5% essa chance para 10 + 5 % para obter um item, se eu usar 10 items aumentarei para 10+50%,

Chance de cada item diferente, como 60% 10 crystal coins, 20% uma bp, 5% uma runa, etc.  removendo o item enquanto estiver usando o baú.


Não tenho certeza se é possível fazer esse tipo de script

Eu sei que poderiamos usar atributos como:

mas nao sei como criar esse tipo de script,

 

cooldown_storage = 44444
cooldown = 60 * 60 * 2
player:setStorageValue(config.cooldown_storage, os.time() + config.cooldown)
_____________________________________________________________________________


local box = Action()

local JEWEL = {2152, 2148}
local REWARD = {2160}
function box.onUse(cid, item, fromPosition, itemEx, toPosition)
      local randomChance = math.random(1, #REWARD)
      doPlayerAddItem(cid, REWARD[randomChance], 1)

local randomLoot = math.random(1,20)
    if randomLoot == 1 then
    doPlayerSendTextMessage(cid, 22, "You found an extra item!")
             local randomChance = math.random(1, #REWARD)
              doPlayerAddItem(cid, REWARD[randomChance], 1)
    end

local randomJewel = math.random(1,10)
    if randomJewel == 1 then
    doPlayerSendTextMessage(cid, 22, "You found an extra item!")
      local randomChance = math.random(1, #JEWEL)
      doPlayerAddItem(cid, JEWEL[randomChance], 1)
    end

doSendMagicEffect(getPlayerPosition(cid), 172)
   doRemoveItem(item.uid, 1)
   return true
end

box:id(18100)
box:register()

 

 



Obrigado

 

 

Link to post
Share on other sites

explica melhor sua ideia, não deu pra entender exatamente o que você quer

 

usa o baú e tem 10% de chance de ganhar item e 90% de não ganhar? isso?

Toda terça-feira um tópico novo:

Descanso para curar mana (Spell): https://tibiaking.com/forums/topic/94615-spell-descanso-para-curar-mana/

Peça sua spell (Suporte):                https://tibiaking.com/forums/topic/84162-peça-sua-spell/                        

Chuva de flechas (Spell):                https://tibiaking.com/forums/topic/72232-chuva-de-flechas-spell/

Doom (Spell):                                https://tibiaking.com/forums/topic/51622-doom-spell/

Utilização do VS Code (Infra)       https://tibiaking.com/forums/topic/94463-utilizando-o-visual-studio-code-notepad-nunca-mais/

SD com Combo (Spell):                 https://tibiaking.com/forums/topic/94520-sd-modificada/

Alteração attack speed (C++):        https://tibiaking.com/forums/topic/94714-c-attack-speed-spells-itens-e-onde-você-quiser/  

Bônus de Speed (NPC)                  https://tibiaking.com/forums/topic/94809-npc-concede-bônus-aos-players/
 

Link to post
Share on other sites
  • Solution
Posted (edited)
Em 29/06/2022 em 04:24, Reds disse:

explica melhor sua ideia, não deu pra entender exatamente o que você quer

 

usa o baú e tem 10% de chance de ganhar item e 90% de não ganhar? isso?

 

Olá desculpe a demora na resposta, parece que o site .com está inacessível, exceto se você clicar em fóruns, eu finalmente encontrei

 

local config = {
    actionId = 45001,
    baseChance = 100,
    cooldown = {
        active = true,
        key = 11111,
        value = 64800 
    },
    chanceIncreasers = {
        [1111] = {chanceIncrease = 10} 
    },
    rewards = {
        {itemId = 1111, minCount = 1, maxCount = 1, chance = 500},
        {itemId = 2222, minCount = 1, maxCount = 10, chance = 50}, 
        {itemId = 3333, minCount = 10, maxCount = 50, chance = 5}  
    }
}

local rewardChest = Action()

function rewardChest.onUse(player, item, fromPosition, target, toPosition, isHotkey)

    if config.cooldown.active then
        local currentTime = os.time()
        local currentStorage = player:getStorageValue(config.cooldown.key)
        if currentStorage > currentTime then
            player:sendCancelMessage("Currently on cooldown. Can use again in ".. os.date("!%Hh %Mm %Ss", currentStorage - currentTime) .."")
            return true
        end
        player:setStorageValue(config.cooldown.key, (currentTime + config.cooldown.value))
    end

    local chance = config.baseChance
    for v, k in pairs(config.chanceIncreasers) do 
        local increaserCount = player:getItemCount(v)
        local increasersUsed = 0
        while chance < 1000 and increaserCount > 0 do 
            chance = chance + k.chanceIncrease
            increasersUsed = increasersUsed - 1
        end
        player:removeItem(config.itemChanceIncreaserId, increasersUsed)
    end
  
    local rand = math.random(1000)
    if chance > rand then
        player:say("No reward.", TALKTYPE_MONSTER_SAY)
        return true
    end
  
    local rewardList = {} 
    while #rewardList < 1 do
        for i = 1, #config.rewards do
            rand = math.random(1000)
            if rand <= config.rewards[i].chance then
                rewardList[#rewardList + 1] = i
            end
        end
    end
  
    rand = math.random(#rewardList)  
    player:addItem(config.rewards[rand].itemId, math.random(config.rewards[rand].minCount, config.rewards[rand].maxCount), true)
    player:say("Received " .. ItemType(config.rewards[rand].itemId):getName():lower() .. " as reward.", TALKTYPE_MONSTER_SAY)
    return true
end

rewardChest:aid(config.actionId)
rewardChest:register()

 

 

 

Edited by Alumoz (see edit history)
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.


  • Similar Content

    • By Pacera
      .Qual servidor ou website você utiliza como base? 
      revscript canary
      Qual o motivo deste tópico? 
       
      Está surgindo algum erro? Se sim coloque-o aqui. 
       
      Você tem o código disponível? Se tiver publique-o aqui: 
      local charms = {
          -- Wound charm
          [1] = {
              name = "Wound",
              description = "Triggers on a creature with a certain chance and deals 5% \z
                             of its initial hit points as physical damage once.",
              type = CHARM_OFFENSIVE,
              damageType = COMBAT_PHYSICALDAMAGE,
              percent = 10,
              chance = 20,
              messageCancel = "You wounded the monster.",
              messageServerLog = "[Wound charm]",
              effect = CONST_ME_HITAREA,
              points = 600
          },
          -- Enflame charm
          [2] = {
              name = "Enflame",
              description = "Triggers on a creature with a certain chance and deals 5% \z
                             of its initial hit points as fire damage once.",
              type = CHARM_OFFENSIVE,
              damageType = COMBAT_FIREDAMAGE,
              percent = 10,
              chance = 20,
              messageCancel = "You enflamed the monster.",
              messageServerLog = "[Enflame charm]",
              effect = CONST_ME_HITBYFIRE,
              points = 1000
          },
          -- Poison charm
          [3] = {
              name = "Poison",
              description = "Triggers on a creature with a certain chance and deals 5% \z
                             of its initial hit points as earth damage once.",
              type = CHARM_OFFENSIVE,
              damageType = COMBAT_EARTHDAMAGE,
              percent = 10,
              chance = 20,
              messageCancel = "You poisoned the monster.",
              messageServerLog = "[Poison charm]",
              effect = CONST_ME_GREEN_RINGS,
              points = 600
          },
          -- Freeze charm
          [4] = {
              name = "Freeze",
              description = "Triggers on a creature with a certain chance and deals 5% \z
                             of its initial hit points as ice damage once.",
              type = CHARM_OFFENSIVE,
              damageType = COMBAT_ICEDAMAGE,
              percent = 10,
              chance = 20,
              messageCancel = "You frozen the monster.",
              messageServerLog = "[Freeze charm]",
              effect = CONST_ME_ICEATTACK,
              points = 800
          },
          --Zap charm
          [5] = {
              name = "Zap",
              description = "Triggers on a creature with a certain chance and deals 5% \z
                             of its initial hit points as energy damage once.",
              type = CHARM_OFFENSIVE,
              damageType = COMBAT_ENERGYDAMAGE,
              percent = 10,
              chance = 20,
              messageCancel = "You eletrocuted the monster.",
              messageServerLog = "[Zap charm]",
              effect = CONST_ME_ENERGYHIT,
              points = 800
          },
          --Curse charm
          [6] = {
              name = "Curse",
              description = "Triggers on a creature with a certain chance and deals 5% \z
                             of its initial hit points as death damage once.",
              type = CHARM_OFFENSIVE,
              damageType = COMBAT_DEATHDAMAGE,
              percent = 10,
              chance = 20,
              messageCancel = "You curse the monster.",
              messageServerLog = "[Curse charm]",
              effect = CONST_ME_SMALLCLOUDS,
              points = 900
          },
          -- Cripple charm
          [7] = {
              name = "Cripple",
              description = "Cripples the creature with a certain chance and paralyzes it for 10 seconds.",
              type = CHARM_OFFENSIVE,
              chance = 20,
              messageCancel = "You cripple the monster.",
              points = 500
          },
          -- Parry charm
          [8] = {
              name = "Parry",
              description = "Any damage taken is reflected to the aggressor with a certain chance.",
              type = CHARM_DEFENSIVE,
              damageType = COMBAT_PHYSICALDAMAGE,
              chance = 10,
              messageCancel = "You parry the attack.",
              messageServerLog = "[Parry charm]",
              effect = CONST_ME_EXPLOSIONAREA,
              points = 1000
          },
          -- Dodge charm
          [9] = {
              name = "Dodge",
              description = "Dodges an attack with a certain chance without taking any damage at all.",
              type = CHARM_DEFENSIVE,
              chance = 20,
              messageCancel = "You dodge the attack.",
              effect = CONST_ME_POFF,
              points = 600
          },
          -- Adrenaline burst charm
          [10] = {
              name = "Adrenaline Burst",
              description = "Bursts of adrenaline enhance your reflexes with a certain chance \z
                             after you get hit and let you move faster for 10 seconds.",
              type = CHARM_DEFENSIVE,
              chance = 20,
              messageCancel = "Your movements where bursted.",
              points = 500
          },
          -- Numb charm
          [11] = {
              name = "Numb",
              description = "Numbs the creature with a certain chance after its attack and paralyzes the creature for 10 seconds.",
              type = CHARM_DEFENSIVE,
              chance = 20,
              messageCancel = "You numb the monster.",
              points = 500
          },
          -- Cleanse charm
          [12] = {
              name = "Cleanse",
              description = "Cleanses you from within with a certain chance after you get hit and \z
                             removes one random active negative status effect and temporarily makes you immune against it.",
              type = CHARM_DEFENSIVE,
              chance = 20,
              messageCancel = "You purified the attack.",
              points = 700
          },
          -- Bless charm
          [13] = {
              name = "Bless",
              description = "Blesses you and reduces skill and xp loss by 10% when killed by the chosen creature.",
              type = CHARM_PASSIVE,
              percent = 10,
              chance = 100,
              points = 800
          },
          -- Scavenge charm
          [14] = {
              name = "Scavenge",
              description = "Enhances your chances to successfully skin/dust a skinnable/dustable creature.",
              type = CHARM_PASSIVE,
              percent = 10,
              points = 800
          },
          -- Gut charm
          [15] = {
              name = "Gut",
              description = "Gutting the creature yields 20% more creature products.",
              type = CHARM_PASSIVE,
              percent = 20,
              points = 800,
          },
          -- Low blow charm
          [16] = {
              name = "Low Blow",
              description = "Adds 8% critical hit chance to attacks with critical hit weapons.",
              type = CHARM_PASSIVE,
              percent = 8,
              chance = 0,
              points = 2000
          },
          -- Divine wrath charm
          [17] = {
              name = "Divine Wrath",
              description = "Triggers on a creature with a certain chance and deals 5% \z
                             of its initial hit points as holy damage once.",
              type = CHARM_OFFENSIVE,
              damageType = COMBAT_HOLYDAMAGE,
              percent = 10,
              chance = 1,
              messageCancel = "You divine the monster.",
              messageServerLog = "[Divine charm]",
              effect = CONST_ME_HOLYDAMAGE,
              points = 1500
          },
          -- Vampiric embrace charm
          [18] = {
              name = "Vampiric Embrace",
              description = "Adds 4% Life Leech to attacks if wearing equipment that provides life leech.",
              type = CHARM_PASSIVE,
              percent = 4,
              chance = 0,
              points = 1500
          },
          -- Void's call charm
          [19] = {
              name = "Void's Call",
              description = "Adds 2% Mana Leech to attacks if wearing equipment that provides mana leech.",
              type = CHARM_PASSIVE,
              percent = 2,
              chance = 0,
              points = 1500
          }
      }
          
      for charmId, chamsTable in ipairs(charms) do
          local charm = Game.createBestiaryCharm(charmId - 1)
          local charmConfig = {}
          if chamsTable.name then
              charmConfig.name = chamsTable.name
          end
          if chamsTable.description then
              charmConfig.description = chamsTable.description
          end
          if chamsTable.type then
              charmConfig.type = chamsTable.type
          end
          if chamsTable.damageType then
              charmConfig.damageType = chamsTable.damageType
          end
          if chamsTable.percent then
              charmConfig.percent = chamsTable.percent
          end
          if chamsTable.messageCancel then
              charmConfig.messageCancel = chamsTable.messageCancel
          end
          if chamsTable.messageServerLog then
              charmConfig.messageServerLog = chamsTable.messageServerLog
          end
          if chamsTable.effect then
              charmConfig.effect = chamsTable.effect
          end
          if chamsTable.points then
              charmConfig.points = chamsTable.points
          end
      if player:hasCharmUpgradeBonus() then        
          if chamsTable.chance then
              charmConfig.chance = chamsTable.chance + 5
          end
          else
          if chamsTable.chance then
              charmConfig.chance = chamsTable.chance
          end
      end    
          -- Create charm and egister charmConfig table
          charm:register(charmConfig)
      end
       
      Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. 
       
    • By Muvuka
      Eu acho que o erro é na pasta lib pois na pasta npcs ta tudo certo alguem pode me ajuda? toda vez tenho que da reload quando acontece esse erro e as vezes reload crasha o servidor aff não sei mais oque faze.
      [14/08/2022 21:48:02] [Error - Npc interface] [14/08/2022 21:48:02] data/npc/scripts/scarabitens.lua:onThink [14/08/2022 21:48:02] Description: [14/08/2022 21:48:02] (luaGetNpcDistanceTo) Thing not found [14/08/2022 21:48:02] [Error - Npc interface] [14/08/2022 21:48:02] data/npc/scripts/scarabitens.lua:onThink [14/08/2022 21:48:02] Description: [14/08/2022 21:48:02] (luaGetCreatureName) Creature not found [14/08/2022 21:48:03] [Error - Npc interface] [14/08/2022 21:48:03] data/npc/scripts/scarabitens.lua:onThink [14/08/2022 21:48:03] Description: [14/08/2022 21:48:03] data/npc/lib/npcsystem/npchandler.lua:301: bad argument #3 to 'gsub' (string/function/table expected) [14/08/2022 21:48:03] stack traceback: [14/08/2022 21:48:03] [C]: in function 'gsub' [14/08/2022 21:48:03] data/npc/lib/npcsystem/npchandler.lua:301: in function 'parseMessage' [14/08/2022 21:48:03] data/npc/lib/npcsystem/npchandler.lua:538: in function 'onWalkAway' [14/08/2022 21:48:03] data/npc/lib/npcsystem/npchandler.lua:473: in function 'onThink' [14/08/2022 21:48:03] data/npc/scripts/scarabitens.lua:8: in function <data/npc/scripts/scarabitens.lua:8> [14/08/2022 21:48:04] [Error - Npc interface] [14/08/2022 21:48:04] data/npc/scripts/scarabitens.lua:onThink [14/08/2022 21:48:04] Description: [14/08/2022 21:48:04] (luaGetNpcDistanceTo) Thing not found [14/08/2022 21:48:05] [Error - Npc interface] [14/08/2022 21:48:05] data/npc/scripts/scarabitens.lua:onThink [14/08/2022 21:48:05] Description: [14/08/2022 21:48:05] (luaGetCreatureName) Creature not found [14/08/2022 21:48:05] [Error - Npc interface] [14/08/2022 21:48:05] data/npc/scripts/scarabitens.lua:onThink [14/08/2022 21:48:05] Description: [14/08/2022 21:48:05] data/npc/lib/npcsystem/npchandler.lua:301: bad argument #3 to 'gsub' (string/function/table expected) [14/08/2022 21:48:05] stack traceback: [14/08/2022 21:48:05] [C]: in function 'gsub' [14/08/2022 21:48:05] data/npc/lib/npcsystem/npchandler.lua:301: in function 'parseMessage' [14/08/2022 21:48:06] data/npc/lib/npcsystem/npchandler.lua:538: in function 'onWalkAway' [14/08/2022 21:48:06] data/npc/lib/npcsystem/npchandler.lua:473: in function 'onThink' [14/08/2022 21:48:06] data/npc/scripts/scarabitens.lua:8: in function <data/npc/scripts/scarabitens.lua:8>  
    • By MIzakinha
      Olá a todos!
       
      Seguinte... No meu servidor toda vez que alguém abre uma box o autoloot para de funcionar (para o servidor todo, não só para o player que abriu). Tanto a box quanto o autoloot funciona perfeitamente, porém, quando alguém usa a box e recebe o pokemon, o autoloot para de funcionar.
       
      Depois de vários testes aqui eu descobri que o problema está na função "doTransformItem(item, id)" que está dentro da função "addPokeToPlayer". Dito isso, não estou conseguindo identificar por que isso acontece. Alguém consegue me ajudar?
       
      Vou deixar aqui embaixo o script da função, da box e do autoloot.
       
      Obs: Estou usando o Pokemon HuatsonOT V2.0 (DXP) como base.
       
      função addPokeToPlayer:
      function addPokeToPlayer(cid, pokemon, boost, gender, ball, unique, mega) --alterado v1.9 \/ peguem ele todo... local genders = { ["male"] = 4, ["female"] = 3, [1] = 4, [0] = 3, [4] = 4, [3] = 3, } if not isCreature(cid) then return false end local pokemon = doCorrectString(pokemon) if not pokes[pokemon] then return false end local GENDER = (gender and genders[gender]) and genders[gender] or getRandomGenderByName(pokemon) local btype = (ball and pokeballs[ball]) and ball or isShinyName(pokemon) and "shinypoke" or "poke" local happy = 250 id = 11829 if pokemon == "Shiny Ditto" then id = 11743 end local cap = getPlayerFreeCap(cid) if (getPlayerFreeCap(cid) <= 1 and not isInArray({ 5, 6 }, getPlayerGroupId(cid))) or not hasSpaceInContainer(getPlayerSlotItem(cid, 3).uid) then item = doCreateItemEx(id) else item = addItemInFreeBag(getPlayerSlotItem(cid, 3).uid, id, 1) end if not item then return false end doItemSetAttribute(item, "poke", pokemon) doItemSetAttribute(item, "hpToDraw", 0) doSetItemAttribute(item, "hands", 0) doItemSetAttribute(item, "ball", btype) doItemSetAttribute(item, "reverseIcon", btype) doSetAttributesBallsByPokeName(cid, item, pokemon) if boost and tonumber(boost) and tonumber(boost) > 0 and tonumber(boost) <= 50 then doItemSetAttribute(item, "boost", boost) end if unique then doItemSetAttribute(item, "unique", getCreatureName(cid)) end if (cap <= 1 and not isInArray({ 5, 6 }, getPlayerGroupId(cid))) or not hasSpaceInContainer(getPlayerSlotItem(cid, 3).uid) then if mega then doItemSetAttribute(item, "yHeldItem", mega .. "|MEGA") end doPlayerSendMailByName(getCreatureName(cid), item, 1) sendMsgToPlayer(cid, 27, "You are already holding six digimons, so your new digimon was sent to your data center.") end doTransformItem(item, id) if mega then doItemSetAttribute(item, "yHeldItem", mega .. "|MEGA") end sendAllPokemonsBarPoke(cid) return true end  
      autoloot:
       function onUse(cid, item, frompos, item2, topos) if isWatchingTv(cid) then return true end if quemMatou then local player = getCreatureByName(quemMatou) if isPlayer(player) then local isInParyWithPlayer = false if isInParty(cid) and isInParty(player) then isInParyWithPlayer = isPartyEquals(player, cid) end if getCreatureName(cid) ~= getCreatureName(player) and not isInParyWithPlayer then doPlayerSendCancel(cid, "Voce nao pode abrir um loot que nao eh seu.") return true end end end local autoLootList = getAllItensInMyList(cid) local bag = getPlayerSlotItem(cid, 3).uid local itemsToRemove = {} if isCollectAll(cid) then for a = 0, getContainerSize(item.uid) do local it = getContainerItem(item.uid, a) if it.uid > 0 then if addItemInFreeBag(bag, it.itemid, it.type) ~= false then table.insert(itemsToRemove, it.uid) end end end end if #autoLootList > 0 and not isCollectAll(cid) then for a = 0, getContainerSize(item.uid) do local it = getContainerItem(item.uid, a) if it.uid > 0 then for i = 1, #autoLootList do if getItemInfo(it.itemid).name == autoLootList[i] then if addItemInFreeBag(bag, it.itemid, it.type) ~= false then table.insert(itemsToRemove, it.uid) end end end end end end if #itemsToRemove > 0 then for i = 1, #itemsToRemove do doChangeTypeItem(itemsToRemove[i], 0) end end end  
      box:
      local a = { [11638] = {pokemons = {"Caterpie", "Weedle"}}, [11639] = {pokemons = {"Bulbasaur", "Charmander", "Squirtle"}}, --[11640] = {pokemons = {"Politoed", "Hitmontop"}}, --[11641] = {pokemons = {"Dragonite", "Shiny Horsea"}}, --[12581] = {pokemons = {"Aerodactyl"}}, --[12227] = {pokemons = {"Shiny Milotic", "Shiny Mr. Mime"}} } local happy = 1000 function onUse(cid, item, frompos, item2, topos) local b = a[item.itemid] if not b then return true end local pokemon = b.pokemons[math.random(#b.pokemons)] if not pokes[pokemon] then return true end doPlayerSendTextMessage(cid, 27, "You opened a Gift!") doPlayerSendTextMessage(cid, 27, "The prize Pokemon was a "..pokemon..", congratulations!") doSendMagicEffect(getThingPos(cid), 29) addPokeToPlayer(cid, pokemon, 0, nil, "poke") --alterado v1.9 doRemoveItem(item.uid, 1) return true end  
    • By Strikerzerh
      Boa tarde galera, tudo bom? bom o sistema funciona da seguinte maneira, como no remeres o respawn da para por somente a cada 3600 segundos ( 1 hora ), eu gostaria de um script que alterasse e x monstro nascesse a cada 7 horas! eu iria ficar extremamente a gradecido se alguem me ajudasse.
       
    • By Ghaz
      Boa tarde Devs, tudo bem?
       
      Preciso da ajuda de vocês com OTC. Estou montando um MOD pro meu OTC e está funcional, porém gostaria que ele sumisse com a window/modal quando o player deslogasse. Podem me ajudar?
       
      Segue o código abaixo:
       
       
×
×
  • Create New...

Important Information

Confirmação de Termo