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

count more than 1 creature

Pedrook

Advanced OT User
Joined
May 24, 2009
Messages
457
Solutions
3
Reaction score
194
Location
Brazil
GitHub
pedrogiampietro
my task script, only reads the first name of the bixo for example
"troll" and if I want to add more than one "troll", "swamp troll", it does not count.
already tried "troll, swamp troll",
no way no one could help me?


lib/task system.


Code:
task_monsters = {
   [1] = {nome = "swamp troll", nome ="troll", storage = 30000, amount = 20, exp = 5000, pointsTask = {1, 1}, items = {{id = 2157, count = 1}, {id = 2160, count = 3}}},
   [2] = {nome = "minotaur" "minotaur archer" "minotaur guard" "minotaur mage", storage = 30001, amount = 10, exp = 1500, pointsTask = {1, 1}, items = {{id = 11244, count = 1}, {id = 5804, count = 1}}},
   [3] = {nome = "monstro2", storage = 30002, amount = 10, exp = 18000, pointsTask = {1, 1}, items = {{id = 2195, count = 1}, {id = 2160, count = 8}}},
   [4] = {nome = "monstro3", storage = 30003, amount = 10, exp = 20000, pointsTask = {1, 1}, items = {{id = 2520, count = 1}, {id = 2160, count = 10}}}
}

task_daily = {
   [1] = {nome = "monstroDay1", storage = 40000, amount = 10, exp = 5000, pointsTask = {1, 1}, items = {{id = 2157, count = 1}, {id = 2160, count = 3}}},
   [2] = {nome = "monstroDay2", storage = 40001, amount = 10, exp = 10000, pointsTask = {1, 1}, items = {{id = 10521, count = 1}, {id = 2160, count = 5}}},
   [3] = {nome = "monstroDay3", storage = 40002, amount = 10, exp = 18000, pointsTask = {1, 1}, items = {{id = 2195, count = 1}, {id = 2160, count = 8}}},
   [4] = {nome = "monstroDay4", storage = 40003, amount = 10, exp = 20000, pointsTask = {1, 1}, items = {{id = 2520, count = 1}, {id = 2160, count = 10}}}
}

task_storage = 20020 -- storage que verifica se está fazendo alguma task e ver qual task é - task normal
task_points = 20021 -- storage que retorna a quantidade de pontos task que o player tem.
task_sto_time = 20022 -- storage de delay para não poder fazer a task novamente caso ela for abandonada.
task_time = 20 -- tempo em horas em que o player ficará sem fazer a task como punição
task_rank = 20023 -- storage do rank task
taskd_storage = 20024 -- storage que verifica se está fazendo alguma task e ver qual task é - task daily
time_daySto = 20025 -- storage do tempo da task daily, no caso para verificar e add 24 horas para fazer novamente a task daily


local ranks_task = {
[{1, 20}] = "Newbie",
[{21, 50}] = "Elite",
[{51, 100}] = "Master",
[{101, 200}] = "Destroyer",       
[{201, math.huge}] = "Juggernaut"
}

function getTaskInfos(uid)
return task_monsters[Player(uid):getStorageValue(task_storage)] or false
end

function getTaskDailyInfo(uid)
return task_daily[Player(uid):getStorageValue(taskd_storage)] or false
end


function taskPoints_get(uid)
if Player(uid):getStorageValue(task_points) == -1 then
return 0
end
return Player(uid):getStorageValue(task_points)
end

function taskPoints_add(uid, count)
return Player(uid):setStorageValue(task_points, taskPoints_get(uid) + count)
end

function taskPoints_remove(uid, count)
return Player(uid):setStorageValue(task_points, taskPoints_get(uid) - count)
end



function taskRank_get(uid)
if Player(uid):getStorageValue(task_rank) == -1 then
return 1
end
return Player(uid):getStorageValue(task_rank)
end

function taskRank_add(uid, count)
return Player(uid):setStorageValue(task_rank, taskRank_get(uid) + count)
end


function getRankTask(uid)
local pontos = taskRank_get(uid)
    for _, z in pairs(ranks_task) do
        if pontos >= _[1] and pontos <= _[2] then
        return z
        end
    end
end


function getItemsFromTable(itemtable)
     local text = ""
     for v = 1, #itemtable do
         count, info = itemtable[v].count, ItemType(itemtable[v].id)
         local ret = ", "
         if v == 1 then
             ret = ""
         elseif v == #itemtable then
             ret = " - "
         end
         text = text .. ret
         text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
     end
     return text
end
 
Do you want to add multiple monsters? Like in the troll task you can kill trolls, frost trolls, swamp trolls?
Post the creaturescript code, there is no code in the lib related to the monster death.
 
You can't have more than 1 element with the same name ('nome' in that case :D)

You can try add them as separate monsters with the same storage, they would save in.

For example:
LUA:
[1] = {nome = "troll", storage = 30000, amount = 20, exp = 5000, pointsTask = {1, 1}, items = {{id = 2157, count = 1}, {id = 2160, count = 3}}},
[2] = {nome = "swamp troll", storage = 30000, amount = 20, exp = 5000, pointsTask = {1, 1}, items = {{id = 2157, count = 1}, {id = 2160, count = 3}}},

Im not sure if it loads correctly but you can follow my idea, and check what happens. Then we will work further.
 
You can't have more than 1 element with the same name ('nome' in that case :D)

You can try add them as separate monsters with the same storage, they would save in.

For example:
LUA:
[1] = {nome = "troll", storage = 30000, amount = 20, exp = 5000, pointsTask = {1, 1}, items = {{id = 2157, count = 1}, {id = 2160, count = 3}}},
[2] = {nome = "swamp troll", storage = 30000, amount = 20, exp = 5000, pointsTask = {1, 1}, items = {{id = 2157, count = 1}, {id = 2160, count = 3}}},

Im not sure if it loads correctly but you can follow my idea, and check what happens. Then we will work further.
nome = {troll, swamp troll} + isInArray in onKill script
 
Do you want to add multiple monsters? Like in the troll task you can kill trolls, frost trolls, swamp trolls?
Post the creaturescript code, there is no code in the lib related to the monster death.

yes, for example, minotaur mage, minotaur archer, minotaur guard ..


creaturescript
Code:
function onKill(player, target)
if target:isPlayer()  or target:getMaster() then
    return true
end

if getTaskInfos(player) then
if target:getName():lower() == getTaskInfos(player).nome then
  if player:getStorageValue(getTaskInfos(player).storage) < getTaskInfos(player).amount then
   player:setStorageValue(getTaskInfos(player).storage, player:getStorageValue(getTaskInfos(player).storage) + 1)
   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, '[Task System] You killed ['..(player:getStorageValue(getTaskInfos(player).storage))..'/'..getTaskInfos(player).amount..'] '..target:getName()..'.')
  end
end
end

if getTaskDailyInfo(player) then
if target:getName():lower() == getTaskDailyInfo(player).nome then
  if player:getStorageValue(getTaskDailyInfo(player).storage) < getTaskDailyInfo(player).amount then
   player:setStorageValue(getTaskDailyInfo(player).storage, player:getStorageValue(getTaskDailyInfo(player).storage) + 1)
   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, '[Daily Task System] You killed ['..(player:getStorageValue(getTaskDailyInfo(player).storage))..'/'..getTaskDailyInfo(player).amount..'] '..target:getName()..'.')
  end
end
end

return true
end

You can't have more than 1 element with the same name ('nome' in that case :D)

You can try add them as separate monsters with the same storage, they would save in.

For example:
LUA:
[1] = {nome = "troll", storage = 30000, amount = 20, exp = 5000, pointsTask = {1, 1}, items = {{id = 2157, count = 1}, {id = 2160, count = 3}}},
[2] = {nome = "swamp troll", storage = 30000, amount = 20, exp = 5000, pointsTask = {1, 1}, items = {{id = 2157, count = 1}, {id = 2160, count = 3}}},

Im not sure if it loads correctly but you can follow my idea, and check what happens. Then we will work further.

I tried that way to see, and it counts, but it counts only the 1st not.
 
Last edited by a moderator:
change:
if target:getName():lower() == getTaskInfos(player).nome then
to:
if isInArray(getTaskInfos(player).nome, target:getName():lower()) then

if 1 name only, use:
{nome = {"troll"}, storage = 30000, amount = 20, exp = 5000, pointsTask = {1, 1}, items = {{id = 2157, count = 1}, {id = 2160, count = 3}}},
if 2 names:
{nome = {"troll", "swamp troll"}, storage = 30000, amount = 20, exp = 5000, pointsTask = {1, 1}, items = {{id = 2157, count = 1}, {id = 2160, count = 3}}},

Remember about { and } even if only 1 name!
 
It counts, but counts only first? What do you mean? It counts only the troll, but not swamp troll? Can you provide more details?
exactly, if I put two tags like you said, anyway he'll only count one, he counts the troll, not the swamp

change:
if target:getName():lower() == getTaskInfos(player).nome then
to:
if isInArray(getTaskInfos(player).nome, target:getName():lower()) then

if 1 name only, use:
{nome = {"troll"}, storage = 30000, amount = 20, exp = 5000, pointsTask = {1, 1}, items = {{id = 2157, count = 1}, {id = 2160, count = 3}}},
if 2 names:
{nome = {"troll", "swamp troll"}, storage = 30000, amount = 20, exp = 5000, pointsTask = {1, 1}, items = {{id = 2157, count = 1}, {id = 2160, count = 3}}},

Remember about { and } even if only 1 name!

12:01 NPC Task: Olá ADM Iykz. Fiquei encarregado da missão de entregar Missões Task para ajuda a vila em alguns aspectos. Gostaria de fazer a task normal, diaria, receber, abandonar, ou gostaria de ver a lista de tasks normais ou a lista de task dailys ?
12:01 ADM Iykz [11]: normal
12:01 NPC Task: Great. Which monster task would you like to do?
12:01 ADM Iykz [11]: Troll
12:01 NPC Task: You are already doing a task. You can only do one at a time. Say ! Task to see information about your current task.

Q7gInFX.png


he says that I'm already doing another task, even without doing it, I've changed storage, reseached, and nothing.

It counts, but counts only first? What do you mean? It counts only the troll, but not swamp troll? Can you provide more details?
lTwfpbO.png


with both lines, it only accepts 1 name.

up
 
Last edited by a moderator:

Similar threads

Back
Top