Ir para conteúdo

Featured Replies

Postado

 Gostaria de pedir um npc que teleporta aleatoriamente para algum lugar, exemplo:

Tem 4 quests, o npc diz "deseja mesmo entrar na Quest aleatória?" "Yes" Aí manda pra algum das 4.

 

Tfs 0.4

Postado
Em 28/08/2022 em 10:35, cesarfilho55 disse:

 Gostaria de pedir um npc que teleporta aleatoriamente para algum lugar, exemplo:

Tem 4 quests, o npc diz "deseja mesmo entrar na Quest aleatória?" "Yes" Aí manda pra algum das 4.

 

Tfs 0.4

 

FIZ ESSE ESPERO QUE AJUDE :)

 

<npc name="Tele" script="data/npc/scripts/npctelerandom.lua" floorchange="0" walkinterval="2000" access="5" level="1" maglevel="1">
  <health now="150" max="150"/>
    <look type="128" head="79" body="95" legs="57" feet="106" addons="2"/>
  <parameters>
    <parameter key="message_greet" value="Hello |PLAYERNAME| posso te levar para um ilugar especial, deseja ir? é só dizer {teleporte}" />     
  </parameters>
</npc>

 

 

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 t = {
	{x = 1002, y = 1000, z = 7}, --troca posisão 1
	{x = 1003, y = 1000, z = 7}, --troca posisão 2
	{x = 1004, y = 1000, z = 7}, --troca posisão 3
    {x = 1005, y = 1000, z = 7} --troca posisão 4
}

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(msgcontains(msg, 'teleporte')) and talkState[talkUser] ~= 2 then
		selfSay('Gostaria de ir para um lugar aletorio? {yes} ou {no}.', cid)
		talkState[talkUser] = 1
		
		
	elseif(msgcontains(msg, 'yes')) and talkState[talkUser] == 1 then

	local v = t[math.random(#t)]
	
	doTeleportThing(cid, v)
	doSendMagicEffect(v, CONST_ME_TELEPORT)
	
	    selfSay('Pronto! Boa jornada.', cid)
		talkState[talkUser] = 0
		
		
	elseif(msgcontains(msg, 'no')) and talkState[talkUser] ~= 1 then
		talkState[talkUser] = 0
		selfSay('Ok, até logo!', cid)
	end
	
	
	return true
end

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

 

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Postado
  • Autor
54 minutos atrás, L3K0T disse:

 

FIZ ESSE ESPERO QUE AJUDE :)

 


<npc name="Tele" script="data/npc/scripts/npctelerandom.lua" floorchange="0" walkinterval="2000" access="5" level="1" maglevel="1">
  <health now="150" max="150"/>
    <look type="128" head="79" body="95" legs="57" feet="106" addons="2"/>
  <parameters>
    <parameter key="message_greet" value="Hello |PLAYERNAME| posso te levar para um ilugar especial, deseja ir? é só dizer {teleporte}" />     
  </parameters>
</npc>

 

 


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 t = {
	{x = 1002, y = 1000, z = 7}, --troca posisão 1
	{x = 1003, y = 1000, z = 7}, --troca posisão 2
	{x = 1004, y = 1000, z = 7}, --troca posisão 3
    {x = 1005, y = 1000, z = 7} --troca posisão 4
}

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(msgcontains(msg, 'teleporte')) and talkState[talkUser] ~= 2 then
		selfSay('Gostaria de ir para um lugar aletorio? {yes} ou {no}.', cid)
		talkState[talkUser] = 1
		
		
	elseif(msgcontains(msg, 'yes')) and talkState[talkUser] == 1 then

	local v = t[math.random(#t)]
	
	doTeleportThing(cid, v)
	doSendMagicEffect(v, CONST_ME_TELEPORT)
	
	    selfSay('Pronto! Boa jornada.', cid)
		talkState[talkUser] = 0
		
		
	elseif(msgcontains(msg, 'no')) and talkState[talkUser] ~= 1 then
		talkState[talkUser] = 0
		selfSay('Ok, até logo!', cid)
	end
	
	
	return true
end

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

 

Vou testar e volto aqui, obrigado pela ajuda!!

Postado
12 minutos atrás, cesarfilho55 disse:

Vou testar e volto aqui, obrigado pela ajuda!!

Certo ;)

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

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