Ir para conteúdo

Featured Replies

Postado

Você pode fazer o seguinte:

elseif msgcontains(msg, 'team red') then

if getPlayerItemCount(cid ,2160) >= 20 then
npcHandler:say('Did you bring me the 20 crystal coins?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need a {20 crystal coins}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,2160) >= 20 then
if doPlayerRemoveItem(cid,2160, 20) == TRUE then

if getGlobalStorageValue(34577) < 20 then
npcHandler:say(done, cid)
else
return doPlayerSendCancel(cid, "Os tickets esgotaram.")
end
else
npcHandler:say(item, cid)
end
  • Respostas 33
  • Visualizações 1.4k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Da pra tu colocar uma global storage, tipo: setGlobalStorageValue(storage_desejada, getGlobalStorageValue(storage_desejada) +1) Ai na verificação do método de comprar você coloca: if getGlobalStor

  • Você pode fazer o seguinte: elseif msgcontains(msg, 'team red') then if getPlayerItemCount(cid ,2160) >= 20 then npcHandler:say('Did you bring me the 20 crystal coins?', cid) npcHandler.topic[ci

  • n tinha pensado nisso, vlw. já editei de novo     @ -- editei de novo pq tinha faltando um "and"   usa o que eu editei lá agr que é esse:   local keywordHandler = KeywordHandler:new()  local

Postado
  • Autor

 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 item = 'I\'m sorry, but you do not have the required items for this trade.'
local done = 'Here you are, thank you for your business.'
 
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
 
if msgcontains(msg, 'tickets') then
npcHandler:say('I sell tickets for the event.', cid)
elseif msgcontains(msg, 'blue') then
if getPlayerItemCount(cid ,2160) >= 20 then
npcHandler:say('Did you bring me the 20 crystal coins?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need a {20 crystal coins}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,2160) >= 20 then
if doPlayerRemoveItem(cid,2160, 20) == TRUE then
npcHandler:say(done, cid)
if getGlobalStorageValue(34577) >= 20 then
                                                                           return doPlayerSendCancel(cid, "Os tickets esgotaram.")
end
else
npcHandler:say(item, cid)
end
elseif msgcontains(msg, 'green') then
if getPlayerItemCount(cid ,2160) >= 20 then
npcHandler:say('Did you bring me the 20 crystal coins?', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('I need a {20 crystal coins}. Please come back when you have them.', cid)
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
npcHandler.topic[cid] = 0
if getPlayerItemCount(cid,2160) >= 20 then
if doPlayerRemoveItem(cid,2160, 20) == TRUE then
npcHandler:say(done, cid)
if getGlobalStorageValue(34578) >= 20 then
                                                                           return doPlayerSendCancel(cid, "Os tickets esgotaram.")
end
else
npcHandler:say(item, cid)
end
    elseif msgcontains(msg, 'no') and npcHandler.topic[cid] >= 1 and npcHandler.topic[cid] <= 90 then
npcHandler:say('Well, then leave.')
npcHandler.topic[cid] = 0
end
 
return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

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

Postado

Testa ai:

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 storage = 23844 -- Storage do player ao comprar para ter acesso ao evento.
local gstorage = 34577 -- Storage global do evento.
local done = 'Here you are, thank you for your business.'
 
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local msg = msg:lower();
if(not npcHandler:isFocused(cid)) then
return false
end

    if msgcontains(msg, 'tickets') then
       if getGlobalStorageValue(gstorage) < 20 then
          npcHandler:say('I sell tickets for the event.', cid)
          talkState[talkUser] = 1
       else
          npcHandler:say('There are no more tickets.', cid)
          talkState[talkUser] = 0
       end
    elseif msgcontains(msg, 'blue') then
       if talkState[talkUser] == 1 then
          npcHandler:say('Did you bring me the 20 crystal coins?', cid)
          talkState[talkUser] = 2
       end
    elseif msgcontains(msg, 'green') then
       if talkState[talkUser] == 1 then
          npcHandler:say('Did you bring me the 20 crystal coins?', cid)
          talkState[talkUser] = 2
    elseif msgcontains(msg, 'yes') then
       if talkState[talkUser] == 2 then
          if doPlayerRemoveItem(cid, 2160, 20) == TRUE then
             npcHandler:say(done, cid)
             setPlayerStorageValue(cid, storage, 1)
          else
             npcHandler:say("You do not have 20 crystal coins.")
          end
       end
    elseif msgcontains(msg, 'no') then
        if talkState[talkUser] = 2 then
           npcHandler:say("Okay...")
           talkState[talkUser] = 0
        end
    end
end
        
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

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