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

Advance points

Brooke

Member
Joined
Mar 7, 2011
Messages
70
Reaction score
8
hello people! I'm having some problem with my advance points, tfs 0.4

Error:
Code:
[Error - CreatureScript Interface]
data/creaturescripts/scripts/points.lua:onAdvance
Description:
data/creaturescripts/scripts/points.lua:14: attempt to perform arithmetic on local 'points' (a boolean value)
stack traceback:
        data/creaturescripts/scripts/points.lua:14: in function <data/creaturescripts/scripts/points.lua:9>



Lua:
local player = {
        {level = 200, points = 25},
        {level = 300, points = 50},
        {level = 400, points = 75},
        {level = 500, points = 100}
    }
local storage = 15999

function onAdvance(cid, skill, oldLevel, newLevel)
    if skill == SKILL__LEVEL then
        for i = 1, #player do
            if newLevel >= player[i].level and getCreatureStorage(cid, storage) < i then
                local points = db.executeQuery('SELECT `premium_points` FROM `accounts` WHERE `id`=' .. getPlayerAccountId(cid) ..';')
                db.executeQuery('UPDATE `accounts` SET `premium_points`='.. (points + player[i].points ) ..' WHERE `id`==' .. getPlayerAccountId(cid) .. ';')
                doCreatureSetStorage(cid, storage, i)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Congratulations! You have advanced to level ' .. newLevel .. ' and you have earned '.. player[i].points ..' Premium Points!')
            end
        end
    end
    return true
end

Thanks :)
 
Lua:
local points = db.executeQuery('SELECT `premium_points` FROM `accounts` WHERE `id`=' .. getPlayerAccountId(cid) ..';')

Try using db.query or even db.storeQuery

Also add

Lua:
if points then
--code here
end
 
Back
Top