Hello, i have found this script on another forum, it should work fine but it gives me an error. I dont know what im doing wrong.
TFS 1.3
Script TFS 1.3:
Global.lua:
Error:
There is also script for TFS 1.2 if someone need it or wana try it.
Script TFS 1.2:
And another question; if it will work it will add you coins one by one? Or complete stack?
Hope someone could help me.
Thanks.
TFS 1.3
Script TFS 1.3:
Code:
local config = {
idcoin = 24774
}
function onUse(Player, item, fromPosition, itemEx, toPosition)
local item = Item(item.uid)
if player:getItemCount(config.idcoin) > 0 then
local coinplayer = player:getCoinsBalance()+item:getCount()
player:getPosition():sendMagicEffect(15)
item:remove()
player:setCoinsBalance(coinplayer)
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have to carry tibia coins in your backpack.")
end
return true
end
Code:
function Player.getCoinsBalance(self)
resultId = db.storeQuery("SELECT coins FROM accounts WHERE id = " .. self:getAccountId())
if not resultId then return 0 end
return result.getDataInt(resultId, "coins")
end
function Player.setCoinsBalance(self, coins)
db.asyncQuery("UPDATE accounts SET coins = " .. coins .. " WHERE id = " .. self:getAccountId())
return true
end
function Player.canRemoveCoins(self, coins)
if self:getCoinsBalance() < coins then
return false
end
return true
end
function Player.removeCoinsBalance(self, coins)
if self:canRemoveCoins(coins) then
return self:setCoinsBalance(self:getCoinsBalance() - coins)
end
return false
end
function Player.addCoinsBalance(self, coins, update)
self:setCoinsBalance(self:getCoinsBalance() + coins)
if update then sendCoinBalanceUpdating(self, true) end
return true
end
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/tibicoin.lua:onUse
data/actions/scripts/tibiacoin.lua:7: attempt to index global 'player' <a nil value>
stack traceback:
[C]: in function '__index'
data/actions/scripts/tibiacoin.lua:7: in function <data/actions/scripts/tibiacoin.lua:5>
There is also script for TFS 1.2 if someone need it or wana try it.
Script TFS 1.2:
Code:
local config = {
idcoin = 24774
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
local item = Item(item.uid)
if player:getItemCount(config.idcoin) > 0 then
local coinplayer = player:getCoinsBalance()+item:getCount()
player:getPosition():sendMagicEffect(15)
item:remove()
player:setCoinsBalance(coinplayer)
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have to carry tibia coins in your backpack.")
end
return true
end
Hope someone could help me.
Thanks.