a duvida de um usuário me insentivou a criar este NPC
achei ÓTIMA a ideia dele
Idéia by 6u6aNPC by Conde Sapo
(excusivo pata XTibia, denunciar aqui se achar este NPC em outro forum)
1° - criando o NPC no MapEditor
editar o arquivo MapEditor\creatures.xml
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) -- OTServ event handling functions start -- BLOCOS de funçoes pre-definidas em data\npc\scripts\lib\npcsystem 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 -- OTServ event handling functions end function creatureSayCallback(cid, type, msg) if(npcHandler.focus ~= cid) then return false end msg = string.lower(msg) if msg == 'help' or msg == 'job' then selfSay('Ohh... My job is easy, I\'ll send your message to all players on-line!') talk_state = 0 elseif msg == 'message' or msg == 'msg' or msg == 'mensagem' then selfSay('Do you want to send a message to all players for 1000 gps?') talk_state = 1 elseif msgcontains(msg, 'yes') and talk_state == 1 then selfSay('What the message you want I send ?') talk_state = 2 elseif msgcontains(msg, 'no') and talk_state > 0 then selfSay('Ok than.') talk_state = 0 elseif msg ~= "" and talk_state == 2 then if pay(cid,1000) then selfSay('/B ' .. creatureGetName(cid) .. ' say: ' .. msg) else selfSay('Sorry, you don\'t have money.') end talk_state = 0 end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Agora as instruções basica.
Em algumas versões de OT , o broadcast não é "/B"
substitua por "/BC"
ficando assim :
selfSay('/BC ' .. creatureGetName(cid) .. ' say: ' .. msg)
(By KingCPI)
- Se trocar o nome do npc , acertar em AMBOS arquivos (xml e lua)
- Se trocar o valor (1000 gps) acertar na mensagem do npc e na parte que remove a grana do player
- Se o comando if pay(cid,1000) then não funcionar , substituir por if doPlayerRemoveMoney(cid,1000) then
Testei todas as ações
HI
BYE
YES
NO
HELP
JOB
MSG
MENSAGEM
MESSAGE
tentei mandar a mensagem sem a grana e fui recusado por falta dela.
acho que não faltou nenhum teste.
Resultados :
18:43 Conde Sapo [51]: hi18:43 Messager: Welcome, Conde Sapo! I have been expecting you.
18:43 Conde Sapo [51]: job
18:43 Messager: Ohh... My job is easy, I'll send your message to all players on-line!
18:43 Conde Sapo [51]: message
18:43 Messager: Do you want to send a message to all players for 1000 gps?
18:43 Conde Sapo [51]: yes
18:43 Messager: What the message you want I send ?
18:44 Conde Sapo [51]: help me with anihi quest PLX
18:44 Conde Sapo say: help me with anihi quest PLX
18:44 Conde Sapo [51]: bye
18:44 Messager: Good bye, Conde Sapo!
divirtam-se
Ps.: qualquer sugestão inteligente eu altero este topico e incluo.
(e coloco crédito... claro...)
Ps.: BUG DE TEMPO acertado.
o NPC parava de falar com você após 30 segundos
mesmo que você estivesse conversando com ele
faltava a linha return TRUE nas ultimas linhas
isso "zera" o tempo cada vez que você fala com o NPC.
Ps.: BUG DE MAIUSCULA/MINUSCULA
msg = string.lower(msg)
Faltava esta linha
isso transforma a mensagem em MINUSCULAS
se o player falasse "Hi" o npc não ia responder
agora vai transformar "Hi" em "hi" e o NPC reconhece.