Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Bom dia , galera , gostaria de pedir ajudar , com o npc grizzly adams , no meu OT , o erro e o seguinte , voce mata os bixos da task, ganha os pontos e tals , mais nao tem boss point , nao tem como matar o boss depois de falar report

 

uso tfs 1.0

 

Scripts:

Grizzly Adams.xml

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Grizzly Adams" script="Grizzly Adams.lua" walkinterval="2000" floorchange="0">
 <health now="100" max="100"/>
<look type="144" head="97" body="97" legs="94" feet="97" addons="3"/>
<voices>
<voice text="Write Task to start a task with number one !" interval2="100" margin="1" yell="no"/>
</voices>
<parameters>
<parameter key="module_shop" value="1" />
		<parameter key="shop_buyable" value="demon backpack,10518,1000;" />
	 <parameter key="shop_sellable" value="cyclops trophy,7398,500;minotaur trophy,7401,500;deer trophy,7397,3000;lion trophy,7400,3000;wolf trophy,7394,3000;behemoth trophy,7396,20000;demon trophy,7393,40000;dragon lord trophy,7399,10000;i,11208,50;i,10549,100;i,11183,35;i,10573,55;i,10564,30;i,11193,600;i,11366,80;i,10578,420;i,11222,400;i,11367,20;i,10547,280;i,11365,60;i,11363,170;i,11184,95" />
        <parameter key="message_greet" value="Be greeted, noble |PLAYERNAME| and welcome to my hut."/>
        <parameter key="message_farewell" value="Come back soon, noble |PLAYERNAME|."/>
		<parameter key="message_walkaway" value="Come back soon, noble." />
		<parameter key="message_sendtrade" value="Let's see what you got there." />
</parameters>

</npc>

Grizzly Adams.lua

dofile('data/lib/killingInTheNameOfQuest.lua')
--dofile('data/lib/StorageList.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
 
local choose = {}
local cancel = {}
local available = {}

local grizzlyAdamsConfig = {
							ranks = {
									huntsMan_rank = {
													{id=11208, buy=0, sell=50, name='antlers'},
													{id=10549, buy=0, sell=100, name='bloody pincers'},
													{id=11183, buy=0, sell=35, name='crab pincers'},
													{id=10573, buy=0, sell=55, name='cyclops toe'},
													{id=10564, buy=0, sell=30, name='frosty ear of a troll'},
													{id=11193, buy=0, sell=600, name='hydra head'},
													{id=11366, buy=0, sell=80, name='lancer beetle shell'},
													{id=10578, buy=0, sell=420, name='mutated bat ear'},
													{id=11222, buy=0, sell=400, name='sabretooth'},
													{id=11367, buy=0, sell=20, name='sandcrawler shell'},
													{id=10547, buy=0, sell=280, name='scarab pincers'},
													{id=11365, buy=0, sell=60, name='terramite legs'},
													{id=11363, buy=0, sell=170, name='terramite shell'},
													{id=11184, buy=0, sell=30000, name='terrorbird beak'},
													
													{id=7398, buy=0, sell=500, name='cyclops trophy'},
													{id=11315, buy=0, sell=15000, name='draken trophy'},
													{id=11330, buy=0, sell=8000, name='lizard trophy'},
													{id=7401, buy=0, sell=500, name='minotaur trophy'}
													},

									bigGameHunter_rank = {
													{id=7397, buy=0, sell=3000, name='deer trophy'},
													{id=7400, buy=0, sell=3000, name='lion trophy'},
													{id=7394, buy=0, sell=3000, name='wolf trophy'}
													},

									trophyHunter_rank = {
													{id=7393, buy=0, sell=40000, name='demon trophy'},
													{id=7396, buy=0, sell=20000, name='behemoth trophy'},
													{id=7399, buy=0, sell=10000, name='dragon lord trophy'},
													
													{id=10518, buy=1000, sell=0, name='demon backpack'},
													},
							        }
							}

local Topic = {}
function greetCallback(cid)
	Topic[cid] = 0
	return true
end

local function setNewTradeTable(table)
	local items = {}
	for _, v in ipairs(table) do
		items[v.id] = {itemId = v.id, buyPrice = v.buy, sellPrice = v.sell, subType = 0, realName = v.name}
	end
	return items
end

local function setNewLineTable(oldTable, newTable)
	for k, v in pairs(oldTable) do
		table.insert(newTable, k, v)
	end
	return true
end

function creatureSayCallback(cid, type, msg)
	local player = Player(cid)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
	if (msgcontains(msg, "hi") or msgcontains(msg, "hello")) and (not npcHandler:isFocused(cid)) then
		if (player:getStorageValue(JOIN_STOR) == -1) then
			npcHandler:say("Welcome "..getCreatureName(cid)..". Would you like to join the 'Paw and Fur - Hunting Elite'?", cid)
			npcHandler:addFocus(cid)
			talkState[talkUser] = 5
		else
			npcHandler:say("Welcome back old chap. What brings you here this time?", cid)
			npcHandler:addFocus(cid)
			talkState[talkUser] = 0
			end
			return true
		end
	 
		if(not npcHandler:isFocused(cid)) then
			return false
		end
		
		if msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
			npcHandler:say("Happy hunting, old chap!", cid, TRUE)
			Topic[talkUser] = 0
			npcHandler:releaseFocus(cid)
			npcHandler:resetNpc(cid)
		end
		
		if (isInArray({"yes", "join"}, msg:lower()) and talkState[talkUser] == 5) then 
			player:setStorageValue(JOIN_STOR, 1)
			npcHandler:say("Great! A warm welcome to our newest member: "..getCreatureName(cid).."! Ask me for a {task} if you want to go on a hunt.", cid)
			talkState[talkUser] = 0
		elseif (msg:lower() == "no" and talkState[talkUser] == 5) then
			npcHandler:say("No problem old chap. Come back if you change your mind.", cid)  
		end

		if (player:getStorageValue(JOIN_STOR) == -1) then
				npcHandler:say("You'll have to {join} us to get more information.",cid)
	return false
end
if isInArray({"offer", "trade"}, msg:lower()) then
	if getPlayerRank(cid) >= 2 then 
		if getPlayerRank(cid) == 2 or getPlayerRank(cid) == 3 then
			tradeRank = grizzlyAdamsConfig.ranks.huntsMan_rank
		elseif getPlayerRank(cid) == 4 then
			tradeRank = grizzlyAdamsConfig.ranks.bigGameHunter_rank
			setNewLineTable(grizzlyAdamsConfig.ranks.huntsMan_rank, grizzlyAdamsConfig.ranks.bigGameHunter_rank)
		elseif getPlayerRank(cid) == 5 or getPlayerRank(cid) == 6 then
			tradeRank = grizzlyAdamsConfig.ranks.trophyHunter_rank
			setNewLineTable(grizzlyAdamsConfig.ranks.huntsMan_rank, grizzlyAdamsConfig.ranks.bigGameHunter_rank)
			setNewLineTable(grizzlyAdamsConfig.ranks.huntsMan_rank, grizzlyAdamsConfig.ranks.trophyHunter_rank)
		end
		local items = setNewTradeTable(tradeRank)
		local function onBuy(cid, item, subType, amount, ignoreCap, inBackpacks)
			if ignoreCap == false and (player:getFreeCapacity() < getItemWeight(items[item].itemId, amount) or inBackpacks and player:getFreeCap() < (getItemWeight(items[item].itemId, amount) + getItemWeight(1988, 1))) then
				return player:sendTextMessage(MESSAGE_INFO_DESCR, 'You don\'t have enough cap.')
			end
			if items[item].buyPrice then
				player:removeMoney(amount * items[item].buyPrice)
				for i = 1, amount do
					if inBackpacks then
						local backpack = doCreateItemEx(1988, 1)
						doAddContainerItem(backpack, items[item].itemId, amount)
					else
						player:addItem(items[item].itemId, amount, true)
					end
				end
				return player:sendTextMessage(MESSAGE_INFO_DESCR, 'You bought '..amount..'x '..items[item].realName..' for '..items[item].buyPrice * amount..' gold coins.')
			end
			return true
			end
			 
		local function onSell(cid, item, subType, amount, ignoreCap, inBackpacks)
			if items[item].sellPrice then
				player:addMoney(items[item].sellPrice * amount)
				player:removeItem(items[item].itemId, amount)
				return player:sendTextMessage(cid, MESSAGE_INFO_DESCR, 'You sold '..amount..'x '..items[item].realName..' for '..items[item].sellPrice * amount..' gold coins.')
			end
			return true
		end
		openShopWindow(cid, tradeRank, onBuy, onSell)
		return npcHandler:say('It\'s my offer.', player)
	else
		return npcHandler:say('You don\'t have any rank.', player)
		end
end
 
	if isInArray({"tasks", "task", "mission"}, msg:lower()) then
		local can = getTasksByPlayer(cid)
		if (player:getStorageValue(JOIN_STOR) == -1) then
 	        return (npcHandler:say("You'll have to {join}, to get any {tasks}.",cid))
        end
		if #can > 0 then
			local text = ""
			local sep = ", "
			table.sort(can, (function(a, b) return (a < b) end))
			local t = 0
			for _, id in ipairs(can) do
				t = t + 1
				if t == #can - 1 then
					sep = " and "
				elseif t == #can then
					sep = "."
				end
				text = text .. "{" .. (tasks[id].name or tasks[id].raceName) .. "}" .. sep
			end
			npcHandler:say("The current task" .. (#can > 1 and "s" or "") .. " that you can choose " .. (#can > 1 and "are" or "is") .. " " .. text, player)
			talkState[talkUser] = 0
		else
			npcHandler:say("I don't have any task for you right now.", player)
		end
	elseif msg ~= "" and canStartTask(cid, msg) then
		if #getPlayerStartedTasks(cid) >= tasksByPlayer then
			npcHandler:say("Sorry, but you already started " .. tasksByPlayer .. " tasks. You can check their {status} or {cancel} a task.", player)
			return true
		end
		local task = getTaskByName(msg)
		if task and player:getStorageValue(QUESTSTORAGE_BASE + task) > 0 then  
			return false
		end
		npcHandler:say("In this task you must defeat " .. tasks[task].killsRequired .. " " .. tasks[task].raceName .. ". Are you sure that you want to start this task?", player)
		choose[cid] = task
		talkState[talkUser] = 1
	elseif msg:lower() == "yes" and talkState[talkUser] == 1 then
		player:setStorageValue(QUESTSTORAGE_BASE + choose[cid], 1)
		player:setStorageValue(KILLSSTORAGE_BASE + choose[cid], 0)
		npcHandler:say("Excellent! You can check the {status} of your task saying {report} to me. Also you can {cancel} tasks to.", player)
		choose[cid] = nil
		talkState[talkUser] = 0	
	elseif (msg:lower() == "report" or msg:lower() == "status") then
		local started = getPlayerStartedTasks(cid)
		local finishedAtLeastOne = false
		local finished = 0
		if started and #started > 0 then
			for _, id in ipairs(started) do
				if player:getStorageValue(KILLSSTORAGE_BASE + id) >= tasks[id].killsRequired then
					for _, reward in ipairs(tasks[id].rewards) do
						local deny = false
						if reward.storage then
							if player:getStorageValue(reward.storage[1]) >= reward.storage[2] then
								deny = true
							end
						end
						if isInArray({REWARD_MONEY, "money"}, reward.type:lower()) and not deny then
							doPlayerAddMoney(cid, reward.value[1])
						elseif isInArray({REWARD_EXP, "exp", "experience"}, reward.type:lower()) and not deny then
							doPlayerAddExp(cid, reward.value[1], false, reward.value[1], false, true)
							doPlayerSendDefaultCancel(cid, "You gained " .. reward.value[1] .. " experience points.")
						elseif isInArray({REWARD_ACHIEVEMENT, "achievement", "ach"}, reward.type:lower()) and not deny then
						elseif isInArray({REWARD_STORAGE, "storage", "stor"}, reward.type:lower()) and not deny then
							player:setStorageValue(reward.value[1], reward.value[2])
						elseif isInArray({REWARD_POINT, "points", "point"}, reward.type:lower()) and not deny then
							player:setStorageValue(POINTSSTORAGE, player:getStorageValue(POINTSSTORAGE) + reward.value[1])
						elseif isInArray({REWARD_ITEM, "item", "items", "object"}, reward.type:lower()) and not deny then
							doPlayerAddItem(cid, reward.value[1], reward.value[2])
						end
 
						if reward.storage then
							player:setStorageValue(reward.storage[1], reward.storage[2])
						end
					end
 
					if tasks[id].norepeatable then
						player:setStorageValue(QUESTSTORAGE_BASE + id, 2)
					else
						player:setStorageValue(QUESTSTORAGE_BASE + id, 0)
					end
					player:setStorageValue(KILLSSTORAGE_BASE + id, 0)
					if player:getStorageValue(REPEATSTORAGE_BASE + id) < 1 then
						player:setStorageValue(REPEATSTORAGE_BASE + id, 0)
					end
					player:setStorageValue(REPEATSTORAGE_BASE + id, player:getStorageValue(REPEATSTORAGE_BASE + id) + 1)
					finishedAtLeastOne = true
					finished = finished + 1
				end
			end
	if (not finishedAtLeastOne) then
 		local started = getPlayerStartedTasks(cid)
		if (started and #started > 0) then	
			local text = ""
			local sep = ", "
			table.sort(started, (function(a, b) return (a < b) end))
			local t = 0
			for _, id in ipairs(started) do
				t = t + 1
				if (t == #started - 1) then
					sep = " and "
				elseif (t == #started) then
					sep = "."
				end
				text = text .. "{" .. (tasks[id].name or tasks[id].raceName) .. "}" .. sep
			end
			    npcHandler:say("The current task" .. (#started > 1 and "s" or "") .. " that you started " .. (#started > 1 and "are" or "is") .. " " .. text, player)
			    Topic[cid] = 1
			else
				npcHandler:say("Awesome! you finished " .. (finished > 1 and "various" or "a") .. " task" .. (finished > 1 and "s" or "") .. ". Talk to me again if you want to start a {task}.", player)
			end
		else
			npcHandler:say("You haven't started any task yet.", player)
		end
	end
	elseif msg:lower() == "started" then
		local started = getPlayerStartedTasks(cid)
		if started and #started > 0 then
			local text = ""
			local sep = ", "
			table.sort(started, (function(a, b) return (a < b) end))
			local t = 0
			for _, id in ipairs(started) do
				t = t + 1
				if t == #started - 1 then
					sep = " and "
				elseif t == #started then
					sep = "."
				end
				text = text .. "{" .. (tasks[id].name or tasks[id].raceName) .. "}" .. sep
			end
 
			npcHandler:say("The current task" .. (#started > 1 and "s" or "") .. " that you started " .. (#started > 1 and "are" or "is") .. " " .. text, player)
		else
			npcHandler:say("You haven't started any task yet.", player)
		end
	elseif msg:lower() == "cancel" then
		local started = getPlayerStartedTasks(cid)
		local task = getTaskByName(msg)
		local text = ""
			local sep = ", "
			table.sort(started, (function(a, b) return (a < b) end))
			local t = 0
			for _, id in ipairs(started) do
				t = t + 1
				if t == #started - 1 then
					sep = " or "
				elseif t == #started then
					sep = "?"
				end
				text = text .. "{" .. (tasks[id].name or tasks[id].raceName) .. "}" .. sep
			end
		if started and #started > 0 then
			npcHandler:say("Cancelling a task will make the counter restart. Which of these tasks you want cancel?" .. (#started > 1 and "" or "") .. " " .. text, player)
			talkState[talkUser] = 2
		else
			npcHandler:say("You haven't started any task yet.", player)
		end
	elseif getTaskByName(msg) and talkState[talkUser] == 2 and isInArray(getPlayerStartedTasks(cid), getTaskByName(msg)) then
		local task = getTaskByName(msg)
		if player:getStorageValue(KILLSSTORAGE_BASE + task) > 0 then
			npcHandler:say("You currently killed " .. player:getStorageValue(KILLSSTORAGE_BASE + task) .. "/" .. tasks[task].killsRequired .. " " .. tasks[task].raceName .. ". Cancelling this task will restart the count. Are you sure you want to cancel this task?", player)
		else
			npcHandler:say("Are you sure you want to cancel this task?", player)
		end
		talkState[talkUser] = 3
		cancel[cid] = task
	elseif getTaskByName(msg) and Topic[cid] == 1 and isInArray(getPlayerStartedTasks(cid), getTaskByName(msg)) then
		local task = getTaskByName(msg)
		if player:getStorageValue(KILLSSTORAGE_BASE + task) > 0 then
			npcHandler:say("You currently killed " .. player:getStorageValue(KILLSSTORAGE_BASE + task) .. "/" .. tasks[task].killsRequired .. " " .. tasks[task].raceName .. ".", player)
			Topic[cid] = 0
		else
		    npcHandler:say("You currently killed 0/" .. tasks[task].killsRequired .. " " .. tasks[task].raceName .. ".", player)
		end
	elseif msg:lower() == "yes" and talkState[talkUser] == 3 then
		player:setStorageValue(QUESTSTORAGE_BASE + cancel[cid], -1)
		player:setStorageValue(KILLSSTORAGE_BASE + cancel[cid], -1)
		npcHandler:say("You have cancelled the task " .. (tasks[cancel[cid]].name or tasks[cancel[cid]].raceName) .. ".", player)
		talkState[talkUser] = 0
	elseif isInArray({"points", "rank"}, msg:lower()) then
	    if player:getStorageValue(POINTSSTORAGE) < 1 then
		npcHandler:say("At this time, you have 0 Paw & Fur points. You " .. (getPlayerRank(cid) == 6 and "are an Elite Hunter" or getPlayerRank(cid) == 5 and "are a Trophy Hunter" or getPlayerRank(cid) == 4 and "are a Big Game Hunter" or getPlayerRank(cid) == 3 and "are a Ranger" or getPlayerRank(cid) == 2 and "are a Huntsman" or getPlayerRank(cid) == 1 and "are a Member"  or "haven't been ranked yet") .. ".", player)
		elseif player:getStorageValue(POINTSSTORAGE) >= 1 then 
		npcHandler:say("At this time, you have " .. player:getStorageValue(POINTSSTORAGE) .. " Paw & Fur points. You " .. (getPlayerRank(cid) == 6 and "are an Elite Hunter" or getPlayerRank(cid) == 5 and "are a Trophy Hunter" or getPlayerRank(cid) == 4 and "are a Big Game Hunter" or getPlayerRank(cid) == 3 and "are a Ranger" or getPlayerRank(cid) == 2 and "are a Huntsman" or getPlayerRank(cid) == 1 and "are a Member"  or "haven't been ranked yet") .. ".", player)
		end
		talkState[talkUser] = 0
	end
end
 
npcHandler:setMessage(MESSAGE_FAREWELL, "Happy hunting, old chap!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

data/lib/killingInTheNameOfQuest.lua

RANK_NONE = 0
RANK_JOIN = 1
RANK_HUNTSMAN = 2
RANK_RANGER = 3
RANK_BIGGAMEHUNTER = 4
RANK_TROPHYHUNTER = 5
RANK_ELITEHUNTER = 6
 
REWARD_MONEY = 1
REWARD_EXP = 2
REWARD_ACHIEVEMENT = 3
REWARD_STORAGE = 4
REWARD_POINT = 5
REWARD_ITEM = 6
 
QUESTSTORAGE_BASE = 1500
JOIN_STOR = 100157
KILLSSTORAGE_BASE = 65000
REPEATSTORAGE_BASE = 48950
POINTSSTORAGE = 2500
tasks =
{
	[1] = {killsRequired = 100, raceName = "Trolls", level = {6, 19}, premium = true, creatures = {"troll", "troll champion", "island troll", "swamp troll"}, rewards = {{type = "exp", value = {200}},{type = "money", value = {200}}}},
	[2] = {killsRequired = 150, raceName = "Goblins", level = {6, 19}, premium = true, creatures = {"goblin", "goblin assassin", "goblin leader"}, rewards = {{type = "exp", value = {300}},{type = "money", value = {250}}}},
	[3] = {killsRequired = 300, raceName = "Crocodiles", level = {6, 49}, premium = true, creatures = {"crocodile"}, rewards = {{type = "exp", value = {800}},{type = "achievement", value = {"Blood-Red Snapper"}},{type = "storage", value = {35000, 1}},{type = "points", value = {1}}}},
	[4] = {killsRequired = 300, raceName = "Badgers", level = {6, 49}, premium = true, creatures = {"badger"}, rewards = {{type = "exp", value = {500}},{type = "points", value = {1}}}},
	[5] = {killsRequired = 300, raceName = "Tarantulas", level = {6, 49}, premium = true, creatures = {"tarantula"}, rewards = {{type = "exp", value = {1500}},{type = "achievement", value = {"No More Hiding"}},{type = "storage", value = {35001, 1}},{type = "points", value = {2}}}},
	[6] = {killsRequired = 150, raceName = "Carniphilas", level = {6, 49}, premium = true, creatures = {"carniphila"}, rewards = {{type = "exp", value = {2500}},{type = "achievement", value = {"Rootless Behaviour"}},{type = "storage", value = {35002, 1}},{type = "points", value = {3}}}},
	[7] = {killsRequired = 200, raceName = "Stone Golems", level = {6, 49}, premium = true, creatures = {"stone golem"}, rewards = {{type = "exp", value = {2000}},{type = "points", value = {3}}}},
	[8] = {killsRequired = 300, raceName = "Mammoths", level = {6, 49}, premium = true, creatures = {"mammoth"}, rewards = {{type = "exp", value = {4000}},{type = "achievement", value = {"Meat Skewer"}},{type = "storage", value = {35003, 1}},{type = "points", value = {3}}}},
	[9] = {killsRequired = 300, raceName = "Gnarlhounds", level = {6, 49}, premium = true, creatures = {"gnarlhound"}, rewards = {{type = "exp", value = {1000}},{type = "points", value = {2}}}},
	[10] = {killsRequired = 300, raceName = "Terramites", level = {6, 49}, premium = true, creatures = {"terramite"}, rewards = {{type = "exp", value = {1000}},{type = "points", value = {2}}}},
	[11] = {killsRequired = 300, raceName = "Apes", level = {6, 49}, premium = true, creatures = {"kongra", "sibang", "merklin"}, rewards = {{type = "exp", value = {1000}},{type = "points", value = {2}}}},
	[12] = {killsRequired = 300, raceName = "Thornback Tortoises", level = {6, 49}, premium = true, creatures = {"thornback tortoise"}, rewards = {{type = "exp", value = {1500}},{type = "points", value = {2}}}},
	[13] = {killsRequired = 300, raceName = "Gargoyles", level = {6, 49}, premium = true, creatures = {"gargoyle"}, rewards = {{type = "exp", value = {1500}}}},
	[14] = {killsRequired = 300, raceName = "Ice Golems", level = {50, 79}, premium = true, creatures = {"ice golem"}, rewards = {{type = "exp", value = {12000}},{type = "achievement", value = {"Breaking The Ice"}},{type = "storage", value = {35004, 1}},{type = "points", value = {2}}}},
	[15] = {killsRequired = 400, raceName = "Quara Scouts", level = {50, 79}, premium = true, creatures = {"quara pincher scout", "quara predator scout", "quara hydromancer scout", "quara constrictor scout", "quara mantassin scout"}, rewards = {{type = "exp", value = {10000}},{type = "points", value = {2}}}},
	[16] = {killsRequired = 400, raceName = "Mutated Rats", level = {50, 79}, premium = true, creatures = {"mutated rat"}, rewards = {{type = "exp", value = {10000}},{type = "achievement", value = {"Twisted Mutation"}},{type = "storage", value = {35005, 1}},{type = "points", value = {2}}}},																								
	[17] = {killsRequired = 250, raceName = "Ancient Scarabs", level = {50, 79}, premium = true, creatures = {"ancient scarab"}, rewards = {{type = "exp", value = {15000}},{type = "achievement", value = {"Crawling Death"}},{type = "storage", value = {35006, 1}},{type = "points", value = {2}}}},	
	[18] = {killsRequired = 300, raceName = "Wyverns", level = {50, 79}, premium = true, creatures = {"wyvern"}, rewards = {{type = "exp", value = {12000}},{type = "points", value = {2}}}},																										
	[19] = {killsRequired = 300, raceName = "Lancer Beetles", level = {50, 79}, premium = true, creatures = {"lancer beetle"}, rewards = {{type = "exp", value = {8000}},{type = "points", value = {2}}}},																										
	[20] = {killsRequired = 400, raceName = "Wailing Widows", level = {50, 79}, premium = true, creatures = {"wailing widow"}, rewards = {{type = "exp", value = {12000}},{type = "points", value = {3}}}},																										
	[21] = {killsRequired = 250, raceName = "Killer Caimans", level = {50, 79}, premium = true, creatures = {"killer caiman"}, rewards = {{type = "exp", value = {10000}},{type = "points", value = {2}}}},																										
	[22] = {killsRequired = 300, raceName = "Bonebeasts", level = {50, 79}, premium = true, creatures = {"bonebeast"}, rewards = {{type = "exp", value = {12000}},{type = "achievement", value = {"Spareribs for Dinner"}},{type = "storage", value = {35007, 1}},{type = "points", value = {2}}}},	
	[23] = {killsRequired = 300, raceName = "Crystal Spiders", level = {50, 79}, creatures = {"crystal spider"}, premium = true, rewards = {{type = "exp", value = {15000}},{type = "achievement", value = {"Arachnoise"}},{type = "storage", value = {35008, 1}},{type = "points", value = {3}}}},	
	[24] = {killsRequired = 300, raceName = "Mutated Tigers", level = {50, 79}, premium = true, creatures = {"mutated tiger"}, rewards = {{type = "exp", value = {12000}},{type = "points", value = {2}}}},	
	[25] = {killsRequired = 600, raceName = "Underwater Quara", level = {80, 129}, premium = true, creatures = {"quara hydromancer", "quara predator", "quara constrictor", "quara mantassin", "quara pincher"}, rewards = {{type = "exp", value = {15000}},{type = "achievement", value = {"Back into the Abyss"}},{type = "storage", value = {35009, 1}},{type = "points", value = {3}}}},	
	[26] = {killsRequired = 500, raceName = "Giant Spiders", level = {80, 129}, premium = true, creatures = {"giant spider"}, rewards = {{type = "exp", value = {20000}},{type = "achievement", value = {"Choking on Her Venom"}},{type = "storage", value = {35010, 1}},{type = "points", value = {3}}}},	
	[27] = {killsRequired = 300, raceName = "Werewolves", level = {80, 129}, premium = true, creatures = {"werewolf"}, rewards = {{type = "exp", value = {30000}},{type = "achievement", value = {"Howly Silence"}},{type = "storage", value = {35011, 1}},{type = "points", value = {4}}}},
	[28] = {killsRequired = 400, raceName = "Nightmares", level = {80, 129}, premium = true, creatures = {"nightmare", "nightmare scion"}, rewards = {{type = "exp", value = {25000}},{type = "achievement", value = {"Dream is Over"}},{type = "storage", value = {35012, 1}},{type = "points", value = {3}}}},		
	[29] = {killsRequired = 600, raceName = "Hellspawns", level = {80, 129}, premium = true, creatures = {"hellspawn"}, rewards = {{type = "exp", value = {25000}},{type = "achievement", value = {"Scorched Flames"}},{type = "storage", value = {35013, 1}}}},
	[30] = {killsRequired = 800, raceName = "High Class Lizards", level = {80, 129}, premium = true, creatures = {"lizard chosen", "lizard dragon priest", "lizard high guard", "lizard legionnaire"}, rewards = {{type = "exp", value = {30000}},{type = "achievement", value = {"Zzztill Zzztanding!"}},{type = "storage", value = {35014, 1}},{type = "points", value = {3}}}},
	[31] = {killsRequired = 600, raceName = "Stampors", level = {80, 129}, premium = true, creatures = {"stampor"}, rewards = {{type = "exp", value = {20000}},{type = "achievement", value = {"Stepped on a Big Toe"}},{type = "storage", value = {35015, 1}},{type = "points", value = {3}}}},		
	[32] = {killsRequired = 500, raceName = "Brimstone Bugs", level = {80, 129}, premium = true, creatures = {"brimstone bug"}, rewards = {{type = "exp", value = {15000}},{type = "achievement", value = {"Something Smells"}},{type = "storage", value = {35016, 1}},{type = "points", value = {3}}}},	
	[33] = {killsRequired = 400, raceName = "Mutated Bats", level = {80, 129}, premium = true, creatures = {"mutated bat"}, rewards = {{type = "exp", value = {20000}},{type = "achievement", value = {"Kapow!"}},{type = "storage", value = {35017, 1}},{type = "points", value = {2}}}},											
	[34] = {killsRequired = 650, raceName = "Hydras", level = {130, 9999}, premium = true, creatures = {"hydra"}, rewards = {{type = "exp", value = {30000}},{type = "achievement", value = {"One Less"}},{type = "storage", value = {35018, 1}},{type = "points", value = {3}}}},	
	[35] = {killsRequired = 800, raceName = "Serpent Spawns", level = {130, 9999}, premium = true, creatures = {"serpent spawn"}, rewards = {{type = "exp", value = {30000}},{type = "achievement", value = {"Hissing Downfall"}},{type = "storage", value = {35019, 1}},{type = "points", value = {4}}}},		
	[36] = {killsRequired = 500, raceName = "Medusae", level = {130, 9999}, premium = true, creatures = {"medusa"}, rewards = {{type = "exp", value = {40000}},{type = "achievement", value = {"The Serpent's Bride"}},{type = "storage", value = {35020, 1}},{type = "points", value = {5}}}},	
	[37] = {killsRequired = 700, raceName = "Behemoths", level = {130, 9999}, premium = true, creatures = {"behemoth"}, rewards = {{type = "exp", value = {30000}},{type = "achievement", value = {"Just Cracked Me Up!"}},{type = "storage", value = {35021, 1}},{type = "points", value = {4}}}},	
	[38] = {killsRequired = 900, raceName = "Sea Serpents and Young Sea Serpents", level = {130, 9999}, premium = true, creatures = {"sea serpent", "young sea serpent"}, rewards = {{type = "exp", value = {30000}},{type = "achievement", value = {"The Drowned Sea God"}},{type = "storage", value = {35022, 1}},{type = "points", value = {4}}}},		
	[39] = {killsRequired = 250, raceName = "Hellhounds", level = {130, 9999}, premium = true, creatures = {"hellhound"}, rewards = {{type = "exp", value = {40000}},{type = "achievement", value = {"The Gates of Hell"}},{type = "storage", value = {35023, 1}},{type = "points", value = {5}}}},		
	[40] = {killsRequired = 500, raceName = "Ghastly Dragons", level = {130, 9999}, premium = true, creatures = {"ghastly dragon"}, rewards = {{type = "exp", value = {30000}},{type = "achievement", value = {"Beautiful Agony"}},{type = "storage", value = {35024, 1}},{type = "points", value = {5}}}},		
	[41] = {killsRequired = 900, raceName = "Drakens", level = {130, 9999}, premium = true, creatures = {"draken spellweaver", "draken warmaster", "draken abomination", "draken elite"} , rewards = {{type = "exp", value = {30000}},{type = "achievement", value = {"Enter zze Draken!"}},{type = "storage", value = {35025, 1}},{type = "points", value = {3}}}},	
	[42] = {killsRequired = 650, raceName = "Destroyers", level = {130, 9999}, premium = true, creatures = {"destroyer"}, rewards = {{type = "exp", value = {30000}},{type = "achievement", value = {"Best there was!"}},{type = "storage", value = {35026, 1}},{type = "points", value = {4}}}},			
	[43] = {killsRequired = 400, raceName = "Undead Dragons", level = {130, 9999}, premium = true, creatures = {"undead dragon"}, rewards = {{type = "exp", value = {50000}},{type = "achievement", value = {"Back from the Dead"}},{type = "storage", value = {35027, 1}},{type = "points", value = {6}}}},	
	[44] = {killsRequired = 6666, raceName = "Demons", level = {130, 9999}, rank = RANK_ELITEHUNTER, premium = true, creatures = {"demon"}, rewards = {{type = "storage", value = {41300, 1}}}},
	[45] = {killsRequired = 500, raceName = "Green Djinns or Efreets", level = {1, 9999}, storage = {12500, 1}, premium = true, creatures = {"green djinn", "efreet"}, rewards = {{type = "exp", value = {10000}},{type = "money", value = {5000}},{type = "storage", value = {35028, 1}}}},
	[46] = {killsRequired = 500, raceName = "Blue Djinns or Marids", level = {1, 9999}, storage = {12501, 1}, premium = true, creatures = {"blue djinn", "marid"}, rewards = {{type = "exp", value = {10000}},{type = "money", value = {5000}},{type = "storage", value = {35029, 1}}}},		
	[47] = {killsRequired = 3000, raceName = "Pirates", level = {1, 9999}, storage = {12600, 1}, premium = true, creatures = {"pirate ghost", "pirate marauder", "pirate cutthroad", "pirate buccaneer", "pirate corsair", "pirate skeleton"}, rewards = {{type = "exp", value = {10000}},{type = "money", value = {5000}},{type = "storage", value = {35030, 1}}}},	 
	[48] = {killsRequired = 3000, raceName = "Pirates second task", level = {1, 9999}, storage = {REPEATSTORAGE_BASE + 47, 3}, norepeatable = true, premium = true, creatures = {"pirate ghost", "pirate marauder", "pirate cutthroad", "pirate buccaneer", "pirate corsair", "pirate skeleton"}, rewards = {{type = "exp", value = {10000}},{type = "money", value = {5000}},{type = "storage", value = {35031, 1}}}},	 
	[49] = {killsRequired = 5000, raceName = "Minotaurs", level = {1, 40}, norepeatable = true, premium = false, creatures = {"minotaur", "minotaur mage", "minotaur archer"}, rewards = {{type = "storage", value = {35032, 1}}}},
	[50] = {killsRequired = 4000, raceName = "Necromancers and Priestess", level = {60, 9999}, norepeatable = true, premium = true, creatures = {"necromancer", "priestess"}, rewards = {{type = "storage", value = {35033, 1}},{type = "storage", value = {12800, 1}}}},
	[51] = {killsRequired = 1000, name = "Necromancers and Priestess second task", raceName = "Necromancers and Priestess", level = {60, 9999}, storage = {12800, 1}, norepeatable = true, premium = true, creatures = {"necromancer", "priestess"}, rewards = {{type = "exp", value = {40000}},{type = "storage", value = {35033, 1}}}},																																		
}
 
tasksByPlayer = 3
repeatTimes = 3
 
function getPlayerRank(cid)
	local p = Player(cid)
	return (p:getStorageValue(POINTSSTORAGE) >= 100 and RANK_ELITEHUNTER or p:getStorageValue(POINTSSTORAGE) >= 70 and RANK_TROPHYHUNTER or p:getStorageValue(POINTSSTORAGE) >= 40 and RANK_BIGGAMEHUNTER or p:getStorageValue(POINTSSTORAGE) >= 20 and RANK_RANGER or p:getStorageValue(POINTSSTORAGE) >= 10 and RANK_HUNTSMAN or p:getStorageValue(JOIN_STOR) == 1 and RANK_JOIN or RANK_NONE)
end
 
function getTaskByName(name, table)
	local t = (table and table or tasks)
	for k, v in pairs(t) do
		if(v.name) then
			if(v.name:lower() == name:lower()) then
				return k
			end
		else
			if(v.raceName:lower() == name:lower()) then
				return k
			end
		end
	end
return false
end
 
function getTasksByPlayer(cid)
	local p = Player(cid)
	local canmake = {}
	local able = {}
	for k, v in pairs(tasks) do
		if(p:getStorageValue(QUESTSTORAGE_BASE + k) < 1 and p:getStorageValue(REPEATSTORAGE_BASE + k) < repeatTimes) then
			able[k] = true
			if(p:getLevel() < v.level[1] or p:getLevel() > v.level[2]) then
				able[k] = false
			end
			if(v.storage and p:getStorageValue(v.storage[1]) < v.storage[2]) then
				able[k] = false
			end
 
			if(v.rank) then
				if(getPlayerRank(cid) < v.rank) then
					able[k] = false
				end
			end
 
			if(v.premium) then
				if(not(isPremium(cid))) then
					able[k] = false
				end
			end
 
			if(able[k]) then
				table.insert(canmake, k)
			end
		end
	end
return canmake
end
 
 
function canStartTask(cid, name, table)
	local p = Player(cid)
	local v = ""
	local id = 0
	local t = (table and table or tasks)
	for k, i in pairs(t) do
		if(i.name) then
			if(i.name:lower() == name:lower()) then
				v = i
				id = k
				break
			end
		else
			if(i.raceName:lower() == name:lower()) then
				v = i
				id = k
				break
			end
		end
	end
	if(v == "") then
		return false
	end
	if(p:getStorageValue(QUESTSTORAGE_BASE + id) > 0) then
		return false
	end
	if(p:getStorageValue(REPEATSTORAGE_BASE +  id) >= repeatTimes) or (v.norepeatable and p:getStorageValue(REPEATSTORAGE_BASE +  id) > 0) then
		return false
	end
	if(p:getLevel() >= v.level[1] and p:getLevel() <= v.level[2]) then
		if(v.premium) then
			if(isPremium(cid)) then
				if(v.rank) then
					if(getPlayerRank(cid) >= v.rank) then
						if(v.storage) then 
							if(p:getStorageValue(v.storage[1]) >= v.storage[2]) then
								return true
							end
						else
							return true
						end
					end
				else
					return true
				end
			end
		else
			return true
		end
	end
return false
end
 
function getPlayerStartedTasks(cid)
	local p = Player(cid)
	local tmp = {}
	for k, v in pairs(tasks) do
		if(p:getStorageValue(QUESTSTORAGE_BASE + k) > 0 and p:getStorageValue(QUESTSTORAGE_BASE + k) < 2) then
			table.insert(tmp, k) 
		end
	end
return tmp
end
Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Conteúdo Similar

    • Por ambrozii0
      Gostaria de fazer um pedido de um NPC de Task progressiva,

      Ele iniciaria dando missões para level 8 para caçar Troll, Rotworm e Ghoul.
       
      No level 30 liberaria: Cyclops, Dragon e Wyrm... e assim em diante se puder deixar comentado eu faço as criaturas na sequencia dos leveis seguintes.
       
      O jogador pode fazer as tasks dos leveis anteriores mesmo que já tenha ultrapassado o level do próximo nível de task.
       
      E o jogador ao terminar a missão poderia escolher a recompensa em gold ou experiência. As tasks podem se repetir sem problema, mas apenas pode pegar uma de cada vez.
       
      Ao finalizar todas as tasks o jogador ganha uma montaria.
       
      Minha versão de cliente é 12.91
      Versão da Canary 2.6.1
      Não sei qual o TFS do meu servidor.
    • Por daviscript
      Após verificar que vários servidores estão sofrendo com problemas na página Guilds, onde era possível fazer diversas modificações com os players de qualquer guild, até a Cipsoft passou por esse problema recentemente...
      Resolvi compartilhar com vocês a correção de todos os Bugs conhecidos na Página de Guilds.
       
      Foram fixados os seguintes Bugs:
      ● Remover Players que não forem de sua guild.
      ● Aceitar guild com 1 personagem que não seja da sua conta.
      ● Editar o Text/Title de 1 player que não esteja na sua guild.
      ● Editar Ranks que não sejam da sua guild.
      ● Editar Rank de Players que não são da sua guild.
       
      Qualquer outro BUG que você encontrar... Pode listar aqui nesse tópico.
       
      OBS: É meu primeiro post... Então se estiver no local errado ou se algum moderador quiser reformular / formatar o tópico, fique a vontade.
       
       Vou deixar o Spoiler do php abaixo, mas também estou anexando o arquivo.
       
       
      Download: Mediafire
      Scan: Virus Total
       
       
    • Por Garou
      QUIZ







      Fala, grande reino! Tudo beleza?

      Eu estava aqui a deriva, sem nada para fazer, quando um colega me chamou no msn e pediu para eu revisar um código que ele havia feito para um NPC. A função era bem simples, o tal NPC iria fazer perguntas ao jogador que devia responder-las corretamente, caso errasse, duas criaturas configuráveis iriam aparecer.

      Quando eu dei uma olhada no código, tomei um grande susto, era algo caótico, tudo embaralhado. Se você quer dar uma olhada, tenha certeza de ter um coração forte.



      --[[ NPC de Perguntas e Respostas Criado por Bruno Lopes / Lpz &#169; 2011 TibiaKing ]]-- local focuses = {} local talk_start = 0 local topic = {} local var = 0 local quiz = { [1] = {"What is the ring of mana?", "energy ring"}, [2] = {"Who sells addons?", "raphael"} } local monster = {"Orc", 2} local prize = { question = 100, all = 10000 } function onCreatureSay(cid, type, msg) local msg = msg:lower() or "" if getNpcDistanceTo(cid) > 3 then return false end if doMessageCheck(msg, {"hi", "hello"}) and not(isFocused(cid, focuses)) then selfSay("Hello, ".. getCreatureName(cid) ..". Can you answer my questions? heh...", cid) addFocus(cid, focuses) selfFocus(cid) topic[cid] = 100 talk_start = os.clock() elseif doMessageCheck(msg, {"hi", "hello"}) and #focuses ~= 0 then selfSay("Sorry, ".. getCreatureName(cid) ..". I am talking with another person, wait!", cid) end if doMessageCheck(msg, {"bye", "farewell", "goodbye"}) and isFocused(cid, focuses) then selfSay("Bye-bye, hehe!", cid) removeFocus(cid, focuses) end if topic[cid] == 100 then if doMessageCheck(msg, "yes") then selfSay("To start my challenge, just say {ready}. I will ask you some questions.", cid) topic[cid] = 1 elseif doMessageCheck(msg, "no") then selfSay("Huh? Why are you here then?", cid) removeFocus(cid, focuses) topic[cid] = 0 end elseif topic[cid] == 1 then if var == 0 then if doMessageCheck(msg, "ready") then var = 1 selfSay(quiz[var][1], cid) end elseif var >= 1 then if var <= #quiz then if doMessageCheck(msg, quiz[var][2]) then selfSay("CORRECT!", cid) doPlayerAddMoney(cid, prize.question) var = var+1 if var > #quiz then selfSay("CONGRATULATIONS! YOU HAVE FINISHED ALL QUESTIONS!", cid) doPlayerAddMoney(cid, prize.all) else selfSay(quiz[var][1], cid) end else selfSay("YOU HAVE WRONG MY QUESTION! GUARDS, COME HERE!", cid) var = 0 topic[cid] = 0 removeFocus(cid, focuses) for i = 1, monster[2] do doCreateMonster(monster[1], getNpcPos()) end end end end end return true end function onThink() for _, cid in ipairs(focuses) do if isPlayer(cid) and isFocused(cid, focuses) then if os.clock() > (talk_start + 180) then talk_start = 0 selfSay("Hmph!") closeShopWindow(cid) removeFocus(cid, focuses) elseif getNpcDistanceTo(cid) > 3 then talk_start = 0 selfSay("How Rude!") closeShopWindow(cid) removeFocus(cid, focuses) end end end lookAtFocus(focuses) end Bom, eu fiz o arquivo .lua que você iria associar a algum npc de seu servidor, deixo o arquivo .xml por sua conta. Como é um NPC que faz perguntas, você pode configurar o seu NPC do jeito que você quiser, com as perguntas que você quiser. Veja abaixo como proceder: local quiz = { [1] = {"What is the ring of mana?", "energy ring"}, [2] = {"Who sells addons?", "raphael"} } Para adicionar novas perguntas, basta você colocar uma vírgula na última linha e criar uma nova linha conforme o modelo: local quiz = { [1] = {"What is the ring of mana?", "energy ring"}, [2] = {"Who sells addons?", "raphael"}, [3] = {"PERGUNTA", "RESPOSTA"}, [4] = {"PERGUNTA", "RESPOSTA"} } Há também algumas outras configurações básicas para você fazer, as criaturas que irão aparecer caso o jogador erre a pergunta e a quantidade. Também você pode configurar a quantidade de dinheiro que o jogador ganha quando acerta uma pergunta e a quantidade de dinheiro do prêmio final. local monster = {"Orc", 2} local prize = { question = 100, all = 10000 } OBSERVAÇÕES Para evitar quaisquer erros no script, substitua o conteúdo de npc.lua em data/npc/lib por este que estou passando abaixo:



      É isso aê, galerinha do tibiaKing!

      Até o próximo tópico.
    • Por Codex NG
      Sorry I don't speak spanish so you will have to bare with me.
       
      This is a new way for people to create npc's which use different types of currency, rather than a coming up with different items to trade with the npc or trying to edit the npc modules this method simplifies everything by providing the npc with a npc currency id.
       
      All this npc currency id is, is a storage value.. pretty simple eh?
      If the npc doesn't have a currency id then it will use the normal currency e.g. gold, plat, cc etc..
       
      I originally posted this on otland, but fuck them xD
       
      Using Lailene here you can see she has a currency attribute with id of 123456
      <?xml version="1.0" encoding="UTF-8"?> <npc name="Lailene" currency="123456" script="lailene.lua" walkinterval="2000" floorchange="0" speechbubble="2"> <health now="100" max="100"/> <look type="279" head="114" body="94" legs="113" feet="114" addons="0"/> </npc>  
      Now any player who has a storage value of 123456 can purchase things from her shop provided they have enough value stored within the storage, similar to having money in the bank.
      The money or in this case the storage value is added and removed from the player in real time.
       
      Lets get to the code
       
      game.cpp
      Find this
      bool Game::removeMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) Replace the whole function with this.
      bool Game::removeMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) { if (cylinder == nullptr) { return false; } if (money == 0) { return true; } uint32_t currencyId = 0; Player* player; if (Creature* creature = cylinder->getCreature()) { if (Player* p = creature->getPlayer()) { currencyId = p->getNpcCurrencyId(); player = p; } } if (!currencyId) { std::vector<Container*> containers; std::multimap<uint32_t, Item*> moneyMap; uint64_t moneyCount = 0; for (size_t i = cylinder->getFirstIndex(), j = cylinder->getLastIndex(); i < j; ++i) { Thing* thing = cylinder->getThing(i); if (!thing) { continue; } Item* item = thing->getItem(); if (!item) { continue; } Container* container = item->getContainer(); if (container) { containers.push_back(container); } else { const uint32_t worth = item->getWorth(); if (worth != 0) { moneyCount += worth; moneyMap.emplace(worth, item); } } } size_t i = 0; while (i < containers.size()) { Container* container = containers[i++]; for (Item* item : container->getItemList()) { Container* tmpContainer = item->getContainer(); if (tmpContainer) { containers.push_back(tmpContainer); } else { const uint32_t worth = item->getWorth(); if (worth != 0) { moneyCount += worth; moneyMap.emplace(worth, item); } } } } if (moneyCount < money) { return false; } for (const auto& moneyEntry : moneyMap) { Item* item = moneyEntry.second; if (moneyEntry.first < money) { internalRemoveItem(item); money -= moneyEntry.first; } else if (moneyEntry.first > money) { const uint32_t worth = moneyEntry.first / item->getItemCount(); const uint32_t removeCount = (money / worth) + 1; addMoney(cylinder, (worth * removeCount) - money, flags); internalRemoveItem(item, removeCount); break; } else { internalRemoveItem(item); break; } } } else { int32_t value; player->getStorageValue(currencyId, value); if (value < money) { return false; } player->addStorageValue(currencyId, value - money); } return true; } Next find this
      void Game::addMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) Replace the whole function with this
      void Game::addMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) { if (money == 0) { return; } if (Creature* creature = cylinder->getCreature()) { if (Player* player = creature->getPlayer()) { if(uint32_t currencyId = player->getNpcCurrencyId()){ int32_t value; player->getStorageValue(currencyId, value); player->addStorageValue(currencyId, value + money); return; } } } uint32_t crystalCoins = money / 10000; money -= crystalCoins * 10000; while (crystalCoins > 0) { const uint16_t count = std::min<uint32_t>(100, crystalCoins); Item* remaindItem = Item::CreateItem(ITEM_CRYSTAL_COIN, count); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if (ret != RETURNVALUE_NOERROR) { internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); } crystalCoins -= count; } uint16_t platinumCoins = money / 100; if (platinumCoins != 0) { Item* remaindItem = Item::CreateItem(ITEM_PLATINUM_COIN, platinumCoins); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if (ret != RETURNVALUE_NOERROR) { internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); } money -= platinumCoins * 100; } if (money != 0) { Item* remaindItem = Item::CreateItem(ITEM_GOLD_COIN, money); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if (ret != RETURNVALUE_NOERROR) { internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); } } }  
      npc.cpp
      Look for this
      pugi::xml_attribute attr; if ((attr = npcNode.attribute("speed"))) { baseSpeed = pugi::cast<uint32_t>(attr.value()); } else { baseSpeed = 100; } Right underneath that you are going to place this.
      if ((attr = npcNode.attribute("currency"))) { currency = pugi::cast<uint32_t>(attr.value()); }  
      npc.h
      Look for this
      bool isPushable() const final { return walkTicks > 0; } Place this right underneath
      uint32_t getCurrencyId() const { return currency; } Look for this
      uint32_t walkTicks; Place this right underneath
      uint32_t currency;  
      player.cpp
      Find this
      void Player::openShopWindow(Npc* npc, const std::list<ShopInfo>& shop) Replace that function with this
      void Player::openShopWindow(Npc* npc, const std::list<ShopInfo>& shop) { shopItemList = shop; sendShop(npc); sendSaleItemList(npc); } Next find this
      bool Player::updateSaleShopList(const Item* item) Replace that function with this
      bool Player::updateSaleShopList(const Item* item) { uint16_t itemId = item->getID(); if (itemId != ITEM_GOLD_COIN && itemId != ITEM_PLATINUM_COIN && itemId != ITEM_CRYSTAL_COIN) { auto it = std::find_if(shopItemList.begin(), shopItemList.end(), [itemId](const ShopInfo& shopInfo) { return shopInfo.itemId == itemId && shopInfo.sellPrice != 0; }); if (it == shopItemList.end()) { const Container* container = item->getContainer(); if (!container) { return false; } const auto& items = container->getItemList(); return std::any_of(items.begin(), items.end(), [this](const Item* containerItem) { return updateSaleShopList(containerItem); }); } } if (client) { client->sendSaleItemList(shopOwner, shopItemList); } return true; } Next you are going to look for
      uint64_t Player::getMoney() const Now right underneath that function you are going to place these.
      uint64_t Player::getMoney(Npc* npc) const { uint64_t cash; setNpcCurrencyId(npc); uint32_t currencyId = getNpcCurrencyId(); if (currencyId) { int32_t value; getStorageValue(currencyId, value); cash = (uint64_t)value; } else { cash = getMoney(); } return cash; } void Player::setNpcCurrencyId(Npc* npc) const{ currencyId = npc->getCurrencyId(); } uint32_t Player::getNpcCurrencyId() const { return currencyId; }  
      player.h
      Look for this
      uint64_t getMoney() const; Place this right underneath
      uint64_t getMoney(Npc*) const; void setNpcCurrencyId(Npc*) const; uint32_t getNpcCurrencyId() const; Find this
      void sendShop(Npc* npc) const { if (client) { client->sendShop(npc, shopItemList); } } Place this right underneath
      void sendSaleItemList(Npc* npc) const { if (client) { client->sendSaleItemList(npc, shopItemList); } } Find this
      uint32_t manaMax; Place this right underneath
      mutable uint32_t currencyId;  
      protocolgame.cpp
      Now find this function
      void ProtocolGame::sendSaleItemList(const std::list<ShopInfo>& shop) Place this right underneath
      void ProtocolGame::sendSaleItemList(Npc* npc, const std::list<ShopInfo>& shop) { NetworkMessage msg; msg.addByte(0x7B); msg.add<uint64_t>(player->getMoney(npc)); std::map<uint16_t, uint32_t> saleMap; if (shop.size() <= 5) { // For very small shops it's not worth it to create the complete map for (const ShopInfo& shopInfo : shop) { if (shopInfo.sellPrice == 0) { continue; } int8_t subtype = -1; const ItemType& itemType = Item::items[shopInfo.itemId]; if (itemType.hasSubType() && !itemType.stackable) { subtype = (shopInfo.subType == 0 ? -1 : shopInfo.subType); } uint32_t count = player->getItemTypeCount(shopInfo.itemId, subtype); if (count > 0) { saleMap[shopInfo.itemId] = count; } } } else { // Large shop, it's better to get a cached map of all item counts and use it // We need a temporary map since the finished map should only contain items // available in the shop std::map<uint32_t, uint32_t> tempSaleMap; player->getAllItemTypeCount(tempSaleMap); // We must still check manually for the special items that require subtype matches // (That is, fluids such as potions etc., actually these items are very few since // health potions now use their own ID) for (const ShopInfo& shopInfo : shop) { if (shopInfo.sellPrice == 0) { continue; } int8_t subtype = -1; const ItemType& itemType = Item::items[shopInfo.itemId]; if (itemType.hasSubType() && !itemType.stackable) { subtype = (shopInfo.subType == 0 ? -1 : shopInfo.subType); } if (subtype != -1) { uint32_t count; if (!itemType.isFluidContainer() && !itemType.isSplash()) { count = player->getItemTypeCount(shopInfo.itemId, subtype); // This shop item requires extra checks } else { count = subtype; } if (count > 0) { saleMap[shopInfo.itemId] = count; } } else { std::map<uint32_t, uint32_t>::const_iterator findIt = tempSaleMap.find(shopInfo.itemId); if (findIt != tempSaleMap.end() && findIt->second > 0) { saleMap[shopInfo.itemId] = findIt->second; } } } } uint8_t itemsToSend = std::min<size_t>(saleMap.size(), std::numeric_limits<uint8_t>::max()); msg.addByte(itemsToSend); uint8_t i = 0; for (std::map<uint16_t, uint32_t>::const_iterator it = saleMap.begin(); i < itemsToSend; ++it, ++i) { msg.addItemId(it->first); msg.addByte(std::min<uint32_t>(it->second, std::numeric_limits<uint8_t>::max())); } writeToOutputBuffer(msg); }  
      protocolgame.h
      Find this
      void sendSaleItemList(const std::list<ShopInfo>& shop); Place this right underneath
      void sendSaleItemList(Npc* npc, const std::list<ShopInfo>& shop);  
      luascript.cpp
      Find
      int LuaScriptInterface::luaPlayerAddMoney(lua_State* L) Replace that whole function with this
      int LuaScriptInterface::luaPlayerAddMoney(lua_State* L) { // player:addMoney(money[, currencyId]) uint64_t money = getNumber<uint64_t>(L, 2); uint32_t currencyId = getNumber<uint32_t>(L, 3); Player* player = getUserdata<Player>(L, 1); if (player) { if (currencyId) { int32_t value; player->getStorageValue(currencyId, value); player->addStorageValue(currencyId, value + money); } else { g_game.addMoney(player, money); } pushBoolean(L, true); } else { lua_pushnil(L); } return 1; } Next find this function which should be right below it.
      int LuaScriptInterface::luaPlayerRemoveMoney(lua_State* L) Replace that whole function with this
      int LuaScriptInterface::luaPlayerRemoveMoney(lua_State* L) { // player:removeMoney(money[, currencyId]) Player* player = getUserdata<Player>(L, 1); if (player) { uint64_t money = getNumber<uint64_t>(L, 2); uint32_t currencyId = getNumber<uint32_t>(L, 3); if (currencyId) { int32_t value; player->getStorageValue(currencyId, value); if (value < money) { pushBoolean(L, false); return 1; } player->addStorageValue(currencyId, value - money); pushBoolean(L, true); } else { pushBoolean(L, g_game.removeMoney(player, money)); } } else { lua_pushnil(L); } return 1; }  
    • Por Ayron5
      Antes de tudo quero deixar claro que pesquisei no fórum, Não encontrei. Resolvi fazer o meu  
      Este NPC faz oq o titulo diz  vende Stone ou Item por Diamond. Npc simples e configurável  Testado em Poketibia 8.54  tfs 0.3.6 
       
      Em data/npc, coloque um novo arquivo com o nome Ditem.xml e cole isso dentro:
       
      Na pasta data/npc/script, crie um arquivo chamado "Ditem.lua" e cole isso:
       
      Para adicionar mais itens:
       
      1º -  adiciona o nome do item para o player falar o nome dele, caso queira comprar - 
      selfSay('Eu vendo Fire stone, Water stone, Leaf stone. Diga qual voce quer adquirir.', cid) 2º - Após o ultimo 
      talkState[talkUser] = 3 Vc adiciona isso - 
      elseif(msgcontains(msg, '----NOME DO ITEM----') or msgcontains(msg, '---nome do item---')) then selfSay('O item Custa 3 Diamonds, Voce vai querer?', cid) talkState[talkUser] = 4 ----- Aqui coloca 4 pq ja tem a 3 3º - Na parte de  -- Confirmação da Compra -- Depois de  um      
      talkState[talkUser] = 0 end Adicione --  elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then ---Coloque 4 por causa da ---talkState[talkUser] = 4--- if(doPlayerRemoveItem(cid, 2145, 3) == true) then ----Item q sera removido no caso 2145 Diamonds e 3 é a quantidade. selfSay('Thanks!', cid) doPlayerAddItem(cid, 11447, 1) ----- 11447 é o item q será entregue no caso é a fire stone, o 1 é a quantidade de itens. talkState[talkUser] = 0 else selfSay('Voce nao tem diamonds suficiente.', cid) talkState[talkUser] = 0 end Bom é isso espero ajudar alguém rsrsrs  
  • Estatísticas dos Fóruns

    96831
    Tópicos
    519565
    Posts
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo