• 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+ Task Counter

Dip Set

Veteran OT User
Joined
Dec 27, 2007
Messages
405
Solutions
2
Reaction score
370
I have as part of a NPC mission line this creature script which should enable you to kill 20 goblins, and change your storage value (count) with each until 20.
Everytime you kill a goblin the player should receive a message "you have killed 1 of 20 goblins" or something like this. The problem is it's not registering with each kill.

In creaturescripts.xml I have:
XML:
<event type="kill" name="MiningQuestkills" script="MiningQuestkills.lua" />
In MiningQuestKills.lua I have:

Lua:
local config = {
    ["goblin"] = {questStarted = 9105, questStorage = 9105, creatureStorage = 15007, killsRequired = 20, raceName = "Goblins"},
}
local msgType = MESSAGE_STATUS_CONSOLE_ORANGE
 
function onKill(cid, target, lastHit)
 
local creature = questCreatures[getCreatureName(target):lower()]
 
    if creature then
        if isPlayer(target) or isSummon(target) then return true end
 
        if getCreatureStorage(cid, creature.questStarted) > 0 then
            if getCreatureStorage(cid, creature.questStorage) < creature.killsRequired then
                if getCreatureStorage(cid, creature.questStorage) < 0 then
                    doCreatureSetStorage(cid, creature.questStorage, 0)
                end
 
                if getCreatureStorage(cid, creature.creatureStorage) < 0 then
                    doCreatureSetStorage(cid, creature.creatureStorage, 0)
                end
                doCreatureSetStorage(cid, creature.questStorage, getCreatureStorage(cid, creature.questStorage) + 1)
                doCreatureSetStorage(cid, creature.creatureStorage, getCreatureStorage(cid, creature.creatureStorage) + 1)
                doPlayerSendTextMessage(cid, msgType, getCreatureStorage(cid, creature.creatureStorage) .. " " .. getCreatureName(target) .. " defeated. Total [" .. getCreatureStorage(cid, creature.questStorage) .. "/" .. creature.killsRequired .. "] " .. creature.raceName .. ".")
            end
        end
    end
    return true
end

I do not understand what's wrong here... any help/guidance would be appreciated!
 
Solution
S
Lua:
local config = {
     ['abyssador'] = {amount = 1, storage = 84735, startstorage = 42351, startvalue = 2},
     ['mutant demon'] = {amount = 1000, storage = 21361, startstorage = 96477, startvalue = 2},
}
function onKill(player, target)
     local monster = config[target:getName():lower()]
     if target:isPlayer() or not monster or target:getMaster() then
         return true
     end
     local stor = player:getStorageValue(monster.storage)+1
     if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
         player:setStorageValue(monster.storage, stor)
         player:sendChannelMessage(nil, '[Quest]: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.'...
Lua:
local config = {
     ['abyssador'] = {amount = 1, storage = 84735, startstorage = 42351, startvalue = 2},
     ['mutant demon'] = {amount = 1000, storage = 21361, startstorage = 96477, startvalue = 2},
}
function onKill(player, target)
     local monster = config[target:getName():lower()]
     if target:isPlayer() or not monster or target:getMaster() then
         return true
     end
     local stor = player:getStorageValue(monster.storage)+1
     if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
         player:setStorageValue(monster.storage, stor)
         player:sendChannelMessage(nil, '[Quest]: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.', TALKTYPE_CHANNEL_R1, 11)
     end
     if (stor +1) == monster.amount then
         player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.')
         player:setStorageValue(monster.storage, stor +1)
     end
     return true
end

use this instead, startstorage is that same as quest storage, and the other storage is to count in it the monsters count start value is at which stage of the quest should the task start counting the monster X
 
Solution
Back
Top