LE
pedido

Npc que teletransporta por storage help-me

Por leandrozera, 11 de set. de 2015 em Scripts

10
1.8k
leandrozeraL
11 de setembro de 2015 às 07:28

gostaria de pedir ajuda de vocês preciso de um npc que teletransporta para 3 lugares diferente mais so teletransportar se o player tiver x storage alguém poderia ajudar?

 

lugar 1 pode ser chamado de =[city1]

lugar 2 pode ser chamado de =[city2]

lugar 3 pode ser chamado de =[city3]

 

abraco!

 

 


.

Editado Setembro 11 por leandrozera

dalvorsnD
11 de setembro de 2015 às 09:37

começa a fazer ele que eu te ajudo na parte da storage

leandrozeraL
11 de setembro de 2015 às 09:51

na parte de storage eu tb sei :s

dalvorsnD
11 de setembro de 2015 às 09:56

Não é dificl, basta pegar um de exemplo, se usar nodes então facilita muito. Eu poderia fazer pra ti, mas não te traria conhecimento se tu não tentasse primeiro.

leandrozeraL
11 de setembro de 2015 às 10:01

eu tenho esse que só leva para uma city tem como adaptar para 3 lugares?

local tab = {
    storage = 10015,
	pos = {x = 2205, y = 573, z = 7},
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
function onCreatureAppear(cid)         npcHandler:onCreatureAppear(cid)         end
function onCreatureDisappear(cid)      npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)   npcHandler:onCreatureSay(cid, type, msg:lower())   end
function onThink()                  npcHandler:onThink()                  end
local talkState = {}
 
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, "city1") then
      selfSay("Você deseja viajar para city1?", cid)
      talkState[talkUser] = 1
   elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
      if getPlayerStorageValue(cid, tab.storage) > 0 and getPlayerLevel(cid) >= 250 then
         selfSay("Chegamos!", cid)
         doSendMagicEffect(getThingPos(cid), 10)
         npcHandler:releaseFocus(cid)
         doTeleportThing(cid, tab.pos)
         doSendMagicEffect(tab.pos, 10)
      else
         selfSay("você não pode viajar", cid)
      end
      talkState[talkUser] = 0
   end
 
   return true
end
 
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
BrunoB
11 de setembro de 2015 às 10:10

gostaria de pedir ajuda de vocês preciso de um npc que teletransporta para 3 lugares diferente mais so teletransportar se o player tiver x storage alguém poderia ajudar?

 

lugar 1 pode ser chamado de =[city1]

lugar 2 pode ser chamado de =[city2]

lugar 3 pode ser chamado de =[city3]

 

abraco!

Tenta assim:

 

local config = {
	["city1"] = {str = 12000, pos = {x = 1, y = 2, z = 3}},
	["city2"] = {str = 12001, pos = {x = 1, y = 2, z = 3}},
	["city3"] = {str = 12002, pos = {x = 1, y = 2, z = 3}}
}

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 creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end

	msg = string.lower(msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if msgcontains(msg, 'city1') or msgcontains(msg, 'city2') or msgcontains(msg, 'city3') then
		local city = config[msg]
		if getPlayerStorageValue(cid, city.str) > 0 then
			doTeleportThing(cid, city.pos)
			doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
			talkState[talkUser] = 0
			selfSay("Chegamos!", cid)
		else
			selfSay("Voce nao tem permissao para esta viagem.", cid)
			talkState[talkUser] = 0
		end
	end	
	return true
end

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

 

Editado Setembro 11 por Bruno Minervino

leandrozeraL
11 de setembro de 2015 às 10:13

 

 

Tenta assim:

 

 

local config = {
    ["city1"] = {str = 12000, pos = {x = 1, y = 2, z = 3}},
    ["city2"] = {str = 12001, pos = {x = 1, y = 2, z = 3}},
    ["city3"] = {str = 12002, pos = {x = 1, y = 2, z = 3}}
}

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 creatureSayCallback(cid, type, msg)
    msg = string.lower(msg)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    
    if not npcHandler:isFocused(cid) then
        return false
    end

    if msgcontains(msg, 'hi') and talkState[talkUser] == 0 then
         selfSay('Ola ' .. getPlayerName(cid) .. '! Eu promovo grandes viagens para {city1}, {city2} e {city3}.')
        talkState[talkUser] = 1

      elseif talkState[talkUser] == 1 then
        local city = config[msg]
        if city then
            if getPlayerStorageValue(cid, city.str) > 0 then
                doTeleportThing(cid, city.pos)
                doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
                talkState[talkUser] = 0
            else
                selfSay('Voce nao tem permissao para esta viagem.')
            end
        else
            selfSay('Eu nao encontrei este destino em meu itinerario.')
        end

    elseif msgcontains(msg, 'bye') then
        selfSay('Ate logo, ' .. getPlayerName(cid) .. '!')
        talkState[talkUser] = 0
    end    
    return true
end

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

 

npc n ta respondendo n

dalvorsnD
11 de setembro de 2015 às 10:25

https://gist.github.com/dalvorsn/ddd2e23ab8c651fb91da

 

 

ps.: tu não falou a respeito do level, então julguei que seria um valor dinamico de acordo com a cidade ...

Editado Setembro 11 por dalvorsn

BrunoB
11 de setembro de 2015 às 10:30

npc n ta respondendo n

Editei, testa lá.

1 mês depois...
LumusL
13 de outubro de 2015 às 11:36

Tópico Movido
Este tópico foi movido de "OTServSuporte OTServSuporte Scripting"
para "OTServSuporte OTServSuporte ScriptingPedidos e dúvidas resolvidos - Scripting".