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

Lua TFS 1.3 script that counts how many monsters player killed and give mount

Icaraii

Well-Known Member
Joined
Jan 5, 2020
Messages
469
Solutions
1
Reaction score
58
Hi guys, I would like a script where it counts how many monsters the player killed and it rewards the player with a specific mount, for example:

If the player kill 200 centipedes and bugs (the sum of them), the player will receive bloodcurl mount.
If the player kill 500 ancient scarabs and giant spiders (the sum of them), the player will receive leafscuttlers mount.
If the player kill 1500 kollos and spidris (the sum of them), the player will receive mouldpincer mount.

And also I would like a way for the player to check how many he already killed.

Thanks guys
 
Solution
Storage values my man.

Storage values start at -1 by default.
Everytime they kill a monster, increase the storage value by 1.

Lua:
local config = {
    [{"centipede", "bug"}]                    = {mountReward = 1111, killGoal = 200,  storage = 45001, monsterType = "bugs"}, -- check mounts.xml for the mountIds
    [{"ancient scarab", "giant spider"}]    = {mountReward = 1111, killGoal = 500,  storage = 45002, monsterType = "crawly things"},
    [{"kollos", "spidris"}]                    = {mountReward = 1111, killGoal = 1500, storage = 45003, monsterType = "bosses"}
}

local killEvent = CreatureEvent("newOnKillEvent")
killEvent:type("kill")

function killEvent.onKill(creature, target)
    if not creature:isPlayer() then
        return...
Storage values my man.

Storage values start at -1 by default.
Everytime they kill a monster, increase the storage value by 1.

Lua:
local config = {
    [{"centipede", "bug"}]                    = {mountReward = 1111, killGoal = 200,  storage = 45001, monsterType = "bugs"}, -- check mounts.xml for the mountIds
    [{"ancient scarab", "giant spider"}]    = {mountReward = 1111, killGoal = 500,  storage = 45002, monsterType = "crawly things"},
    [{"kollos", "spidris"}]                    = {mountReward = 1111, killGoal = 1500, storage = 45003, monsterType = "bosses"}
}

local killEvent = CreatureEvent("newOnKillEvent")
killEvent:type("kill")

function killEvent.onKill(creature, target)
    if not creature:isPlayer() then
        return true
    end
    if not target:isMonster() then
        return true
    end
    local monsterName = target:getName():lower()
    for v, k in pairs(config) do
        if table.contains(v, monsterName) then
            local currentStorage = creature:getStorageValue(k.storage)
            if currentStorage >= k.killGoal then
                return true
            end
            currentStorage = currentStorage < 1 and 1 or currentStorage + 1
            creature:setStorageValue(k.storage, currentStorage)
            if currentStorage == k.killGoal then
                player:addMount(k.mountReward)
            end
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. currentStorage .. "/" .. k.killGoal .. " " .. k.monsterType .. ".")
            return true
        end
    end
    return true
end

killEvent:register()


local loginEvent = CreatureEvent("registerOnKill")
loginEvent:type("login")

function loginEvent.onLogin(player)
    player:registerEvent("newOnKillEvent")
    return true
end

loginEvent:register()
 
Solution
Storage values my man.

Storage values start at -1 by default.
Everytime they kill a monster, increase the storage value by 1.

Lua:
local config = {
    [{"centipede", "bug"}]                    = {mountReward = 1111, killGoal = 200,  storage = 45001, monsterType = "bugs"}, -- check mounts.xml for the mountIds
    [{"ancient scarab", "giant spider"}]    = {mountReward = 1111, killGoal = 500,  storage = 45002, monsterType = "crawly things"},
    [{"kollos", "spidris"}]                    = {mountReward = 1111, killGoal = 1500, storage = 45003, monsterType = "bosses"}
}

local killEvent = CreatureEvent("newOnKillEvent")
killEvent:type("kill")

function killEvent.onKill(creature, target)
    if not creature:isPlayer() then
        return true
    end
    if not target:isMonster() then
        return true
    end
    local monsterName = target:getName():lower()
    for v, k in pairs(config) do
        if table.contains(v, monsterName) then
            local currentStorage = creature:getStorageValue(k.storage)
            if currentStorage >= k.killGoal then
                return true
            end
            currentStorage = currentStorage < 1 and 1 or currentStorage + 1
            creature:setStorageValue(k.storage, currentStorage)
            if currentStorage == k.killGoal then
                player:addMount(k.mountReward)
            end
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. currentStorage .. "/" .. k.killGoal .. " " .. k.monsterType .. ".")
            return true
        end
    end
    return true
end

killEvent:register()


local loginEvent = CreatureEvent("registerOnKill")
loginEvent:type("login")

function loginEvent.onLogin(player)
    player:registerEvent("newOnKillEvent")
    return true
end

loginEvent:register()
I only need to put this on script folder because it's revscript right?
It didn't work. No erros appears, no count downs and no mounts received.

Lua:
local config = {
    [{"centipede", "bug"}]                    = {mountReward = 866, killGoal = 2,  storage = 84753, monsterType = "bugs"}, -- check mounts.xml for the mountIds
    [{"ancient scarab", "giant spider"}]    = {mountReward = 1111, killGoal = 500,  storage = 45002, monsterType = "crawly things"},
    [{"kollos", "spidris"}]                    = {mountReward = 1111, killGoal = 1500, storage = 45003, monsterType = "bosses"}
}

local killEvent = CreatureEvent("newOnKillEvent")
killEvent:type("kill")

function killEvent.onKill(creature, target)
    if not creature:isPlayer() then
        return true
    end
    if not target:isMonster() then
        return true
    end
    local monsterName = target:getName():lower()
    for v, k in pairs(config) do
        if table.contains(v, monsterName) then
            local currentStorage = creature:getStorageValue(k.storage)
            if currentStorage < k.killGoal then
                return true
            end
            currentStorage = currentStorage + 1
            creature:setStorageValue(k.storage, currentStorage)
            if currentStorage == k.killGoal then
                player:addMount(k.mountReward)
            end
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. currentStorage .. "/" .. k.killGoal .. " " .. k.monsterType .. ".")
            return true
        end
    end
    return true
end

killEvent:register()


local loginEvent = CreatureEvent("registerOnKill")
loginEvent:type("login")

function loginEvent.onLogin(player)
    player:registerEvent("newOnKillEvent")
    return true
end

loginEvent:register()
 
I only need to put this on script folder because it's revscript right?
It didn't work. No erros appears, no count downs and no mounts received.

Lua:
local config = {
    [{"centipede", "bug"}]                    = {mountReward = 866, killGoal = 2,  storage = 84753, monsterType = "bugs"}, -- check mounts.xml for the mountIds
    [{"ancient scarab", "giant spider"}]    = {mountReward = 1111, killGoal = 500,  storage = 45002, monsterType = "crawly things"},
    [{"kollos", "spidris"}]                    = {mountReward = 1111, killGoal = 1500, storage = 45003, monsterType = "bosses"}
}

local killEvent = CreatureEvent("newOnKillEvent")
killEvent:type("kill")

function killEvent.onKill(creature, target)
    if not creature:isPlayer() then
        return true
    end
    if not target:isMonster() then
        return true
    end
    local monsterName = target:getName():lower()
    for v, k in pairs(config) do
        if table.contains(v, monsterName) then
            local currentStorage = creature:getStorageValue(k.storage)
            if currentStorage < k.killGoal then
                return true
            end
            currentStorage = currentStorage + 1
            creature:setStorageValue(k.storage, currentStorage)
            if currentStorage == k.killGoal then
                player:addMount(k.mountReward)
            end
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. currentStorage .. "/" .. k.killGoal .. " " .. k.monsterType .. ".")
            return true
        end
    end
    return true
end

killEvent:register()


local loginEvent = CreatureEvent("registerOnKill")
loginEvent:type("login")

function loginEvent.onLogin(player)
    player:registerEvent("newOnKillEvent")
    return true
end

loginEvent:register()
You saw my post before my ninja edit.

Copy the script from my post again.
I resolved this issue already.
 
Back
Top