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

TFS 1.X+ Trying to get a Monster Counter

Szka

Member
Joined
Jul 27, 2016
Messages
65
Reaction score
11
Location
Chile
Hello, I'm using TFS 1.5 the Nekiro downgraded version 8.60. And I managed to get the questlog working perfectly, but I'm trying to get the player an update eachtime a rotworm gets killed.
For now, I'm not getting the missionstate updated when the rotworm is getting killed, and I use a "print" to check if the script is being trigerred but it is not.

Here it is my script when killing a rotworm, I added it on creaturescripts.xml as an "kill" event type.


Lua:
function onKill(player, target)
    print("onKill function triggered")  -- Debugging line

    if target:getName():lower() ~= "rotworm" then
        print("Target is not a rotworm")  -- Debugging line
        return true
    end

    local cid = player:getId()
    local mission1DirtyBeginning = 25003
    local currentCount = player:getStorageValue(mission1DirtyBeginning)

    print("Rotworm killed by player ID: " .. cid)  -- Debugging line

    if currentCount >= 0 and currentCount < 16 then
        player:setStorageValue(mission1DirtyBeginning, currentCount + 1)
        print("Player ID: " .. cid .. " has killed a rotworm. Count: " .. (currentCount + 1))
    end

    return true
end

And here it is my quests.xml to be easier to understand the missionstates id.

XML:
<?xml version="1.0" encoding="UTF-8"?>
<quests>
<quest name="Questing, the chest" startstorageid="80555" startstoragevalue="1">
        <mission name="A Dirty Beginning" storageid="25003" startvalue="0" endvalue="17">
            <missionstate id="0" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 0 of 15 rotworms killed."/>
            <missionstate id="1" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 1 of 15 rotworms killed."/>
            <missionstate id="2" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 2 of 15 rotworms killed."/>
            <missionstate id="3" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 3 of 15 rotworms killed."/>
            <missionstate id="4" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 4 of 15 rotworms killed."/>
            <missionstate id="5" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 5 of 15 rotworms killed."/>
            <missionstate id="6" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 6 of 15 rotworms killed."/>
            <missionstate id="7" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 7 of 15 rotworms killed."/>
            <missionstate id="8" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 8 of 15 rotworms killed."/>
            <missionstate id="9" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 9 of 15 rotworms killed."/>
            <missionstate id="10" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 10 of 15 rotworms killed."/>
            <missionstate id="11" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 11 of 15 rotworms killed."/>
            <missionstate id="12" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 12 of 15 rotworms killed."/>
            <missionstate id="13" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 13 of 15 rotworms killed."/>
            <missionstate id="14" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 14 of 15 rotworms killed."/>
            <missionstate id="15" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 15 of 15 rotworms killed."/>
            <missionstate id="16" description="You killed all the dirty beasts. You should probably go and talk to Questing now."/>
            <missionstate id="17" description="You proved yourself to Questing. If you help unlock him from the chest and his curse, you will be trully rewarded."/>
        </mission>
    </quest>
</quests>

My npc is working excellent, so it is just that I cant manage to storage the monster killing count
Thank you so much, I'm very rusty with scripting so I imagine I made some mistakes. I don't remember too so much how to call some functions as I used to work with tfs .3 and .4
 
Solution
Hello, I'm using TFS 1.5 the Nekiro downgraded version 8.60. And I managed to get the questlog working perfectly, but I'm trying to get the player an update eachtime a rotworm gets killed.
For now, I'm not getting the missionstate updated when the rotworm is getting killed, and I use a "print" to check if the script is being trigerred but it is not.

Here it is my script when killing a rotworm, I added it on creaturescripts.xml as an "kill" event type.


Lua:
function onKill(player, target)
    print("onKill function triggered")  -- Debugging line

    if target:getName():lower() ~= "rotworm" then
        print("Target is not a rotworm")  -- Debugging line
        return true
    end

    local cid = player:getId()
    local...
Hello, I'm using TFS 1.5 the Nekiro downgraded version 8.60. And I managed to get the questlog working perfectly, but I'm trying to get the player an update eachtime a rotworm gets killed.
For now, I'm not getting the missionstate updated when the rotworm is getting killed, and I use a "print" to check if the script is being trigerred but it is not.

Here it is my script when killing a rotworm, I added it on creaturescripts.xml as an "kill" event type.


Lua:
function onKill(player, target)
    print("onKill function triggered")  -- Debugging line

    if target:getName():lower() ~= "rotworm" then
        print("Target is not a rotworm")  -- Debugging line
        return true
    end

    local cid = player:getId()
    local mission1DirtyBeginning = 25003
    local currentCount = player:getStorageValue(mission1DirtyBeginning)

    print("Rotworm killed by player ID: " .. cid)  -- Debugging line

    if currentCount >= 0 and currentCount < 16 then
        player:setStorageValue(mission1DirtyBeginning, currentCount + 1)
        print("Player ID: " .. cid .. " has killed a rotworm. Count: " .. (currentCount + 1))
    end

    return true
end

And here it is my quests.xml to be easier to understand the missionstates id.

XML:
<?xml version="1.0" encoding="UTF-8"?>
<quests>
<quest name="Questing, the chest" startstorageid="80555" startstoragevalue="1">
        <mission name="A Dirty Beginning" storageid="25003" startvalue="0" endvalue="17">
            <missionstate id="0" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 0 of 15 rotworms killed."/>
            <missionstate id="1" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 1 of 15 rotworms killed."/>
            <missionstate id="2" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 2 of 15 rotworms killed."/>
            <missionstate id="3" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 3 of 15 rotworms killed."/>
            <missionstate id="4" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 4 of 15 rotworms killed."/>
            <missionstate id="5" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 5 of 15 rotworms killed."/>
            <missionstate id="6" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 6 of 15 rotworms killed."/>
            <missionstate id="7" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 7 of 15 rotworms killed."/>
            <missionstate id="8" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 8 of 15 rotworms killed."/>
            <missionstate id="9" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 9 of 15 rotworms killed."/>
            <missionstate id="10" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 10 of 15 rotworms killed."/>
            <missionstate id="11" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 11 of 15 rotworms killed."/>
            <missionstate id="12" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 12 of 15 rotworms killed."/>
            <missionstate id="13" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 13 of 15 rotworms killed."/>
            <missionstate id="14" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 14 of 15 rotworms killed."/>
            <missionstate id="15" description="Questing has been cursed and is trapped in a chest. He asked you to kill 15 rotworms below the city to see if you can handle yourself. 15 of 15 rotworms killed."/>
            <missionstate id="16" description="You killed all the dirty beasts. You should probably go and talk to Questing now."/>
            <missionstate id="17" description="You proved yourself to Questing. If you help unlock him from the chest and his curse, you will be trully rewarded."/>
        </mission>
    </quest>
</quests>

My npc is working excellent, so it is just that I cant manage to storage the monster killing count
Thank you so much, I'm very rusty with scripting so I imagine I made some mistakes. I don't remember too so much how to call some functions as I used to work with tfs .3 and .4
You need to register the onKill event to the player in login.lua (near the bottom with the other registered events)
Then the event will have a way to be triggered.

probably worth to check that the target is a monster as well, otherwise a player named "rotworm" could be used to trigger the quest status.
 
Solution
You need to register the onKill event to the player in login.lua (near the bottom with the other registered events)
Then the event will have a way to be triggered.

probably worth to check that the target is a monster as well, otherwise a player named "rotworm" could be used to trigger the quest status.
Okay, I will check around the registered events at login.lua, will edit this comment if its work

use this its way better
I will try first with my script, maybe it is just that at login.lua I never register the event and then will try out with this one

Thank you lads
 
use this its way better

This is the better way indeed.
You just add storage to whatever your STATE is.

Now you have to create 15 different mission states, for like one setting...
Lua:
<quest name="Character Statistics" startstorageid="1001" startstoragevalue="0">
        <mission name="General" storageid="249" startvalue="1" endvalue="2">
            <missionstate id="1" description="Discovered Locations: |STATE|250|"/>
        </mission>

With this, you can just add storage to 250 and it will count the STATE a number up and keep your quest file somewhat organized.

I just have to add for my example whenever someone walks on specific tiles the following:

Code:
player:setStorageValue(250, 1)

4d1957881b7fa0c221a88b96d87d1861.png
 
You need to register the onKill event to the player in login.lua (near the bottom with the other registered events)
Then the event will have a way to be triggered.

probably worth to check that the target is a monster as well, otherwise a player named "rotworm" could be used to trigger the quest status.
I needed to register the event... Thank you very much !!
This was the solution to get it work!
 
Back
Top