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

NPC Kill Quest possible ?

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,855
Solutions
18
Reaction score
665
Hello
It possible to do a kill quest npc ?
He must contains 5 types of kills.

example.
NPC: Welcome in my house bro, this f#$king creatures are everywhere! Can you help me with {killing} ?

{killing} - "Huh, I need to kill {wolves}, {bears}, {goblins}, {hunters}, {rats}. What do you choose for warm-up ? haha!

If player type {wolves}
NPC: You must kill 30 wolves, come back when you kill for reward.

If player type {bears}
NPC: You must kill 15 bears, come back when you kill for reward.

If player type {goblins}
NPC: You must kill 5 goblins, come back when you kill for reward.

If player type {hunters}
NPC: You must kill 10 hunters, come back when you kill for reward.

If player type {rats}
NPC: You must kill 20 rats, come back when you kill for reward.


If you go away
NPC: Ch-ch-chicken !

After killing monster for reward you get from npc: exp and money, i configure it, just i need script ;(

After killing all quests the NPC set storage. Its possible to do that npc ?
Help me :(
 
Ok here it is
Please read well the instructions inside each script


go to npc make a new.xml {named like npc will be named}
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="npc name as xml name" script="quest.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="139" head="20" body="39" legs="45" feet="7" addons="0"/>
	<parameters>
                <parameter key="message_greet" value="Welcome in my house bro, this f#$king creatures are everywhere! Can you help me with {killing} ?, or if you started ask me for {monster name}."/>
                <parameter key="message_farewell" value="Good bye."/>
                <parameter key="message_walkaway" value="Ch-ch-chicken !" />
    </parameters>

</npc>

now go to scripts make new quest.lua paste
LUA:
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
--Copy those locals paste them in the top of the creature script i gave you
local words = { ["Wolves"] = {storage = 1234, count = 35, reward = 2466},   
                ["bears"] = {storage = 1235, count = 30, reward = 2446},
				["goblins"] = {storage = 1236, count = 20, reward = 2157},
				["hunters"] = {storage = 1237, count = 30, reward = 2446},
				["rats"] = {storage = 1238, count = 30, reward = 2446}
				--["monster name"] = {storage = put unused storage , count = kills for each, rewards = itemid}
				}  
local monsters = "Wolves, Bears, Goblins, Hunters, Rats"  -- here put the name of monster in list 
local unique = 7070
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if msgcontains(msg, "killing") then
		if getPlayerStorageValue(cid,unique) == 1 then
		    npcHandler:say(" You already in quest ask me for monster to see your progress.", cid)
	   else
		npcHandler:say("Huh, I need to kill {"..monsters.."}. What do you choose for warm-up ? haha!", cid)
		 talkState[talkUser] = 1
		end
	end
		for k, v in pairs(words) do
		    
		if msgcontains(msg, k) and (talkState[talkUser] == 1 or talkState[talkUser] == 4) then
	      if getPlayerStorageValue(cid,v.storage) < 0 then
		     npcHandler:say(" You must kill {"..v.count.."} "..k..", come back when you kill and ask for {"..k.."}.You can leave by asking for {leave}.", cid)
			 setPlayerStorageValue(cid,v.storage,0)
			 setPlayerStorageValue(cid,unique,1)
			 talkState[talkUser] = 4
          elseif getPlayerStorageValue(cid,v.storage) >= 0 then
		     if getPlayerStorageValue(cid,v.storage) >= 0 and getPlayerStorageValue(cid,v.storage) < v.count then
			   npcHandler:say("You Still need to kill {"..v.count -(getPlayerStorageValue(cid,v.storage)).." "..k..".", cid)
	         elseif getPlayerStorageValue(cid,v.storage) == (v.count)+3 then
			    npcHandler:say(" You have already finished this quest.", cid)
	         elseif getPlayerStorageValue(cid,v.storage) >= v.count and getPlayerStorageValue(cid,v.storage) < (v.count)+3 then
			    npcHandler:say("Ahh! I see you have killed them all , Here take this {"..getItemNameById(v.reward).."}.", cid)
				doPlayerAddItem(cid,v.reward,1)
				setPlayerStorageValue(cid,complete,1)
				 setPlayerStorageValue(cid,v.storage,(v.count)+3)
				doSendMagicEffect(getThingPos(cid),27)
				talkState[talkUser] = 0
			 end
		end
		end
		end
		if msgcontains(msg, "leave") then
		 if talkState[talkUser] == 4 then 
		    		   npcHandler:say("Are you sure you want to leave? You will lose all your kills if you did so.", cid)
		   talkState[talkUser] = 3
		 else
		  npcHandler:say("You havn't started a quest yet.", cid) 
        end		   
		elseif msgcontains(msg, "yes") and talkState[talkUser] == 3 then
		  
		    for k, v in pairs(words) do 
               if getPlayerStorageValue(cid,v.storage) > -1 then 
                    setPlayerStorageValue(cid,v.storage,-1) 
					setPlayerStorageValue(cid,unique,-1)
                npcHandler:say("You have cancelled all your kills.To start again come ask for {killing}", cid)	
		        end
			end

		elseif  msgcontains(msg, "no") and talkState[talkUser] == 3 then 
		     npcHandler:say("Then go continue killing.", cid)	

        end
return true
end
			
	
	
	
	
	
	
	
	
	
	
	
	
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Now need to make creature event for the kills:

creature.xml and paste
Code:
<event type="kill" name="Quest" event="script" value="quest.lua"/>

Then go to creaturscript.xml --> scripts --> make new quest.lua
LUA:
    ---locals copied from npc script :)
  --keep in mind that names of monsters here must be as same in game so it is "wolf" not "wolves nor Wolf"
  -- just edit nams
  --["monster name"] = {storage = put unused storage , count = kills for each, rewards = {itemid}
  local words = {["wolf"] = {storage = 1234, count = 35, reward = 2466},   
                ["bear"] = {storage = 1235, count = 30, reward = 2446},
				["goblin"] = {storage = 1236, count = 20, reward = 2157},
				["hunter"] = {storage = 1237, count = 30, reward = 2446},
				["rat"] = {storage = 1238, count = 30, reward = 2446}
				}  
   function onKill(cid, target)
        if(isPlayer(target) == TRUE) then
                return TRUE
        end

        local monster = words[string.lower(getCreatureName(target))]
        if(not monster) then
                return TRUE
        end
        if getPlayerStorageValue(cid,monster.storage) == ((monster.count)-1) then
		setPlayerStorageValue(cid,monster.storage, (monster.kills)+1)
                   doPlayerPopupFYI(cid, "                          *#Congratulations!#*\n\n\n    You have completed the ["..getCreatureName(target).."] quest.\n\n   *Go talk to the npc to recieve your reward.")
        return true
        end
                if getPlayerStorageValue(cid,monster.storage) == ((monster.count)+1) then

         return true
        end
		 if getPlayerStorageValue(cid,monster.storage) < 0 then

         return true
        end
      setPlayerStorageValue(cid, monster.storage ,(getPlayerStorageValue(cid, monster.storage))+1)
      doSendAnimatedText(getPlayerPosition(cid),""..getPlayerStorageValue(cid, monster.storage).."", math.random(01,255))
         return true
        end

Then go to creaturscript.xml --> scripts --> login.lua
paste this before last return true
Code:
registerCreatureEvent(cid, "Quest")

Again read what i wrote inside the npc and creature script.
 
OK but how to add exp for kills example goblins ?
how to make rewards countable example:
2160, 10 ? If i want 10 cc for kills all monsters - goblins ?
 
So can you fix it please ? I need to configure exp and reward :)
And can you tell me what is final storage ? After kill all monsters ?
 
take
LUA:
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
--Copy those locals paste them in the top of the creature script i gave you
local words = { ["Wolves"] = {storage = 1234, count = 35, reward = 2466 , itemcount = 1, expe =100},   
                ["bears"] = {storage = 1235, count = 30, reward = 2446, itemcount = 1, expe =100},
                                ["goblins"] = {storage = 1236, count = 20, reward = 2157, itemcount = 1, expe =100},
                                ["hunters"] = {storage = 1237, count = 30, reward = 2446, itemcount = 1, expe =100},
                                ["rats"] = {storage = 1238, count = 30, reward = 2446, itemcount = 1, expe =100}
                                --["monster name"] = {storage = put unused storage , count = kills for each, rewards = itemid}
                                }  
local monsters = "Wolves, Bears, Goblins, Hunters, Rats"  -- here put the name of monster in list 
local unique = 7070

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
        if msgcontains(msg, "killing") then
                if getPlayerStorageValue(cid,unique) == 1 then
                    npcHandler:say(" You already in quest ask me for monster to see your progress.", cid)
           else
                npcHandler:say("Huh, I need to kill {"..monsters.."}. What do you choose for warm-up ? haha!", cid)
                 talkState[talkUser] = 1
                end
        end
                for k, v in pairs(words) do
                    
                if msgcontains(msg, k) and (talkState[talkUser] == 1 or talkState[talkUser] == 4) then
              if getPlayerStorageValue(cid,v.storage) < 0 then
                     npcHandler:say(" You must kill {"..v.count.."} "..k..", come back when you kill and ask for {"..k.."}.You can leave by asking for {leave}.", cid)
                         setPlayerStorageValue(cid,v.storage,0)
                         setPlayerStorageValue(cid,unique,1)
                         talkState[talkUser] = 4
          elseif getPlayerStorageValue(cid,v.storage) >= 0 then
                     if getPlayerStorageValue(cid,v.storage) >= 0 and getPlayerStorageValue(cid,v.storage) < v.count then
                           npcHandler:say("You Still need to kill {"..v.count -(getPlayerStorageValue(cid,v.storage)).." "..k..".", cid)
                 elseif getPlayerStorageValue(cid,v.storage) == (v.count)+3 then
                            npcHandler:say(" You have already finished this quest.", cid)
                 elseif getPlayerStorageValue(cid,v.storage) >= v.count and getPlayerStorageValue(cid,v.storage) < (v.count)+3 then
                            npcHandler:say("Ahh! I see you have killed them all , here your reward is {"..itemcount.." "..getItemNameById(v.reward).."} and {"..v.expe.." experience}.", cid)
                                doPlayerAddItem(cid,v.reward,itemcount)
								doPlayerAddExp(cid,expe)
                                setPlayerStorageValue(cid,complete,1)
                                 setPlayerStorageValue(cid,v.storage,(v.count)+3)
                                doSendMagicEffect(getThingPos(cid),27)
                                talkState[talkUser] = 0
                         end
                end
                end
                end
                if msgcontains(msg, "leave") then
                 if talkState[talkUser] == 4 then 
                                   npcHandler:say("Are you sure you want to leave? You will lose all your kills if you did so.", cid)
                   talkState[talkUser] = 3
                 else
                  npcHandler:say("You havn't started a quest yet.", cid) 
        end                
                elseif msgcontains(msg, "yes") and talkState[talkUser] == 3 then
                  
                    for k, v in pairs(words) do 
               if getPlayerStorageValue(cid,v.storage) > -1 then 
                    setPlayerStorageValue(cid,v.storage,-1) 
                                        setPlayerStorageValue(cid,unique,-1)
                npcHandler:say("You have cancelled all your kills.To start again come ask for {killing}", cid)  
                        end
                        end

                elseif  msgcontains(msg, "no") and talkState[talkUser] == 3 then 
                     npcHandler:say("Then go continue killing.", cid)   

        end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

what do you mean you need a storage to be made when player had killed all monsters?

I made that when you finish killing rat you cant make it again etc.. , you can't start new monster untill you finish the one you are in or go to npc and leave it ( by doing that you lose all your kills)

if you are in a quest so the when you kill the quest monster you get animated number of monster you killed .
 
ok thanks,
Can you help me with my dragon ball project ? I need few npcs i.a npc who can learn you techniques, ask me in PW.

REP ++
 
1. If is new player, who doesn't start task yet

09:56 Alex: Welcome in village my bro. This f#$king creatures are everywhere! Can you help me with killing? Or if you started ask me for monster name.
09:56 GOD Adi [200]: monster name
09:56 GOD Adi [200]: monster
[nothing]
09:57 GOD Adi [200]: hi
09:57 Alex: Welcome in village my bro. This f#$king creatures are everywhere! Can you help me with killing? Or if you started ask me for monster name.
09:58 GOD Adi [200]: killing
09:58 Alex: Huh, I need to kill Wolves, Bears, Goblins, Hunters, Rats. What do you choose for warm-up ? haha!
09:58 GOD Adi [200]: Rats
09:58 Alex: You must kill 5 rats, come back when you kill and ask for rats.You can leave by asking for leave.
09:58 GOD Adi [200]: rats
09:58 Alex: You Still need to kill 5 rats.
09:58 GOD Adi [200]: rats
09:58 Alex: You Still need to kill 5 rats.
09:58 GOD Adi [200]: ok
[Ok, lets check i go kill rats and]







data\creaturescripts\scripts\QUEST.lua

Code:
 ---locals copied from npc script :)
  --keep in mind that names of monsters here must be as same in game so it is "wolf" not "wolves nor Wolf"
  -- just edit nams
  --["monster name"] = {storage = put unused storage , count = kills for each, rewards = {itemid}
  local words = {["wolf"] = {storage = 20000, count = 35, reward = 2146},   
                ["bear"] = {storage = 20001, count = 30, reward = 2146},
				["goblin"] = {storage = 20002, count = 20, reward = 2146},
				["hunter"] = {storage = 20003, count = 30, reward = 2146},
				["rat"] = {storage = 20004, count = 5, reward = 2146}
				}  
   function onKill(cid, target)
        if(isPlayer(target) == TRUE) then
                return TRUE
        end
 
        local monster = words[string.lower(getCreatureName(target))]
        if(not monster) then
                return TRUE
        end
        if getPlayerStorageValue(cid,monster.storage) == ((monster.count)-1) then
		setPlayerStorageValue(cid,monster.storage, (monster.count)+1)
                   doPlayerPopupFYI(cid, "                          *#Congratulations!#*\n\n\n    You have completed the ["..getCreatureName(target).."] quest.\n\n   *Go talk to the npc to recieve your reward.")
        return true
        end
                if getPlayerStorageValue(cid,monster.storage) == ((monster.count)+1) then
 
         return true
        end
		 if getPlayerStorageValue(cid,monster.storage) < 0 then
 
         return true
        end
      setPlayerStorageValue(cid, monster.storage ,(getPlayerStorageValue(cid, monster.storage))+1)
      doSendAnimatedText(getPlayerPosition(cid),""..getPlayerStorageValue(cid, monster.storage).."", math.random(01,255))
         return true
        end

data\npc\scripts\ratmission.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
--Copy those locals paste them in the top of the creature script i gave you
local words = { ["Wolves"] = {storage = 20000, count = 35, reward = 2148 , itemcount = 1, expe =100},   
                ["bears"] = {storage = 20001, count = 30, reward = 2148, itemcount = 1, expe =100},
                                ["goblins"] = {storage = 20002, count = 20, reward = 2148, itemcount = 1, expe =100},
                                ["hunters"] = {storage = 20003, count = 30, reward = 2148, itemcount = 1, expe =100},
                                ["rats"] = {storage = 20004, count = 5, reward = 2148, itemcount = 30, expe =100}
                                --["monster name"] = {storage = put unused storage , count = kills for each, rewards = itemid}
                                }  
local monsters = "Wolves, Bears, Goblins, Hunters, Rats" -- here put the name of monster in list 
local unique = 7080
 
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
        if msgcontains(msg, "killing") then
                if getPlayerStorageValue(cid,unique) == 1 then
                    npcHandler:say(" You already in quest ask me for monster to see your progress.", cid)
           else
                npcHandler:say("Huh, I need to kill {"..monsters.."}. What do you choose for warm-up ? haha!", cid)
                 talkState[talkUser] = 1
                end
        end
                for k, v in pairs(words) do
 
                if msgcontains(msg, k) and (talkState[talkUser] == 1 or talkState[talkUser] == 4) then
              if getPlayerStorageValue(cid,v.storage) < 0 then
                     npcHandler:say(" You must kill {"..v.count.."} "..k..", come back when you kill and ask for {"..k.."}.You can leave by asking for {leave}.", cid)
                         setPlayerStorageValue(cid,v.storage,0)
                         setPlayerStorageValue(cid,unique,1)
                         talkState[talkUser] = 4
          elseif getPlayerStorageValue(cid,v.storage) >= 0 then
                     if getPlayerStorageValue(cid,v.storage) >= 0 and getPlayerStorageValue(cid,v.storage) < v.count then
                           npcHandler:say("You Still need to kill {"..v.count -(getPlayerStorageValue(cid,v.storage)).." "..k..".", cid)
                 elseif getPlayerStorageValue(cid,v.storage) == (v.count)+3 then
                            npcHandler:say(" You have already finished this quest.", cid)
                 elseif getPlayerStorageValue(cid,v.storage) >= v.count and getPlayerStorageValue(cid,v.storage) < (v.count)+3 then
                            npcHandler:say("Ahh! I see you have killed them all , here your reward is {"..getItemNameById(v.reward).."} and {"..v.expe.." experience}.", cid)
                                doPlayerAddItem(cid,v.reward,itemcount)
								doPlayerAddExp(cid,expe)
                                setPlayerStorageValue(cid,complete,1)
                                 setPlayerStorageValue(cid,v.storage,(v.count)+3)
                                doSendMagicEffect(getThingPos(cid),27)
                                talkState[talkUser] = 0
                         end
                end
                end
                end
                if msgcontains(msg, "leave") then
                 if talkState[talkUser] == 4 then 
                                   npcHandler:say("Are you sure you want to leave? You will lose all your kills if you did so.", cid)
                   talkState[talkUser] = 3
                 else
                  npcHandler:say("You havn't started a quest yet.", cid) 
        end                
                elseif msgcontains(msg, "yes") and talkState[talkUser] == 3 then
 
                    for k, v in pairs(words) do 
               if getPlayerStorageValue(cid,v.storage) > -1 then 
                    setPlayerStorageValue(cid,v.storage,-1) 
                                        setPlayerStorageValue(cid,unique,-1)
                npcHandler:say("You have cancelled all your kills.To start again come ask for {killing}", cid)  
                        end
                        end
 
                elseif  msgcontains(msg, "no") and talkState[talkUser] == 3 then 
                     npcHandler:say("Then go continue killing.", cid)   
 
        end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

WHO HELP?
REP++ :)
 
Replace this with the quest in creaturescript and try :
LUA:
---locals copied from npc script :)
--keep in mind that names of monsters here must be as same in game so it is "wolf" not "wolves nor Wolf"
-- just edit nams
--["monster name"] = {storage = put unused storage , count = kills for each, rewards = {itemid}
local words = 	{	["wolf"] = {storage = 1234, count = 35, reward = 2466},   
					["bear"] = {storage = 1235, count = 30, reward = 2446},
					["goblin"] = {storage = 1236, count = 20, reward = 2157},
					["hunter"] = {storage = 1237, count = 30, reward = 2446},
					["rat"] = {storage = 1238, count = 30, reward = 2446}
				}  
function onKill(cid, target)
	if(isPlayer(target) == true) then
		return true
	end
	local monster = words[string.lower(getCreatureName(target))]
	if(not monster) then
		return true
	end
	if getPlayerStorageValue(cid,monster.storage) == ((monster.count)-1) then
		setPlayerStorageValue(cid,monster.storage, (monster.count)+1)
		doPlayerPopupFYI(cid, "                          *#Congratulations!#*\n\n\n    You have completed the ["..getCreatureName(target).."] quest.\n\n   *Go talk to the npc to recieve your reward.")
		return true
	end
	if getPlayerStorageValue(cid,monster.storage) == ((monster.count)+1) then
         return true
	end
	if getPlayerStorageValue(cid,monster.storage) < 0 then
		return true
	end
	setPlayerStorageValue(cid, monster.storage ,(getPlayerStorageValue(cid, monster.storage))+1)
	doSendAnimatedText(getPlayerPosition(cid),""..getPlayerStorageValue(cid, monster.storage).."", math.random(01,255))
	return true
end
 

Similar threads

Back
Top