• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Help onKill event

Sigoles

Discord: @sigoles
Joined
Nov 20, 2015
Messages
1,209
Solutions
2
Reaction score
154
Hello, I have error when kill Paiz the Pauperizer
8156e79a0f8a4b8284ff7d5678f2105e.png

TFS 1.2

LUA:
--: Configurações Gerais  :--
local storage = 321403 --: Storage do script
local msg = "You have found a lucky coin, say !luckycoins for more info." --: Mensagem ao jogador quando recebe uma coin
local showqtd = 1 --: Mostrar QTD de coins na msg? 1-Sim, 0-Não
local qtdtext = "You have" --: Texto que mostra antes da qtd de lucky coins, ex: você pode trocar para 'voce tem'

--: VISUAL :--
local enableeffect = 1 --: Mostrar efeito ao pegar a coin(ajuda a visualizar melhor)? 1 - Sim, 0 - Não.
local effect = CONST_ME_FERUMBRAS --: Efeito para mostrar, só é usado se for habilitado

  --: RATES :--
  local boost = 1 --: Aumenta as chances de obter coins para todos os monstros. 1 = 1x, 2 = 2x etc...
  local anycreature = 1 --: Todas as criaturas podem dropar. 0 - Não, 1 - Sim.
  local anycrate = 200 --: Chance de dropar em qlqr criatura 200 = 0,005%
  local ignorecfg = 0 --: Ignorar as chances da configuração? 1=sim 0=não

  --: Nota: ignorecfg = 1 faz com que todas as chances passem a ser da anycrate, independente da cfg

  --: Altere os monstros, o nome e o a chance de obter a coin  :--
  local config = {
    -- Quanto maior for o valor, menores são as chances de conseguir a coin
   -- ["Arachir the Ancient One"] = {chance = 1}, -- 600 significa a chance de um em 600
    ["Ferumbras"] = {chance = 1}, -- 30 significa a chance de uma em 30... etc
    ["The Many"] = {chance = 1}, -- 100% de chance
    ["Ascending Ferumbras"] = {chance = 1}, -- 100% de chance
    ["Necropharus"] = {chance = 1}, -- 100% de chance
    ["Paiz the Pauperizer"] = {chance = 1}, -- 100% de chance
    ["The Noxious Spawn"] = {chance = 1}, -- 100% de chance
    ["Gorgo"] = {chance = 1}, -- 100% de chance
    ["Stonecracker"] = {chance = 1}, -- 100% de chance
    ["Leviathan"] = {chance = 1}, -- 100% de chance
    ["Kerberos"] = {chance = 1}, -- 100% de chance
    ["Ethershreck"] = {chance = 1}, -- 100% de chance
    ["Zanakeph"] = {chance = 1}, -- 100% de chance
    ["Tiquandas Revenge"] = {chance = 1}, -- 100% de chance
    ["Demodras"] = {chance = 1}, -- 100% de chance
    ["Bretzecutioner"] = {chance = 1} -- 100% de chance
    --["Bretzecutioner"] = {chance = 2} -- 50% de chance
    --["Dog"] = {chance = 10} -- 10% de chance
  }

  function onKill(cid, target, lastHit)
    if (isPlayer(target)) then return true end
    local monster = getCreatureName(target)
    local rand
    local isnotinarray

    for index, arraymonster in ipairs(config) do
      if ((arraymonster ~= monster) and (anycreature == 0)) then return true elseif (anycreature == 1) then isnotinarray = true end
    end

    local storageatual = getPlayerStorageValue(cid, storage)
    local plural = "s"
    local qtd = ""

    if (isnotinarray == true) then 
    rand = anycrate 
    else 
    rand = ((config[monster].chance) / boost) 
    end
   
    if (ignorecfg == 1) then rand = anycrate end
    if (rand < 1) then rand = 1 end
    if (storageatual == 1) then    plural = ""    end
    if (showqtd == 1) then qtd = " " .. qtdtext .. " " .. storageatual + 1 .. " lucky coin" .. plural .. "." end

    if  (math.random(rand) == 1) then
      setPlayerStorageValue(cid, storage, storageatual + 1)
      doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, msg .. qtd)
      if (enableeffect == 1) then doSendMagicEffect(getPlayerPosition(cid), effect) end
    end

    return true
  end

help? :D
 
Last edited by a moderator:
rand hasnt been initialized and its null here

if (rand < 1) then rand = 1 end

You can try with

if not rand then rand = 1 end

But it depends on what you want to do. (I haven't read whole code)
 
Hey I edited the main post, read again please and thank you
 
Last edited by a moderator:

Similar threads

Back
Top