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

Solved Task system edit.

Shadowman321

Member
Joined
Mar 27, 2010
Messages
205
Reaction score
22
Code:
local tasks =
{
	[1] = {questStarted = 1515, questStorage = 65015, killsRequired = 5, raceName = "Trolls", rewards = {{enable = true, type = "exp", values = 2000}, {enable = true, type = "money", values = 20000}}},
	[2] = {questStarted = 1516, questStorage = 65016, killsRequired = 5, raceName = "Dragons", rewards = {{enable = true, type = "exp", values = 20000}, {enable = true, type = "money", values = 20000}}},
	[3] = {questStarted = 1517, questStorage = 65017, killsRequired = 50, raceName = "Dragon Lords", rewards = {{enable = true, type = "exp", values = 20000}, {enable = true, type = "money", values = 200000}}}


}
 
local rankStorage = 32150
 

function onSay(cid, words, param)
	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wpisz !task list aby zobaczyc liste taskow. !task report aby sprawdzic ile potworow zabiles lub otrzymac nagrode. !task numer aby wybrac zadanie.")
		return true
	end
	if (param == 'list') then
		local text = "Lista zadan:"
		for i = 1, table.maxn(tasks) do
			text = text .. "\n" .. i .. "  -  " .. tasks[i].raceName .. (getCreatureStorage(cid, tasks[i].questStarted) == 2 and " [Done]" or "")
		end
		doShowTextDialog(cid, 5956, text)
end
	if tasks[tonumber(param)] then
		param = tonumber(param)
		if getCreatureStorage(cid, tasks[param].questStarted) == 1 then
			doPlayerSendTextMessage(cid, 22, "Jestes w trakcje wykonywania tego zadania.")
			return true
		end
		for k, v in pairs(tasks) do
			if getCreatureStorage(cid, v.questStarted) == 1 and param ~= k then
				doPlayerSendTextMessage(cid, 22, "Wlasnie wykonujesz inne zadanie.")
				return true
			end
		end

		doCreatureSetStorage(cid, tasks[param].questStarted, 1)
		doPlayerSendTextMessage(cid, 22, "Rozpoczales zadanie numer:  " .. param .. ", pamietaj, w tym zadaniu musisz pokonac " .. tasks[param].killsRequired .. " " .. tasks[param].raceName .. ". Powodzenia!")
	end
	if (param == 'report') then
		for k, v in pairs(tasks) do
			if getCreatureStorage(cid, v.questStarted) == 1 then
				if getCreatureStorage(cid, v.questStorage) >= v.killsRequired then
					for i = 1, table.maxn(v.rewards) do
						if(v.rewards[i].enable) then
							if isInArray({"boss", "teleport", 1}, v.rewards[i].type) then
								doTeleportThing(cid, v.rewards[i].values)
							elseif isInArray({"exp", "experience", 2}, v.rewards[i].type) then
								doPlayerAddExperience(cid, v.rewards[i].values)
							elseif isInArray({"item", 3}, v.rewards[i].type) then
								doPlayerAddItem(cid, v.rewards[i].values[1], v.rewards[i].values[2])
							elseif isInArray({"money", 4}, v.rewards[i].type) then
								doPlayerAddMoney(cid, v.rewards[i].values)
							elseif isInArray({"storage", "stor", 5}, v.rewards[i].type) then
								doCreatureSetStorage(cid, v.rewards[i].values[1], v.rewards[i].values[2])
							elseif isInArray({"points", "rank", 2}, v.rewards[i].type) then
								doCreatureSetStorage(cid, rankStorage, getCreatureStorage(cid, rankStorage) + v.rewards[i].values)
							else
								print("[Warning - Error::Killing in the name of::Tasks config] Bad reward type: " .. v.rewards[i].type .. ", reward could not be loaded.")
							end
						end
					end
					local rank = getCreatureStorage(cid, rankStorage)
					doPlayerSendTextMessage(cid, 22, "Swietnie!... skonczyles zadanie numer " .. k .. ". Dobra robota.")
					doCreatureSetStorage(cid, v.questStarted, -1)
					doCreatureSetStorage(cid, v.questStorage, -1)
					break
				else
					if getCreatureStorage(cid, v.questStorage) < 0 then
						doCreatureSetStorage(cid, v.questStorage, 0)
					end
					doPlayerSendTextMessage(cid, 22, "W tym momencie " .. getCreatureStorage(cid, v.questStorage) .. " " .. v.raceName .. " pokonanych, musisz zabic " .. v.killsRequired .. ".")
					break
				end
			elseif getCreatureStorage(cid, v.questStarted) == -1 then
			doPlayerSendTextMessage(cid, 22, "Nie rozpoczales jeszcze zadnego tasku.")
			end
		end
	end
	return true
end

Every time when i report task it send messages:
01:57 Nie rozpoczales jeszcze zadnego tasku.
01:57 Nie rozpoczales jeszcze zadnego tasku.
01:57 W tym momencie 1 Dragon Lords pokonanych, musisz zabic 50.
But it should send only:
01:57 W tym momencie 1 Dragon Lords pokonanych, musisz zabic 50.

There is condition "elseif getCreatureStorage(cid, v.questStarted) == -1 then", and while i got active task, v.questStarted storage = 1.
So, i don't know whats wrong.

Just added "break".
 
Last edited:
Back
Top