I wanted a system that would add coins to the players account when the character reaches a specific level.
I found something similar, but it gives items, I want to give the coins straight into the account.
While researching I found a tibia coins action that adds to the database when using the item, the code includes:
How can I replace the additem with this query without destroying the logic?
I found something similar, but it gives items, I want to give the coins straight into the account.
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
local config = {
[50] = {item = 2160, count = 1},
}
if skill == 8 then
for level, info in pairs(config) do
if newLevel >= level and (getPlayerStorageValue(cid, 30700) == -1 or not (string.find(getPlayerStorageValue(cid, 30700), "'" .. level .. "'"))) then
doPlayerAddItem(cid, info.item, info.count)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Parabéns, você atingiu o level "..newLevel.." e ganhou "..info.count.." "..getItemNameById(info.item)..".")
local sat = getPlayerStorageValue(cid, 30700) == -1 and "Values: '" .. level .. "'" or getPlayerStorageValue(cid, 30700) .. ",'" .. level .. "'"
setPlayerStorageValue(cid, 30700, sat)
end
end
end
return TRUE
end
While researching I found a tibia coins action that adds to the database when using the item, the code includes:
Lua:
local count = 50
db.query('UPDATE accounts SET coins = coins+'.. count ..' WHERE id = ' .. getAccountNumberByPlayerName(getCreatureName(cid)))
How can I replace the additem with this query without destroying the logic?