• 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!

Lua Dropchance global of all monsters

Dohko

Active Member
Joined
Mar 7, 2017
Messages
100
Reaction score
29
I wanted a global drop script for my server, as if it were a Tibia event, in which all monsters have a chance to drop the right item. I was searching the forum and found a so-called luck-coin, with an ingame-store, really is what I needed, unfortunately post is incomplete..

Link from post = [TFS 1.2][Client 9.7 +] Lucky Coins - Diminuindo o pay to win de servidores

someone would have this script working or something similar?
 
Matheus, pode ser mais específico ? eu instalei esse helper e não funcionou.
O que seria deletar a stuff ?
Obrigado pela ajuda
 
Old:
Lua:
--: Configurações Gerais  :--
local storage = 32143 --: 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'

New:
Lua:
local storage = 32143
local msg = "You have found a lucky coin, say !luckycoins for more info."
local showqtd = 1
local qtdtext = "You have"
 
Old:
Lua:
--: Configurações Gerais  :--
local storage = 32143 --: 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'

New:
Lua:
local storage = 32143
local msg = "You have found a lucky coin, say !luckycoins for more info."
local showqtd = 1
local qtdtext = "You have"


I made the alteration but i have some erros.
Lua:
local storage = 32143
local msg = "You have found a lucky coin, say !luckycoins for more info."
local showqtd = 1
local qtdtext = "You have"


function onModalWindow(player, modalWindowId, buttonId, choiceId)
  player:unregisterEvent("ModalWindow_LuckyCoins")
  if modalWindowId == modalid then
    if buttonId == 100 and choiceId ~= nil and choiceId ~= 255 then
      local itemprice = (lucky_items[ordem[choiceId]].price)
      local pstorage = (player:getStorageValue(storage))
      local itemid = (ordem[choiceId])

      if ((pstorage) >= (itemprice)) then
        player:setStorageValue(storage, (pstorage - itemprice))
        player:addItem(itemid, 1)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Voce comprou um " .. (ItemType(itemid):getName()) .. " por " .. (itemprice) .. " coin(s)." )
      else
        player:sendCancelMessage('Voce nao possui mirror coins suficientes.')
      end
    end
  end
end

In game, i receive this messages when i say !luckycoins : 17:09 Lucky Coins are used here to buy vip items by playing the game. You can buy it at our shop, tp at temple. You can view your luckycoins by typing !luckycoins amount.

after, i say !luckycoins amount, and the message changes to 17:09 You have -1 lucky coins.

at my creaturescripts xml

<event type="modalwindow" name="ModalWindowHelper" script="modalwindowhelper.lua" />
<event type="kill" name="LuckyPoints" script="luckypoints.lua"/>
<event type="ModalWindow" name="ModalWindow_LuckyCoins" script="modalluckycoins.lua"/>

at my talkactions.xml

<talkaction words="!luckycoins" separator=" " script="luckycoinstalk.lua" />
 
You can try change this on talkaction:

Lua:
function onSay(player, words, param)
   local storageatual = player:getStorageValue(storage)
   local plural = "s"
   local qtd = ""

For:

Lua:
function onSay(player, words, param)
   local storageatual = player:getStorageValue(storage)
   local plural = "s"
   local qtd = ""

    if (storageatual == nil) then    player:setStorageValue(storage, 0)    end

My guess:
This error occurs because you don't have a default storage set. It's like "read X for me", but X does not exists.
 
Last edited:
I changed the code and nothing happened, the same messages in the other try:(
"
My guess:
This error occurs because you don't have a default storage set. It's like "read X for me", but X does not exists."

How do i resolve it ?
 
Can you try run this on your MySQL and print the values (if not empty, of course)?

Code:
SELECT * FROM player_storage WHERE key = 32143;

If you have some value < 0, maybe this is the problem.

It should be working, don't know what can be happening tbh. Try to reload talkactions/restart the server.
 
Of course, i executed this command and no return values,
2.jpg
in the game i execute !luckycoins buy and it shows the shop normally, but all players and all accounts have -1 lucky coins.
1.jpg
 
not worked , i continue with -1 storage.

edit : i changed my storage and worked, now show's 0 points
but monsters doesn't drop points, i changed changed drop in config to 100% and no worked.
 
Last edited:
Back
Top