Ir para conteúdo
  • Cadastre-se

(Resolvido)[Pedido] NPC DA ITEM APENAS 1 VEZ


Ir para solução Resolvido por Dwarfer,

Posts Recomendados

Iae galera, bom estou tentando a um tempo a criar um npc como esta na descrição exemplo, ele vai dar 5 items, somnente 1 vez, depois que o player voltar lá ele vai falar que ele ja recebeu isso, somente 1 vez, tentei aqui não consegui, por isso estou recorrendo a vocês, se poder ajuda hahahah <3

                                                        

Link para o post
Compartilhar em outros sites
Spoiler

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

local items = {1111, 2222, 3333, 4444, 5555}
local stor = 87632

    if(msgcontains(msg, 'item') or msgcontains(msg, 'ITEM')) then
        if getPlayerStorageValue(cid, stor) ~= -1 then
            selfSay('Você já recebeu seus itens.', cid)
            talkState[talkUser] = 0
            return true
        end
        selfSay('Você deseja receber os itens?', cid)
        talkState[talkUser] = 1
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        setPlayerStorageValue(cid, stor, 1)
        for i = 1, #items do
            doPlayerAddItem(cid, items[i], 1)
        end
        selfSay('Faça bom proveito.', cid)
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
        selfSay('Ok then.', cid)
        talkState[talkUser] = 0
	end
	return true
end

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

 

 

Contato:

 

Link para o post
Compartilhar em outros sites



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

local items = {1111, 2222, 3333, 4444, 5555}
local stor = 87632

    if(msgcontains(msg, 'item') or msgcontains(msg, 'ITEM')) then
        if getPlayerStorageValue(cid, stor) ~= -1 then
            selfSay('Você já recebeu seus itens.', cid)
            talkState[talkUser] = 0
            return true
        end
        selfSay('Você deseja receber os itens?', cid)
        talkState[talkUser] = 1
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        setPlayerStorageValue(cid, stor, 1)
        doPlayerAddItem(cid, math.random(#items), 1)
        selfSay('Faça bom proveito.', cid)
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
        selfSay('Ok then.', cid)
        talkState[talkUser] = 0
    end
    return true
end

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

 

Te ajudei ?? Que tal fazer uma contribuição ?

Doar

Link para o post
Compartilhar em outros sites

Mano não funcionou, ach que voces não entenderam, ele vai ter que escolher um dos 5, exemplo voce deseja o item 1 2 3 4 ou 5, ai ele fala 5 e quando ele voltar nao vai dar mais

                                                        

Link para o post
Compartilhar em outros sites
  • Solução

Não é que a gente não tenha entendido. Você que não falou nada disso, leia novamente o que você escreveu:

 

14 horas atrás, ScreMMo disse:

Iae galera, bom estou tentando a um tempo a criar um npc como esta na descrição exemplo, ele vai dar 5 items, somnente 1 vez, depois que o player voltar lá ele vai falar que ele ja recebeu isso, somente 1 vez, tentei aqui não consegui, por isso estou recorrendo a vocês, se poder ajuda hahahah <3

 

Edite as falas como quiser:

 

Spoiler

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

local items = {1111, 2222, 3333, 4444, 5555}
local stor = 87632

    if(msgcontains(msg, 'item') or msgcontains(msg, 'ITEM')) then
        if getPlayerStorageValue(cid, stor) ~= -1 then
            selfSay('Você já recebeu seus itens.', cid)
            talkState[talkUser] = 0
            return true
        end
        local text = ""
        for i = 1, #items do
            text = text .. "{" .. getItemNameById(items[i]) .. "}, "
        end
        selfSay('Os items que possuo são '..text..' qual você deseja?', cid)
        talkState[talkUser] = 1
    elseif(isInArray(items, getItemIdByName(msg)) and talkState[talkUser] == 1) then
        setPlayerStorageValue(cid, stor, 1)
        doPlayerAddItem(cid, getItemIdByName(msg), 1)
        selfSay('Faça bom proveito.', cid)
        talkState[talkUser] = 0
    elseif(not isInArray(items, getItemIdByName(msg)) and talkState[talkUser] == 1) then
        selfSay('Não tenho esse item.', cid)
        talkState[talkUser] = 1
        return true
    else
        selfSay('Ok.', cid)
        talkState[talkUser] = 0
    end
	return true
end

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

 

 

Contato:

 

Link para o post
Compartilhar em outros sites
  • 2 months later...
Em 26/08/2017 em 12:48, DboExplorer disse:

Mas no caso o item a ser escolhido é random não é? 

 

Eu quero fazer o npc Weaponmaster do global, da isle of destiny, na qual o player vai chegar e falar com ele, ele vai informar que tem 3 items pro player escolher, o player escolhe 1 item e ele da pra ele o item que escolheu, se o player voltar, o npc vai falar que ele já recebeu o item assim que falar hi.

Transcrição do NPC:

Jogador: hi

Weaponmaster: Hello Jogador! I have already heard about you! As our newest member you are eligible to be granted a weapon of your choice!
Jogador: choice
Weaponmaster: You can choose a daramian mace, a steel axe or a jagged sword!
Jogador: daramian mace
Weaponmaster: The first rule of club fighting is: you do not talk about club fighting! But let us ignore this rule for a moment. ...
Weaponmaster: The daramian mace is obviously used in the mace fighting style. Maces tend to be a bit more defensive then other weapon category. ...
Weaponmaster: This becomes especially interesting when using two handed weapons without the protection of a shield. So shall the daramian mace become your weapon of choice?
Jogador: steel axe
Weaponmaster: The steel axe suits the style of axe fighters well. Axes tend to be better for attacking then for defense, which becomes most important while using two handed weapons. Do you really want to choose the steel axe as your weapon?
Jogador: jagged sword
Weaponmaster: Sword fighting is a balanced style, not giving up attack power for defense or the other way round. Swords are not as damaging as comparable axes or defensive as comparable maces but does neither share their weaknesses. ...
Weaponmaster: Do you want to take the jagged sword as your first weapon?
Jogador: yes
Weaponmasterr: And here it is! Your first weapon of knighthood! May it serve you well. Remember this choice does not restrict you to this weapon type. You can train your weapon skills freely as it pleases you.
Jogador: bye
Weaponmaster: Farewell then, adventurer!

Após pegar a sua arma:

Jogador: hi

Weaponmaster: Greetings Jogador! Now that you have your weapon, waste no time and seek out adventure. Farewell!

 

 

 

Em 26/08/2017 em 12:48, DboExplorer disse:

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

local items = {1111, 2222, 3333, 4444, 5555}
local stor = 87632

    if(msgcontains(msg, 'item') or msgcontains(msg, 'ITEM')) then
        if getPlayerStorageValue(cid, stor) ~= -1 then
            selfSay('Você já recebeu seus itens.', cid)
            talkState[talkUser] = 0
            return true
        end
        selfSay('Você deseja receber os itens?', cid)
        talkState[talkUser] = 1
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        setPlayerStorageValue(cid, stor, 1)
        doPlayerAddItem(cid, math.random(#items), 1)
        selfSay('Faça bom proveito.', cid)
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
        selfSay('Ok then.', cid)
        talkState[talkUser] = 0
    end
    return true
end

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

 

 

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo