Ir para conteúdo

Featured Replies

Postado

Boa noite galera, tudo bom? gente eu preciso de uma ajuda mais uma vez kkkkk, bom eu preciso de um script de um npc que funciona da seguinte forma, ele seria um barqueiro certo? ele teria 2 lugares para levar, o primeiro lugar precisar de somente 1 item, e no segundo lugar, 3 itens diferentes! ( obs: preciso colocar quantidade de item necessário também ) espero que me ajudem ;)

 

Editado por Strikerzerh (veja o histórico de edições)

Postado

@Strikerzerh Boa noite

 

XML do Npc

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Traveller" script="data/npc/scripts/traveler.lua" walkinterval="1000" floorchange="0">
    <health now="100" max="100"/>
    <look type="128" head="96" body="99" legs="76" feet="115" addons="1"/>
</npc>

 

Na pasta data/npc/scripts crie um arquivo chamado traveler.lua e adicione isso dentro: 

local TELEPORT_EFFECT = 10

local config = {
	['Demonland'] = {
		position = { x=160, y=54, z=7 },
		items = {
			[2160] = { count = 1 },
			[2124] = { count = 1 }
		}
	},
	['Orc Hall'] = {
		position = { x=160, y=54, z=7 },
		items = {
			[8299] = { count = 1 },
		}
	},
	-- [DESTINO] = {
	-- 	position = { x=160, y=54, z=7 },
	-- 	items = {
	-- 		[ITEM_ID] = { count = QUANTIDADE_DO_ITEM },
	-- 	}
	-- },
}

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 creatureSayCallback(cid, type, msg)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

		if (not checkDestinyExists(msg)) then
			selfSay('Este lugar nao existe. Por favor diga outro.', cid)
			return false
		end

		local destinyData = getDestinyData(msg)

    if msgcontains(string.lower(msg), string.lower(destinyData.destiny)) then
			local items = {}
			for item, data in pairs(destinyData.data.items) do
				if (getPlayerItemCount(cid, item) < data.count) then
					table.insert(items, { item = item })
				end
			end

			if (#items <= 0) then
				removePlayerItems(cid, destinyData.data.items)
				doTeleportThing(cid, destinyData.data.position)
				doSendMagicEffect(getThingPos(cid), TELEPORT_EFFECT)
				selfSay('Ate mais.', cid)
				return true
			end

			selfSay('Voce nao possui todos os itens necessarios para viajar.', cid)
		end

    return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

function checkDestinyExists(destiny)
	for dest, _ in pairs(config) do
		if (string.lower(dest) == string.lower(destiny)) then
			return true
		end
	end
	return false
end

function getDestinyData(destiny)
	for dest, data in pairs(config) do
		if (string.lower(dest) == string.lower(destiny)) then
			return { destiny = dest, data = data }
		end
	end
end

function removePlayerItems(cid, items)
	for item, data in pairs(items) do
		doPlayerRemoveItem(cid, item, data.count)
	end
end

 

Postado

@Strikerzerh Tem que criar o arquivo Traveler.xml na pasta data/npc e adicionar esse código nele.

 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Traveller" script="data/npc/scripts/traveler.lua" walkinterval="1000" floorchange="0">
    <health now="100" max="100"/>
    <look type="128" head="96" body="99" legs="76" feet="115" addons="1"/>
</npc>

 

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.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo