Ir para conteúdo

Featured Replies

Postado
  • Autor
7 minutos atrás, Frenesy disse:

Sim.

 


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 doCreatureSayWithDelay(cid,text,type,delay,e)
   if delay<=0 then
      doCreatureSay(cid,text,type)
   else
      local func=function(pars)
                    doCreatureSay(pars.cid,pars.text,pars.type)
                    pars.e.done=TRUE
                 end
      e.done=FALSE
      e.event=addEvent(func,delay,{cid=cid, text=text, type=type, e=e})
   end
end


function cancelNPCTalk(events)
  local ret=1
  for aux=1,table.getn(events) do
     if events[aux].done==FALSE then
        stopEvent(events[aux].event)
     else
        ret=ret+1
     end
  end
  events=nil
  return(ret)
end


function doNPCTalkALot(msgs,interval)
  local e={}
  local ret={}
  if interval==nil then interval=3000 end --3 seconds is default time between messages
  for aux=1,table.getn(msgs) do
      e[aux]={}
      doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_PRIVATE_NP,(aux-1)*interval,e[aux])
      table.insert(ret,e[aux])
  end
  return(ret)
end

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, 'Comando') or msgcontains(msg, 'comando')) then
	selfSay('Vejamos, posso vender pra você agora o Comando {bless full} ou {Blessing} e também {Bless PvP}, o que deseja?', cid)
	talkState[talkUser] = 1
	
	elseif((msgcontains(msg, 'Bless Full') or msgcontains(msg, 'bless full')) and talkState[talkUser] == 1) then
    selfSay('O comando "!bless full" custa {10.000 gold coin}. Deseja comprar?', cid)
	talkState[talkUser] = 2
	
	elseif((msgcontains(msg, 'Yes') or msgcontains(msg, 'yes')) and talkState[talkUser] == 2) then
		if getPlayerStorageValue(cid,834005) == 1 then
			selfSay('Você já comprou esse comando.', cid)
			talkState[talkUser] = 0
		else
			if doPlayerRemoveMoney(cid, 10000) == TRUE then
				selfSay('Pronto! Agora você pode usar o comando {!bless full}', cid)
				doSendMagicEffect(getPlayerPosition(cid), 49)
				setPlayerStorageValue(cid, 834005, 1)
				talkState[talkUser] = 0
			else
			selfSay('Você não tem o dinheiro necessário.', cid)
			talkState[talkUser] = 0
			end
		end
		
	elseif((msgcontains(msg, 'No') or msgcontains(msg, 'no')) and talkState[talkUser] == 2) then
			selfSay('Sem problemas.', cid)
			talkState[talkUser] = 0
	
		end	  
	return TRUE
end

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

 

Agora deu certo, quando falo Hi > Comando > bless full, vende por 10k certinho!

 

Agora falta o npc responder quando fala Bless também kkk, e o comando Talkactions que está saindo como mensagem normal! ehhe

 

                                                           

55f6tc.gif                     

  • Respostas 30
  • Visualizações 1.2k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • É só por nos comandos que quer vender um requisito de storage. (O player precisa de storage para usar tal comando) E no NPC, colocar pra dar tal storage pro player valendo certa quantia.  

  • Tudo bem. Faz o seguinte. Me dê as seguintes coisas:   - O Script de um comando que você planeja vender. - A ID de um item qualquer que você não use no servidor para por a venda no NPC.

  • Ok, então vejamos. Fiz um aqui sem testar. Vejamos como fica. Começando com o NPC:   Ana.xml <?xml version="1.0"?> <npc name="Ana" script="Ana.lua" walkinterval="2000">

Postado
Agora, Digoshow disse:

Agora falta o npc responder quando fala Bless também kkk, e o comando Talkactions que está saindo como mensagem normal! ehhe

 

Você tem certeza que instalou corretamente a talkaction?

Porque cara, eu acabei de testar aqui e deu tudo certo. Verifica de novo aí com calma.

 

cms1-pr%C3%AAmio.png

Postado
  • Autor
34 minutos atrás, Frenesy disse:

 

Você tem certeza que instalou corretamente a talkaction?

Porque cara, eu acabei de testar aqui e deu tudo certo. Verifica de novo aí com calma.

 

Vou copiar novamente o script que você mandou de Talkactions e refazer o teste, um segundo já volto..

20 minutos atrás, Digoshow disse:

Vou copiar novamente o script que você mandou de Talkactions e refazer o teste, um segundo já volto..

@Edite

 

Nada amigo, olha ae testei de 2 formas as tags em talkactions e também não funcionou, e sem nenhum erro no distro:
 

talkactions.xml testadas de 2 formas:

Spoiler

 

<talkaction words="!bless full;/bless full" event="script" value="bless.lua"/>

<talkaction words="!bless full;/bless full" script="bless.lua"/>

 

 

talkactions/script/bless.lua:

Spoiler

 

local bless = {1, 2, 3, 4, 5}

function onSay(cid, words, param)
    for i = 1, table.maxn(bless) do
        if(getPlayerBlessing(cid, bless)) then
        doPlayerSendCancel(cid, "Você já possui todas as Benções.")
        return TRUE
        end
    end

    if getPlayerStorageValue(cid,834005) == 1 then
        for i = 1, table.maxn(bless) do
            doPlayerAddBlessing(cid, bless)
        end
    
    doCreatureSay(cid, "Você recebeu as Benções dos Deuses!" ,19)
    doSendMagicEffect(getPlayerPosition(cid), 49)
    
    else
        doPlayerSendCancel(cid, "Você não tem o comando, compre na npc X.")
    end
    return TRUE
end

 

 

@Edite

 

Pronto, o problema era o espaço no comando da talkactions, tem que deixar tudo junto "blessfull" e ae funcionou, porem o npc ainda não responde algumas funções, e perguntando para a npc sobre "Comando" ele cita as bless também, não teria como separar, se falar "Comando" a npc Ana só citar sobre o comando, e se o Player falar de Bless ela vai citar sobre Blessing e Bless PvP?

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

 

                                                           

55f6tc.gif                     

Postado

Que tal assim?

 

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 doCreatureSayWithDelay(cid,text,type,delay,e)
   if delay<=0 then
      doCreatureSay(cid,text,type)
   else
      local func=function(pars)
                    doCreatureSay(pars.cid,pars.text,pars.type)
                    pars.e.done=TRUE
                 end
      e.done=FALSE
      e.event=addEvent(func,delay,{cid=cid, text=text, type=type, e=e})
   end
end


function cancelNPCTalk(events)
  local ret=1
  for aux=1,table.getn(events) do
     if events[aux].done==FALSE then
        stopEvent(events[aux].event)
     else
        ret=ret+1
     end
  end
  events=nil
  return(ret)
end


function doNPCTalkALot(msgs,interval)
  local e={}
  local ret={}
  if interval==nil then interval=3000 end --3 seconds is default time between messages
  for aux=1,table.getn(msgs) do
      e[aux]={}
      doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_PRIVATE_NP,(aux-1)*interval,e[aux])
      table.insert(ret,e[aux])
  end
  return(ret)
end

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, 'Bless') or msgcontains(msg, 'bless')) then
	selfSay('Vejamos, posso vender pra você agora o Comando {bless full} ou {Blessing} e também {Bless PvP}, o que deseja?', cid)
	talkState[talkUser] = 1
	
	elseif(msgcontains(msg, 'Comando') or msgcontains(msg, 'comando') or msgcontains(msg, 'Bless Full') or msgcontains(msg, 'bless full')) then
    selfSay('Eu posso vender para você o comando "!bless full". No entanto, ele custa {10.000 gold coin}. Deseja comprar?', cid)
	talkState[talkUser] = 2
	
	elseif((msgcontains(msg, 'Yes') or msgcontains(msg, 'yes')) and talkState[talkUser] == 2) then
		if getPlayerStorageValue(cid,834005) == 1 then
			selfSay('Você já comprou esse comando.', cid)
			talkState[talkUser] = 0
		else
			if doPlayerRemoveMoney(cid, 10000) == TRUE then
				selfSay('Pronto! Agora você pode usar o comando {!bless full}', cid)
				doSendMagicEffect(getPlayerPosition(cid), 49)
				setPlayerStorageValue(cid, 834005, 1)
				talkState[talkUser] = 0
			else
			selfSay('Você não tem o dinheiro necessário.', cid)
			talkState[talkUser] = 0
			end
		end
		
	elseif((msgcontains(msg, 'No') or msgcontains(msg, 'no')) and talkState[talkUser] == 2) then
			selfSay('Sem problemas.', cid)
			talkState[talkUser] = 0
	
		end	  
	return TRUE
end

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

 

cms1-pr%C3%AAmio.png

Postado
  • Autor
25 minutos atrás, Frenesy disse:

Que tal assim?

 


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 doCreatureSayWithDelay(cid,text,type,delay,e)
   if delay<=0 then
      doCreatureSay(cid,text,type)
   else
      local func=function(pars)
                    doCreatureSay(pars.cid,pars.text,pars.type)
                    pars.e.done=TRUE
                 end
      e.done=FALSE
      e.event=addEvent(func,delay,{cid=cid, text=text, type=type, e=e})
   end
end


function cancelNPCTalk(events)
  local ret=1
  for aux=1,table.getn(events) do
     if events[aux].done==FALSE then
        stopEvent(events[aux].event)
     else
        ret=ret+1
     end
  end
  events=nil
  return(ret)
end


function doNPCTalkALot(msgs,interval)
  local e={}
  local ret={}
  if interval==nil then interval=3000 end --3 seconds is default time between messages
  for aux=1,table.getn(msgs) do
      e[aux]={}
      doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_PRIVATE_NP,(aux-1)*interval,e[aux])
      table.insert(ret,e[aux])
  end
  return(ret)
end

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, 'Bless') or msgcontains(msg, 'bless')) then
	selfSay('Vejamos, posso vender pra você agora o Comando {bless full} ou {Blessing} e também {Bless PvP}, o que deseja?', cid)
	talkState[talkUser] = 1
	
	elseif(msgcontains(msg, 'Comando') or msgcontains(msg, 'comando') or msgcontains(msg, 'Bless Full') or msgcontains(msg, 'bless full')) then
    selfSay('Eu posso vender para você o comando "!bless full". No entanto, ele custa {10.000 gold coin}. Deseja comprar?', cid)
	talkState[talkUser] = 2
	
	elseif((msgcontains(msg, 'Yes') or msgcontains(msg, 'yes')) and talkState[talkUser] == 2) then
		if getPlayerStorageValue(cid,834005) == 1 then
			selfSay('Você já comprou esse comando.', cid)
			talkState[talkUser] = 0
		else
			if doPlayerRemoveMoney(cid, 10000) == TRUE then
				selfSay('Pronto! Agora você pode usar o comando {!bless full}', cid)
				doSendMagicEffect(getPlayerPosition(cid), 49)
				setPlayerStorageValue(cid, 834005, 1)
				talkState[talkUser] = 0
			else
			selfSay('Você não tem o dinheiro necessário.', cid)
			talkState[talkUser] = 0
			end
		end
		
	elseif((msgcontains(msg, 'No') or msgcontains(msg, 'no')) and talkState[talkUser] == 2) then
			selfSay('Sem problemas.', cid)
			talkState[talkUser] = 0
	
		end	  
	return TRUE
end

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

 

Perfeito, só editei está parte:

Spoiler

selfSay('Vejamos, posso vender pra você agora o Comando {bless full} ou {Blessing} e também {Bless PvP}, o que deseja?', cid)

Ficando assim:

Spoiler

selfSay('Vejamos, posso vender pra você agora {Blessing} e também {Bless PvP}, o que deseja?', cid)

 

Porem agora só falta adicionar as funções finais para que quando o Player responde as opções da NPC com: Blessing ou Bless PvP se o Player não tiver ela colocar...no momento quando responde alguma dessas opções ela retorna a mesma mensagem anterior, olhe só:

Spoiler

16:01 Ana: Vejamos, posso vender pra você agora o Comando Blessing e também Bless PvP, o que deseja?
16:01 Teste [1]: blessing
16:01 Ana: Vejamos, posso vender pra você agora o Comando Blessing e também Bless PvP, o que deseja?

16:07 Teste [1]: bless pvp
16:07 Ana: Vejamos, posso vender pra você agora o Comando Blessing e também Bless PvP, o que deseja?

 

E por ultimo e não menos importante, teria como colocar a Bless PvP para ser adicionada ao Player pelo comando comprada pela NPC também? 

 

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

 

                                                           

55f6tc.gif                     

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