Legal, eu tinha feito um sistema quase assim só que para 8.6, mas não fico tão bom quanto esse.
- Fórum
- OTServ
- Recursos
- Scripting
- Globalevents e Spells
- [ModalWindow][TFS 1.2][NPC] Sistema de Diálogo
[ModalWindow][TFS 1.2][NPC] Sistema de Diálogo
Por DeCarvalho, 02 de ago. de 2015 em Globalevents e Spells
info
Grupo: Visconde
Registrado: 05/02/14
Posts: 411
Reputação: +285
Gênero: Masculino
Char no Tibia: Zeh Sergipano

info
Grupo: Barão
Registrado: 28/10/10
Posts: 206
Reputação: +65
Char no Tibia: Mage Junkie

Eu tava online na hora que o karain tinha postado.. dei uma testada por alto e pedi autorização pra trazer... particularmente não me ganhou.. mas tem gente que curte né
isso de modalwindow é bem top e deixa com um ar bem moderno mesmo ![]()
info
Grupo: Cavaleiro
Registrado: 26/02/10
Posts: 158
Reputação: +35
Gênero: Masculino
Char no Tibia: Vampiresco

Desculpe, este sistema funciona na versão 8.6? Excelente, mesmo que não...
info
Grupo: Barão
Registrado: 28/10/10
Posts: 206
Reputação: +65
Char no Tibia: Mage Junkie

Bom dia fera, bem, é por isso que usamos as tags para identificar o sistema.. [TFS 1.2] quer dizer que é para servidores que utilizam essa versão.. bem funciona em tfs 1.1 também..
Se não me engano, é possível usar 8.6 com 1.2,m mas imagino que o seu seja outra versão.. enfim..
O comentou ter feito um para 8.6, quem sabe, se por acaso, voc~e pedir com jeitinho ele não venha a liberar ![]()
info
Grupo: Campones
Registrado: 24/09/15
Posts: 7
Reputação: 0

good ![]()
pra que server isso ai ?
teria como adaptar para tfs 0.3.6?
info
Grupo: Conde
Registrado: 14/04/15
Posts: 956
Reputação: +333
Gênero: Masculino

teria como adaptar para tfs 0.3.6?
Não, pois o Tfs 0.3.6 não tem a função de ModalWindow nas sources, a não ser que alguem consiga extrair está função do Tfs 1.1 ou 1.2









info
Grupo: Barão
Registrado: 28/10/10
Posts: 206
Reputação: +65
Char no Tibia: Mage Junkie
Esse sistema/script/sei lá o que foi desenvolvido por Karain que quis trazer um 'ar' mais moderno ao tibia..
Com esse script conversar com o npc será mais uma experiência mais amigável, continua sendo customizável mas de uma forma mais fácil!
Como instalar
Em data/creaturescripts/creaturescrips.xml adicione
Em data/creaturescripts/scripts/login.lua adicione isso antes do "return true"
player:registerEvent("Dialogue")Crie em data/creaturescripts o arquivo dialogue.lua e adicione
player_choices = {} defaultButtons = {{id = 0x00, text = "Select", enter = true, escape = false}, {id = 0x01, text = "End", enter = false, escape = true}} function Player:getChoiceText(choice_id) if player_choices and player_choices[self:getId()] then return player_choices[self:getId()][choice_id].text else return false end end function Player:createDialogueWindowWithButtons(modalWindowId, headerText, bodyText, buttonTable, choiceTable, sendToPlayer, priority) local var = ModalWindow(modalWindowId, headerText, bodyText) for i = 1, #buttonTable do var:addButton(buttonTable[i].id, buttonTable[i].text) if buttonTable[i].enter then var:setDefaultEnterButton(buttonTable[i].id) end if buttonTable[i].escape then var:setDefaultEscapeButton(buttonTable[i].id) end end player_choices[self:getId()] = choiceTable for i = 0, #choiceTable do if choiceTable[i] ~= nil and (choiceTable[i].storage == false or self:getStorageValue(choiceTable[i].storage[1]) == choiceTable[i].storage[2]) then var:addChoice(i, choiceTable[i].text) end end if not priority then var:setPriority(false) end if sendToPlayer then var:sendToPlayer(self) end end function onModalWindow(player, modalWindowId, buttonId, choiceId) -- be careful here if you have other modalwindow scripts if buttonId == 0x00 then player:say(player:getChoiceText(choiceId),TALKTYPE_SAY) elseif buttonId == 0x01 then player:say("Good Bye.",TALKTYPE_SAY) end return true endCrie em data/npc/scripts o arquivo dialogue.lua e adicione
local npc_dialogue = { [1] = { message="This is the message that shows up before the choices, make sure it's long enough if you are having long choices.", choices= { [1]={text="Choice 1", storage=false, dialogue=1, script="end"}, [2]={text="Choice 2",storage=false, dialogue=2, script="script1"}, [3]={text="Choice 3",storage={1234,1}, dialogue=3, script="trade"}, [4]={text="Choice 4",storage=false, dialogue=3, script="quest"}, [5]={text="Choice 5",storage=false, dialogue=false, script="quest2"}}}, [2] = { message="Bla bla bla bla bla bla bla.", choices= { [1]={text="Choice 1",storage=false, dialogue=1, script="end"}, [2]={text="Choice 2",storage=false, dialogue=2, script="end"}, [3]={text="Choice 3",storage={1234,1}, dialogue=false, script="end"}, [4]={text="Choice 4",storage=false, dialogue=false, script="end"}, [5]={text="Choice 5",storage=false, dialogue=3, script="end"}}}, [3] = { message="Brought to you by Matt Shadowwing.", choices= { [1]={text="Choice 1",storage={1245,2}, dialogue=false, script="end"}, [2]={text="Choice 2",storage=false, dialogue=false, script="end"}, [3]={text="Choice 3",storage={1234,1}, dialogue=false, script="end"}, [4]={text="Choice 4",storage=false, dialogue=1, script="end"}, [5]={text="Choice 5",storage=false, dialogue=2, script="end"}}} } 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 talkstate = {} local function greetCallback(cid) local player = Player(cid) local npc = Npc(getNpcCid()) npcHandler:setMessage(MESSAGE_GREET, npc_dialogue[1].message) player:createDialogueWindowWithButtons(1, npc:getName(), npc_dialogue[1].message, defaultButtons, npc_dialogue[1].choices, true, false) talkstate[player:getId()] = 1 return true end local function creatureSayCallback(cid, type, msg) local player = Player(cid) local npc = Npc(getNpcCid()) if not npcHandler:isFocused(cid) then return false elseif talkstate[player:getId()] then for _, v in pairs(npc_dialogue[talkstate[player:getId()]].choices) do if msgcontains(msg, v.text) and (v.storage == false or player:getStorageValue(v.storage[1]) == v.storage[2]) then if v.script == "end" then talkstate[player:getId()] = v.dialogue npcHandler:say(npc_dialogue[v.dialogue].message, cid) player:createDialogueWindowWithButtons(1, npc:getName(), npc_dialogue[v.dialogue].message, defaultButtons, npc_dialogue[v.dialogue].choices, true, false) elseif v.script == "trade" then -- trading script here talkstate[player:getId()] = v.dialogue npcHandler:say(npc_dialogue[v.dialogue].message, cid) player:createDialogueWindowWithButtons(1, npc:getName(), npc_dialogue[v.dialogue].message, defaultButtons, npc_dialogue[v.dialogue].choices, true, false) elseif v.script == "quest" then -- quest script here talkstate[player:getId()] = v.dialogue npcHandler:say(npc_dialogue[v.dialogue].message, cid) player:createDialogueWindowWithButtons(1, npc:getName(), npc_dialogue[v.dialogue].message, defaultButtons, npc_dialogue[v.dialogue].choices, true, false) end end end end return true end npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())Em data/npc/lib/npcsystem/npchandler.lua altere todos os
para
Depois é só criar seu npc.xml referenciar o lua e seja feliz.. Qualquer problema eu terei que repassar para o criador pois não sou apto a dar suporte.. Estou somente trazendo para cá!
Editado Agosto 2 por DeCarvalho