GA
pedido

Npc Quest

Por Gabrielkss, 15 de set. de 2015 em Scripts

resolvido
script
6
1k
GabrielkssG
15 de setembro de 2015 às 18:28

Gostaria de um npc que ao falar com ele, ele daria 5 opções e na qual quando escolher, ganhara uma storage... obs: pode escolher qualquer opção

 

Por favor. Agradeço desde de já.


Alguém ?


Alguém ?
​plz

zipter98Z
15 de setembro de 2015 às 20:33
Melhor resposta


local options = {

--["option"] = key,

--Ex.:

["task_1"] = 9230,

["task_2"] = 9321,

["quest"] = 9322,

}

 

local choose_more_times = true --True se puder escolher mais de uma opção, false caso contrário.

 

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)

msg = msg:lower()

if(not npcHandler:isFocused(cid)) then

return false

end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

 

if msgcontains(msg, "quest") or msgcontains(msg, "help") or msgcontains(msg, "options") then

local option_table = {}

for option, key in pairs(options) do

if not choose_more_times and getPlayerStorageValue(cid, key) > -1 then

return selfSay("You already have chosen your option.", cid)

end

option_table[#option_table + 1] = option

end

selfSay("I have "..#option_table.." options for you. Which one do you choose? {"..table.concat(option_table, ",").."}", cid)

talkState[talkUser] = 1

elseif talkState[talkUser] == 1 then

if options[msg] then

selfSay("Ok, you chose "..msg.."!", cid)

setPlayerStorageValue(cid, options[msg], 1)

talkState[talkUser] = 0

else

selfSay("I didn't give you this option. Please, tell me a valid one.", cid)

end

else

selfSay("Sorry, I didn't understand what you said.", cid)

talkState[talkUser] = 0

end

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Editado Setembro 15 por zipter98

GabrielkssG
15 de setembro de 2015 às 21:01

Teria como fazer para o chat ficar no channel NPCS ? pq ele fica como se fosse um player falando as opções...

zipter98Z
15 de setembro de 2015 às 21:10

Uhum, editado.

GabrielkssG
16 de setembro de 2015 às 00:11

Valeu mesmo obrigado cara !!

zipter98Z
16 de setembro de 2015 às 00:18

Tópico movido para dúvidas / pedidos resolvidos.