• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Reward, after reaching certain level

reebo

New Member
Joined
Nov 22, 2014
Messages
28
Reaction score
1
Hello, I've another problem, I've tried some script here for adding some items into inventory after reaching certain level(s). But when I reach that level, nothing happens.


Code:
local t = {
    39001, {
    [30] = {2160, 3, "Congratulations, you have achieved level 30! You have been awarded with 3 crystal coints!", 1}
    }
}
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill == SKILL__LEVEL then
        for level, v in pairs(t[2]) do
            if oldlevel < level and getPlayerLevel(cid) >= level and getPlayerStorageValue(cid, t[1]) < v[4] then
                doPlayerAddItem(cid, v[1], v[2])
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, v[3])
                setPlayerStorageValue(cid, t[1], v[4])
            end
        end
    end
    doPlayerSave(cid, true)
    return true
end
 
Updated but still not working. By the wave I deleted one _, becouse there were 2 previously... + I've added this in creaturescript.xml only... found somewhere, I should add event into login.lua... then I should put the reward in same directory guess?
 
Code:
local events = {
    'TutorialCockroach',
    'ElementalSpheresOverlords',
    'BigfootBurdenVersperoth',
    'BigfootBurdenWarzone',
    'BigfootBurdenWeeper',
    'BigfootBurdenWiggler',
    'SvargrondArenaKill',
    'NewFrontierShardOfCorruption',
    'NewFrontierTirecz',
    'ServiceOfYalaharDiseasedTrio',
    'ServiceOfYalaharAzerus',
    'ServiceOfYalaharQuaraLeaders',
    'InquisitionBosses',
    'InquisitionUngreez',
    'KillingInTheNameOfKills',
    'MastersVoiceServants',
    'PharaoKillPortal',
    'SecretServiceBlackKnight',
    'ThievesGuildNomad',
    'WotELizardMagistratus',
    'WotELizardNoble',
    'WotEKeeper',
    'WotEBosses',
    'WotEZalamon',
    'PlayerDeath',
    'reward'
    'AdvanceSave'
}

function onLogin(player)
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendTutorial(1)
    else
        if loginStr ~= '' then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    for i = 1, #events do
        player:registerEvent(events[i])
    end
    return true
end

guess I got it correct there, I'll check my console if it writes anything..

<event type="advance" name="reward" script="others/reward.lua"/>
this is my line at creaturescript.xml
 
Actually i had missing , in line after reward in login.lua... that was the only thing console writes, but its not working anyway after I fixed it. Gonna try the skill == 8 now

Sorry for double post but, now it writes some error in console

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/reward.lua:onAdvance
data/creaturescripts/scripts/others/reward.lua:16: attempt to call global 'doPlayerSave' (a nil value)
stack traceback:
        [C]: in function 'doPlayerSave'
        data/creaturescripts/scripts/others/reward.lua:16: in function <data/creaturescripts/scripts/others/reward.lua

After I deleted doPlayerSave, becouse I didnt found it in compat.lua, it writes error same error with getplayerlevel, which i found in compat.lua + still it has the problem with onadvance function and I can't figure out what
 
Last edited:
Code:
local t = {
    39001, {
    [30] = {2160, 3, "Congratulations, you have achieved level 30! You have been awarded with 3 crystal coints!", 1}
    }
}
function onAdvance(player, skill, oldlevel, newlevel)
    if skill == 8 then
        for level, v in pairs(t[2]) do
            if oldlevel < level and player:getLevel() >= level and player:getStorageValue(t[1]) < v[4] then
                player:addItem(v[1], v[2])
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, v[3])
                player:setStorageValue(t[1], v[4])
            end
        end
    end
    player:save()
    return true
end
 
Back
Top