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

Achievements

Jfrye

Mapper, trying to learn scripting
Joined
Jan 8, 2009
Messages
365
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:
player:addAchievementProgress('Fireworks in the Sky', 250)
parameters:
1.- name of the achievement
2.- times that need to be used to gain the achievement

you have to use 250 times the fireworks and you gain the achievement, assuming that you are using a global data pack (lol) you can do this:
go to kills.lua related to killing in the name of and do something like

Lua:
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[i]
        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:addAchievementProgress('First Dragon', 1)
    end
    return true
end
 
player:addAchievementProgress('Fireworks in the Sky', 250)
parameters:
1.- name of the achievement
2.- times that need to be used to gain the achievement

you have to use 250 times the fireworks and you gain the achievement, assuming that you are using a global data pack (lol) you can do this:
go to kills.lua related to killing in the name of and do something like

Lua:
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[i]
        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:addAchievementProgress('First Dragon', 1)
    end
    return true
end

If I understood you right then Im supposed to add this code to the end of kills.lua? If thats the case, I tried it, and nothing happens. Maybe I am missing something else. I am using tfs 1.1, and havent added any additional data packs
 
Was looking for information about that first dragon achievement that you said and couldnt find any, but just add that part at the bottom of the lua file bafore the return and add it to achievements lib
 
I have tried that, and nothing happens. I have copied the lines from the link you listed, and everything, and still doesnt work. No console errors either

Edit : looking at the link you posted, that is for TFS 1.3, and im using TFS 1.1. Maybe there is a difference somewhere?
 
This is what is in there now. I got the original from the link you posted, and then added the last function that you posted to start with.

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 table.contains(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
    return true
end
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:addAchievementProgress('First Dragon', 1)
    end
    return true
end

I added this in the creaturescripts.xml

Code:
    <!-- Killing In The Name Of Quest -->
    <event type="kill" name="KillingInTheNameOfKills" script="quests/killing in the name of/kills.lua" />
I made the correct folders, and named correctly, so I know the script path is correct as well. Triple checked that.
 
well wtf is that
change it all to

Lua:
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
and see what it prints.
 
just tested it and its working, you are doing something wrong and im not doing it all for you, have you checked if its registered? its even working the killing in the name of counter? also even if the quest event is not working the onkill event should work either, so you doing something wrong.
 
achievement lib is only when achs are working but if you using that piece of code and after you kill a dragon no messages appear on console, it means that this event is not being executed.
 
Ok. Well I dont know then. The script is registered in creaturescripts.xml. I have copied and pasted the codes just as you have. I dont know where the problem could be then.

Also the counter does not work on tasks.

is there anyone with teamviewer that would be willing to take a look at this and see what I've done wrong? @StreamSide was very helpful but unfortunately for me, the achievements don't seem to be working.
 
Last edited by a moderator:
is there anyone with teamviewer that would be willing to take a look at this and see what I've done wrong? @StreamSide was very helpful but unfortunately for me, the achievements don't seem to be working.
 
creaturescripts.xml
Code:
<event type="kill" name="Kills" script="kills.lua" />

login.lua
Code:
player:registerEvent("Kills")
 
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>
 
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>
Did you copy every necessary lib file for this system? And if you did, check if they're registered in global.lua/libs.lua.
 
Back
Top