Ir para conteúdo

Featured Replies

Postado

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

local need = {2145, 25} -- id, quantidade
local pokemon = "Moltres" -- nome do poke

    if msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
    if getPlayerItemCount(cid, need[1]) < need[2] then
        selfSay('Voce precisa de '..need[2]..' '..getItemNameById(need[1])..' para compra um Pokemon mega evoluido!', cid)
        talkState[talkUser] = 0
    return true
    if not addPokeToPlayer(cid, pokemon, 0, -1, "normal", true) then
        selfSay('Voce este com 6 pokemons e não pode fazer a compra do mega Pokemon!', cid)
        talkState[talkUser] = 0
    return true
    end
    else    
        doPlayerRemoveItem(cid, need[1], need[2])
        addPokeToPlayer(cid, pokemon, 0, 1, 'normal', true)
        selfSay('Nossa muito bom, obrigado e faça bom proveito do seu novo pokémon!', cid)
        talkState[talkUser] = 0
    end
    end
  return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Boa sorte.

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

  • Respostas 23
  • Visualizações 957
  • Created
  • Última resposta

Top Posters In This Topic

Postado
  • Autor

Irei testar o do adriano. Esse npc vai vende o pokemon moltres por 25 diamonds ID 2145, ele vai executar com a função addPokeToPlayer mais eu não sei porque está dando esse erro, irei testar o do adriano

Postado
  Em 23/08/2014 em 15:25, Adriano SwaTT disse:

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

local need = {2145, 25} -- id, quantidade
local pokemon = "Moltres" -- nome do poke

    if msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
    if getPlayerItemCount(cid, need[1]) < need[2] then
        selfSay('Voce precisa de '..need[2]..' '..need[1]..' para compra um Pokemon mega evoluido!', cid)
        talkState[talkUser] = 0
    return true
    if not addPokeToPlayer(cid, pokemon, 0, -1, "normal", true) then
        selfSay("Voce este com 6 pokemons e não pode fazer a compra do mega Pokemon!", cid)
        talkState[talkUser] = 0
    return true
    end
    else    
        doPlayerRemoveItem(cid, need[1], need[2])
        addPokeToPlayer(cid, pokemon, 0, 1, 'normal', true)
        selfSay("Nossa muito bom, obrigado e faça bom proveito do seu novo pokémon!", cid)
        talkState[talkUser] = 0
    end
    end
  return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Boa sorte.

Adriano cadê o id da pokebola?

aí só tem o do diamante.

Postado
  Em 23/08/2014 em 15:58, AnnaFeeh disse:

Não precisa do id da pokeball porque já está fixa no script

ata, eu só perguntei porquê quero entender mais de script.

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