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

points for level dont work

simson361

The Grim Reaper
Joined
Aug 4, 2010
Messages
626
Reaction score
27
Location
sweden
hey donate points for level dossent work anymore it worked before. but i added some scripts and then noticed after time that it dident work this is the script
Code:
local t, storage = {
    {160, 30},
    {190, 30},
    {220, 30},
    {250, 30},
    {280, 30},
    {300, 30},
    {315, 30},
    {330, 30}
}, 256
function onAdvance(cid, skill, oldLevel, newLevel)
    if skill ~= SKILL__LEVEL then
        return true
    end
    for i = 1, #t do
        local v = t[i]
        if newLevel >= v[1] and getStorage(storage) < i then
            db.executeQuery('UPDATE znote_accounts SET points=points+'.. v[2] ..' WHERE account_id=' .. getPlayerAccountId(cid))
            doSetStorage(storage, i)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have earned '.. v[2] ..' Premium Points!')
            doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) .. ' advenced to ' .. v[1] .. 'lvl and got ' .. v[2] .. ' ptz to sms shop.')
            break
        end
    end
    return true
end
 
It's only giving points to players who reached those levels first because the script is using global storage.

Changed so it's giving points to all players instead of just 1.
Code:
local t, storage = {
    {160, 30},
    {190, 30},
    {220, 30},
    {250, 30},
    {280, 30},
    {300, 30},
    {315, 30},
    {330, 30}
}, 256
function onAdvance(cid, skill, oldLevel, newLevel)
    if skill ~= SKILL__LEVEL then
        return true
    end
    for i = 1, #t do
        local v = t[i]
        if newLevel >= v[1] and getCreatureStorage(cid, storage) < i then
            db.executeQuery('UPDATE znote_accounts SET points=points+'.. v[2] ..' WHERE account_id=' .. getPlayerAccountId(cid))
            doCreatureSetStorage(cid, storage, i)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have earned '.. v[2] ..' Premium Points!')
            doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) .. ' advenced to ' .. v[1] .. 'lvl and got ' .. v[2] .. ' ptz to sms shop.')
            break
        end
    end
    return true
end

Make sure it's registered in login.lua before testing the script. :p
 
Last edited:
@Ninja getting this error, also this erorr is coming up every time i level :/

Code:
[23/09/2013 17:12:49] [Error - CreatureScript Interface]
[23/09/2013 17:12:49] data/creaturescripts/scripts/points.lua:eek:nAdvance
[23/09/2013 17:12:49] Description:
[23/09/2013 17:12:49] data/creaturescripts/scripts/points.lua:17: attempt to compare table with number
[23/09/2013 17:12:49] stack traceback:
[23/09/2013 17:12:49]    data/creaturescripts/scripts/points.lua:17: in function <data/creaturescripts/scripts/points.lua:11>
 
Last edited:
@Ninja awesome it works! btw its another bugg everytime i level, in any skill the hp and mana gets refiled to max on the character do you know how to fix this aswell? :(/!
 
@Ninja this 1 else no :/
Code:
    <event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>

-- [( Script edited by: DoidinMapper for XTibia.com )] --
function onAdvance(cid, skill, oldLevel, newLevel)
local config = {savePlayersOnAdvance = true}
if(config.savePlayersOnAdvance) then
doPlayerSave(cid, TRUE)
end
return TRUE
end
 
Back
Top