Postado Agosto 26, 2017 7 anos 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 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: Email: [email protected] Discord: Dwarfer#2715
Postado Novembro 2, 2017 7 anos 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: choiceWeaponmaster: You can choose a daramian mace, a steel axe or a jagged sword!Jogador: daramian maceWeaponmaster: 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 axeWeaponmaster: 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 swordWeaponmaster: 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: yesWeaponmasterr: 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: byeWeaponmaster: 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())
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.