• 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 add tibia coins every hour by charge

Crixpx

New Member
Joined
Jan 11, 2015
Messages
70
Reaction score
3
Hello :D I have edited this script so that every one of the characters connect you to a load every 1 hour with a limit of 5 loads "5 hours" to complete the 5 hours of as a reward 25 coins and the time will be saved even when disconnected so that Continue running the time when you connect and also how many loads you have

but i have a problem in console when i login

my ot is tfs 1.3

this is the script
Lua:
function addOnlineBonus(cid, horas, bonus_contador, bonus_max)

   if not isPlayer(cid) then
   return false
   end
   setPlayerStorageValue(cid, bonus_contador, getPlayerStorageValue(cid, bonus_contador) + 1)
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Has stayed connected for 1 hour, And you have won a [tibia coin charge] = 5 tibia coins: ".. getPlayerStorageValue(cid,bonus_contador) .. ".") 
   if getPlayerStorageValue(cid, bonus_contador) >= bonus_max then
   doPlayerSendTextMessage(cid, 19, "Seus ".. bonus_max .." tibia coin charge now are 25 Tibia coins!")
   doPlayerAddTibiaCoins(cid, 25)
   setPlayerStorageValue(cid, bonus_contador, 0)
   end    
   addEvent(addOnlineBonus, horas * 3600 * 1000, cid, horas, bonus_contador, bonus_max) 
 
end

function onLogin(cid)

   local bonus_contador = 72702 -- Storage que vai guardar quantos online bonus o char possui.
   local horas = 1 -- Quantidade de horas o char precisa ficar logado pra receber cada online bonus.
   local bonus_max = 5 -- Quantidade de bonus que o char precisa atingir para ganhar 1 dia de premium account, zerando o contador.
   if getPlayerStorageValue(cid, bonus_contador) > 0 then
   doPlayerSendTextMessage(cid,22,"you have: " .. getPlayerStorageValue(cid,bonus_contador) .. "tibia coin charge.")
   else
   setPlayerStorageValue(cid, bonus_contador, 0)
   doPlayerSendTextMessage(cid,22,"you have: 0 tibia coin charge.")
   end
   addEvent(addOnlineBonus, horas * 3600 * 1000, cid, horas, bonus_contador, bonus_max)

return true 
end



Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/onlinebonus.lua:eek:nLogin
luaAddEvent(). Argument #3 is unsafe
stack traceback:
[C]: in function 'addEvent'
data/creaturescripts/scripts/onlinebonus.lua:28: in function <data/creaturescripts/scripts/onlinebonus.lua:17>
 
Last edited by a moderator:
change cid on add event parameters to getPlayerByGUID(cid) and test.

no error but when i have 5 charges get this error in console


in a timer event called from:
(Unknown scriptfile)
data/creaturescripts/scripts/onlinebonus.lua:10: attempt to index global 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/onlinebonus.lua:10: in function <data/creaturescripts/scripts/onlinebonus.lua:1>
 
no error but when i have 5 charges get this error in console


in a timer event called from:
(Unknown scriptfile)
data/creaturescripts/scripts/onlinebonus.lua:10: attempt to index global 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/onlinebonus.lua:10: in function <data/creaturescripts/scripts/onlinebonus.lua:1>

Please read the rules; Rules for the Support board
Insted of editing the thread and writing "solved" add the solution and report your own post so we can mark it as the best answer.
 
Back
Top