• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Task System, need some help

Bash

Member
Joined
Nov 7, 2008
Messages
116
Reaction score
15
Hello, i have already a working task system. Made some rework at script to work with my otx based on fs 0.3.6.

The problem now is that when they cancel the task by saying the new name of task, the task shows done at website and ofc can't do it because its like he completed it.

Some1 knows how to add the possibility of cancel the current task saying "cancel", also when he wants he can start the task again?
Also the npc is confusing dragon with dragon lords, don't know how to make it works.


npc/script/tasks.lua:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
keywordHandler:addKeyword({'task'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I Have for you some tasks: money, easy, medium or hard?"})
keywordHandler:addKeyword({'tasks'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I Have for you some tasks: money, easy, medium or hard?"})
keywordHandler:addKeyword({'money'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Rats, cave rats (caves), scorpions, amazons, valkyries and banshees."})
keywordHandler:addKeyword({'easy'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Trolls, rotworms, wasps, goblins, dwarfs, larvas, orcs, minotaurs, skeletons, beholders, slimes and outlaws."})
keywordHandler:addKeyword({'medium'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Cyclops, scarabs, apes, dworcs, lizards, ghouls, ghosts, mummys, stalkers, minotaur guards, minotaur mages, orcs strong (warlords), dwarf guards, dwarf geomancers, elfs, crypt shamblers, ds and bonebeasts."})
keywordHandler:addKeyword({'hard'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Giant Spiders, ancient scarabs, hydras, serpent spawns, dragons, dragon lords (dls), heroes, black knights, warlocks, behemoths, necromancers, vampires, liches, djinns, yetis and defenders. "})
function creatureSayCallback(cid, type, msg)
function creatureSayCallback(cid, type, msg)
return false
end      
    
local storage = 82000
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid        
    
if msgcontains(msg, 'mummy') or msgcontains(msg, 'mummys') then 
    if getPlayerStorageValue(cid, 82045) == -1 then
        npcHandler:say(" Can you help me and kill 150 of these creatures?", cid)
        talk_state = 1
    elseif getPlayerStorageValue(cid, storage) == 90 then    
        npcHandler:say("Great! You killed 150 mummies and finished the task. Your reward is 80000 experience points.", cid)
         setPlayerStorageValue(cid, storage, -90)
            doPlayerAddExp(cid, 80000)
else
        npcHandler:say("You already finished this task.", cid)
    end    
    elseif msgcontains(msg, 'yes') and talk_state == 1 then      
        npcHandler:say("I appreciate that! Now go and kill 150 of this creatures, then back to me if you done this.", cid)
        setPlayerStorageValue(cid, storage, 89) 
        talk_state = 2       
    end

if msgcontains(msg, 'necromancer') or msgcontains(msg, 'necromancers') then
    if getPlayerStorageValue(cid, 82046) == -1 then
        npcHandler:say("Can you help me and kill 500 of these creatures?", cid)
        talk_state = 3
    elseif getPlayerStorageValue(cid, storage) == 92 then    
        npcHandler:say("Great! You killed 500 necromancers and finished the task. Your reward is 550000 experience points and Arcane Staff.", cid)
         setPlayerStorageValue(cid, storage, -92)
                       doPlayerAddExp(cid, 550000)
                       doPlayerAddItem(cid, 2453, 1)
else
        npcHandler:say("You already finished this task.", cid)
    end    
    elseif msgcontains(msg, 'yes') and talk_state == 3 then      
        npcHandler:say("I appreciate that! Now go and kill 500 of this creatures, then back to me if you done this.", cid)
        setPlayerStorageValue(cid, storage, 91) 
        talk_state = 4       
    end

  if msgcontains(msg, 'scorpion') or msgcontains(msg, 'scorpions') then
    if getPlayerStorageValue(cid, 82001) == -1 then
        npcHandler:say("Can you help me and kill 80 of these creatures?", cid)
        talk_state = 107
    elseif getPlayerStorageValue(cid, storage) == 2 then    
        npcHandler:say("Great! You killed 80 scorpions and finished the task. Your reward is 3000 gold coins", cid)
         setPlayerStorageValue(cid, storage, -2)
              doPlayerAddItem(cid, 2152, 30)
else
        npcHandler:say("You already finished this task.", cid)
    end    
    elseif msgcontains(msg, 'yes') and talk_state == 107 then      
        npcHandler:say("I appreciate that! Now go and kill 80 of this creatures, then back to me if you done this.", cid)
        setPlayerStorageValue(cid, storage, 1) 
        talk_state = 108       
    end 
 
   
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


Thanks in advance!
 
Back
Top