Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado

Tem como fazer ele perguntar antes de dar o item? tipo:

 

"Você quer trocar X item por X item?"

player: yes

"Troca efetuada"

Faça mesmo procedimento que eu citei só substitua o script do Jax.lua por esse

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 items = {
          item1 = {2346, 2349}, -- item1 item que será pedido e que será dado na primeira troca
          item2 = {2033, 15515} -- item2 item que será pedido e que será dado na segunda troca
}
local counts = {
          count1 = {1, 1}, -- count1 quantidade que será pedido e que será dado na primeira troca
          count2 = {10, 1} -- count2 quantidade que será pedido e que será dado na segunda troca
}

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, 'blue note') then
                    selfSay('You want to swap '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' for '.. counts.count1[2] ..' '.. getItemNameById(items.item1[2]) ..'.',cid)
                    talkState[talkUser] = 1
          elseif talkState[talkUser] == 1 then
                    if msgcontains(msg, 'yes') then
                              if getPlayerItemCount(cid, items.item1[1]) >= counts.count1[1] then
                                        doPlayerRemoveItem(cid, items.item1[1], counts.count1[1])
                                        doPlayerAddItem(cid, items.item1[2], counts.count1[2])
                                        selfSay('You just swap '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' for '.. counts.count1[2] ..' '.. getItemNameById(items.item1[2]) ..'.', cid)
          talkState[talkUser] = 0
                              else
                                        selfSay('You need '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..'.', cid)
                              end
                    else
                              selSay('Ok then!', cid)
         talkState[talkUser] = 0
                    end
          elseif msgcontains(msg, 'bar of gold') then
                    selfSay('You want to swap '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..' for '.. counts.count2[2] ..' '.. getItemNameById(items.item2[2]) ..'.', cid)
     talkState[talkUser] = 2
          elseif talkSate[talkUser] == 2
                    if msgcontains(msg, 'yes') then
                              if getPlayerItemCount(cid, items.item2[1]) >= counts.count2[1] then
                                        doPlayerRemoveItem(cid, items.item2[1], counts.count2[1])
                                        doPlayerAddItem(cid, items.item2[2], counts.count2[2])
                                        selfSay('You just swap '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..' for '.. counts.count2[2] ..' '.. getItemNameById(items.item2[2]) ..'.', cid)
          talkState[talkUser] = 0
                              else
                                        selfSay('You need '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..'.', cid)
                              end
                    else
                              selfSay('Ok then!', cid)
                              talkState[talkUser] = 0
                    end
          end
          return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Att.

Giovani Rodrigo

Spoiler

local config = {
	delrey = getPlayerCarValue(cid, DELREY),
	cigarro = getPlayerCancer(cid, DERBY),
	prostituta = getPlayerAIDS(cid, cracuda),
	tresOitao = getPlayerRevorvi(cid, 38)
}

if(delrey == "Ligado" and cigarro == "Aceso" and prostituta == "No Colo" and tresOitao == "Carregado") then
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Começou o fim de semana. #PAS")
end

 

  • 6 months later...
  • Respostas 10
  • Visualizações 8.1k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • GiovaniRodrigo
    GiovaniRodrigo

    Crie um arquivo chamado Jax.lua na pasta data/npc/scripts e cole isso   local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHa

  • GiovaniRodrigo
    GiovaniRodrigo

    Faça mesmo procedimento que eu citei só substitua o script do Jax.lua por esse local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParamete

Posted Images

Postado

Giovanni vc poderia me ajudar?

Eu tenho um otserv ai eu queria botar nele um npc q vende itens vip ai eu fiz tudo certinho botei ele pra vender os itens só q ele aceita Hundred Dollar ai eu quero mudar o Hundred  Dollar para Vip dollar q é a moeda vip, coma faço isso? 

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

  • 2 years later...
Postado
Em 30/05/2013 13:40:54, GiovaniRodrigo disse:

 

ola consegue mudar ele pra funcionar em TFS 1.2 ?

pra ta dando este erro:

 

Lua Script Error: [Npc interface] 
data/npc/scripts/Capitao Boss.lua:onCreatureSay 
data/npc/scripts/Capitao Boss.lua:40: attempt to call global 'getItemNameById' (a nil value) 
stack traceback: 
[C]: in function 'getItemNameById' 
data/npc/scripts/Capitao Boss.lua:40: in function 'callback' 
data/npc/lib/npcsystem/npchandler.lua:430: in function 'onCreatureSay' 
data/npc/scripts/Capitao Boss.lua:7: in function 

 

 

consegue me ajudar

 

 

TFS 1.2

 

 

e.PNG

Capitao Boss.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Capitao Boss" script="Capitao Boss.lua" walkinterval="2000" floorchange="0">
          <health now="150" max="150" />
          <look type="134" head="57" body="59" legs="40" feet="76" corpse="2212" />
          <parameters>
                    <parameter key="message_greet" value="OI |PLAYERNAME|. Você tem o que eu preciso? {magic plate armor} and {dragon shield}." />
                    <parameter key="message_farewell" value="Bye bye!" />
          </parameters>
</npc>

 

 

Capitao Boss.lua

 

 

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)        end
function onThink()        npcHandler:onThink()        end
 
local items = {
          item1 = {2472, 25560}, -- item1 item que será pedido e que será dado na primeira troca
          item2 = {2516, 25560} -- item2 item que será pedido e que será dado na segunda troca
}
local counts = {
          count1 = {1, 1}, -- count1 quantidade que será pedido e que será dado na primeira troca
          count2 = {50, 1} -- count2 quantidade que será pedido e que será dado na segunda troca
}
 
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, 'magic plate armor') then
                    selfSay('voce quer trocar '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' por '.. counts.count1[2] ..' '.. getItemNameById(items.item1[2]) ..'.',cid)
                    talkState[talkUser] = 1
          elseif talkState[talkUser] == 1 then
                    if msgcontains(msg, 'yes') then
                              if getPlayerItemCount(cid, items.item1[1]) >= counts.count1[1] then
                                        doPlayerRemoveItem(cid, items.item1[1], counts.count1[1])
                                        doPlayerAddItem(cid, items.item1[2], counts.count1[2])
                                        selfSay('voce acabou de trocar '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' por '.. counts.count1[2] ..' '.. getItemNameById(items.item1[2]) ..'.', cid)
          talkState[talkUser] = 0
                              else
                                        selfSay('voce precisa '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..'.', cid)
                              end
                    else
                              selSay('Ok, ate mais!', cid)
         talkState[talkUser] = 0
                    end
          elseif msgcontains(msg, 'dragon shield') then
                    selfSay('voce quer trocar '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..' por '.. counts.count2[2] ..' '.. getItemNameById(items.item2[2]) ..'.', cid)
     talkState[talkUser] = 2
          elseif talkSate[talkUser] == 2
                    if msgcontains(msg, 'yes') then
                              if getPlayerItemCount(cid, items.item2[1]) >= counts.count2[1] then
                                        doPlayerRemoveItem(cid, items.item2[1], counts.count2[1])
                                        doPlayerAddItem(cid, items.item2[2], counts.count2[2])
                                        selfSay('voce acabou de trocar '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..' por '.. counts.count2[2] ..' '.. getItemNameById(items.item2[2]) ..'.', cid)
          talkState[talkUser] = 0
                              else
                                        selfSay('voce precisa '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..'.', cid)
                              end
                    else
                              selfSay('Ok ate mais!', cid)
                              talkState[talkUser] = 0
                    end
          end
          return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

Postado

ola amigoo

 

pra mim esta dando este erro... mais ele troca os itens certinho

 

 

Lua Script Error: [Npc interface]
data/npc/scripts/Capitao Boss.lua:onCreatureSay
data/npc/scripts/Capitao Boss.lua:38: attempt to call global 'getItemNameById' (a nil value)
stack traceback:
[C]: in function 'getItemNameById'
data/npc/scripts/Capitao Boss.lua:38: in function 'callback'
data/npc/lib/npcsystem/npchandler.lua:430: in function 'onCreatureSay'
data/npc/scripts/Capitao Boss.lua:8: in function

  • 1 year later...
Postado
Em ‎24‎/‎05‎/‎2013 em 16:24, GiovaniRodrigo disse:

Crie um arquivo chamado Jax.lua na pasta data/npc/scripts e cole isso

 


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 items = {
          item1 = {2346, 2349}, -- item1 item que será pedido e que será dado na primeira troca
          item2 = {2033, 15515} -- item2 item que será pedido e que será dado na segunda troca
}
local counts = {
          count1 = {1, 1}, -- count1 quantidade que será pedido e que será dado na primeira troca
          count2 = {10, 1} -- count2 quantidade que será pedido e que será dado na segunda troca
}
 
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, 'blue note') then
                    if getPlayerItemCount(cid, items.item1[1]) >= counts.count1[1] then
                              doPlayerRemoveItem(cid, items.item1[1], counts.count1[1])
                              doPlayerAddItem(cid, items.item1[2], counts.count1[2])
                              selfSay('You just swap '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' for '.. counts.count1[2] ..' '.. getItemNameById(items.item1[2]) ..'.', cid)
                    else
                              selfSay('You need '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..'.', cid)
                    end

          elseif msgcontains(msg, 'bar of gold') then
                    if getPlayerItemCount(cid, items.item2[1]) >= counts.count2[1] then
                              doPlayerRemoveItem(cid, items.item2[1], counts.count2[1])
                              doPlayerAddItem(cid, items.item2[2], counts.count2[2])
                              selfSay('You just swap '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..' for '.. counts.count2[2] ..' '.. getItemNameById(items.item2[2]) ..'.', cid)
                    else
                              selfSay('You need '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..'.', cid)
                    end
          end
          return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Crie um arquivo chamado Jax.xml na pasta data/npc e cole isso

 


<?xml version="1.0" encoding="UTF-8"?>
<npc name="Jax" script="Jax.lua" walkinterval="2000" floorchange="0">
          <health now="150" max="150" />
          <look type="134" head="57" body="59" legs="40" feet="76" corpse="2212" />
          <parameters>
                    <parameter key="message_greet" value="Hello |PLAYERNAME|. Do not want to make an exchange? I have {blue note} and {bar of gold}." />
                    <parameter key="message_farewell" value="Bye bye!" />
          </parameters>
</npc>

 

Testado e está 100% funcional

 

Att.

Giovani Rodrigo

 

Vlw irmão, ajudo pra caramba.

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.6k

Informação Importante

Confirmação de Termo