fix a onKill function for Lucky coin system please..

oshrigames

Intermediate OT User
Joined
Nov 9, 2012
Messages
123
Reaction score
14
Location
israel
Original post:

the Issue: lucky coins don't drop.

TFS 1.2, format 10.98.

i think the issue is in here?

Code:
--: Configs  :--
local storage = 32143 --: Script Storage
local msg = "You have found a lucky coin, say !luckycoins for more info." --: Message when a player find a lucky coin
local showqtd = 1 --: Show coin quantity on above message? 1-Yes, 0-No
local qtdtext = "You have" --: Text can be changed here for translation

--: VISUAL :--
local enableeffect = 1 --: Show effects when user get a coin? 1-Yes, 0-No
local effect = CONST_ME_FERUMBRAS --: Effect to show, if enableeffect = 1

--: RATES :--
local boost = 5 --: Boots lucky coins rate by this value, don't works with ignorecfg/anycrate yet. 1 = 1x, 2 = 2x etc...
local anycreature = 1 --: All creatures can drop lucky coins. 0 - No, 1 - Yes.
local anycrate = 20 --: Lucky Coins drop rate on every creature 200 = 0,005%
local ignorecfg = 1 --: Ignore rates of below table? 1-Yes, 0-No

--: Note: with ignorecfg = 1 all rates will be from anycrate value

--: Change the monster, the name and the drop rate  :--
local config = {
  -- Higher value = Low drop rate. Drop Rate = 1 / chance
  ["Demon"] = {chance = 600}, -- 600 = 1/600
  ["Ferumbras"] = {chance = 30}, -- 30 = 1/30 etc
  ["Rat"] = {chance = 1}, -- 100% drop rate
  ["Rotworm"] = {chance = 2}, -- 50% drop rate
  ["Dog"] = {chance = 10} -- 10% drop rate
}

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

  if (ignorecfg ~= 1) then
    for index, arraymonster in ipairs(config) do
      if ((arraymonster ~= monster) and (anycreature == 0)) then return true end
    end
    if (((config[monster])) == nil) then rand = anycrate else rand = ((config[monster].chance) / boost) end
  else
    rand = anycrate
  end

  local storageatual = getPlayerStorageValue(cid, storage)
  local plural = "s"
  local qtd = ""
  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
 

Dries390

New Member
Joined
Sep 8, 2007
Messages
7
Reaction score
1
If it's anything like older distributions it seems a registration in login.lua (creaturescripts/scripts/login.lua) might be missing. You should probably add

Lua:
registerCreatureEvent(cid, "Luckypoints")
to the file.

Edit: fixed name.
 
OP
oshrigames

oshrigames

Intermediate OT User
Joined
Nov 9, 2012
Messages
123
Reaction score
14
Location
israel
ive just tested with that in login.lua.
still no drop.

ill leave it in there for now since i don't get error, and thats the issue no error so i have no clue how to find the problem. ;c
 
Top