• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent [CreatureEvent/Npc] Killing in the name of. [Now player can start more than one task]

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
  • Updated At: Saturday February 12nd, 2011 at 4:00 P.M (GMT -4:30)
  • Last Tested At: Saturday February 12nd, 2011 at 4:00 P.M (GMT -4:30)
  • Tested On: The Forgotten Server 0.3.6pl1

    [*]How i test my scripts? Every time when i test a script, i create a new char and then test the script with the new char.


  • Now player can start more than one task.

Update Log:
Code:
.
[B]V0.3: [12 / 02 / 2011][/B]
- Release of the new script --[[
        Player can start more than one task.
        Added bosses positions.
]]--

First, add this to your lib/function.lua:
Lua:
function isSummon(cid)
	return getCreatureMaster(cid) ~= cid or false
end

Or this if you are using 0.4 DEV:
Lua:
function isSummon(cid)
	return getCreatureMaster(cid) ~= nil
end

Create a file in data/creaturescripts/scripts called killinginthenameof.lua, and paste this:
Lua:
local questCreatures =
{
	["troll"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15000, killsRequired = 100, raceName = "Trolls"},
	["frost troll"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15001, killsRequired = 100, raceName = "Trolls"},
	["furious troll"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15002, killsRequired = 100, raceName = "Trolls"},
	["island troll"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15003, killsRequired = 100, raceName = "Trolls"},
	["swamp troll"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15004, killsRequired = 100, raceName = "Trolls"},
	["troll champion"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15005, killsRequired = 100, raceName = "Trolls"},
	["troll legionnaire"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15006, killsRequired = 100, raceName = "Trolls"},
 
	["goblin"] = {questStarted = 1511, questStorage = 65001, creatureStorage = 15007, killsRequired = 150, raceName = "Goblins"},
	["goblin assassin"] = {questStarted = 1511, questStorage = 65001, creatureStorage = 15008, killsRequired = 150, raceName = "Goblins"},
	["goblin leader"] = {questStarted = 1511, questStorage = 65001, creatureStorage = 15009, killsRequired = 150, raceName = "Goblins"},
	["goblin scavenger"] = {questStarted = 1511, questStorage = 65001, creatureStorage = 15010, killsRequired = 150, raceName = "Goblins"},
 
	["rotworm"] = {questStarted = 1512, questStorage = 65002, creatureStorage = 15011, killsRequired = 300, raceName = "Rotworms"},
	["carriom worm"] = {questStarted = 1512, questStorage = 65002, creatureStorage = 15012, killsRequired = 300, raceName = "Rotworms"},
 
	["cyclops"] = {questStarted = 1513, questStorage = 65003, creatureStorage = 15013, killsRequired = 500, raceName = "Cyclops"},
	["cyclops smith"] = {questStarted = 1513, questStorage = 65003, creatureStorage = 15014, killsRequired = 500, raceName = "Cyclops"},
	["cyclops drone"] = {questStarted = 1513, questStorage = 65003, creatureStorage = 15015, killsRequired = 500, raceName = "Cyclops"},
 
 
	["crocodile"] = {questStarted = 1514, questStorage = 65004, creatureStorage = 15016, killsRequired = 300, raceName = "Crocodiles"},
 
	["tarantula"] = {questStarted = 1515, questStorage = 65005, creatureStorage = 15017, killsRequired = 300, raceName = "Tarantulas"},
 
	["carniphila"] = {questStarted = 1516, questStorage = 65006, creatureStorage = 15018, killsRequired = 150, raceName = "Carniphilas"},
 
	["stone golem"] = {questStarted = 1517, questStorage = 65007, creatureStorage = 15019, killsRequired = 200, raceName = "Stone Golems"},
 
	["mammoth"] = {questStarted = 1518, questStorage = 65008, creatureStorage = 15020, killsRequired = 300, raceName = "Mammoths"},
 
	["ice golem"] = {questStarted = 1519, questStorage = 65009, creatureStorage = 15021, killsRequired = 300, raceName = "Ice Golems"},
 
	["quara predator scout"] = {questStarted = 1520, questStorage = 65010, creatureStorage = 15022, killsRequired = 300, raceName = "Quaras Scout"},
	["quara constrictor scout"] = {questStarted = 1520, questStorage = 65010, creatureStorage = 15023, killsRequired = 300, raceName = "Quaras Scout"},
	["quara hydromancer scout"] = {questStarted = 1520, questStorage = 65010, creatureStorage = 15024, killsRequired = 300, raceName = "Quaras Scout"},
	["quara mantassin scout"] = {questStarted = 1520, questStorage = 65010, creatureStorage = 15025, killsRequired = 300, raceName = "Quaras Scout"},
	["quara pincher scout"] = {questStarted = 1520, questStorage = 65010, creatureStorage = 15026, killsRequired = 300, raceName = "Quaras Scout"},
 
	["quara predator"] = {questStarted = 1521, questStorage = 65011, creatureStorage = 15027, killsRequired = 300, raceName = "Quaras"},
	["quara constrictor"] = {questStarted = 1521, questStorage = 65011, creatureStorage = 15028, killsRequired = 300, raceName = "Quaras"},
	["quara hydromancer"] = {questStarted = 1521, questStorage = 65011, creatureStorage = 15029, killsRequired = 300, raceName = "Quaras"},
	["quara mantassin"] = {questStarted = 1521, questStorage = 65011, creatureStorage = 15030, killsRequired = 300, raceName = "Quaras"},
	["quara pincher"] = {questStarted = 1521, questStorage = 65011, creatureStorage = 15031, killsRequired = 300, raceName = "Quaras"},
 
	["water elemental"] = {questStarted = 1522, questStorage = 65012, creatureStorage = 15032, killsRequired = 70, raceName = "Water Elementals"},
	["roaring water elemental"] = {questStarted = 1522, questStorage = 65012, creatureStorage = 15033, killsRequired = 70, raceName = "Water Elementals"},
	["slick water elemental"] = {questStarted = 1522, questStorage = 65012, creatureStorage = 15034, killsRequired = 70, raceName = "Water Elementals"},
	["massive water elemental"] = {questStarted = 1522, questStorage = 65012, creatureStorage = 15035, killsRequired = 70, raceName = "Water Elementals"},
 
	["earth elemental"] = {questStarted = 1523, questStorage = 65013, creatureStorage = 15036, killsRequired = 70, raceName = "Earth Elementals"},
	["jagged earth elemental"] = {questStarted = 1523, questStorage = 65013, creatureStorage = 15037, killsRequired = 70, raceName = "Earth Elementals"},
	["massive earth elemental"] = {questStarted = 1523, questStorage = 65013, creatureStorage = 15038, killsRequired = 70, raceName = "Earth Elementals"},
	["muddy earth elemental"] = {questStarted = 1523, questStorage = 65013, creatureStorage = 15039, killsRequired = 70, raceName = "Earth Elementals"},
 
	["energy elemental"] = {questStarted = 1524, questStorage = 65014, creatureStorage = 15040, killsRequired = 70, raceName = "Energy Elementals"},
	["charged energy elemental"] = {questStarted = 1524, questStorage = 65014, creatureStorage = 15041, killsRequired = 70, raceName = "Energy Elementals"},
	["massive energy elemental"] = {questStarted = 1524, questStorage = 65014, creatureStorage = 15042, killsRequired = 70, raceName = "Energy Elementals"},
	["overcharged energy elemental"] = {questStarted = 1524, questStorage = 65014, creatureStorage = 15043, killsRequired = 70, raceName = "Energy Elementals"},
 
	["fire elemental"] = {questStarted = 1525, questStorage = 65015, creatureStorage = 15044, killsRequired = 70, raceName = "Fire Elementals"},
	["blazing fire elemental"] = {questStarted = 1525, questStorage = 65015, creatureStorage = 15045, killsRequired = 70, raceName = "Fire Elementals"},
	["blistering fire elemental"] = {questStarted = 1525, questStorage = 65015, creatureStorage = 15046, killsRequired = 70, raceName = "Fire Elementals"},
	["massive fire elemental"] = {questStarted = 1525, questStorage = 65015, creatureStorage = 15047, killsRequired = 70, raceName = "Fire Elementals"},
 
	["mutated rat"] = {questStarted = 1526, questStorage = 65016, creatureStorage = 15048, killsRequired = 200, raceName = "Mutated Rats"},
 
	["giant spider"] = {questStarted = 1527, questStorage = 65017, creatureStorage = 15049, killsRequired = 500, raceName = "Giant Spiders"},
 
	["hydra"] = {questStarted = 1528, questStorage = 65018, creatureStorage = 15050, killsRequired = 2000, raceName = "Hydras"},
 
	["sea serpent"] = {questStarted = 1529, questStorage = 65019, creatureStorage = 15051, killsRequired = 2000, raceName = "Sea Serpents"},
 
	["behemoth"] = {questStarted = 1530, questStorage = 65020, creatureStorage = 15052, killsRequired = 2000, raceName = "Behemoths"},
 
	["serpent spawn"] = {questStarted = 1531, questStorage = 65021, creatureStorage = 15053, killsRequired = 1500, raceName = "Serpents Spawn"},
 
	["green djinn"] = {questStarted = 1532, questStorage = 65022, creatureStorage = 15054, killsRequired = 500, raceName = "Green Djinns"},
	["efreet"] = {questStarted = 1532, questStorage = 65022, creatureStorage = 15055, killsRequired = 500, raceName = "Green Djinns"},
 
	["blue djinn"] = {questStarted = 1533, questStorage = 65023, creatureStorage = 15056, killsRequired = 500, raceName = "Blue Djinns"},
	["marid"] = {questStarted = 1533, questStorage = 65023, creatureStorage = 15057, killsRequired = 500, raceName = "Blue Djinns"},
 
	["pirate buccaneer"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15058, killsRequired = 3000, raceName = "Pirates"},
	["pirate corsair"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15059, killsRequired = 3000, raceName = "Pirates"},
	["pirate cutthroat"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15060, killsRequired = 3000, raceName = "Pirates"},
	["pirate ghost"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15061, killsRequired = 3000, raceName = "Pirates"},
	["pirate marauder"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15062, killsRequired = 3000, raceName = "Pirates"},
	["pirate skeleton"] = {questStarted = 1534, questStorage = 65024, creatureStorage = 15063, killsRequired = 3000, raceName = "Pirates"},
 
	["pirate buccaneer"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15064, killsRequired = 3000, raceName = "Pirates"},
	["pirate corsair"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15065, killsRequired = 3000, raceName = "Pirates"},
	["pirate cutthroat"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15066, killsRequired = 3000, raceName = "Pirates"},
	["pirate ghost"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15067, killsRequired = 3000, raceName = "Pirates"},
	["pirate marauder"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15068, killsRequired = 3000, raceName = "Pirates"},
	["pirate skeleton"] = {questStarted = 1535, questStorage = 65025, creatureStorage = 15069, killsRequired = 3000, raceName = "Pirates"},
 
	["minotaur"] = {questStarted = 1536, questStorage = 65026, creatureStorage = 15070, killsRequired = 5000, raceName = "Minotaurs"},
 
	["necromancer"] = {questStarted = 1537, questStorage = 65027, creatureStorage = 15071, killsRequired = 4000, raceName = "Magicians"},
	["priestess"] = {questStarted = 1537, questStorage = 65027, creatureStorage = 15072, killsRequired = 4000, raceName = "Magicians"},
 
	["necromancer"] = {questStarted = 1538, questStorage = 65028, creatureStorage = 15073, killsRequired = 1000, raceName = "Magicians"},
	["priestess"] = {questStarted = 1538, questStorage = 65028, creatureStorage = 15074, killsRequired = 1000, raceName = "Magicians"},
 
	["demon"] = {questStarted = 1539, questStorage = 65029, creatureStorage = 15075, killsRequired = 6666, raceName = "Demons"}
}
 
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

Paste this in login.lua:
Lua:
	registerCreatureEvent(cid, "KillingInTheNameOf")

And this in creaturescripts.xml:
XML:
	<event type="kill" name="KillingInTheNameOf" event="script" value="killinginthenameof.lua"/>

Now, go to data/npc/ and create a file called Grizzly Adams.xml and paste this:
XML:
<?xml version="1.0" encoding="UTF-8"?>

<npc name="Grizzly Adams" script="data/npc/scripts/killinginthenameof.lua" access="3" walkinterval="2000" lookdir="2">
	<mana now="800" max="800"/>
	<health now="200" max="200"/>
<look type="144" head="97" body="97" legs="94" feet="97" addons="3"/>
</npc>

Go to data/npc/scripts/ and create a file called killinginthenameof.lua and paste this:
Lua:
local THESNAPPER_POSITION = {x = 100, y = 100, z = 7}
local HIDE_POSITION = {x = 100, y = 100, z = 7}
local THEBLOODTUSK_POSITION = {x = 100, y = 100, z = 7}
local SHARDHEAD_POSITION = {x = 100, y = 100, z = 7}
local THUL_POSITION = {x = 100, y = 100, z = 7}
local ESMERALDA_POSITION = {x = 100, y = 100, z = 7}
local THEOLDWIDOW_POSITION = {x = 100, y = 100, z = 7}
local THEMANY_POSITION = {x = 100, y = 100, z = 7}
local LEVIATHAN_POSITION = {x = 100, y = 100, z = 7}
local STONECRACKER_POSITION = {x = 100, y = 100, z = 7}
local THENOXIUSSPAWN_POSITION = {x = 100, y = 100, z = 7}
local MERIKHTHESLAUGHTERER_POSITION = {x = 100, y = 100, z = 7}
local FAHIMTHEWISE_POSITION = {x = 100, y = 100, z = 7}
local RANDOMPIRATEBOSS_POSITION = {x = 100, y = 100, z = 7}
local THEHORNEDFOX_POSITION = {x = 100, y = 100, z = 7}
local NECROPHARUS_POSITION = {x = 100, y = 100, z = 7}


local tasks =
{
	[1] = {questStarted = 1510, questStorage = 65000, killsRequired = 100, raceName = "Trolls", rewards = {{enable = true, type = "exp", values = 200}, {enable = true, type = "money", values = 200}}},
 
	[2] = {questStarted = 1511, questStorage = 65001, killsRequired = 150, raceName = "Goblins", rewards = {{enable = true, type = "exp", values = 300}, {enable = true, type = "money", values = 250}}},
 
	[3] = {questStarted = 1512, questStorage = 65002, killsRequired = 300, raceName = "Rotworms", rewards = {{enable = true, type = "exp", values = 1000}, {enable = true, type = "money", values = 400}}},
 
	[4] = {questStarted = 1513, questStorage = 65003, killsRequired = 500, raceName = "Cyclops", rewards = {{enable = true, type = "exp", values = 3000}, {enable = true, type = "money", values = 800}}},
 
	[5] = {questStarted = 1514, questStorage = 65004, killsRequired = 300, raceName = "Crocodiles", rewards = {{enable = true, type = "exp", values = 800}, {enable = true, type = "boss", values = THESNAPPER_POSITION}, {enable = true, type = "points", values = 7}}},
 
	[6] = {questStarted = 1515, questStorage = 65005, killsRequired = 300, raceName = "Tarantulas", rewards = {{enable = true, type = "money", values = 1500}, {enable = true, type = "boss", values = HIDE_POSITION}, {enable = true, type = "points", values = 2}}},
 
	[7] = {questStarted = 1516, questStorage = 65006, killsRequired = 150, raceName = "Carniphilas", rewards = {{enable = true, type = "exp", values = 1500}, {enable = true, type = "points", values = 1}}},
 
	[8] = {questStarted = 1517, questStorage = 65007, killsRequired = 200, raceName = "Stone Golems", rewards = {{enable = true, type = "exp", values = 2000}, {enable = true, type = "points", values = 1}}},
 
	[9] = {questStarted = 1518, questStorage = 65008, killsRequired = 300, raceName = "Mammoths", rewards = {{enable = true, type = "exp", values = 4000}, {enable = true, type = "boss", values = THEBLOODTUSK_POSITION}, {enable = true, type = "points", values = 2}}},
 
	[10] = {questStarted = 1519, questStorage = 65009, killsRequired = 300, raceName = "Ice Golems", rewards = {{enable = true, type = "exp", values = 15000}, {enable = true, type = "boss", values = SHARDHEAD_POSITION}, {enable = true, type = "points", values = 2}}},
 
	[11] = {questStarted = 1520, questStorage = 65010, killsRequired = 300, raceName = "Quaras Scout", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "points", values = 1}}},
 
	[12] = {questStarted = 1521, questStorage = 65011, killsRequired = 300, raceName = "Quaras", rewards = {{enable = true, type = "exp", values = 12000}, {enable = true, type = "boss", values = THUL_POSITION}, {enable = true, type = "points", values = 2}}},
 
	[13] = {questStarted = 1522, questStorage = 65012, killsRequired = 70, raceName = "Water Elementals", rewards = {{enable = true, type = "exp", values = 7000}, {enable = true, type = "points", values = 1}}},
 
	[14] = {questStarted = 1523, questStorage = 65013, killsRequired = 70, raceName = "Earth Elementals", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "points", values = 1}}},
 
	[15] = {questStarted = 1524, questStorage = 65014, killsRequired = 70, raceName = "Energy Elementals", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "points", values = 1}}},
 
	[16] = {questStarted = 1525, questStorage = 65015, killsRequired = 70, raceName = "Fire Elementals", rewards = {{enable = true, type = "exp", values = 7000}, {enable = true, type = "points", values = 1}}},
 
	[17] = {questStarted = 1526, questStorage = 65016, killsRequired = 200, raceName = "Mutated Rats", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "boss", values = ESMERALDA_POSITION}, {enable = true, type = "points", values = 2}}},
 
	[18] = {questStarted = 1527, questStorage = 65017, killsRequired = 500, raceName = "Giant Spiders", rewards = {{enable = true, type = "exp", values = 5000}, {enable = true, type = "boss", values = THEOLDWIDOW_POSITION}, {enable = true, type = "points", values = 2}}},
 
	[19] = {questStarted = 1528, questStorage = 65018, killsRequired = 2000, raceName = "Hydras", rewards = {{enable = true, type = "boss", values = THEMANY_POSITION}, {enable = true, type = "points", values = 4}}},
 
	[20] = {questStarted = 1529, questStorage = 65019, killsRequired = 2000, raceName = "Sea Serpents", rewards = {{enable = true, type = "boss", values = LEVIATHAN_POSITION}, {enable = true, type = "points", values = 4}}},
 
	[21] = {questStarted = 1530, questStorage = 65020, killsRequired = 2000, raceName = "Behemoths", rewards = {{enable = true, type = "boss", values = STONECRACKER_POSITION}, {enable = true, type = "points", values = 4}}},
 
	[22] = {questStarted = 1531, questStorage = 65021, killsRequired = 1500, raceName = "Serpents Spawn", rewards = {{enable = true, type = "teleport", values = THENOXIUSSPAWN_POSITION}, {enable = true, type = "points", values = 4}}},
 
	[23] = {questStarted = 1532, questStorage = 65022, killsRequired = 500, raceName = "Green Djinns", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "money", values = 5000}, {enable = true, type = "boss", values = MERIKHTHESLAUGHTERER_POSITION}}},
 
	[24] = {questStarted = 1533, questStorage = 65023, killsRequired = 500, raceName = "Blue Djinns", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "money", values = 5000}, {enable = true, type = "boss", values = FAHIMTHEWISE_POSITION}}},
 
	[25] = {questStarted = 1534, questStorage = 65024, killsRequired = 3000, raceName = "Pirates1", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "money", values = 5000}, {enable = true, type = "boss", values = RANDOMPIRATEBOSS_POSITION}}},
 
	[26] = {questStarted = 1535, questStorage = 65025, killsRequired = 3000, raceName = "Pirates2", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "money", values = 5000}}},
 
	[27] = {questStarted = 1536, questStorage = 65026, killsRequired = 5000, raceName = "Minotaurs", rewards = {{enable = true, type = "boss", values = THEHORNEDFOX_POSITION}}},
 
	[28] = {questStarted = 1537, questStorage = 65027, killsRequired = 4000, raceName = "Magicians1", rewards = {{enable = true, type = "boss", values = NECROPHARUS_POSITION}}},
 
	[29] = {questStarted = 1538, questStorage = 65028, killsRequired = 1000, raceName = "Magicians2", rewards = {{enable = true, type = "exp", values = 40000}}},
 
	[30] = {questStarted = 1539, questStorage = 65029, killsRequired = 6666, raceName = "Demons", rewards = {{enable = true, type = "storage", values = {65535, 1}}}}
}

local rankStorage = 32150
local choose = {}
 
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local voc = {}
 
function onCreatureAppear(cid)                          npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                                      npcHandler:onThink() end

function getTasksStarted(cid)
	local tmp = {}
	for k, v in pairs(tasks) do
		if getCreatureStorage(cid, v.questStarted) == 1 then
			table.insert(tmp, k)
		end
	end
	return tmp
end

function getTaskByName(name)
	for k, v in pairs(tasks) do
		if v.raceName:lower() == name:lower() then
			return k
		end
	end
	return false
end
 
function creatureSayCallback(cid, type, msg)
 
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
	if msgcontains(msg, "task") then
		selfSay("There you can see the following tasks, please tell me the number of the task that you want to do.", cid)
		local text = "Number  -  Name"
		for i = 1, table.maxn(tasks) do
			text = text .. "\n" .. i .. "  -  " .. tasks[i].raceName .. (getCreatureStorage(cid, tasks[i].questStarted) == 2 and " [Done]" or "")
		end
		doShowTextDialog(cid, 5956, text)
 
	elseif tasks[tonumber(msg)] then
		msg = tonumber(msg)
		if getCreatureStorage(cid, tasks[msg].questStarted) == 1 then
			selfSay("You are already making this task.", cid)
			talkState[talkUser] = 0
			return true
		end
		if getCreatureStorage(cid, tasks[msg].questStarted) == 2 then
			selfSay("You already finished this task.", cid)
			talkState[talkUser] = 0
			return true
		end
		if tasks[msg].level and getPlayerLevel(cid) < tasks[msg].level then
			selfSay("You need level " .. tasks[msg].level .. " or higher to make this task.", cid)
			talkState[talkUser] = 0
			return true
		end
		selfSay("Are you sure that do you want to start the task number " .. msg .. "?. In this task you will need to defeat " .. tasks[msg].killsRequired .. " " .. tasks[msg].raceName .. ".", cid)
		choose[cid] = msg
		talkState[talkUser] = 1
	elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
		doCreatureSetStorage(cid, tasks[choose[cid]].questStarted, 1)
		selfSay("You have started the task number " .. choose[cid] .. ", remember... in this task you will need to defeat " .. tasks[choose[cid]].killsRequired .. " " .. tasks[choose[cid]].raceName .. ". Good luck!", cid)
		talkState[talkUser] = 0
 
	elseif msgcontains(msg, "report") then
		local t = getTasksStarted(cid)
		local response = "You are currently making " .. (#t > 1 and "these" or "this") .. " task" .. (#t > 1 and "s" or "") .. ":\n"
		if table.maxn(t) > 0 then
			for _, tsk in ipairs(t) do
				if getCreatureStorage(cid, tasks[tsk].questStorage) < 0 then doCreatureSetStorage(cid, tasks[tsk].questStorage, 0) end
				response = response .. "     Name: " .. tasks[tsk].raceName .. "     Kills: " .. getCreatureStorage(cid, tasks[tsk].questStorage) .. " - " .. tasks[tsk].killsRequired .. ".\n"
			end
			response = response .. "Please tell me the name of the task that do you want to report."
			selfSay(response, cid)
		else
			selfSay("You need to start at least one task first.", cid)
		end
	elseif getTaskByName(msg) then
		local t = getTaskByName(msg)
		if getCreatureStorage(cid, tasks[t].questStarted) == 2 then
			return selfSay("You already finished this task.", cid)
		end

		if getCreatureStorage(cid, tasks[t].questStarted) < 1 then
			return selfSay("You don't have started this task.", cid)
		end

		if tasks[t].killsRequired > getCreatureStorage(cid, tasks[t].questStorage) then
			return selfSay("Current " .. getCreatureStorage(cid, tasks[t].questStorage) .. " " .. tasks[t].raceName .. " killed, you need to kill " .. tasks[t].killsRequired .. ".", cid)
		end
	
		for i = 1, table.maxn(tasks[t].rewards) do
			if(tasks[t].rewards[i].enable) then
				if isInArray({"boss", "teleport", 1}, tasks[t].rewards[i].type) then
					doTeleportThing(cid, tasks[t].rewards[i].values)
				elseif isInArray({"exp", "experience", 2}, tasks[t].rewards[i].type) then
					doPlayerAddExperience(cid, tasks[t].rewards[i].values)
				elseif isInArray({"item", 3}, tasks[t].rewards[i].type) then
					doPlayerAddItem(cid, v.rewards[i].values[1], tasks[t].rewards[i].values[2])
				elseif isInArray({"money", 4}, tasks[t].rewards[i].type) then
					doPlayerAddMoney(cid, tasks[t].rewards[i].values)
				elseif isInArray({"storage", "stor", 5}, tasks[t].rewards[i].type) then
					doCreatureSetStorage(cid, tasks[t].rewards[i].values[1], tasks[t].rewards[i].values[2])
				elseif isInArray({"points", "rank", 2}, tasks[t].rewards[i].type) then
					doCreatureSetStorage(cid, rankStorage, getCreatureStorage(cid, rankStorage) + tasks[t].rewards[i].values)
				else
					print("[Warning - Error::Killing in the name of::Tasks config] Bad reward type: " .. tasks[t].rewards[i].type .. ", reward could not be loaded.")
				end
			end
		end
		local rank = getCreatureStorage(cid, rankStorage)
		selfSay("Great!... you have finished the task number " .. t .. "" .. (rank > 4 and ", you are a " or "") .. "" .. (((rank > 4 and rank < 10) and ("Huntsman") or (rank > 9 and rank < 20) and ("Ranger") or (rank > 19 and rank < 30) and ("Big Game Hunter") or (rank > 29 and rank < 50) and ("Trophy Hunter") or (rank > 49) and ("Elite Hunter")) or "") .. ". Good job.", cid)
		doCreatureSetStorage(cid, tasks[t].questStarted, 2)
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

IMPORTANT!
If you've been using my first script and you want to implement this new script, to prevent players can repeat finished tasks change:
This:
Lua:
		if getCreatureStorage(cid, tasks[msg].questStarted) == 2 then
			selfSay("You already finished this task.", cid)
			talkState[talkUser] = 0
			can = false
		end

For this:
Lua:
		local storage = 64521 --same storage used in other script
		if getCreatureStorage(cid, tasks[msg].questStarted) == 2 or getCreatureStorage(cid, storage) <= msg then
			selfSay("You already finished this task.", cid)
			talkState[talkUser] = 0
			can = false
		end

How to config?
Lua:
-- Troll task example
[1] = {questStarted = 1510, questStorage = 65000, killsRequired = 100, raceName = "Trolls", rewards = {{enable = true, type = "exp", values = 200}, {enable = true, type = "money", values = 200}}},
Code:
[B]- [1][/B] =  Number of task.
[B]- quesStarted[/B] = Storage to check if the task has been started.
[B]- questStorage[/B] = Storage to check of player has killed the monter the needed times.
[B]- killsRequired[/B] = How many times the player needs to kill the creature.
[B]- raceName[/B] = Monster's race name.
[B]- rewards[/B] = Here you can config how many rewards will obtain the player in each task.
	--[[
		[B]enable[/B] = Here you can enable/disable the reward, use [COLOR="seagreen"][B]true[/B][/COLOR] or [COLOR="red"][B]false[/B][/COLOR].
		[B]type[/B] = Here you declare the reward type.
			--[[
				[B]boss[/B] or [b]1[/B] = Player will be teleported to the boss position.
				[B]exp[/B] or [b]2[/B] = Player will get experience.
				[B]item[/B] or [b]3[/B] = Player will get an item.
				[B]money[/B] or [b]4[/B] = Player will get money.
				[B]storage[/B] or [b]5[/B] = Player will get a storage value.
				[B]points[/B] or [b]6[/B] = Player will get points(storage value) for the rank.
			]]--
		[B]values[/B] = Here you declare the values for the reward type.
			--[[
				[B]Use a position for "boss", Ex: {x = 100, y = 100, z = 7}.
				Use a number value for "exp", Ex: 1000.
				Use a table value with two numbers for "item", the first value will be the item id and the second value will be the count, Ex: {2160, 10}.[/B]
				Use a number value for "money", Ex: 1000.
				Use a table value with two numbers for "storage", the first value will be the storage value and the second value will be the count, Ex: {10500, 1}.
				Use a number value for "points", Ex: 5.[/B]
			]]--
	]]--
--Only in the creaturescript.
[B]- creatureStorage[/B] = Storage to check the kills for each creature.


How it works?
Talk with the npc:
- Player: Hi
- Grizzly Adams: Hello Player!
- Player: Task
- Grizzly Adams: There you can see the following tasks, please tell me the number or the name of the task that you want to do.
[Show dialog with all tasks]
- Player: 5
- Grizzly Adams: Are you sure that do you want to start the task number 5?, in this task you will need to defeat 300 Crocodiles.
- Player: yes
- Grizzly Adams: You have started the task number 5, remember... in this task you will need to defeat 300 Crocodiles. Good luck!

- Player: Hi
- Grizzly Adams: Hello Player!
- Player: Report
(Here grizzly adams show all tasks started by the player)
- Grizzly Adams: Please tell me the name of the task that do you want to report.
- Player: Trolls
- Grizzly Adams: Great!... you have finished the task number n. Good job.

-- If you have te required points for a rank.

- Player: Hi
- Grizzly Adams: Hello Player!
- Player: Trolls
- Grizzly Adams: Great!... You have finished the task number 5, you are a "Huntsman". Good job.
 
Last edited:
It's really working right now?
I'll test it.

Nice job.

---------
- Grizzly Adams: Great!... you have finished the task number n. Good job.

Number N ? o.o'
 
It's really working right now?
I'll test it.

Nice job.

---------
- Grizzly Adams: Great!... you have finished the task number n. Good job.

Number N ? o.o'

That is the example, he will say ("taks number 5") for example
 
local THESNAPPER_POSITION = {x = 100, y = 100, z = 7}
local HIDE_POSITION = {x = 100, y = 100, z = 7}
local THEBLOODTUSK_POSITION = {x = 100, y = 100, z = 7}
local SHARDHEAD_POSITION = {x = 100, y = 100, z = 7}
local THUL_POSITION = {x = 100, y = 100, z = 7}
local ESMERALDA_POSITION = {x = 100, y = 100, z = 7}
local THEOLDWIDOW_POSITION = {x = 100, y = 100, z = 7}
local THEMANY_POSITION = {x = 100, y = 100, z = 7}
local LEVIATHAN_POSITION = {x = 100, y = 100, z = 7}
local STONECRACKER_POSITION = {x = 100, y = 100, z = 7}
local THENOXIUSSPAWN_POSITION = {x = 100, y = 100, z = 7}
local MERIKHTHESLAUGHTERER_POSITION = {x = 100, y = 100, z = 7}
local FAHIMTHEWISE_POSITION = {x = 100, y = 100, z = 7}
local RANDOMPIRATEBOSS_POSITION = {x = 100, y = 100, z = 7}
local THEHORNEDFOX_POSITION = {x = 100, y = 100, z = 7}
local NECROPHARUS_POSITION = {x = 100, y = 100, z = 7}

Here is summon position? where i config player position ? and one player per time kill boss?
 
Quest log [99% done.]

Here is the tutorial to get monster's counting in quest log:
Click here.

If you use dev 0.4 and/or get error in compilation(tested in rev3884).

Replace all
[cpp]atoi(temp.c_str())[/cpp]

to
[cpp]temp[/cpp]
Lua:
<quest name="Killing in the Name of..." startstorageid="33150" startstoragevalue="1">
	    <mission name="Paw and Fur - Hunting Elite" storageid="33150" startvalue="0" endvalue="2">
            <missionstate id="1" description="You joined the 'Paw and Fur - Hunting Elite'. Ask Grizzly Adams for some hunting tasks. You already completed |STORAGE:32150| of them."/>
        </mission>
	    <mission name="Paw and Fur - Rank" storageid="32150" startvalue="1" endvalue="6">
            <missionstate id="1" description="You have been promoted to the rank of a 'Huntsman' in the 'Paw and Fur - Hunting Elite'."/>
            <missionstate id="2" description="You have been promoted to the rank of a 'Ranger' in the 'Paw and Fur - Hunting Elite'."/>
            <missionstate id="3" description="You have been promoted to the rank of a 'Big Game Hunter' in the 'Paw and Fur - Hunting Elite'."/>
            <missionstate id="4" description="You have been promoted to the rank of a 'Trophy Hunter' in the 'Paw and Fur - Hunting Elite'."/>
            <missionstate id="5" description="You have been promoted to the rank 'Elite Hunter' in the 'Paw and fur - Hunting Elite'. This is the highest rank you can get."/>
	      </mission>


	    <mission name="Paw and Fur: Trolls" storageid="1510" startvalue="0" endvalue="2">
            <missionstate id="1" description="You already hunted |STORAGE:65000| trolls. You are supposed to kill 100 in total."/>
            <missionstate id="2" description="You killed 100 trolls."/>
	</mission>
	<mission name="Paw and Fur: Goblins" storageid="1511" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65001| goblins. You are supposed to kill 150 in total."/>
		<missionstate id="2" description="You killed 150 goblins."/>
	</mission>
	<mission name="Paw and Fur: Rotworms" storageid="1512" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65002| rotworms. You are supposed to kill 300 in total."/>
		<missionstate id="2" description="You killed 300 rotworms."/>
	</mission>
	<mission name="Paw and Fur: Cyclops" storageid="1513" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65003| cyclops. You are supposed to kill 500 in total."/>
		<missionstate id="2" description="You killed 500 cyclops."/>
	</mission>
	<mission name="Paw and Fur: Crocodiles" storageid="1514" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65004| crocodiles. You are supposed to kill 300 in total."/>
		<missionstate id="2" description="You killed 300 crocodiles."/>
	</mission>
	<mission name="Paw and Fur: Tarantulas" storageid="1515" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65005| tarantulas. You are supposed to kill 300 in total."/>
		<missionstate id="2" description="You killed 300 tarantulas."/>
	</mission>
	<mission name="Paw and Fur: Carniphilas" storageid="1516" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65006| carniphilas. You are supposed to kill 150 in total."/>
		<missionstate id="2" description="You killed 150 carniphilas."/>
	</mission>
	<mission name="Paw and Fur: Stone Golems" storageid="1517" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65007| stone golems. You are supposed to kill 200 in total."/>
		<missionstate id="2" description="You killed 200 stone golems."/>
	</mission>
	<mission name="Paw and Fur: Mammoths" storageid="1518" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65008| mammoths. You are supposed to kill 300 in total."/>
		<missionstate id="2" description="You killed 300 mammoths."/>
	</mission>
	<mission name="Paw and Fur: Ice Golems" storageid="1519" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65009| ice golems. You are supposed to kill 300 in total."/>
		<missionstate id="2" description="You killed 300 ice golems."/>
	</mission>
	<mission name="Paw and Fur: Quara Scouts" storageid="1520" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65010| quara scouts. You are supposed to kill 300 in total."/>
		<missionstate id="2" description="You killed 300 quara scouts."/>
	</mission>
	<mission name="Paw and Fur: Quaras" storageid="1521" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65011| quaras. You are supposed to kill 300 in total."/>
		<missionstate id="2" description="You killed 300 quaras."/>
	</mission>
	<mission name="Paw and Fur: Water Elementals" storageid="1522" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65012| water elementals. You are supposed to kill 70 in total."/>
		<missionstate id="2" description="You killed 70 water elementals."/>
	</mission>
	<mission name="Paw and Fur: Earth Elementals" storageid="1523" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65013| earth elementals. You are supposed to kill 70 in total."/>
		<missionstate id="2" description="You killed 70 earth elementals."/>
	</mission>
	<mission name="Paw and Fur: Energy Elementals" storageid="1524" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65014| energy elementals. You are supposed to kill 70 in total."/>
		<missionstate id="2" description="You killed 70 energy elementals."/>
	</mission>
	<mission name="Paw and Fur: Fire Elementals" storageid="1525" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65015| fire elementals. You are supposed to kill 70 in total."/>
		<missionstate id="2" description="You killed 70 fire elementals."/>
	</mission>
	<mission name="Paw and Fur: Mutated Rats" storageid="1526" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65016| mutated rats. You are supposed to kill 200 in total."/>
		<missionstate id="2" description="You killed 200 mutated rats."/>
	</mission>
	<mission name="Paw and Fur: Giant Spiders" storageid="1527" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65017| giant spiders. You are supposed to kill 500 in total."/>
		<missionstate id="2" description="You killed 500 giant spiders."/>
	</mission>
	<mission name="Paw and Fur: Hydras" storageid="1528" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65018| hydras. You are supposed to kill 2000 in total."/>
		<missionstate id="2" description="You killed 2000 hydras."/>
	</mission>
	<mission name="Paw and Fur: Sea Serpents" storageid="1529" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65019| sea serpents. You are supposed to kill 2000 in total."/>
		<missionstate id="2" description="You killed 2000 sea serpents."/>
	</mission>
	<mission name="Paw and Fur: Behemoths" storageid="1530" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65020| behemoths. You are supposed to kill 2000 in total."/>
		<missionstate id="2" description="You killed 2000 behemoths."/>
	</mission>
	<mission name="Paw and Fur: Serpents Spawns" storageid="1531" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65021| serpent spawns. You are supposed to kill 1500 in total."/>
		<missionstate id="2" description="You killed 1500 serpents spawns."/>
	</mission>
	<mission name="Paw and Fur: Green Djinns" storageid="1532" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65022| green djins. You are supposed to kill 500 in total."/>
		<missionstate id="2" description="You killed 500 green djinns."/>
	</mission>
	<mission name="Paw and Fur: Blue Djinns" storageid="1533" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65023| blue djins. You are supposed to kill 500 in total."/>
		<missionstate id="2" description="You killed 500 blue djinns."/>
	</mission>
	<mission name="Paw and Fur: Pirates" storageid="1534" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65024| pirates. You are supposed to kill 3000 in total."/>
		<missionstate id="2" description="You killed 3000 pirates."/>
	</mission>
	<mission name="Paw and Fur: Pirates" storageid="1535" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65025| pirates. You are supposed to kill 3000 in total."/>
		<missionstate id="2" description="You killed 3000 pirates."/>
	</mission>
	<mission name="Paw and Fur: Minotaurs" storageid="1536" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65026| minotaurs. You are supposed to kill 5000 in total."/>
		<missionstate id="2" description="You killed 5000 minotaurs."/>
	</mission>
	<mission name="Paw and Fur: Necromancers" storageid="1537" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65027| necromancers. You are supposed to kill 4000 in total."/>
		<missionstate id="2" description="You killed 4000 necromancers."/>
	</mission>
	<mission name="Paw and Fur: Necromancers" storageid="1538" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65028| necromancers. You are supposed to kill 1000 in total."/>
		<missionstate id="2" description="You killed 1000 necromancers."/>
	</mission>
	<mission name="Paw and Fur: Demons" storageid="1539" startvalue="0" endvalue="2">
		<missionstate id="1" description="You already hunted |STORAGE:65029| demons. You are supposed to kill 6666 in total."/>
		<missionstate id="2" description="You killed 6666 demons."/>
	</mission>
</quest>




PS.:
**************************************
1. Missing 'choose task by name'.
and achievement's script that you said you would xD
**************************************
 
Last edited:
@xtremoxx,
It's the position that player will be teleported when say 'report'. You must set the boss room position.

@esfomeado,
It's working 100% with dev 0.4. If you find any bugs report in this Thread.
 
Hey, I'm in trouble
I killed some trolls, but is not counting on the list npc that I'm killing troll

Name: Trolls Kills: 0 - 100.
Name: Fire Elementals Kills: 0 - 70.
Name: Minotaurs Kills: 0 - 300.

not scoring, and not getting the reward
 
First, add this to your lib/function.lua:
Lua Code:
function isSummon(cid)
return getCreatureMaster(cid) ~= cid or false
end

with this you mean the lib that is located inside creaturescripts??
 
why i can't do twice one task ?
to example when i finish task with trolls and want to make it one more time i get message "you already finished this task"
 
Im if have killed 2/2 troll have only "22:32 Blood Missions: You are already making this task." and npc dont give me reward "22:31 2 Wolf defeated. Total [2/2] Trolls." I have good storage in npc and creaturescript
 
Im if have killed 2/2 troll have only "22:32 Blood Missions: You are already making this task." and npc dont give me reward "22:31 2 Wolf defeated. Total [2/2] Trolls." I have good storage in npc and creaturescript

What are you telling to the npc? you need to say the task name not the task number
 
Back
Top