• 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 npc] Little problem

Glecko

Veteran OT User
Joined
Aug 21, 2007
Messages
1,054
Reaction score
270
Location
Spain
got a problem with my task npc, when I tell him "mission" he sends me 3 messages at once, 2 of them he is suposed to send later on.

Player: mission
NPC: Could you go and kill 3 trolls for me?
NPC: I will find someone braver than you. Hurry and get to the harbour
NPC: Grmpf. Get out of my sight then

If i kill a creature then it does not count towards my task (task is not started).

Code:
local tasks =
{
	[1] = {questStarted = 2510, questStorage = 65200, killsRequired = 3, raceName = "trolls", rewards = {{enable = true, type = "exp", values = 400}, {enable = true, type = "storage", values = 7653,1}}},
 
	[2] = {questStarted = 2511, questStorage = 65201, killsRequired = 1, raceName = "troll champion", rewards = {{enable = true, type = "exp", values = 600}, {enable = true, type = "storage", values = 7653,0},{enable = true, type = "money", values = 300}},
 
}
 
local rankStorage = 33150
local storage = 65521
 
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local voc = {}
 
function onCreatureAppear(cid)                          npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                                      npcHandler:onThink() end
 
function creatureSayCallback(cid, type, msg)
 
	local s = getCreatureStorage(cid, storage)
 
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
	if msgcontains(msg, "mission") then
 
		if(s < 1) then
			doCreatureSetStorage(cid, storage, 1)
			s = getCreatureStorage(cid, storage)
		end
 
		if(getCreatureStorage(cid, rankStorage) < 1) then
			doCreatureSetStorage(cid, rankStorage, 0)
		end
 
		if tasks[1] then
			if(getCreatureStorage(cid, tasks[1].questStarted) < 1) then
				selfSay("Could you go and kill 3 trolls for me?", cid)
				if msgcontains(msg, "yes") then
					if(getCreatureStorage(cid, tasks[1].creatureStorage) < 0) then
						doCreatureSetStorage(cid, tasks[1].creatureStorage, 0)
					end
 
					if(getCreatureStorage(cid, tasks[1].questStorage) < 0) then
						doCreatureSetStorage(cid, tasks[1].questStorage, 0)
					end
 
					doCreatureSetStorage(cid, tasks[1].questStarted, 1)
					selfSay("Alright, {report} to me when you\'re done.", cid)
				else
					selfSay("I will find someone braver than you. Hurry and get to the harbour!", cid)	
			else
				selfSay("You have not killed enough of them yet. Hurry!", cid)
			end
		if tasks[2] then
			if(getCreatureStorage(cid, tasks[2].questStarted) < 1) then
				selfSay("Can you go and kill a troll champion for me?", cid)
				if msgcontains(msg, "yes") then
					if(getCreatureStorage(cid, tasks[2].creatureStorage) < 0) then
						doCreatureSetStorage(cid, tasks[2].creatureStorage, 0)
					end
 
					if(getCreatureStorage(cid, tasks[2].questStorage) < 0) then
						doCreatureSetStorage(cid, tasks[2].questStorage, 0)
					end
 
					doCreatureSetStorage(cid, tasks[2].questStarted, 1)
					selfSay("You will find him in the sewers, two floors below. {Report} to me when you are done.", cid)
				else
					selfSay("Grmpf. Get out of my sight then.", cid)	
			else
				selfSay("You have not killed him yet. He\'s in the sewers, two floors below. Hurry!", cid)
			end
		else
			selfSay({"Your work here is completed...","Now hurry and try to get to a boat before they leave...","Me and my warriors will hold the line and give you time to depart. Hurry now!"}, cid)
		end
 
	elseif msgcontains(msg, "report") then
		if tasks[s] and tasks[s].questStarted > 0 then
			if(getCreatureStorage(cid, tasks[s].creatureStorage) < 0) then
				doCreatureSetStorage(cid, tasks[s].creatureStorage, 0)
			end
 
			if(getCreatureStorage(cid, tasks[s].questStorage) < 0) then
				doCreatureSetStorage(cid, tasks[s].questStorage, 0)
			end
 
			if(getCreatureStorage(cid, tasks[s].questStorage) >= tasks[s].killsRequired) then
				for i = 1, table.maxn(tasks[s].rewards) do
					if(tasks[s].rewards[i].enable) then
						if isInArray({"boss", "teleport", 1}, tasks[s].rewards[i].type) then
							doTeleportThing(cid, tasks[s].rewards[i].values)
						elseif isInArray({"exp", "experience", 2}, tasks[s].rewards[i].type) then
							doPlayerAddExperience(cid, tasks[s].rewards[i].values)
						elseif isInArray({"item", 3}, tasks[s].rewards[i].type) then
							doPlayerAddItem(cid, tasks[s].rewards[i].values[1], tasks[s].rewards[i].values[2])
						elseif isInArray({"money", 4}, tasks[s].rewards[i].type) then
							doPlayerAddMoney(cid, tasks[s].rewards[i].values)
						elseif isInArray({"storage", "stor", 5}, tasks[s].rewards[i].type) then
							doCreatureSetStorage(cid, tasks[s].rewards[i].values[1], tasks[s].rewards[i].values[2])
						elseif isInArray({"points", "rank", 2}, tasks[s].rewards[i].type) then
							doCreatureSetStorage(cid, rankStorage, getCreatureStorage(cid, rankStorage) + tasks[s].rewards[i].values)
						else
							print("[Warning - Error::Killing in the name of::Tasks config] Bad reward type: " .. tasks[s].rewards[i].type .. ", reward could not be loaded.")
						end
					end
				end
				local rank = getCreatureStorage(cid, rankStorage)
				selfSay("Your actions will save lives. Now ask me for another {mission}.", cid)
				doCreatureSetStorage(cid, storage, s + 1)
			else
				selfSay("You have killed " .. getCreatureStorage(cid, tasks[s].questStorage) .. " " .. tasks[s].raceName .. " of " .. tasks[s].killsRequired .. ".", cid)
			end
		else
			selfSay("You are not doing any task.", cid)
		end
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Anybody knows how to solve this?
Thanks in advance :)
 
Back
Top