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

CreatureEvent Advance tasks system.

I've also made this system once, but it's arround 1-2 years ago and I don't know how it really was built-on, but it's easy to add a special function with which you're also able to kill the boss, after talking with the NPC (I was used to do it with teleporters like CIP did/do it today). It'd be nice if you'd add something like that :p Also you could be more friendly to users who have question about your system...

Even though it's a nice release :p
 
I have a problem when a player takes task and the task will fall to erase count like monsters from scratch? please help

Sorry for my english
 
I have a problem with this script when i kill 200 trolls sometimes its saying you have killed 201 trolls and it won't let me do other tasks. Rep++ if you fix
 
My task reset when i kill other monster, but only if i kill other monster that have in the task list.
 
Last edited:
I am making task with trolls. I killed 4x trolls and i go back to npc and i said "Hi" and "task" and he wrote: 14:10 Grizzly Adams: You have kill 0 trolls.

8.6 tfs 0.4
 
@Oscar1121
Move config and task along with any other configuration to a separate file where those two scripts will read that config, if any user of that script want's to add more monsters or change it, it will be easier and you will avoid some headache on if someone makes changes to it, asking "Your script stopped working.".
It's just a tip ;)
 
I've got errors:

[16/11/2011 7:11:11] [Error - LuaInterface::loadFile] data/npc/scripts/tasks_system.lua:104: unexpected symbol near ','
then
[16/11/2011 7:11:11] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/tasks_system.lua

and:
[16/11/2011 7:11:11] [Warning - Monster::Monster] Unknown event name - KillingInTheNameOf

Help, please.
 
104 line
change:
Code:
['behemoth'] = {name = ,  min_level = 90, max_level = 250, 
                    rewards = {'money', 0, 5000, 'addon', {143,147}, 2, 'skill', SKILL_AXE, 1}, 
                    begin_storage_value = 53, finish_storage_value = 54, boss = true, before_kill_boss = 11, after_kill_boss = 12, talkstate = 18},
to:
Code:
['behemoth'] = {min_level = 90, max_level = 250, 
                    rewards = {'money', 0, 5000, 'addon', {143,147}, 2, 'skill', SKILL_AXE, 1}, 
                    begin_storage_value = 53, finish_storage_value = 54, boss = true, before_kill_boss = 11, after_kill_boss = 12, talkstate = 18},



and go to login.lua

and remove line where u have reister creature event kilinginthenameof
because oskar change it's to: advanceTasksKill btw. i think u musn't register it again to login.lua, because it;s allready registered in MOD
 
Ok i changed it.
I don't have in login.lua an event like kilinginthenameof~

#something is wrong with npc.

Code:
21:17 Grizzly Adams: 
21:17 Grizzly Adams: 
21:17 Grizzly Adams: 
21:17 Grizzly Adams: 
21:17 Grizzly Adams: 
21:17 Grizzly Adams: 
21:17 Grizzly Adams: 
21:17 Grizzly Adams: 
21:17 Grizzly Adams: 
21:17 Grizzly Adams: 
21:18 Grizzly Adams: 
21:18 Grizzly Adams: 
21:18 Grizzly Adams: 
21:18 Grizzly Adams: 
21:18 Grizzly Adams:
I don't must msg to him ... /\

When i msg to him:
Code:
21:18 [GOD] [10]: hi
21:18 [GOD] [10]: troll
21:18 Grizzly Adams: 
21:18 [GOD][10]: task
21:19 [GOD]  [10]: report
21:19 [GOD]  [10]: trolls
21:19 Grizzly Adams: 
21:19 Grizzly Adams: 
21:19 Grizzly Adams: 
21:19 Grizzly Adams: 
21:19 [GOD] [10]: mission
21:19 [GOD] [10]: quest


#edit

i repaired problem with warning event "kilinginthenameof".
But i've got problems with NPC.
0 errors in console
 
Last edited:
First we go to mods folder and make file tasksSystem.xml and paste this:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Advance Tasks System" version="1.0" author="Oskar" contact="http://tibia.net.pl/members/oskar.html" enabled="yes">
<config name="advanceTasks_conf"><=!=[=C=D=A=T=A=[
task = {
--each monsters
--['monsterName'] = {storage = storage, beginStorageValue = startingStorageValue, finishStorageValue = finishingStorageValue, count = countOfMonster}
['crocodile'] = {storage = 9960, beginStorageValue = 39, finishStorageValue = 40, count = 300},
['tarantula'] = {storage = 9959, beginStorageValue = 41, finishStorageValue = 42, count = 300},
['carniphila'] = {storage = 9958, beginStorageValue = 43, finishStorageValue = 44, count = 250},
['stone golem'] = {storage = 9957, beginStorageValue = 45, finishStorageValue = 46, count = 200},
['mutated rat'] = {storage = 9956, beginStorageValue = 47, finishStorageValue = 48, count = 200},
['giant spider'] = {storage = 9955, beginStorageValue = 49, finishStorageValue = 50, count = 500},
['hydra'] = {storage = 9954, beginStorageValue = 51, finishStorageValue = 52, count = 650},
['behemoth'] = {storage = 9953, beginStorageValue = 53, finishStorageValue = 54, count = 700},
['serpent spawn'] = {storage = 9952, beginStorageValue = 55, finishStorageValue = 56, count = 550},
['demon'] = {storage = 9951, beginStorageValue = 57, finishStorageValue = 58, count = 350},

--mass monsters
--['race name'] = {monsterTypes = {['name1'] = storage1, ['name2'] = storage2 ...},
-- beginStorageValue = startingStorageValue, finishStorageValue = finishingStorageValue, count = countOfMonster}
['trolls'] = {monsterTypes = {['troll']=9950,['swamp troll']=9949,['island troll']=9948,['frost troll']=9947,['troll champion']=9946},
beginStorageValue = 1, finishStorageValue = 2, count = 150},
['goblins'] = {monsterTypes = {['goblin']=9945,['goblin assassin']=9944,['goblin scavenger']=9943},
beginStorageValue = 3, finishStorageValue = 4, count = 150},
['rotworms'] = {monsterTypes = {['rotworm']=9942,['carrion worm']=9941},
beginStorageValue = 5, finishStorageValue = 6, count = 300},
['cyclops'] = {monsterTypes = {['cyclops']=9940,['cyclops drone']=9939,['cyclops smith']=9938},
beginStorageValue = 7, finishStorageValue = 8, count = 500},
['quaras'] = {monsterTypes = {['quara predator']=9937,['quara constrictor']=9936,['quara hydromancer']=9935,['quara mantassin']=9934,['quara pincher']=9933},
beginStorageValue = 9, finishStorageValue = 10, count = 300},
['water'] = {monsterTypes = {['water elemental']=9932,['massive water elemental']=9931},
beginStorageValue = 11, finishStorageValue = 12, count = 70},
['fire'] = {monsterTypes = {['fire elemental']=9930,['massive fire elemental']=9929},
beginStorageValue = 13, finishStorageValue = 14, count = 70},
['earth'] = {monsterTypes = {['earth elemental']=9928,['massive earth elemental']=9927},
beginStorageValue = 15, finishStorageValue = 16, count = 70},
['energy'] = {monsterTypes = {['energy elemental']=9926,['massive energy elemental']=9925},
beginStorageValue = 17, finishStorageValue = 18, count = 70},
['sea serpents'] = {monsterTypes = {['sea serpent']=9924,['young sea serpent']=9923},
beginStorageValue = 19, finishStorageValue = 20, count = 700},
['green djinns'] = {monsterTypes = {['green djinn']=9922,['efreet']=9921},
beginStorageValue = 21, finishStorageValue = 22, count = 500},
['blue djinns'] = {monsterTypes = {['blue djinn']=9920,['marid']=9919},
beginStorageValue = 23, finishStorageValue = 24, count = 500},
['pirates'] = {monsterTypes = {['pirate buccaneer']=9918,['pirate corsair']=9917,['pirate ghost']=9916,['pirate marauder']=9915,['pirate cutthroat']=9914,['pirate skeleton']=9913},
beginStorageValue = 25, finishStorageValue = 26, count = 1500},
['minotaurs'] = {monsterTypes = {['minotaur']=9912,['minotaur archer']=9911,['minotaur guard']=9910,['minotaur mage']=9909},
beginStorageValue = 27, finishStorageValue = 28, count = 5000},
['necromancers'] = {monsterTypes = {['necromancer']=9908,['priestess']=9907},
beginStorageValue = 29, finishStorageValue = 30, count = 2000},
['high class lizards'] = {monsterTypes = {['lizard zaogun']=9906,['lizard noble']=9905,['lizard magistratus']=9904,['lizard legionnaire']=9903,['lizard high guard']=9902,['lizard dragon priest']=9901,['lizard chosen']=9900},
beginStorageValue = 31, finishStorageValue = 32, count = 800},
['dragons'] = {monsterTypes = {['dragon']=9899,['dragon lord']=9898,['frost dragon']=9897,['wyrm']=9896},
beginStorageValue = 33, finishStorageValue = 34, count = 500},
['dragon hatchlings'] = {monsterTypes = {['dragon hatchling']=9895,['dragon lord hatchling']=9894,['frost dragon hatchling']=9893},
beginStorageValue = 35, finishStorageValue = 36, count = 750},
['undead dragons'] = {monsterTypes = {['undead dragon']=9892,['ghastly dragon']=9891},
beginStorageValue = 37, finishStorageValue = 38, count = 350},
}
specialTask = {
--bosses
-- ['boss name'] = {beginStorageValue = startingStorageValue, finishStorageValue = finishingStorageValue
-- [itemUid] = {effect = effectOnPlayerSpawn, centerRoomPosition = playerSpawnAndCenterRoomPosition,
-- bossSummonPlace = whereSummonBoss, bossEffect = effectOnBossSpawn,
-- sizeRoom = roomSize{cordinateX, cordinateY}}
['the snapper'] = {beginBossStorageValue = 1, finishedBossStorageValue = 2,
[5302] = {effect = CONST_ME_CARNIPHILA, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_CARNIPHILA,
sizeRoom = {5,5}}},
['hide'] = {beginBossStorageValue = 3, finishedBossStorageValue = 4,
[5303] = {effect = CONST_ME_STONES, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_STONES,
sizeRoom = {5,5}}},
['deathbine'] = {beginBossStorageValue = 5, finishedBossStorageValue = 6,
[5304] = {effect = CONST_ME_CARNIPHILA, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_CARNIPHILA,
sizeRoom = {5,5}}},
['the bloodtusk'] = {beginBossStorageValue = 7, finishedBossStorageValue = 8,
[5305] = {effect = CONST_ME_ICEAREA, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_ICEAREA,
sizeRoom = {5,5}}},
['shardhead'] = {beginBossStorageValue = 9, finishedBossStorageValue = 10,
[5306] = {effect = CONST_ME_ICEATTACK, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_ICEATTACK,
sizeRoom = {5,5}}},
['esmeralda'] = {beginBossStorageValue = 11, finishedBossStorageValue = 12,
[5307] = {effect = CONST_ME_HITBYPOISON, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_HITBYPOISON,
sizeRoom = {5,5}}},
['bloodweb'] = {beginBossStorageValue = 13, finishedBossStorageValue = 14,
[5308] = {effect = CONST_ME_ICEATTACK, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_ICEATTACK,
sizeRoom = {5,5}}},
['fleshcrawler'] = {beginBossStorageValue = 15, finishedBossStorageValue = 16,
[5309] = {effect = CONST_ME_SMALLPLANTS, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_SMALLPLANTS,
sizeRoom = {5,5}}},
['ribstride'] = {beginBossStorageValue = 17, finishedBossStorageValue = 18,
[5310] = {effect = CONST_ME_SMALLCLOUDS, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_SMALLCLOUDS,
sizeRoom = {5,5}}},
['the old widow'] = {beginBossStorageValue = 19, finishedBossStorageValue = 20,
[5311] = {effect = CONST_ME_SMALLPLANTS, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_SMALLPLANTS,
sizeRoom = {5,5}}},
['thul'] = {beginBossStorageValue = 21, finishedBossStorageValue = 22,
[5312] = {effect = CONST_ME_WATERSPLASH, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_WATERSPLASH,
sizeRoom = {5,5}}},
['flameborn'] = {beginBossStorageValue = 23, finishedBossStorageValue = 24,
[5313] = {effect = CONST_ME_HITBYFIRE, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_HITBYFIRE,
sizeRoom = {5,5}}},
['sulphur scuttler'] = {beginBossStorageValue = 25, finishedBossStorageValue = 26,
[5314] = {effect = CONST_ME_SMALLPLANTS, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_SMALLPLANTS,
sizeRoom = {5,5}}},
['the many'] = {beginBossStorageValue = 27, finishedBossStorageValue = 28,
[5315] = {effect = CONST_ME_SMALLPLANTS, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_SMALLPLANTS,
sizeRoom = {5,5}}},
['leviathan'] = {beginBossStorageValue = 29, finishedBossStorageValue = 30,
[5316] = {effect = CONST_ME_ICEATTACK, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_ICEATTACK,
sizeRoom = {5,5}}},
['stonecracker'] = {beginBossStorageValue = 31, finishedBossStorageValue = 32,
[5317] = {effect = CONST_ME_POFF, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_POFF,
sizeRoom = {5,5}}},
['the noxious spawn'] = {beginBossStorageValue = 33, finishedBossStorageValue = 34,
[5318] = {effect = CONST_ME_YELLOW_RINGS, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_YELLOW_RINGS,
sizeRoom = {5,5}}},
['gorgo'] = {beginBossStorageValue = 35, finishedBossStorageValue = 36,
[5319] = {effect = CONST_ME_GROUNDSHAKER, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_GROUNDSHAKER,
sizeRoom = {5,5}}},
['kerberos'] = {beginBossStorageValue = 37, finishedBossStorageValue = 38,
[5320] = {effect = CONST_ME_FIREAREA, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_FIREAREA,
sizeRoom = {5,5}}},
['ethershrek'] = {beginBossStorageValue = 39, finishedBossStorageValue = 40,
[5321] = {effect = CONST_ME_MORTAREA, centerRoomPosition = {x=1000,y=1000,z=7},
bossSummonPlace = {x=1000,y=1000,z=7}, bossEffect = CONST_ME_MORTAREA,
sizeRoom = {5,5}}}
}
mainStorage = 10001
bossesStorage = 10002

function isSummon(cid)
if(not isCreature(cid)) then
return false
end
return getCreatureMaster(cid) ~= cid
end
]=]=></config>

<event type="kill" name="advanceTasksKill" event="script"><=!=[=C=D=A=T=A=[
domodlib('advanceTasks_conf')
function onKill(cid, target)
if isPlayer(target) or isSummon(target) or isNpc(target) then
return true
end
for k, v in pairs(task) do
if (v.monsterTypes and v.monsterTypes[getCreatureName(target):lower()]) or k:lower() == getCreatureName(target):lower() then
if getPlayerStorageValue(cid, mainStorage) == v.beginStorageValue then
storages = v.monsterTypes and v.monsterTypes[getCreatureName(target)] or v.storage
if getPlayerStorageValue(cid, storages) <= v.count then
local x, s = 0, 'You killed '
if v.monsterTypes then
for monster, storage in pairs(v.monsterTypes) do
if getPlayerStorageValue(cid, storage) == -1 then
doPlayerSetStorageValue(cid, storage, 0)
end
if monster:lower() == getCreatureName(target):lower() then
doPlayerSetStorageValue(cid, storage, getPlayerStorageValue(cid, storage) + 1)
end
x = x + getPlayerStorageValue(cid, storage)
s = s .. getPlayerStorageValue(cid, storage) .. ' ' .. monster .. ', '
end
else
doPlayerSetStorageValue(cid, storages, getPlayerStorageValue(cid, storages) + 1)
s = s .. getPlayerStorageValue(cid, storages) .. ' of ' .. v.count .. ' ' .. k .. '.'
end
s = (x > 0 and (string.sub(s, 1, string.len(s) - 2)..'. You have killed ' .. x ..' of '.. v.count ..' '..k..'.') or s)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, s)
if getPlayerStorageValue(cid, storages) == v.count then
doPlayerSetStorageValue(cid, mainStorage, v.finishStorageValue)
if v.monsterTypes then
for monster, storage in pairs(v.monsterTypes) do
doPlayerSetStorageValue(cid, storage, 0)
end
else
doPlayerSetStorageValue(cid, v.storage, 0)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have killed enough '..(v.monsterTypes and k or getCreatureName(target)..'s')..'.')
end
end
end
end
end
for k, v in pairs(specialTask) do
if k:lower() == getCreatureName(target):lower() and v.storage and getPlayerStorageValue(cid, v.storage) == v.beginBossStorageValue then
doPlayerSetStorageValue(cid, v.storage, v.finishedBossStorageValue)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have killed '..getCreatureName(target)..'.')
elseif k:lower() == getCreatureName(target):lower() and getPlayerStorageValue(cid, bossesStorage) == v.beginBossStorageValue then
doPlayerSetStorageValue(cid, bossesStorage, v.finishedBossStorageValue)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have killed '..getCreatureName(target)..'.')
end
end
return true
end
]=]=></event>

<moveevent type="stepIn" name="advanceTasksStepIn" fromuid="5300" touid="5321" event="script"><=!=[=C=D=A=T=A=[
domodlib('advanceTasks_conf')
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
for k, v in pairs(specialTask) do
if v[item.uid] and isPlayer(cid) then
if getSpectators(v[item.uid].centerRoomPosition, v[item.uid].sizeRoom[1], v[item.uid].sizeRoom[2]) then
for _, target in ipairs(getSpectators(v[item.uid].centerRoomPosition, v[item.uid].sizeRoom[1], v[item.uid].sizeRoom[2])) do
if isPlayer(target) then
return doTeleportThing(cid, fromPosition, true) and doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Somebody fight with '..k..'!')
elseif isMonster(target) then
doRemoveThing(target)
end
end
end
if getPlayerStorageValue(cid, bossesStorage) == v.beginBossStorageValue then
doTeleportThing(cid, v[item.uid].centerRoomPosition, true)
doSendMagicEffect(v[item.uid].centerRoomPosition, v[item.uid].effect)
doSendMagicEffect(v[item.uid].bossSummonPlace, v[item.uid].bossEffect)
return doCreateMonster(k, v[item.uid].bossSummonPlace)
end
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You can\'t enter here!')
elseif v[item.uid-100] and isPlayer(cid) then
if getSpectators(v[item.uid-100].centerRoomPosition, v[item.uid-100].sizeRoom[1], v[item.uid-100].sizeRoom[2]) then
for _, target in ipairs(getSpectators(v[item.uid-100].centerRoomPosition, v[item.uid-100].sizeRoom[1], v[item.uid-100].sizeRoom[2])) do
if isMonster(target) then
doRemoveThing(target)
end
end
end
return true
end
end
return true
end
]=]=></moveevent>

<event type="login" name="advanceTasksLogin" event="buffer"><=!=[=C=D=A=T=A=[
registerCreatureEvent(cid, 'advanceTasksKill')
]=]=></event>
</mod>


Now we go to data/NPC/scripts and create tasks_system.lua and paste this:
local function doNPCTalkALot(cid, npc, delay, message)
addEvent(function()
if isPlayer(cid) then
doCreatureSay(npc, message, TALKTYPE_PRIVATE_NP, false, cid)
end end,
(i > 1 and 5000*i+delay or delay),
cid, message, i)
end

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

local main_storage, bosses_storage = 10001, 10002
local good_hunting = {'Happy hunting, old chap! Come back to me when you are through with your {task}.', 'Good show, old chap! Speak to me again when you are done hunting.'}
local good_job = {'That took some time, huh? Good hunting though. If you\'re up for another hunting mission just ask me for a {task}.', 'If you\'re up for another hunting mission just ask me for a {task}.'}
local tasks = {
['trolls'] = {min_level = 8, max_level = 20,
rewards = {'money', 0, 200, 'exp', 0, 200},
begin_storage_value = 1, finish_storage_value = 2, boss = false, talkstate = 1},
['goblins'] = {min_level = 10, max_level = 20,
rewards = {'money', 0, 250, 'exp', 0, 300},
begin_storage_value = 3, finish_storage_value = 4, boss = false, talkstate = 2},
['rotworms'] = {min_level = 15, max_level = 30,
rewards = {'money', 0, 400, 'exp', 0, 1000},
begin_storage_value = 5, finish_storage_value = 6, boss = true, before_kill_boss = 1, after_kill_boss = 2, talkstate = 3},
['cyclops'] = {min_level = 18, max_level = 50,
rewards = {'money', 0, 800, 'exp', 0, 3000, 'item', 2381, 1},
begin_storage_value = 7, finish_storage_value = 8, boss = false, talkstate = 4},
['quaras'] = {min_level = 30, max_level = 80,
rewards = {'exp', 0, 12000, 'item', 5895, 1},
begin_storage_value = 9, finish_storage_value = 10, boss = false, talkstate = 9},
['water elementals'] = {min_level = 35, max_level = 60,
rewards = {'exp', 0, 7000, 'money', 0, 3000},
begin_storage_value = 11, finish_storage_value = 12, boss = false, talkstate = 10},
['fire elementals'] = {min_level = 35, max_level = 60,
rewards = {'exp', 0, 7000, 'money', 0, 3000},
begin_storage_value = 13, finish_storage_value = 14, boss = false, talkstate = 13},
['earth elementals'] = {min_level = 35, max_level = 60,
rewards = {'exp', 0, 10000, 'money', 0, 2000},
begin_storage_value = 15, finish_storage_value = 16, boss = false, talkstate = 11},
['energy elementals'] = {min_level = 35, max_level = 60,
rewards = {'exp', 0, 7000, 'money', 0, 3000},
begin_storage_value = 17, finish_storage_value = 18, boss = false, talkstate = 12},
['sea serpents'] = {min_level = 90, max_level = 250,
rewards = {'money', 0, 10000, 'skill', SKILL__LEVEL, 1},
begin_storage_value = 19, finish_storage_value = 20, boss = false, talkstate = 17},
['green djinns'] = {min_level = 40, max_level = 100,
rewards = {'money', 0, 5000, 'exp', 0, 10000},
begin_storage_value = 21, finish_storage_value = 22, boss = false, talkstate = 20},
['blue djinns'] = {min_level = 40, max_level = 100,
rewards = {'money', 0, 5000, 'exp', 0, 10000},
begin_storage_value = 23, finish_storage_value = 24, boss = false, talkstate = 21},
['pirates'] = {min_level = 50, max_level = 120,
rewards = {'money', 0, 5000, 'addon', {151,155}, 1, 'exp', 0, 10000},
begin_storage_value = 25, finish_storage_value = 26, boss = false, talkstate = 22},
['minotaurs'] = {min_level = 20, max_level = 60,
rewards = {},
begin_storage_value = 27, finish_storage_value = 28, boss = true, before_kill_boss = 3, after_kill_boss = 4, talkstate = 23},
['necromancers'] = {min_level = 40, max_level = 110,
rewards = {'addon', {145,149}, 1},
begin_storage_value = 29, finish_storage_value = 30, boss = true, before_kill_boss = 5, after_kill_boss = 6, talkstate = 24},
['high lizards'] = {min_level = 80, max_level = 220,
rewards = {'item', 11295, 1, 'addon', {335,336}, 1},
begin_storage_value = 31, finish_storage_value = 32, boss = false, talkstate = 26},
['dragons'] = {min_level = 40, max_level = 180,
rewards = {'item', 2516, 1, 'exp', 0, 10000, 'money', 0, 5000},
begin_storage_value = 33, finish_storage_value = 34, boss = true, before_kill_boss = 7, after_kill_boss = 8, talkstate = 27},
['dragon hatchlings'] = {min_level = 20, max_level = 50,
rewards = {'item', 2434, 1, 'exp', 0, 4000},
begin_storage_value = 35, finish_storage_value = 36, boss = false, talkstate = 28},
['undead dragons'] = {min_level = 100, max_level = 300,
rewards = {'item', 11299, 1, 'exp', 0, 25000, 'addon', {335,336}, 2},
begin_storage_value = 37, finish_storage_value = 38, boss = false, talkstate = 29},

['crocodile'] = {min_level = 20, max_level = 45,
rewards = {'exp', 0, 800},
begin_storage_value = 39, finish_storage_value = 40, boss = false, talkstate = 5},
['tarantula'] = {min_level = 20, max_level = 50,
rewards = {'money', 0, 1500},
begin_storage_value = 41, finish_storage_value = 42, boss = false, talkstate = 6},
['carniphila'] = {min_level = 20, max_level = 50,
rewards = {'exp', 0, 1500},
begin_storage_value = 43, finish_storage_value = 44, boss = false, talkstate = 7},
['stone golem'] = {min_level = 24, max_level = 50,
rewards = {'exp', 0, 2000, 'item', 5880, 1},
begin_storage_value = 45, finish_storage_value = 46, boss = false, talkstate = 8},
['mutated rat'] = {min_level = 40, max_level = 80,
rewards = {'exp', 0, 10000},
begin_storage_value = 47, finish_storage_value = 48, boss = false, talkstate = 14},
['giant spider'] = {min_level = 50, max_level = 90,
rewards = {'exp', 0, 5000, 'item', 5879, 1},
begin_storage_value = 49, finish_storage_value = 50, boss = true, before_kill_boss = 9, after_kill_boss = 10, talkstate = 15},
['hydra'] = {min_level = 90, max_level = 250,
rewards = {'exp', 0, 15000, 'addon', {144,148}, 1},
begin_storage_value = 51, finish_storage_value = 52, boss = false, talkstate = 16},
['behemoth'] = {min_level = 90, max_level = 250,
rewards = {'money', 0, 5000, 'addon', {143,147}, 2, 'skill', SKILL_AXE, 1},
begin_storage_value = 53, finish_storage_value = 54, boss = true, before_kill_boss = 11, after_kill_boss = 12, talkstate = 18},
['serpent spawn'] = {min_level = 90, max_level = 250,
rewards = {'money', 0, 15000, 'addon', {144,148}, 2},
begin_storage_value = 55, finish_storage_value = 56, boss = false, talkstate = 19},
['demon'] = {min_level = 100, max_level = 300,
rewards = {'item', 2128, 75, 'addon', {288,289}, 2, 'item', 10518, 1},
begin_storage_value = 57, finish_storage_value = 58, boss = true, before_kill_boss = 13, after_kill_boss = 14, talkstate = 25},
}

local function doTakeReward(cid, table)
for i = 1, #table/3 do
if table[i*3-2] == 'item' then
doPlayerAddItem(cid, table[i*3-1], table[i*3], true)
elseif table[i*3-2] == 'exp' then
doAddExp(cid, table[i*3])
elseif table[i*3-2] == 'storage' then
doPlayerSetStorageValue(cid, table[i*3-1], table[i*3])
elseif table[i*3-2] == 'money' then
doPlayerAddMoney(cid, table[i*3])
elseif table[i*3-2] == 'skill' then
doPlayerAddSkill(cid, table[i*3-1], table[i*3])
elseif table[i*3-2] == 'addon' then
doPlayerAddOutfit(cid, (getPlayerSex(cid) == 0 and table[i*3-1][1] or table[i*3-1][2]), table[i*3])
end
end
return true
end

function creatureSayCallback(cid, type, msg)
s = 'All right, what would you like to hunt - '
for k, v in pairs(tasks) do
s = s .. (getPlayerLevel(cid) >= v.min_level and getPlayerLevel(cid) <= v.max_level and '{'..k..',} ' or '')
end
s = string.sub(s, 1, s:len() - 3)..'}.'
if isInArray({'task','mission','quest'}, msg:lower()) then
if getPlayerStorageValue(cid, main_storage) <= 0 then
talkState[cid] = 100
return doNPCTalkALot(cid, getNpcCid(), 200, s)
else
for k, v in pairs(tasks) do
if getPlayerStorageValue(cid, main_storage) == v.finish_storage_value and getPlayerStorageValue(cid, bosses_storage) < v.before_kill_boss then
if v.boss then
doPlayerSetStorageValue(cid, bosses_storage, v.before_kill_boss)
return doNPCTalkALot(cid, getNpcCid(), 200, 'Good job, go kill boss of '..k..'.')
else
doPlayerSetStorageValue(cid, bosses_storage, 0)
doPlayerSetStorageValue(cid, main_storage, 0)
doTakeReward(cid, v.rewards)
return doNPCTalkALot(cid, getNpcCid(), 200, good_job[math.random(#good_job)])
end
elseif getPlayerStorageValue(cid, bosses_storage) == v.after_kill_boss then
doPlayerSetStorageValue(cid, bosses_storage, -1)
doPlayerSetStorageValue(cid, main_storage, -1)
doTakeReward(cid, v.rewards)
return doNPCTalkALot(cid, getNpcCid(), 200, good_job[math.random(#good_job)])
elseif getPlayerStorageValue(cid, bosses_storage) == v.before_kill_boss then
return doNPCTalkALot(cid, getNpcCid(), 200, 'You do not kill boss yet.')
end
end
end
elseif isInArray({'cancel','abort','stop'}, msg:lower()) then
if getPlayerStorageValue(cid, main_storage) > 0 then
talkState[cid] = 101
return doNPCTalkALot(cid, getNpcCid(), 200, 'Do you want cancel actual mission?')
else
return doNPCTalkALot(cid, getNpcCid(), 200, 'You don\'t have started any task!')
end
end
for k, v in pairs(tasks) do
if isInArray({'yes','ok','yep'}, msg:lower()) then
if talkState[cid] == v.talkstate then
doPlayerSetStorageValue(cid, main_storage, v.begin_storage_value)
return doNPCTalkALot(cid, getNpcCid(), 200, good_hunting[math.random(#good_hunting)])
elseif talkState[cid] == 101 and getPlayerStorageValue(cid, main_storage) > 0 then
doPlayerSetStorageValue(cid, main_storage, -1)
return doNPCTalkALot(cid, getNpcCid(), 200, 'Speak to me again when you are done hunting.')
end
elseif isInArray({'no','never','nope'}, msg:lower()) and talkState[cid] > 0 then
return doNPCTalkALot(cid, getNpcCid(), 200, 'Ok then.')
elseif isInArray({k,string.sub(k, 1, k:len() - 1)}, msg:lower()) and talkState[cid] == 100 then
if getPlayerLevel(cid) >= v.min_level and getPlayerLevel(cid) <= v.max_level then
talkState[cid] = v.talkstate
return doNPCTalkALot(cid, getNpcCid(), 200, 'Do you want hunt '..k..'?')
else
return doNPCTalkALot(cid, getNpcCid(), 200, 'You do not have enough level.')
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

What?
 
Error:
PHP:
[19:49:05.016] [Error - NpcScript Interface]
[19:49:05.019] data/npc/scripts/tasks_system.lua:onCreatureSay
[19:49:05.041] Description:
[19:49:05.050] data/npc/scripts/tasks_system.lua:7: attempt to compare number with nil
[19:49:05.062] stack traceback:
[19:49:05.066]  data/npc/scripts/tasks_system.lua:7: in function <data/npc/scripts/tasks_system.lua:1>
[19:49:05.078]  (tail call): ?
[19:49:05.083]  data/npc/lib/npcsystem/npchandler.lua:455: in function 'onCreatu
reSay'
[19:49:05.092]  data/npc/scripts/tasks_system.lua:16: in function <data/npc/scri
pts/tasks_system.lua:16>
 
When i say hi to npc he respond but when i say task or mission it gives me error in console and it doesn't respond to me TFS 0.4
Error:
[19:49:05.016] [Error - NpcScript Interface]
[19:49:05.019] data/npc/scripts/tasks_system.lua:eek:nCreatureSay[19:49:05.041] Description:
[19:49:05.050] data/npc/scripts/tasks_system.lua:7: attempt to compare number with nil[19:49:05.062] stack traceback:
[19:49:05.066] data/npc/scripts/tasks_system.lua:7: in function <data/npc/scripts/tasks_system.lua:1>
[19:49:05.078] (tail call): ?
[19:49:05.083] data/npc/lib/npcsystem/npchandler.lua:455: in function 'onCreatu
reSay'[19:49:05.092] data/npc/scripts/tasks_system.lua:16: in function <data/npc/scri
pts/tasks_system.lua:16>
 
Last edited:
Back
Top