Skrypty & Kody B??d Task System

Status
Zamknięty.

HulaHops

Advanced User
Zarejestrowany
Dołączył
Maj 1, 2009
Posty
186
Liczba reakcji
2
Witam u?ywam tego Task System:
CreatureEvent [CreatureEvent/Npc] Killing in the name of...

Przerobi?em go wedle swoich potrzeb. Task system mniej wi?cej dzia?a, normalnie mo?na rozmawia? z npc i przydziela nam taska, tak samo i nalicza ilo?? potwor?w.

Problem jest w tym, ?e nie dzia?a "Report Dragon", czyli raportowanie sko?czonej misji... Wyskakuj? o takie b??dy...

http://imageshack.us/photo/my-images/339/blado.png/

Wog?le jak pisz? NPC nie odpowiada.
Prosz? o pomoc, z g?ry dzi?ki REPUT!!!!
 
Odp: B??d Task System

Poka? prosz? sw?j przerobiony skrypt poniewa? ci??ko cokolwiek wyczyta? bez orygina?u, poniewa? uk?ad linijek si? zmienia.
 
Odp: B??d Task System

Skrypt do Creature Script


PHP:
local questCreatures =
{
	["dwarf"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15000, killsRequired = 100, raceName = "Dwarfs"},
	["dwarf soldier"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15001, killsRequired = 100, raceName = "Dwarfs"},
	["dwarf guard"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15002, killsRequired = 100, raceName = "Dwarfs"},
 
	["dragon"] = {questStarted = 1514, questStorage = 65004, creatureStorage = 15016, killsRequired = 300, raceName = "Dragons"},
 
	["giant spider"] = {questStarted = 1515, questStorage = 65005, creatureStorage = 15017, killsRequired = 300, raceName = "Giant Spiders"},
 
	["hero"] = {questStarted = 1516, questStorage = 65006, creatureStorage = 15018, killsRequired = 150, raceName = "Heros"},
 
	["bog raider"] = {questStarted = 1517, questStorage = 65007, creatureStorage = 15019, killsRequired = 200, raceName = "Bog Raiders"},
 
	["hydra"] = {questStarted = 1518, questStorage = 65008, creatureStorage = 15020, killsRequired = 300, raceName = "Hydras"},
 
	["dragon lord"] = {questStarted = 1519, questStorage = 65009, creatureStorage = 15021, killsRequired = 300, raceName = "Dragon Lords"},
 
	["frost dragon"] = {questStarted = 1520, questStorage = 65010, creatureStorage = 15022, killsRequired = 300, raceName = "Frost Dragons"},
 
	["wyrm"] = {questStarted = 1522, questStorage = 65012, creatureStorage = 15032, killsRequired = 70, raceName = "Wyrms"},

	["young sea serpent"] = {questStarted = 1523, questStorage = 65013, creatureStorage = 15036, killsRequired = 70, raceName = "Sea Serpents"},
 
	["serpent spawn"] = {questStarted = 1524, questStorage = 65014, creatureStorage = 15040, killsRequired = 70, raceName = "Serpent Spawns"},
 
	["nightmare"] = {questStarted = 1525, questStorage = 65015, creatureStorage = 15044, killsRequired = 70, raceName = "Nightmares"},
 
	["hellhound"] = {questStarted = 1526, questStorage = 65016, creatureStorage = 15048, killsRequired = 200, raceName = "Hellhounds"},
 
	["diabolic imp"] = {questStarted = 1527, questStorage = 65017, creatureStorage = 15049, killsRequired = 500, raceName = "Diabolic Imps"},
 
	["fury"] = {questStarted = 1528, questStorage = 65018, creatureStorage = 15050, killsRequired = 2000, raceName = "Furys"},
 
	["hellfire fighter"] = {questStarted = 1529, questStorage = 65019, creatureStorage = 15051, killsRequired = 2000, raceName = "Hellfire Fighters"},
 
	["grim reaper"] = {questStarted = 1530, questStorage = 65020, creatureStorage = 15052, killsRequired = 2000, raceName = "Grim Reapers"},
 
	["infernalist"] = {questStarted = 1531, questStorage = 65021, creatureStorage = 15053, killsRequired = 1500, raceName = "Infernalists"},
 
	["warlock"] = {questStarted = 1532, questStorage = 65022, creatureStorage = 15054, killsRequired = 500, raceName = "Warlocks"},

	["behemoth"] = {questStarted = 1533, questStorage = 65023, creatureStorage = 15056, killsRequired = 500, raceName = "Behemoths"},
 
	["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


Skrypt do NpC


PHP:
local tasks =
{
	[1] = {questStarted = 1510, questStorage = 65000, killsRequired = 100, raceName = "Dwarfs", rewards = {{enable = true, type = "exp", values = 1000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "money", values = 25000}}},
 
	[2] = {questStarted = 1514, questStorage = 65004, killsRequired = 300, raceName = "Dragons", rewards = {{enable = true, type = "exp", values = 8000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "money", values = 50000}}},
 
	[3] = {questStarted = 1515, questStorage = 65005, killsRequired = 300, raceName = "Giant Spiders", rewards = {{enable = true, type = "exp", values = 10000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "money", values = 50000}}},
 
	[4] = {questStarted = 1516, questStorage = 65006, killsRequired = 150, raceName = "Heros", rewards = {{enable = true, type = "exp", values = 15000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[5] = {questStarted = 1517, questStorage = 65007, killsRequired = 200, raceName = "Bog Raiders", rewards = {{enable = true, type = "exp", values = 2000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[6] = {questStarted = 1518, questStorage = 65008, killsRequired = 300, raceName = "Hydras", rewards = {{enable = true, type = "exp", values = 20000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "money", values = 100000}}},
 
	[7] = {questStarted = 1519, questStorage = 65009, killsRequired = 300, raceName = "Dragon Lords", rewards = {{enable = true, type = "exp", values = 30000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[8] = {questStarted = 1520, questStorage = 65010, killsRequired = 300, raceName = "Frost Dragons", rewards = {{enable = true, type = "exp", values = 25000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[9] = {questStarted = 1522, questStorage = 65012, killsRequired = 70, raceName = "Wyrms", rewards = {{enable = true, type = "exp", values = 30000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[10] = {questStarted = 1523, questStorage = 65013, killsRequired = 70, raceName = "Sea Serpents", rewards = {{enable = true, type = "exp", values = 25000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[11] = {questStarted = 1524, questStorage = 65014, killsRequired = 70, raceName = "Serpent Spawns", rewards = {{enable = true, type = "exp", values = 25000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[12] = {questStarted = 1525, questStorage = 65015, killsRequired = 70, raceName = "Nightmares", rewards = {{enable = true, type = "exp", values = 25000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[13] = {questStarted = 1526, questStorage = 65016, killsRequired = 200, raceName = "Hellhounds", rewards = {{enable = true, type = "exp", values = 40000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[14] = {questStarted = 1527, questStorage = 65017, killsRequired = 500, raceName = "Diabolic Imps", rewards = {{enable = true, type = "exp", values = 25000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[15] = {questStarted = 1528, questStorage = 65018, killsRequired = 2000, raceName = "Furys", rewards = {{enable = true, type = "exp", values = 30000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[16] = {questStarted = 1529, questStorage = 65019, killsRequired = 2000, raceName = "Hellfire Fighters", rewards = {{enable = true, type = "exp", values = 35000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[17] = {questStarted = 1530, questStorage = 65020, killsRequired = 2000, raceName = "Grim Reapers", rewards = {{enable = true, type = "exp", values = 35000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[18] = {questStarted = 1531, questStorage = 65021, killsRequired = 1500, raceName = "Infernalists", rewards = {{enable = true, type = "exp", values = 30000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[19] = {questStarted = 1532, questStorage = 65022, killsRequired = 500, raceName = "Warlocks", rewards = {{enable = true, type = "exp", values = 35000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[20] = {questStarted = 1533, questStorage = 65023, killsRequired = 500, raceName = "Behemoths", rewards = {{enable = true, type = "exp", values = 35000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
 
	[21] = {questStarted = 1539, questStorage = 65029, killsRequired = 6666, raceName = "Demons", rewards = {{enable = true, type = "exp", values = 40000000}, {enable = true, type = "item", values = 2000000}, {enable = true, type = "item", values = 1}}},
}
 
 
 
local rankStorage = 32150
local choose = {}
 
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
 
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[i].raceName .. (getCreatureStorage(cid, tasks[i].questStarted) == 1 and " [...]" or getCreatureStorage(cid, tasks[i].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[i].enable) then
				if isInArray({"boss", "teleport", 1}, tasks[t].rewards[i].type) then
					doTeleportThing(cid, tasks[t].rewards[i].values)
				elseif isInArray({"exp", "experience", 2}, tasks[t].rewards[i].type) then
					doPlayerAddExperience(cid, tasks[t].rewards[i].values)
				elseif isInArray({"item", 3}, tasks[t].rewards[i].type) then
					doPlayerAddItem(cid, v.rewards[i].values[1], tasks[t].rewards[i].values[2])
				elseif isInArray({"money", 4}, tasks[t].rewards[i].type) then
					doPlayerAddMoney(cid, tasks[t].rewards[i].values)
				elseif isInArray({"storage", "stor", 5}, tasks[t].rewards[i].type) then
					doCreatureSetStorage(cid, tasks[t].rewards[i].values[1], tasks[t].rewards[i].values[2])
				elseif isInArray({"points", "rank", 2}, tasks[t].rewards[i].type) then
					doCreatureSetStorage(cid, rankStorage, getCreatureStorage(cid, rankStorage) + tasks[t].rewards[i].values)
				else
					print("[Warning - Npc::KillingInTheNameOf] Wrong reward type: " .. (tasks[t].rewards[i].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())
 
Odp: B??d Task System

No i? poda?em.... RE E F R E S HH
 
Odp: B??d Task System

Zmie? linijk?
Kod:
 doPlayerAddItem(cid, v.rewards[i].values[1], tasks[t].rewards[i].values[2])
Na
Kod:
 doPlayerAddItem(cid, tasks[t].rewards[i].values[1], tasks[t].rewards[i].values[2])
I teraz je?eli dajesz item jako nagrod? to pole values musi by? tablic? gdzie pierwszy element to id itemu, a drugi to ilo??. Na przyk?ad:
Kod:
[2] = {questStarted = 1514, questStorage = 65004, killsRequired = 300, raceName = "Dragons", rewards = {{enable = true, type = "exp", values = 8000000}, {enable = true, type = "item", [b]values = {2126, 1}[/b]}, {enable = true, type = "money", values = 50000}}},
 
Status
Zamknięty.
Back
Do góry