CreatureEvent [CreatureEvent/Npc] Killing in the name of...

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by Darkhaos, Mar 16, 2011.

  1. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    • Now player can start task saying the task name and report task saying (Ex: "report trolls").

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

    Or this if you are using 0.4 DEV
    [lua]function isSummon(cid)
    return getCreatureMaster(cid) ~= nil
    end[/lua]

    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[/lua]

    Paste this in login.lua:
    [lua] registerCreatureEvent(cid, "KillingInTheNameOf")[/lua]

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

    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>[/xml]

    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 = {}

    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

    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 isInArray({"task", "tasks"}, msg:lower()) 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 = ""
    for i = 1, table.maxn(tasks) do
    text = text .. (text == "" and "" or "\n") .. i .. " - " .. tasks.raceName .. (getCreatureStorage(cid, tasks.questStarted) == 1 and " [...]" or getCreatureStorage(cid, tasks.questStarted) == 2 and " [x]" or "")
    end
    return doShowTextDialog(cid, 5956, text)

    elseif getTaskByName(msg) or tasks[tonumber(msg)] then
    msg = (getTaskByName(msg) or tonumber(msg))
    if getCreatureStorage(cid, tasks[msg].questStarted) == 1 then
    selfSay("You already started 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
    return true

    elseif msg:lower() == "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 say report and the name of the task that do you want to report, example: 'Report Trolls'."
    return selfSay(response, cid)
    else
    return selfSay("You need to start at least one task first.", cid)
    end
    elseif string.sub(msg:lower(), 0, 6) == "report" then
    local t = getTaskByName(string.sub(msg, 8, string.len(msg)))
    if not t then
    return selfSay("That task does not exists.", cid)
    end

    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.enable) then
    if isInArray({"boss", "teleport", 1}, tasks[t].rewards.type) then
    doTeleportThing(cid, tasks[t].rewards.values)
    elseif isInArray({"exp", "experience", 2}, tasks[t].rewards.type) then
    doPlayerAddExperience(cid, tasks[t].rewards.values)
    elseif isInArray({"item", 3}, tasks[t].rewards.type) then
    doPlayerAddItem(cid, v.rewards.values[1], tasks[t].rewards.values[2])
    elseif isInArray({"money", 4}, tasks[t].rewards.type) then
    doPlayerAddMoney(cid, tasks[t].rewards.values)
    elseif isInArray({"storage", "stor", 5}, tasks[t].rewards.type) then
    doCreatureSetStorage(cid, tasks[t].rewards.values[1], tasks[t].rewards.values[2])
    elseif isInArray({"points", "rank", 2}, tasks[t].rewards.type) then
    doCreatureSetStorage(cid, rankStorage, getCreatureStorage(cid, rankStorage) + tasks[t].rewards.values)
    else
    print("[Warning - Npc::KillingInTheNameOf] Wrong reward type: " .. (tasks[t].rewards.type or "nil") .. ", 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)
    return doCreatureSetStorage(cid, tasks[t].questStarted, 2)
    end
    return true
    end

    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:addModule(FocusModule:new())[/lua]

    [SIZE="5"][COLOR="red"]IMPORTANT![/COLOR][/SIZE]
    If you've been using my other 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[/lua]

    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
    [/lua]

    [SIZE="6"]H[/SIZE]ow 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}}},
    [/lua]
    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.

    [SIZE="6"]H[/SIZE]ow it works?
    Talk with the npc:
     
    Last edited: Jul 20, 2011
    tucom likes this.
  2. Cykotitan

    Cykotitan Experienced G'

    Joined:
    Nov 4, 2008
    Messages:
    16,897
    alternative version:

    quests.xml

    000-constant.lua:
    [lua]tasks = {
    ['demon'] = {storage = 14006, amount = 6666},
    ['crocodile'] = {storage = 14007, amount = 300},
    ['tarantula'] = {storage = 14008, amount = 300},
    ['carniphila'] = {storage = 14009, amount = 150},
    ['stone golem'] = {storage = 14010, amount = 200},
    ['mammoth'] = {storage = 14011, amount = 300},
    ['ice golem'] = {storage = 14012, amount = 300},
    ['quara constrictor scout'] = {storage = 14013, amount = 300},
    ['quara hydromancer scout'] = {storage = 14013, amount = 300},
    ['quara mantassin scout'] = {storage = 14013, amount = 300},
    ['quara pincher scout'] = {storage = 14013, amount = 300},
    ['quara predator scout'] = {storage = 14013, amount = 300},
    ['quara constrictor'] = {storage = 14014, amount = 300},
    ['quara hydromancer'] = {storage = 14014, amount = 300},
    ['quara mantassin'] = {storage = 14014, amount = 300},
    ['quara pincher'] = {storage = 14014, amount = 300},
    ['quara predator'] = {storage = 14014, amount = 300},
    ['water elemental'] = {storage = 14015, amount = 70},
    ['massive water elemental'] = {storage = 14015, amount = 70},
    ['earth elemental'] = {storage = 14016, amount = 70},
    ['massive earth elemental'] = {storage = 14016, amount = 70},
    ['energy elemental'] = {storage = 14017, amount = 70},
    ['massive energy elemental'] = {storage = 14017, amount = 70},
    ['fire elemental'] = {storage = 14018, amount = 70},
    ['massive fire elemental'] = {storage = 14018, amount = 70},
    ['mutated rat'] = {storage = 14019, amount = 200},
    ['giant spider'] = {storage = 14020, amount = 500},
    ['hydra'] = {storage = 14021, amount = 2000},
    ['sea serpent'] = {storage = 14001, amount = 2000},
    ['behemoth'] = {storage = 14022, amount = 2000},
    ['serpent spawn'] = {storage = 14002, amount = 1500},
    }[/lua]
    kill creaturescript:
    [lua]function onKill(cid, target, damage, flags)
    if damage == false or (flags and flags ~= 3) then
    return true
    else
    local f = getCreatureMaster(target)
    if f and f ~= target then
    return true
    end
    end

    local name = getCreatureName(target):lower()
    local a = tasks[name]
    if a then
    if getPlayerStorageValue(cid, 14500) ~= a.storage or getPlayerStorageValue(cid, a.storage) == a.amount then
    return true
    end

    local b = getPlayerStorageValue(cid, a.storage) + 1
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Task (".. name:upper() .."): " .. (b == a.amount and "Completed!" or b .." / ".. a.amount))
    setPlayerStorageValue(cid, a.storage, b)
    end
    return true
    end[/lua]
    npc.lua:
    [lua]function customCallbackOnBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks, shopWindow)
    local shopItem, npcHandler = nil, NpcHandler
    for _, item in ipairs(shopWindow) do
    if not item.subType then
    item.subType = (isItemFluidContainer(item.id) or isItemStackable(item.id)) and 0 or 1
    end
    if item.id == itemid and item.subType == subType then
    shopItem = item
    break
    end
    end

    if(shopItem == nil) then
    error("[ShopModule.onBuy]", "Item not found on shopItems list")
    return false
    end

    if(shopItem.buy < 0) then
    error("[ShopModule.onSell]", "Attempt to purchase an item which is only sellable")
    return false
    end

    local backpack, totalCost = 1988, amount * shopItem.buy
    if(inBackpacks) then
    totalCost = isItemStackable(itemid) == TRUE and totalCost + 20 or totalCost + (math.max(1, math.floor(amount / getContainerCapById(backpack))) * 20)
    end

    if(getPlayerMoney(cid) < totalCost) then
    doPlayerSendCancel(cid, npcHandler:parseMessage(npcHandler:getMessage(MESSAGE_NEEDMONEY), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = totalCost, [TAG_ITEMNAME] = shopItem.name}))
    return false
    end

    local a, b = doNpcSellItem(cid, itemid, amount, shopItem.subType or isItemFluidContainer(itemid) and 0 or 1, ignoreCap, inBackpacks, backpack)
    if(a < amount) then
    local msgId = MESSAGE_NEEDMORESPACE
    if(a == 0) then
    msgId = MESSAGE_NEEDSPACE
    end

    doPlayerSendCancel(cid, npcHandler:parseMessage(npcHandler:getMessage(msgId), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = totalCost, [TAG_ITEMNAME] = shopItem.name, [TAG_ITEMCOUNT] = a}))

    if(a > 0) then
    doPlayerRemoveMoney(cid, ((a * shopItem.buy) + (b * 20)))
    return true
    end

    return false
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, npcHandler:parseMessage(npcHandler:getMessage(MESSAGE_BOUGHT), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = totalCost, [TAG_ITEMNAME] = shopItem.name}))
    doPlayerRemoveMoney(cid, totalCost)

    return true
    end

    function customCallbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks, shopWindow)
    local shopItem, npcHandler, subType = nil, NpcHandler, subType or 0
    for _, item in ipairs(shopWindow) do
    if item.id == itemid and ((item.subType or 0) == subType or not isItemFluidContainer(itemid)) then
    shopItem = item
    break
    end
    end

    if(shopItem == nil) then
    error("[ShopModule.onBuy]", "Item not found on shopItems list")
    return false
    end

    if(not shopItem.sell or shopItem.sell < 0) then
    error("[ShopModule.onSell]", "Attempt to sell an item which is only buyable")
    return false
    end

    if(doPlayerRemoveItem(cid, itemid, amount, isItemFluidContainer(itemid) == TRUE and subType or isItemStackable(itemid) == TRUE and amount or 1) == TRUE) then
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, npcHandler:parseMessage(npcHandler:getMessage(MESSAGE_SOLD), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = amount * shopItem.sell, [TAG_ITEMNAME] = shopItem.name}))
    doPlayerAddMoney(cid, amount * shopItem.sell)

    return true
    end
    doPlayerSendCancel(cid, npcHandler:parseMessage(npcHandler:getMessage(MESSAGE_NEEDITEM), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = amount * shopItem.sell, [TAG_ITEMNAME] = shopItem.name}))

    return false
    end[/lua]
    grizzly adams:
    [lua]local keywordHandler = KeywordHandler:new()
    local npcHandler = NpcHandler:new(keywordHandler)
    NpcSystem.parseParameters(npcHandler)
    local Topic = {}

    local data = {
    [14007] = {'crocodile', 'Happy hunting, old chap! Come back to me when you are through with your task.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u crocodiles. Come back to me when you are done.', 'Spiffing work, old chap. Now I have a special task for you. Recently several citizens of Port Hope have vanished. It is rumoured that they were killed by a crocodile. The people call it \'Snapper\'. Hunt down and kill that evil man eating beast.', 800, 1, 'Snapper', },
    [14008] = {'tarantula', 'Happy hunting, old chap! Come back to me when you are through with your task.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u tarantulas. Come back to me when you are done.', 'Nicely done! Now I shall assign you a special task. Rumour has it that there is an ancient and evil tarantula who preys on humans. She is called \'Hide\'. Track her down and kill her! Good luck, old chap.', 1500, 1, 'Hide'},
    [14009] = {'carniphila', 'Good show, old chap! Speak to me again when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u carniphilas. Come back to me when you are done.', 'That took some time, huh? Good hunting though. If you\'re up for another hunting mission just ask me for a {task}.', 1500, 1},
    [14010] = {'stone golem', 'Happy hunting, friend! When you have finished hunting, return here. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u stone golems. Come back to me when you are done.', 'Good show, old chap. If you\'re up for another hunting mission just ask me for a task.', 2000, 1},
    [14011] = {'mammoth', 'Happy hunting, friend! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u mammoths. Come back to me when you are done.', 'Jolly good job you did there, but now I have a special task for you. The citizens of Svargrond live in fear because of a frightfully bad-tempered mammoth they call \'Blood Tusk\'. Go there and put an end to him. Happy hunting!', 'Bloodtusk', 4000, 1},
    [14012] = {'ice golem', 'Happy hunting, friend! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u ice golems. Come back to me when you are done.', 'As i see it, you need more of a challenge! I have heard that there is an ice golem the hunters in Svargrond call \'Shardhead\'. He is an extremely dangerous example of his kind! I believe you are equal to the task, %s!', 15000, 1, 'Shardhead'},
    [14013] = {'quara constrictor scout', 'Happy hunting, friend! Come back to me when you are done hunting.', 'Alright, then you should go on with your task. You have already killed %u quara scouts in total. Come back to me when you are done.', 'Jolly good show! What a hunter! If you\'re up for another hunting mission just ask me for a {task}.', 10000, 1}, -- ?
    [14014] = {'quara constrictor', 'Happy hunting, friend! Come back to me when you are done hunting.', 'Alright, then you should go on with your task. You have already killed %u underwater quaras in total. Come back to me when you are done.', 'Superb work. However, there is something else I want you to do. It is said that there is a Quara general named \'Thul\' who is responsible for the attacks on Liberty Bay. Find him and kill him and bring peace to Liberty bay!', 12000, 1, 'Thul'}, -- OK
    [14015] = {'water elemental', 'Happy hunting, my old mocker! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u water elementals. Come back to me when you are done.', 'Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', 7000, 1},
    [14016] = {'earth elemental', 'Happy hunting, friend! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u earth elementals. Come back to me when you are done.', 'Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', 10000, 1},
    [14017] = {'energy elemental', 'Happy hunting, pal! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u energy elementals. Come back to me when you are done.', 'Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', 10000, 1},
    [14018] = {'fire elemental', 'Happy hunting, old friend! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u fire elementals. Come back to me when you are done.', 'Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', 7000, 1},
    [14019] = {'mutated rat', 'Happy hunting, old chap! Come back to me when you are done hunting. ', 'Alright, then stop dilly dallying here and go on with your task. You have already exterminated %u mutated rats. Come back to me when you are done.', {'Very good work, old chap. Lucky you are here - I have just been told of a task which is perfect for you. ...', 'The Yalaharians are having a spot of bother with a huge mutated rat. They call it \'Esmeralda\' and you should find her somewhere in the sewers. Good hunting!'}, 10000, 1, 'Esmeralda'}, -- OK
    [14020] = {'giant spider', 'Jolly good show! Come back to me when you are done hunting. ', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u giant spiders. Come back to me when you are done.', 'Well THAT was a hunt. Good job. Have you heared about \'The Old Widow\'? It must have a hideout. Try to find it and slay the beast.', 5000, 1, 'Old Widow'},
    [14021] = {'hydra', 'Happy hunting, old chap! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u hydras. Come back to me when you are done.', {'With Nornur the God of Fate as my witness, you are truly born to hunt. If anyone can do this task, you can! Listen: ...', 'It is said that the Lizards of Chor are training hydras for attacks against us. They have already successfully bred a hydra named \'The Many\'. Find her and kill her!'}, 0, 2, 'Many'},
    [14001] = {'sea serpent', 'Happy hunting, old chap! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u sea serpents. Come back to me when you are done.', 'Good job, old chap! Are you up for a challenge? Have you heard of the legendary sea serpent called \'The Leviathan\'? It must be somewhere near the spot you found. This is a true test of your hunting skills - find it and kill it. Good hunting!', 0, 2, 'Leviathan'},
    [14022] = {'behemoth', 'Happy hunting, old chap! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u behemoths. Come back to me when you are done.', 'Such marvellous hunting skills! Perhaps you can help me with this one. Have you heard about \'Stonecracker\'? ...', 0, 2, 'Stonecracker'}, -- OK
    [14002] = {'serpent spawn', 'Happy hunting, old chap! Come back to me when you are done hunting.', 'Alright, then return to your duties! Day light is a-wasting! You have already smashed %u serpent spawns. Come back to me when you are done.', 'My - you can be proud of yourself! However, you\'re not finished yet. There are rumours about a being called \'The Noxious Spawn\' which was seen deep down in the ruins of Banuta. Try to find its hideout.', 0, 2, 'Noxious Spawn'},
    }

    local curTask = 14500
    local points = 14501
    local rank = 14502
    local questLog = 14503
    local tiquanda = 14505
    local demodras = 14506

    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

    function greetCallback(cid)
    local cur, r, msg = getPlayerStorageValue(cid, points), getPlayerStorageValue(cid, rank)
    if cur >= 5 and r < 1 then
    msg = 'Welcome back |PLAYERNAME|. You have completed 5 tasks for our society. Ask me for a {promotion} to advance your rank!'
    elseif cur >= 10 and r < 2 then
    msg = 'Good to see you again |PLAYERNAME|. You have completed 10 tasks for our society. Ask me for a {promotion} to advance your rank!'
    elseif cur >= 20 and r < 3 then
    msg = 'Salutations |PLAYERNAME|. You have completed 20 tasks for our society. Ask me for a {promotion} to advance your rank!'
    elseif cur >= 30 and r < 4 then
    msg = 'Always good to welcome you back, |PLAYERNAME|. You have completed 30 tasks for our society. Ask me for a {promotion} to advance your rank!'
    elseif cur >= 50 and r < 5 then
    msg = 'By the gods....50 hunting tasks....this is astounding! Ask me for a {promotion} to advance your rank! And while you are here, I also have another {special} task for you.'
    else
    msg = 'Welcome back |PLAYERNAME|. What brings you here this time?'
    end
    npcHandler:setMessage(MESSAGE_GREET, msg)
    Topic[cid] = 0
    return true
    end

    function creatureSayCallback(cid, _type, msg)
    if not npcHandler:isFocused(cid) then
    return false
    end

    if msgcontains(msg, 'task') then
    local cur = getPlayerStorageValue(cid, curTask)
    if cur < 1 or (cur ~= 14006 and getPlayerStorageValue(cid, cur) == tasks[data[cur][1]].amount + 1 and getPlayerStorageValue(cid, cur + 100) == -1) then
    local v, lvl = '', getPlayerLevel(cid)
    if lvl < 50 then
    v, Topic[cid] = '{Crocodiles}, {tarantulas}, {carniphilas}, {stone golems} or {mammoths}', 1
    elseif lvl < 90 then
    v, Topic[cid] = '{Ice golems}, {Quara}, {elementals}, {mutated rats} or {giant spiders}', 2
    elseif 90 <= lvl then
    v, Topic[cid] = '{Hydras}, {sea serpents}, {behemoths}' .. (getPlayerStorageValue(cid, rank) == 5 and ', {serpent spawns} or {demons}' or ' or {serpent spawns}'), 3
    end
    selfSay('All right, what would you like to hunt? ' .. v .. '?', cid)
    elseif cur == 14006 and getPlayerStorageValue(cid, cur) == tasks['demon'].amount then
    selfSay({'Such derring do deserves a special reward! Take this holy icon. It neutralizes great evil and gives you access to areas which are protected by those forces. But remember ...', 'This is a one time opportunity! You won\'t get the holy icon twice.'}, cid)
    doPlayerAddItem(cid, 10305, 1)
    setPlayerStorageValue(cid, curTask, -1)
    elseif cur ~= 14006 and getPlayerStorageValue(cid, cur) == tasks[data[cur][1]].amount and getPlayerStorageValue(cid, cur + 100) < 1 then
    local tmp
    if type(data[cur][4]) == 'table' then
    tmp = {}
    for i = 1, #data[cur][4] do
    tmp = string.format(data[cur][4], getCreatureName(cid))
    end
    end
    selfSay(tmp or string.format(data[cur][4], getCreatureName(cid)), cid)
    if data[cur][5] > 0 then
    doPlayerAddExp(cid, data[cur][5])
    doSendAnimatedText(getThingPos(cid), data[cur][5], 215)
    end
    if data[cur][6] then
    setPlayerStorageValue(cid, points, getPlayerStorageValue(cid, points) + 1)
    end
    if data[cur][7] then -- special task (he sends you to kill the boss)
    setPlayerStorageValue(cid, cur + 100, 1)
    end
    setPlayerStorageValue(cid, cur, getPlayerStorageValue(cid, cur) + 1)
    Topic[cid] = 0
    elseif getPlayerStorageValue(cid, cur + 100) == 2 then
    setPlayerStorageValue(cid, points, getPlayerStorageValue(cid, points) + (isInArray({14001, 14002, 14021, 14022}, cur) and 2 or 1))
    selfSay('Fantastic! If you\'re up for another hunting mission just ask me for a {task}.', cid)
    setPlayerStorageValue(cid, cur + 100, -1)
    else
    selfSay(getPlayerStorageValue(cid, cur + 100) < 1 and 'You are not done with your task yet. Come back to me when you are. Or do you want to abort your task to start a different one?' or string.format('Find %s\'s hideout. I hope for you that you are skilled enough to kill him. Or do you want to abort your task to start a different one?', data[cur][7]), cid)
    Topic[cid] = 4
    end
    elseif msgcontains(msg, 'trade') and getPlayerStorageValue(cid, rank) >= 1 then
    local items = {
    {name='antlers', id=11208, sell=50},
    {name='bloody pincers', id=10549, sell=50},
    {name='crab pincers', id=11183, sell=35},
    {name='cyclops toe', id=10573, sell=55},
    {name='frosty ear of a troll', id=10564, sell=30},
    {name='hydra head', id=11193, sell=600},
    {name='lancer leetle shell', id=11366, sell=80},
    {name='mutated bat ear', id=10578, sell=420},
    {name='sabretooth', id=11222, sell=400},
    {name='sandcrawler shell', id=11367, sell=20},
    {name='scarab pincers', id=10547, sell=280},
    {name='terramite legs', id=11365, sell=60},
    {name='terramite shell', id=11363, sell=170},
    {name='terrorbird beak', id=11184, sell=95},
    {name='cyclops trophy', id=7398, sell=500},
    {name='minotaur trophy', id=7401, sell=500},
    }
    if getPlayerStorageValue(cid, rank) >= 3 then
    table.insert(items, {name='deer trophy', id=7397, sell=3000})
    table.insert(items, {name='lion trophy', id=7400, sell=3000})
    table.insert(items, {name='wolf trophy', id=7394, sell=3000})
    end
    if getPlayerStorageValue(cid, rank) >= 4 then
    table.insert(items, {name='behemoth trophy', id=7396, sell=20000})
    table.insert(items, {name='demon trophy', id=7393, sell=40000})
    table.insert(items, {name='dragon lord trophy', id=7399, sell=10000})
    table.insert(items, {name='demon backpack', id=10518, buy=1000})
    end
    openShopWindow(cid, items,
    function(cid, itemid, subType, amount, ignoreCap, inBackpacks)
    customCallbackOnBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks, items)
    end,
    function(cid, itemid, subType, amount, ignoreCap, inBackpacks)
    customCallbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks, items)
    end
    )
    selfSay("Alright, show me what you've got.", cid)
    elseif Topic[cid] == 4 then
    local cur = getPlayerStorageValue(cid, curTask)
    if msgcontains(msg, 'yes') or msgcontains(msg, 'abort') then
    selfSay('Alright, as you wish. Ask me for a task if you are interested in a different hunting mission.', cid)
    setPlayerStorageValue(cid, cur, -1)
    setPlayerStorageValue(cid, curTask, -1)
    if getPlayerStorageValue(cid, cur + 100) > 0 then
    setPlayerStorageValue(cid, cur + 100, -1)
    end
    else
    selfSay(cur == 14006 and string.format('Alright, then stop dilly dallying here and go on with your task. You have already exterminated %u demons. Come back to me when you are done.', getPlayerStorageValue(cid, cur)) or getPlayerStorageValue(cid, cur + 100) < 1 and string.format(data[getPlayerStorageValue(cid, curTask)][3], getPlayerStorageValue(cid, cur)) or 'Alright, then you should go on with your task.', cid)
    end
    Topic[cid] = 0
    elseif Topic[cid] == 1 and msgcontains(msg, 'crocodile') then
    local v = tasks['crocodile']
    selfSay('They are a nuisance! You\'ll find them here in the jungle near the river. Hunt ' .. v.amount .. ' crocodiles and you\'ll get a nice reward. Interested?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 1 and msgcontains(msg, 'tarantula') then
    local v = tasks['tarantula']
    selfSay('There is a veritable plague of tarantulas living in the caves north of the river to the east. Can you squish ' .. v.amount .. ' tarantulas for the Hunting Elite. What do you say?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 1 and msgcontains(msg, 'carniphila') then
    local v = tasks['carniphila']
    selfSay('Damn walking weed-thingies! You\'ll find them deeper in the jungle. Weed out ' .. v.amount .. ' carniphilas for our society. Alright?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 1 and msgcontains(msg, 'golem') then
    local v = tasks['stone golem']
    selfSay('They can be found all over Tibia. You\'ll find them in mountain caves or rocky dungeons. Hunt ' .. v.amount .. ' of them and come back to me. Understood?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 1 and msgcontains(msg, 'mammoth') then
    local v = tasks['mammoth']
    selfSay('This particular species are found in Svargrond. Impressive beasts, but you wouldn\'t want one in your back garden. Hunt ' .. v.amount .. ' of them. Alright?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 2 and msgcontains(msg, 'golem') then
    local v = tasks['ice golem']
    selfSay('The ice golems on the glacier of Hrodmir are becoming a threat to the civilians in Svargrond. Travel to the Ice Islands and hunt ' .. v.amount .. ' Ice Golems. Do you accept this task?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 2 and msgcontains(msg, 'quara') then
    selfSay('There are different types of quaras. The weaker {scouts} which can be found on Malada, one of the shattered Islands and the more skilled {underwater} kind which can be found in Calassa and some smaller colonies. Which one do you wish to hunt?', cid)
    Topic[cid] = 5
    elseif Topic[cid] == 5 and msgcontains(msg, 'scout') then
    local v = tasks['quara constrictor scout']
    selfSay('Good choice! Hunt down those Quara scouts - remember no less than ' .. v.amount .. '! Focus! Do you accept this task?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 5 and msgcontains(msg, 'underwater') then
    local v = tasks['quara constrictor']
    selfSay('As you wish. Seek out a Quara settlement and hunt ' .. v.amount .. ' Quaras, it doesn\'t matter which type you hunt. Alright?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 2 and msgcontains(msg, 'elemental') then
    selfSay({'Since the creation of the elemental shrines and the portals, the curtain separating the worlds is thin, allowing the elementals to surge into our world. They have to be contained. ...', 'The choice as to which kind of elementals you hunt is yours, as long as they are in the lands of Tibia. Hunt 70 {earth}, {energy}, {fire} or {water} elementals. Which one do you choose?'} , cid)
    Topic[cid] = 6
    elseif Topic[cid] == 6 and msgcontains(msg, 'water') then
    local v = tasks['water elemental']
    selfSay('Alright, go hunt ' .. v.amount .. ' water elementals or massive water elementals. Don\'t forget your umbrella! Alright?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 6 and msgcontains(msg, 'earth') then
    local v = tasks['earth elemental']
    selfSay('Good choice! I need you to slay ' .. v.amount .. ' earth elementals or massive earth elementals. There are some in the so called Taboo-area in the eastern jungle of Tiquanda and I heard about a cave in Edron where you\'ll find them. Are you game?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 6 and msgcontains(msg, 'energy') then
    local v = tasks['energy elemental']
    selfSay('A brave hunter! Kill ' .. v.amount .. ' energy elementals or massive energy elementals. You\'ll find them in the mountains between Darama and Tiquanda. Are you sure you want to do this?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 6 and msgcontains(msg, 'fire') then
    local v = tasks['fire elemental']
    selfSay('Don\'t get burnt! Your challenge, should you choose to accept it, is to kill ' .. v.amount .. ' fire elementals or massive fire elementals. Are you ready?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 2 and msgcontains(msg, 'mutated rat') then
    local v = tasks['mutated rat']
    selfSay('Recently, I heard of a disturbing development in Yalahar - a plague of monstrous Mutated rats! If they were to spread to the rest of Tibia.. <shudders> My task for you is to contain their numbers in Yalahar. Hunt ' .. v.amount .. ' of them. What do you say?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 2 and msgcontains(msg, 'giant spider') then
    local v = tasks['giant spider']
    selfSay('Never liked spiders. Entirely too many legs. And I always find them in my bath! Those nasty creepy crawlies are a threat to the hygiene of every living being in Tibia. Hunt ' .. v.amount .. ' of them. Okay?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 3 and msgcontains(msg, 'hydra') then
    local v = tasks['hydra']
    selfSay('The hydras are located in the eastern jungle of Tiquanda and there are several mountain caves that are inhabited by them. Your task is to hunt a mere ' .. v.amount .. ' hydras. Are you willing to do that?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 3 and msgcontains(msg, 'sea serpent') then
    local v = tasks['sea serpent']
    selfSay({'The sea serpents are a threat to honest seafarers! Captain Haba knows where to find them. ...', 'Go to Svargrond and talk to him. ' .. v.amount .. ' sea serpents should be enough to reduce the threat - but not their young though! After all, they are an endangered species! Got it?'}, cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 3 and msgcontains(msg, 'behemoth') then
    local v = tasks['behemoth']
    selfSay('Behemoths must be kept away from the settlements at all costs. You\'ll find them east of here in the taboo-area or under the cyclopolis in Edron. Go there and hunt a few of them - shall we say... ' .. v.amount .. '? Are you up for that?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 3 and msgcontains(msg, 'serpent spawn') then
    local v = tasks['serpent spawn']
    selfSay('Very dangerous, nasty, slimey creatures. They live deep in the old ruins of Banuta. I think a mere ' .. v.amount .. ' serpent spawns should do the trick. What do you say?', cid)
    Topic[cid] = v.storage
    elseif Topic[cid] == 3 and getPlayerStorageValue(cid, rank) == 5 and msgcontains(msg, 'demon') and getPlayerStorageValue(cid, curTask) < 1 then
    local v = tasks['demon']
    selfSay('The spawn of pure evil must be erased from Tibia. You\'ll find demons lurking in the northern ruins of Edron as well as in some of other deeper dungeons of Tibia. We need to wipe them out! Slay ' .. v.amount .. ' demons for the Greater Good!', cid)
    setPlayerStorageValue(cid, curTask, v.storage)
    setPlayerStorageValue(cid, v.storage, 0)
    Topic[cid] = 0
    elseif Topic[cid] >= 14000 and msgcontains(msg, 'yes') then
    selfSay(data[Topic[cid]][2], cid)
    setPlayerStorageValue(cid, curTask, Topic[cid])
    setPlayerStorageValue(cid, Topic[cid], 0)
    if getPlayerStorageValue(cid, questLog) < 1 then
    setPlayerStorageValue(cid, questLog, 1)
    setPlayerStorageValue(cid, points, 0)
    end
    Topic[cid] = 0
    elseif msgcontains(msg, 'special') and getPlayerStorageValue(cid, rank) == 5 then
    local v, k = getPlayerStorageValue(cid, tiquanda), getPlayerStorageValue(cid, demodras)
    if v < 1 then
    if getPlayerLevel(cid) >= 90 then
    setPlayerStorageValue(cid, tiquanda, 1)
    selfSay({'Have you heard about {Tiquandas Revenge}? It is said that the jungle itself is alive and takes revenge for all the bad things people have done to it. ...', 'I myself believe that there is some truth in this clap trap. Something \'real\' which therefore must have a hideout somewhere. Go find it and take revenge yourself! Ask me about the {special} task when you\'re done.'}, cid)
    else
    selfSay('Your eagerness is commendable, and your rank within our hunting elite is great buuuut I\'m afraid you\'re a little bit too weak for the special tasks. Get more experience and the special tasks will be no match for you.', cid)
    end
    elseif v == 2 then
    selfSay('Great achievement, old chap! You are an outstanding hunter, no doubt about it!', cid)
    setPlayerStorageValue(cid, tiquanda, 3)
    elseif v == 3 and k < 1 then
    if getPlayerLevel(cid) >= 100 then
    setPlayerStorageValue(cid, demodras, 1)
    selfSay('This task is a very dangerous one. I want you to look for {Demodras}\' hideout. It might be somewhere under the {Plains of Havoc}. Good luck, old chap, come back in one piece and ask me about the {special} task when you\'re done.', cid)
    else
    selfSay('Your eagerness is commendable, and your rank within our hunting elite is great buuuut I\'m afraid you\'re a little bit too weak for the special tasks. Get more experience and the special tasks will be no match for you.', cid)
    end
    elseif k == 2 then
    selfSay('Great achievement, old chap! You are an outstanding hunter, no doubt about it!', cid)
    setPlayerStorageValue(cid, demodras, 3)
    end
    elseif msgcontains(msg, 'promotion') then
    local cur, r, msg, exp, item = getPlayerStorageValue(cid, points), getPlayerStorageValue(cid, rank)
    if cur >= 5 and r < 1 then
    msg, exp = {'You have completed 5 tasks! Let me promote you to the first rank: Huntsman. Congratulations! ...', 'If you find any trophies that you don\'t need, feel free to ask me for a trade.'}, 5000
    elseif cur >= 10 and r < 2 then
    msg, exp = {'You have completed 10 hunting tasks. It\'s time for a promotion. You advance to the rank of \'Ranger\'. Congratulations! ...', 'Oh, I made a deal with Lorek. He ships Rangers from our society - and higher ranks of course - to Banuta, Chor or near the mountain pass to Darama. Just ask him for a passage.'}, 8000
    elseif cur >= 20 and r < 3 then
    msg, exp = {'Good show! You have completed 20 hunting tasks for the \'Paw and Fur - Hunting Elite. You have earned the right to join the ranks of those known as \'Big game hunter\'. Congratulations! ...', 'From now on I\'ll buy more trophies from you!'}, 10000
    elseif cur >= 30 and r < 4 then
    msg, exp, item = 'Spiffing! You have done 30 hunting tasks! From now on you can call yourself a \'Trophy hunter\'. As a reward I have this special backpack for you and in addition you can sell some more rare trophies to me.', 15000, 10518
    elseif cur >= 50 and r < 5 then
    msg, exp = 'Congratulations! You have made the highest rank: \'Elite hunter\'. If haven\'t yet done so ask me for the {special} task.', 30000
    end
    if msg then
    selfSay(msg, cid)
    setPlayerStorageValue(cid, rank, math.max(1, r + 1))
    if exp then
    doPlayerAddExp(cid, exp)
    doSendAnimatedText(getThingPos(cid), exp, 215)
    end
    if item then
    doPlayerAddItem(cid, item, 1)
    end
    end
    end
    end

    npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    npcHandler:setMessage(MESSAGE_FAREWELL, 'Happy hunting, old chap!')
    npcHandler:setMessage(MESSAGE_WALKAWAY, 'Happy hunting, old chap!')
    npcHandler:setCallback(CALLBACK_GREET, greetCallback)
    npcHandler:addModule(FocusModule:new())[/lua]
    boss rooms movement:
    [lua]local t={
    [14001]={{'Leviathan'}, tp={x=31914, y=31071, z=10}, spawn={x=31905, y=31071, z=10}, from={x=31900, y=31064, z=10}, to={x=31918, y=31081, z=10}},
    [14002]={{'The Noxious Spawn'}, tp={x=32842, y=32668, z=11}, spawn={x=32842, y=32673, z=11}, from={x=32836, y=32665, z=11}, to={x=32849, y=32677, z=11}},
    [14003]={{'Necropharus'}, tp={x=33028, y=32427, z=12}, spawn={x=33028, y=32421, z=12}, from={x=33020, y=32415, z=12}, to={x=33035, y=32430, z=12}},
    [14004]={{'The Horned Fox'}, tp={x=32458, y=31993, z=9}, spawn={x=32458, y=32004, z=9}, from={x=32453, y=31992, z=9}, to={x=32464, y=32008, z=9}},
    [14005]={{'Lethal Lissy', 'Ron The Ripper', 'Deadeye Devious', 'Brutus Bloodbeard'}, tp={x=31975, y=32896, z=0}, spawn={x=31982, y=32896, z=0}, from={x=31972, y=32890, z=0}, to={x=31988, y=32904, z=0}},
    [14007]={{'The Snapper'}, tp={x=32610, y=32724, z=8}, spawn={x=32611, y=32727, z=8}, from={x=32606, y=32720, z=8}, to={x=32620, y=32733, z=8}},
    [14008]={{'Hide'}, tp={x=32815, y=32704, z=8}, spawn={x=32816, y=32708, z=8}, from={x=32810, y=32701, z=8}, to={x=32824, y=32713, z=8}},
    [14012]={{'Shardhead'}, tp={x=32102, y=31125, z=2}, spawn={x=32101, y=31130, z=2}, from={x=32095, y=31122, z=2}, to={x=32108, y=31136, z=2}},
    [14019]={{'Esmeralda'}, tp={x=32759, y=31253, z=9}, spawn={x=32759, y=31256, z=9}, from={x=32755, y=31250, z=9}, to={x=32764, y=31259, z=9}},
    [14020]={{'The Old Widow'}, tp={x=32804, y=32280, z=8}, spawn={x=32800, y=32280, z=8}, from={x=32794, y=32273, z=8}, to={x=32807, y=32288, z=8}},
    [14021]={{'The Many'}, tp={x=32921, y=32894, z=8}, spawn={x=32921, y=32899, z=8}, from={x=32915, y=32891, z=8}, to={x=32927, y=32904, z=8}},
    [14506]={{'Demodras'}, tp={x=32748, y=32287, z=10}, spawn={x=32745, y=32292, z=10}, from={x=32738, y=32283, z=10}, to={x=32757, y=32300, z=10}},
    [14505]={{'Tiquandas Revenge'}, tp={x=32888, y=32580, z=4}, spawn={x=32883, y=32580, z=4}, from={x=32881, y=32578, z=4}, to={x=32892, y=32588, z=4}},
    [14022]={{'Stonecracker'}, tp={x=33259, y=31695, z=15}, spawn={x=33257, y=31702, z=15}, from={x=33252, y=31691, z=15}, to={x=33266, y=31708, z=15}},
    }

    function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) then
    local k=t[item.uid]
    if getCreatureStorage(cid, item.uid + (item.uid < 14500 and 100 or 0)) == 1 then
    local m={}
    for x=k.from.x, k.to.x do
    for y=k.from.y, k.to.y do
    local v=getTopCreature({x=x, y=y, z=k.from.z}).uid
    if v ~= 0 then
    if isPlayer(v) then
    doTeleportThing(cid, fromPosition, true)
    doCreatureSay(cid, 'Someone else is in the room.', TALKTYPE_ORANGE_1, false, cid)
    return
    elseif isMonster(v) then
    table.insert(m, v)
    end
    end
    end
    end
    for i=1, #m do
    doRemoveCreature(m)
    end
    doCreatureSetStorage(cid, item.uid + (item.uid < 14500 and 100 or 0), 2)
    doTeleportThing(cid, k.tp)
    doSendMagicEffect(position, CONST_ME_TELEPORT)
    doSendMagicEffect(k.tp, CONST_ME_TELEPORT)
    doCreateMonster(k[1][math.random(#k[1])], k.spawn)
    doSendMagicEffect(k.spawn, CONST_ME_TELEPORT)
    return
    end
    end
    doTeleportThing(cid, fromPosition, true)
    end[/lua]

    quests.cpp patch: (if you don't patch it, quest log won't work)
     
    Last edited: Jun 22, 2011
    nsanee likes this.
  3. Stewie

    Stewie Family Guy # ;3

    Joined:
    May 3, 2010
    Messages:
    786
    your task system is same RL?
     
  4. Bogart

    Bogart ...has super panda powers

    Joined:
    Jun 21, 2009
    Messages:
    7,743
    check the code, and check the 'How it works?' section, stop posting dumb questions.

    @ONTOPIC.

    Nice again, 'You must spread some Reputation around before giving it to darkhaos again.' it has been like 4 months since I last repped you. uhmm..
     
  5. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,855
    1. Can player make more than 1 task?
     
  6. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    yes
     
  7. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,855
    I'm using your script 'Now player can choose the task'.
    What do I must change? (I cant replace that because I changed somethings)
     
  8. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    If you want that player can start more than one task and start task by name, you need to change all code except the config.
     
  9. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,855
    "01:10 Grizzly Adams: Are you sure that do you want to start the task number 1?. In this task you will need to defeat 100 Trolls."

    Can you change to:
    "01:10 Grizzly Adams: In this task you will need to defeat 100 Trolls. Are you sure that do you want to start?"
    (Showwing the monster counts, and monster name)?
     
  10. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    You can do that, just edit the text, emove 'Are you sure that do you want to start the task number n?. And after 'In this task bla bla..' write 'Are you sure bla bla..'
     
  11. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,855
    "01:10 Grizzly Adams: In this task you will need to defeat 100 Trolls. Are you sure that do you want to start?"

    How can I set in message the COUNT and TASKNAME(example: Trolls)?
     
  12. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    But there is already
    "01:10 Grizzly Adams: In this task you will need to defeat 100 Trolls. Are you sure that do you want to start?"
     
  13. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,855
    Will it works? (My test is offline)
    selfSay("In this task you will need to defeat " .. tasks[msg].killsRequired .. " " .. tasks[msg].raceName .. ". Are you sure that do you want to start?", cid)
     
  14. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    Yes :)
     
  15. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,855
    Thank you again!

    When you say 'tasks' is possible a better way? This window is not good, maybe NPC list?
    Adams: Trolls, Quaras(done)..


    Edit: You must spread some Reputation around before giving it to darkhaos again.
     
    Last edited: Mar 17, 2011
  16. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    Change
    [lua]doShowTextDialog(cid, 5956, text)[/lua]

    With
    [lua]selfSay(text, cid)[/lua]

    I don't understand what's that
     
  17. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,855
    I tried to give you reputation, but I don't have reputation to give.

    How can I set [done] here?
    [lua]selfSay(bla bla bla, cid)[/lua]
     
  18. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922
    Do what i told you, that's already setted here:
    [lua] for i = 1, table.maxn(tasks) do
    text = text .. "\n" .. i .. " - " .. tasks.raceName .. (getCreatureStorage(cid, tasks.questStarted) == 2 and " [Done]" or "")
    end[/lua]
     
  19. LucasFerraz

    LucasFerraz Systems Analyst

    Joined:
    Jun 10, 2010
    Messages:
    2,855
    Will it work?
    [lua]selfSay(text .. "\n" .. i .. " - " .. tasks.raceName .. (getCreatureStorage(cid, tasks.questStarted) == 2 and " [Done]" or "", cid)[/lua]
     
  20. Darkhaos

    Darkhaos (:

    Joined:
    Apr 17, 2008
    Messages:
    1,922


    That's already included on 'text', just paste
    [lua]selfSay(text, cid)[/lua]

    You'll see the same message as in the text dialog but in the npc channel.
     

Share This Page