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

Solved Update Questline after bosskill

Knutte

New Member
Joined
Jan 4, 2024
Messages
10
Reaction score
0
Hello,

Im currently working on a questline where there will be 3 missions that the player is asked to kill a boss on each mission.
I need help to get the Storage value updated after the boss been slain.
The scripts that im running
Creaturescripts/scripts/custom
function onKill(cid, target, damage, flags)
local bossName = "Bossname"
if isMonster(target) and getCreatureName(target) == bossName and bit.band(flags, 1) == 1 then
local player = Player(cid)
if player then
if player:getStorageValue(Storage.Quest.Bossname) ~= 2 then
-- Update the storage value to 2 when boss is killed
player:setStorageValue(Storage.Quest.Bossname, 2)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have defeated XXXXXX.")
end

if player:getStorageValue(Storage.Quest.BossName) ~= 3 then
player:setStorageValue(Storage.Quest.Bossname, 3)
player:setStorageValue(Storage.Quest.PlaceX, 1) -- Grant access to PlaceX
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have slain the boss and got access to PlaceX.")
end
end
end
return true
end
Creaturescripts.xml
<event type="kill" name="BossName" event="script" value="custom/bossName.lua"/>
Login.lua
registerCreatureEvent(cid, "bossName")

I dont get it to work, so i cannot return the quest after the boss is killed.

Anyone has any ideas why? Scripts that i used is found here on otLand. but im Using TFS 1.5 and i think they are for some earlier versions
 
Last edited:
Hello,

Im currently working on a questline where there will be 3 missions that the player is asked to kill a boss on each mission.
I need help to get the Storage value updated after the boss been slain.
The scripts that im running
Creaturescripts/scripts/custom

Creaturescripts.xml

Login.lua


I dont get it to work, so i cannot return the quest after the boss is killed.

Anyone has any ideas why? Scripts that i used is found here on otLand. but im Using TFS 1.5 and i think they are for some earlier versions
local bossName = "Bossname"

Is the creature you are killing named "Bossname" ?

If not, you should update this line.
 
local bossName = "Bossname"

Is the creature you are killing named "Bossname" ?

If not, you should update this line.
Hi, No i changed it to Bossname before i posted it. Since the name will change depends on what state in the quest the player are on :)
Also, if it matters. The boss is placed on the map with RME. and has a spawntimer. Its not spawned via an Action
 
Hi, No i changed it to Bossname before i posted it. Since the name will change depends on what state in the quest the player are on :)
Also, if it matters. The boss is placed on the map with RME. and has a spawntimer. Its not spawned via an Action
I see that these 2 lines have different capitalization on bossname. It's probably the issue.
if player:getStorageValue(Storage.Quest.Bossname) ~= 2 then
if player:getStorageValue(Storage.Quest.BossName) ~= 3 then

The other problem I see is that if both of these storages lead to the same number.. then it's just going to flop back and forth between the 2, and ultimately give storage 3 everytime you kill the boss.

Ideally you want to make sure the startValue and endValue of your boss quests doesn't interfere with each other.

So as an example
  • Gain Quest to kill Boss (storage (-1) -> 1)
  • kill boss (storage 1 -> 2)
  • tell someone the boss died (storage 2 -> 3)
  • kill boss again (storage 3 -> 4)
  • + gain additional storage (storage_2 (-1) -> 1)

So, something like this..
Lua:
local bosses = {
    ["Rat"] = { -- mission 1
        storage = 11111,
        startValue = 1, -- if you don't have this storage value, then killing the boss get's you nothing.
        endValue = 2,
        text = "You have defeated XXXXXX."
    },
    ["Rat"] = { -- mission 2?
        storage = 11111,
        startValue = 3,
        endValue = 4,
        text = "You have slain the boss and got access to PlaceX.",
        additionalStorage = {
            storage = 55555,
            value = 1
        }
    },
}

function onKill(creature, target)
    if not target:isMonster() then
        return true
    end
  
    local player = Player(creature:getId())
    if not player then
        return true
    end
  
    local bossName = target:getName():lower()
    for k, v in pairs(bosses) do
        if k:lower() == bossName then
            if player:getStorageValue(v.storage) == v.startValue then
                player:setStorageValue(v.storage, v.endValue)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, v.text)
                if v.additionalStorage then
                    player:setStorageValue(v.additionalStorage.storage, v.additionalStorage.value)
                end
            end
        end
    end
    return true
end
 
I see that these 2 lines have different capitalization on bossname. It's probably the issue.
if player:getStorageValue(Storage.Quest.Bossname) ~= 2 then
if player:getStorageValue(Storage.Quest.BossName) ~= 3 then

The other problem I see is that if both of these storages lead to the same number.. then it's just going to flop back and forth between the 2, and ultimately give storage 3 everytime you kill the boss.

Ideally you want to make sure the startValue and endValue of your boss quests doesn't interfere with each other.

So as an example
  • Gain Quest to kill Boss (storage (-1) -> 1)
  • kill boss (storage 1 -> 2)
  • tell someone the boss died (storage 2 -> 3)
  • kill boss again (storage 3 -> 4)
  • + gain additional storage (storage_2 (-1) -> 1)

So, something like this..
Lua:
local bosses = {
    ["Rat"] = { -- mission 1
        storage = 11111,
        startValue = 1, -- if you don't have this storage value, then killing the boss get's you nothing.
        endValue = 2,
        text = "You have defeated XXXXXX."
    },
    ["Rat"] = { -- mission 2?
        storage = 11111,
        startValue = 3,
        endValue = 4,
        text = "You have slain the boss and got access to PlaceX.",
        additionalStorage = {
            storage = 55555,
            value = 1
        }
    },
}

function onKill(creature, target)
    if not target:isMonster() then
        return true
    end
 
    local player = Player(creature:getId())
    if not player then
        return true
    end
 
    local bossName = target:getName():lower()
    for k, v in pairs(bosses) do
        if k:lower() == bossName then
            if player:getStorageValue(v.storage) == v.startValue then
                player:setStorageValue(v.storage, v.endValue)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, v.text)
                if v.additionalStorage then
                    player:setStorageValue(v.additionalStorage.storage, v.additionalStorage.value)
                end
            end
        end
    end
    return true
end
Thanks, I figured it out that i if print anything that has to do with this one it dosent show up. so none of my 3 scripts above is running at all. Tried this one aswell, same same. its not running

XML:
    <mission name="La Muerta Boss Fight" storageid="1062" startvalue="1" endvalue="3">
        <missionstate id="1" description="Kristian has tasked you to defeat the boss La Muerta."/>
        <missionstate id="2" description="You have defeated La Muerta. Talk to Kristian to gain access to next place."/>
        <missionstate id="3" description="Kristian is happy you killed one of his enemies!.He Grants you access"/>
    </mission>

this is how each "bossfight" will be set up, and so on and so on with the other 2 boss fights.
Im using different Storagevalue on each Boss and its set to 3 states, accept the quest, killing the boss, returning to NPC. thats why they have it comes back to the same number

have i placed them in the correct folder? change the correct files :p feels like not since nothing is running
 
Last edited:
Thanks, I figured it out that i if print anything that has to do with this one it dosent show up. so none of my 3 scripts above is running at all. Tried this one aswell, same same. its not running

XML:
    <mission name="La Muerta Boss Fight" storageid="1062" startvalue="1" endvalue="3">
        <missionstate id="1" description="Kristian has tasked you to defeat the boss La Muerta."/>
        <missionstate id="2" description="You have defeated La Muerta. Talk to Kristian to gain access to next place."/>
        <missionstate id="3" description="Kristian is happy you killed one of his enemies!.He Grants you access"/>
    </mission>

this is how each "bossfight" will be set up, and so on and so on with the other 2 boss fights.
Im using different Storagevalue on each Boss and its set to 3 states, accept the quest, killing the boss, returning to NPC. thats why they have it comes back to the same number

have i placed them in the correct folder? change the correct files :p feels like not since nothing is running
Yes this storage makes sense.

So in my above script, you just need the initial mission.

NPC -> changes storage from -1 to 1
Kill Boss -> changes storage from 1 to 2
NPC -> changes storage from 2 to 3 and gives another storage -1 to 1 for access

as far as the registering of the script, should be 3 steps.

(note: Spelling and capitalization are Very important here.)
creaturescripts.xml
login.lua - registering the event
-- here might be the issue. try using player:registerEvent("BossName")
scriptName.lua

or you could convert it to revscript, then it's just a drag & drop into data/scripts folder.

Like this.
Lua:
local scriptName = "killBoss_getStorage"
local bosses = {
    ["Rat"] = { -- mission 1
        storage = 11111,
        startValue = 1, -- if you don't have this storage value, then killing the boss get's you nothing.
        endValue = 2,
        text = "You have defeated XXXXXX."
    }
}

local creatureevent = CreatureEvent("onKill" .. scriptName)

function creatureevent.onKill(creature, target)
    print("Boss onKill script working!")
    if not target:isMonster() then
        return true
    end
 
    local player = Player(creature:getId())
    if not player then
        return true
    end
 
    local bossName = target:getName():lower()
    for k, v in pairs(bosses) do
        if k:lower() == bossName then
            if player:getStorageValue(v.storage) == v.startValue then
                player:setStorageValue(v.storage, v.endValue)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, v.text)
            end
        end
    end
    return true
end

creatureevent:register()



local creatureevent = CreatureEvent("onLogin" .. scriptName)

function creatureevent.onLogin(player)
    player:registerEvent("onKill" .. scriptName)
    return true
end

creatureevent:register()
 
Last edited:
Back
Top