Ir para conteúdo

Featured Replies

Postado

Alguém poderia me ajudar ? To precisando passar um script para a versão 1.2 mais não to conseguindo alguém poderia me ajudar ?

Eu tava lendo o winki no giht mais não entendi nada 

 

https://github.com/otland/forgottenserver/wiki/Script-Interface

Segue script :

 

 

 

-- Collecting items and monster missions by Limos
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 missions = {
	[1] = {
		items = {
			{id = 5890, count = 12},
			{id = 5878, count = 20},
			{id = 5894, count = 8}
		},
		message = "Ótimo, para a sua primeira missão, você precisa coletar alguns itens, eu preciso",
		level = 8, -- minimum level voor this mission
		rewarditems = {
			{id = 2160, count = 1},
			{id = 2152, count = 1}
		},
		rewardexp = 15000
	},
	[2] = {
		monsters = {
			{name = "Rats", count = 20, storage = 21900},
			{name = "Rotworms", count = 26, storage = 21901}
		},
		message = "Obrigado, por sua próxima missão matar",
		level = 30,
		rewarditems = {
			{id = 2160, count = 5}
		},
		rewardexp = 40000 
	},
	[3] = {
		items = {
			{id = 5920, count = 45},
			{id = 5877, count = 22}
		},
		message = "Incrível, agora receba",
		level = 50,
		rewarditems = {
			{id = 2160, count = 15}
		},
		rewardexp = 100000 
	},
	[4] = {
		monsters = {
			{name = "Dragon Lords", count = 25, storage = 21902}
		},
		message = "Bom trabalho, agora mata",
		level = 70,
		rewarditems = {
			{id = 2160, count = 25}
		},
		rewardexp = 200000 
	},
	[5] = {
		items = {
			{id = 5906, count = 35},
			{id = 5882, count = 42},
			{id = 4850, count = 1}
		},
		message = "Bom, agora sua missão final, há mais alguns itens que você precisa obter,",
		level = 100,
		rewarditems = {
			{id = 2160, count = 50}
		},
		rewardexp = 450000 
	}
}

local storage = 45551

local function getItemsMonstersFromTable(imtable)
		local text = ""
		for v = 1, #imtable do
				local ret = ", "
				if v == 1 then
						ret = ""
				elseif v == #imtable then
						ret = " e "
				end
				text = text .. ret
				count = imtable[v].count
				if imtable[v].id then
						info = getItemInfo(imtable[v].id)
						text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
				else
						text = text .. count .." "..imtable[v].name
				end
		end
		return text
end

function creatureSayCallback(cid, type, msg)

		local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

		if not npcHandler:isFocused(cid) then
				return false
		end
		
		local x = missions[getPlayerStorageValue(cid, storage)]

		if msgcontains(msg, 'aceitas') or msgcontains(msg, 'quest') then
				if getPlayerStorageValue(cid, storage) == -1 then
						selfSay("Eu tenho várias missões para você, você aceita o desafio?", cid)
						talkState[talkUser] = 1
				elseif x then
						if getPlayerLevel(cid) >= x.level then
								local mess = x.items and "get "..getItemsMonstersFromTable(x.items) or "matou "..getItemsMonstersFromTable(x.monsters)
								selfSay("Você "..mess.."?", cid)
								talkState[talkUser] = 1
						else
								selfSay("A missão que eu dei é para o nível "..x.level..", volte mais tarde.", cid)
						end
				else
						selfSay("Você já fez todas as missões, ótimo trabalho.", cid)
						npcHandler:releaseFocus(cid)
				end
		elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
				if getPlayerStorageValue(cid, storage) == -1 then
						setPlayerStorageValue(cid, storage, 1)
						local x = missions[getPlayerStorageValue(cid, storage)]
						local imtable = x.items or x.monsters
						selfSay(x.message.." "..getItemsMonstersFromTable(imtable)..".", cid)
				elseif x then
						local imtable = x.items or x.monsters
						local amount = 0
						for it = 1, #imtable do
								local check = x.items and getPlayerItemCount(cid, imtable[it].id) or getPlayerStorageValue(cid, imtable[it].storage)
								if check >= imtable[it].count then
										amount = amount + 1
								end
						end
						if amount == #imtable then
								if x.items then
										for it = 1, #x.items do
												doPlayerRemoveItem(cid, x.items[it].id, x.items[it].count)
										end
								end
								if x.rewarditems then
										for r = 1, #x.rewarditems do
												doPlayerAddItem(cid, x.rewarditems[r].id, x.rewarditems[r].count)
										end
										doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você recebeu "..getItemsMonstersFromTable(x.rewarditems)..".")
								end
								if x.rewardexp then
										doPlayerAddExp(cid, x.rewardexp)
										doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você recebeu "..x.rewardexp.." experience.")
								end
								setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) + 1)
								local x = missions[getPlayerStorageValue(cid, storage)]
								if x then
										selfSay(x.message.." "..getItemsMonstersFromTable(x.items or x.monsters)..".", cid)
								else
										selfSay("Bem feito! Você fez um ótimo trabalho em todas as suas missões.", cid)
								end
						else
								local n = 0
								for i = 1, #imtable do
										local check = x.items and getPlayerItemCount(cid, imtable[i].id) or getPlayerStorageValue(cid, imtable[i].storage)
										if check < imtable[i].count then
												n = n + 1
										end
								end
								local text = ""
								local c = 0
								for v = 1, #imtable do
										local check = x.items and getPlayerItemCount(cid, imtable[v].id) or getPlayerStorageValue(cid, imtable[v].storage)
										if check < imtable[v].count then
												c = c + 1
												local ret = ", "
												if c == 1 then
														ret = ""
												elseif c == n then
														ret = " and "
												end
												text = text .. ret
												if x.items then
														local count, info = imtable[v].count - getPlayerItemCount(cid, imtable[v].id), getItemInfo(imtable[v].id)
														text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
												else
														local count = imtable[v].count - (getPlayerStorageValue(cid, imtable[v].storage) + 1)
														text = text .. count.." "..imtable[v].name
												end
										end
								end
								selfSay(x.items and "Você não tem todos os itens, você ainda precisa obter "..text.."." or "Você não matou todos os monstros, você ainda precisa matar "..text..".", cid)
						end
				end
				talkState[talkUser] = 0
		elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
				selfSay("Bem, acho que não, então.", cid)
		end
		return true
end

npcHandler:setMessage(MESSAGE_FAREWELL, "Tchau!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Adeus tenha um bom dia!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo