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

Achievements

Jfrye

Mapper, trying to learn scripting
Joined
Jan 8, 2009
Messages
366
Solutions
5
Reaction score
86
Location
Mexico Missouri
Hey, Im using TFS 1.1 and client version 10.77

It seems like my Achievements arent working. I tried using the first dragon one as a test, and when you kill a dragon, it does nothing.

Isnt it supposed to give a point for this?

Code:
    //Achivements based on "D:/theforgottenserver-v1.1-64win/data/lib/miscellanious/achievements_lib.lua"  (TFS 1.0)
    $config['Ach'] =true;
    $config['achievements'] = array(
        35000 => array(
    'First Dragon', //name
    'Rumours say that you will never forget your first Dragon', //comment
    'points' => '1', //points
   
    ),

I could be missing something altogether, but i dont know what it would be.

Bump

Can anyone give me some insight on how this system works?
 
Last edited by a moderator:
I just started my server, and tried this again, and now I am getting console error. I was not getting any errors last night.

Code:
function onKill(player, target)
    if target:isPlayer() or target:getMaster() then
        return true
    end
    local targetName, startedTasks, taskId = target:getName():lower(), player:getStartedTasks()
    for i = 1, #startedTasks do
        taskId = startedTasks
        if isInArray(tasks[taskId].creatures, targetName) then
            local killAmount = player:getStorageValue(KILLSSTORAGE_BASE + taskId)
            if killAmount < tasks[taskId].killsRequired then
                player:setStorageValue(KILLSSTORAGE_BASE + taskId, killAmount + 1)
            end
        end
    end
   if targetName:find("dragon") then
        print("testing ffs")
    end
    return true
end


Error :
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/kills.lua:onKill
data/creaturescripts/scripts/kills.lua:8: attempt to index a nil value
stack traceback:
          [C]: in function '_index'
          data/creaturescripts/scripts/kills.lua:8: in function <data/creaturescripts/scripts/kills.lua:1>

This error only occurs when I kill a dragon on my GOD char. When a normal player kills the dragon, it prents testing ffs on the server window.

I do not remember messing with any lib files.
 
Its finally working for me.

Code:
20:26 A dragon loses 1000 hitpoints due to your attack.
20:26 Congratulations! You earned the achievement "First Dragon".

Heres how I got it to work.
Code:
function onKill(player, target)
    if target:isPlayer() or target:getMaster() then
        return true
    end
    local targetName, startedTasks, taskId = target:getName():lower(), player:getStartedTasks()
    for i = 1, #startedTasks do
        taskId = startedTasks
        if isInArray(tasks[taskId].creatures, targetName) then
            local killAmount = player:getStorageValue(KILLSSTORAGE_BASE + taskId)
            if killAmount < tasks[taskId].killsRequired then
                player:setStorageValue(KILLSSTORAGE_BASE + taskId, killAmount + 1)
            end
        end
    end
    if targetName:find("dragon") then
        player:addAchievement('First Dragon')
    end
    return true
end

I had to remove the 1 after player:addAchievement('First Dragon')

EDIT : There seems to be an issue with the ach points showing on website now. The player storage in database is being updated, but the points show nothing on website
 
Last edited:
Back
Top