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

Task count more than one monster

icekis

Member
Joined
Jan 18, 2018
Messages
91
Reaction score
5
How can i change this script to count more than one monster.

I want to count drillworms and giant spiders at the same task

Lua:
local config = {
     ['drillworm'] = {amount = 220, storage = Storage.Quest.Quest.TaskDrillWormCount, startstorage = Storage.Quest.Quest.TaskDrillWorm, startvalue = 1}
}
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:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
     end
     if (stor +1) == monster.amount then
         player:sendTextMessage(MESSAGE_INFO_DESCR, '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
 
Solution
How can i change this script to count more than one monster.

I want to count drillworms and giant spiders at the same task

Lua:
local config = {
     ['drillworm'] = {amount = 220, storage = Storage.Quest.Quest.TaskDrillWormCount, startstorage = Storage.Quest.Quest.TaskDrillWorm, startvalue = 1}
}
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)...
How can i change this script to count more than one monster.

I want to count drillworms and giant spiders at the same task

Lua:
local config = {
     ['drillworm'] = {amount = 220, storage = Storage.Quest.Quest.TaskDrillWormCount, startstorage = Storage.Quest.Quest.TaskDrillWorm, startvalue = 1}
}
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:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
     end
     if (stor +1) == monster.amount then
         player:sendTextMessage(MESSAGE_INFO_DESCR, '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

Lua:
local config = {
     ['drillworm'] = {amount = 220, storage = Storage.Quest.Quest.TaskDrillWormCount, startstorage = Storage.Quest.Quest.TaskDrillWorm, startvalue = 1},
     ['giant spider'] = {amount = 220, storage = Storage.Quest.Quest.TaskDrillWormCount, startstorage = Storage.Quest.Quest.TaskDrillWorm, startvalue = 1}
}
 
Solution
Back
Top