eletross 3 Postado Outubro 7, 2008 Share Postado Outubro 7, 2008 (editado) NPC BROADCAST MSG: Player paga para o npc, podendo enviar uma broadcast msg. Salve em "data\npc\scripts\broadcaster.lua" -- NPC Broadcaster by Alreth, v1.40, 2008-09-22 17:50 CET -- Idea by souhlen (Anel) -- Thanks to Qwerty| for helping fix the spambug -- Thanks to Colandus for providing changes for compability with Tibia 8.21/22. focus = 0 next_focus = 0 talk_start = 0 msgHi = 'Heylo! Would you like to broadcast anything?' msgBye = 'See you another time!' price = 2500 inConvo = 0 broadcast = '' cast = '' target = 0 following = false attacking = false function onThingMove(creature, thing, oldpos, oldstackpos) end function onCreatureAppear(creature) end function onCreatureDisappear(cid, pos) if (focus == cid) then selfSay(msgBye) distFocus = getDistanceToCreature(next_focus) if (distFocus ~= nil and distFocus < 4) then selfSay(msgHi) talk_start = os.clock() focus = next_focus next_focus = 0 inConvo = 1 else focus = 0 talk_start = 0 inConvo = 0 end end end function onCreatureTurn(creature) end function msgcontains(txt, str) return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)')) end function onCreatureSay(cid, type, msg) msg2 = msg msg = string.lower(msg) if (cast ~= '') then selfSay('does nothing') -- do nothing, wait until message has been broadcasted and npc has replied elseif (getDistanceToCreature(cid) >= 4 and focus == cid) then selfSay('Please come closer, '..getCreatureName(cid)..'. I can\'t hear what you are saying from over there.') elseif (type == 1) then if ((string.find(msg, '(%a*)hi(%a*)') or string.find(msg, '(%a*)hello(%a*)') or string.find(msg, '(%a*)heylo(%a*)') or string.find(msg, '(%a*)greetings(%a*)')) and (focus == 0) and getDistanceToCreature(cid) < 4) then selfSay(msgHi) focus = cid talk_start = os.clock() inConvo = 1 elseif ((string.find(msg, '(%a*)hi(%a*)') or string.find(msg, '(%a*)hello(%a*)') or string.find(msg, '(%a*)heylo(%a*)') or string.find(msg, '(%a*)greetings(%a*)')) and (focus ~= cid) and getDistanceToCreature(cid) < 4) then if (next_focus > 0 and getDistanceToCreature(next_focus) < 4) then selfSay('Take a nap while I help the ones before you, ' .. getCreatureName(cid) .. '.') else selfSay('I\'ll soon come to you, ' .. getCreatureName(cid) .. '.') next_focus = cid end elseif (focus == cid) then talk_start = os.clock() if ((msgcontains(msg, 'broadcast') or msgcontains(msg, 'say')) and inConvo == 0) then if (getPlayerLevel(cid) >= 30) then selfSay('Do you want me to broadcast anything for you?') inConvo = 1 else selfSay('Come back when you\'re older!') end elseif (msgcontains(msg, 'yes') and inConvo == 1) then selfSay('Tell me what you want me to broadcast.') inConvo = 2 elseif (msgcontains(msg, 'no') and inConvo == 1) then selfSay('Perhaps tomorrow then..') if (next_focus > 0 and getDistanceToCreature(next_focus) < 4) then selfSay(msgHi) talk_start = os.clock() focus = next_focus next_focus = 0 inConvo = 1 else focus = 0 talk_start = 0 inConvo = 0 end broadcast = '' elseif (inConvo == 2 and (msg ~= 'stop')) then if (string.len(msg) > 90) then selfSay('I am sorry, but your message can not be longer than 90 letters, including spaces and other characters. Say a new message or say STOP to end.') else broadcast = msg2 selfSay('Do you want to pay '..price..' gold for me to broadcast this message? "'..broadcast..'"') inConvo = 3 end elseif (msgcontains(msg, 'yes') and inConvo == 3) then if (doPlayerRemoveMoney(cid, price) == 1) then selfSay('/B '..getCreatureName(cid)..' says: '..broadcast) saycast = os.clock() inConvo = 1 io.output(io.open("broadcast.log", "a")) io.write("["..os.date("%y.%m.%d %X").."] <"..getCreatureName(cid).."> "..broadcast.."\n") io.close() cast = broadcast else selfSay('You can not afford this service. Please come back another time when you have more money!') if (next_focus > 0) then distFocus = getDistanceToCreature(next_focus) if (distFocus ~= nil and distFocus < 4) then selfSay(msgHi) talk_start = os.clock() focus = next_focus next_focus = 0 inConvo = 1 else focus = 0 talk_start = 0 inConvo = 0 end broadcast = '' end end elseif (msgcontains(msg, 'no') and inConvo == 3) then selfSay('Ok then.') inConvo = 0 broadcast = '' elseif (string.find(msg, '(%a*)job(%a*)')) then selfSay('I have the strongest voice in the world! People sometimes pay me to broadcast things for them.') inConvo = 0 elseif (string.find(msg, '(%a*)bye(%a*)')) then selfSay(msgBye) if (next_focus > 0) then distFocus = getDistanceToCreature(next_focus) if (distFocus ~= nil and distFocus < 4) then selfSay(msgHi) talk_start = os.clock() focus = next_focus next_focus = 0 inConvo = 1 else focus = 0 talk_start = 0 inConvo = 0 end broadcast = '' end end end end end function onCreatureChangeOutfit(creature) end function onThink() if (cast ~= '' and (os.clock() - saycast) > 1) then selfSay('Do you want to broadcast anything else?') cast = '' elseif (os.clock() - talk_start) > 30 then if (focus > 0) then selfSay(msgBye) if (next_focus > 0) then distFocus = getDistanceToCreature(next_focus) if (distFocus ~= nil and distFocus < 4) then selfSay(msgHi) talk_start = os.clock() focus = next_focus next_focus = 0 inConvo = 1 else focus = 0 talk_start = 0 inConvo = 0 end else focus = 0 talk_start = 0 inConvo = 0 end broadcast = '' end elseif (focus ~= 0) then distFocus = getDistanceToCreature(focus) if (distFocus ~= nil and distFocus > 5) then selfSay(msgBye) if (next_focus > 0) then distFocus = getDistanceToCreature(next_focus) if (distFocus ~= nil and distFocus < 4) then selfSay(msgHi) talk_start = os.clock() focus = next_focus next_focus = 0 inConvo = 1 end else focus = 0 talk_start = 0 inConvo = 0 end broadcast = '' end end end Cria um arquivo xml com nome do npc e coloque na pasta "data\npc\nimral.xml" <?xml version="1.0"?> <npc name="Nimral" script="data/npc/scripts/broadcaster.lua" access="[color="#FF0000"]3[/color]"> <look type="129" head="114" body="119" legs="114" feet="114"/> <parameters> <parameter key="module_shop" value="1" /> <parameter key="message_greet" value="Hello |PLAYERNAME|. Eu envio Broadcast msg por um preço legal." /> </parameters> </npc> Exemplo: 21:52 Isaac Brewton: Heylo 21:52 Broadcaster: Heylo! Would you like to broadcast anything? 21:52 Isaac Brewton: Yes 21:52 Broadcaster: Tell me what you want me to broadcast. 21:52 Isaac Brewton: Hello there Rookira! 21:52 Broadcaster: Do you want to pay 2500 gold for me to broadcast this message? "Hello there Rookira!" 21:52 Isaac Brewton: Yes 21:52 Broadcaster: Isaac Brewton says: Hello there Rookira! 21:52 Broadcaster: Do you want to broadcast anything else? 21:52 Isaac Brewton: No thanks 21:52 Broadcaster: Perhaps tomorrow then.. ----------- Retirado do OTFans 80%... Eu 20% Quero coments... Façam um bom uso, abração! :smile_positivo: Editado Outubro 30, 2008 por Eletross Link para o comentário https://xtibia.com/forum/topic/97932-npc-que-envia-broadcast-msg/ Compartilhar em outros sites More sharing options...
Malzbier 0 Postado Outubro 18, 2008 Share Postado Outubro 18, 2008 ja deve te vo forum + esses npc sao realmente mto uteis em quest q precisam de um team como anih e poi gostei do seu npc Link para o comentário https://xtibia.com/forum/topic/97932-npc-que-envia-broadcast-msg/#findComment-628252 Compartilhar em outros sites More sharing options...
Myself 0 Postado Outubro 18, 2008 Share Postado Outubro 18, 2008 Esse script já existe no fórum, porém este está bem mais elaborado e organizado! Ótimo trabalho em trazê-lo para cá. (: Usarei ele na próxima versão do Red Legion. ~ Link para o comentário https://xtibia.com/forum/topic/97932-npc-que-envia-broadcast-msg/#findComment-628254 Compartilhar em outros sites More sharing options...
marcaodailha 0 Postado Outubro 19, 2008 Share Postado Outubro 19, 2008 Você não olhou o script direito. O NPC não tem atributos de GM para enviar essas mensagens. Dê uma olhada melhor nesse script pois a idéia é boa. E esqueceu também de falar que deve ser criado um arquivo .XML senão o NPC não carrega. Grande abraço! Link para o comentário https://xtibia.com/forum/topic/97932-npc-que-envia-broadcast-msg/#findComment-628937 Compartilhar em outros sites More sharing options...
eletross 3 Postado Outubro 30, 2008 Autor Share Postado Outubro 30, 2008 É mesmo valew dica ! Link para o comentário https://xtibia.com/forum/topic/97932-npc-que-envia-broadcast-msg/#findComment-633107 Compartilhar em outros sites More sharing options...
marcaodailha 0 Postado Novembro 1, 2008 Share Postado Novembro 1, 2008 É mesmo valew dica ! E ai, arrumou o script? Link para o comentário https://xtibia.com/forum/topic/97932-npc-que-envia-broadcast-msg/#findComment-633659 Compartilhar em outros sites More sharing options...
guilhermes26 26 Postado Novembro 1, 2008 Share Postado Novembro 1, 2008 Eu ja conhecia esse script, tinha visto em um Ot. mesmo assim, valeu por trazer pra cá. Link para o comentário https://xtibia.com/forum/topic/97932-npc-que-envia-broadcast-msg/#findComment-633662 Compartilhar em outros sites More sharing options...
Blekwave 0 Postado Novembro 7, 2008 Share Postado Novembro 7, 2008 bom, tentei implementar lá no meu ot mas n deu, justamente pelo fato de que o npc n pode manda broadcast. Então o player paga mas o npc fala "/B Mensagem" em vez de broadcastar a mensagem própriamente dita. E seu script de access n tah funfando aki, já que meu serv eh sql, ou seja, eh de group id e acc. type. Tem como fazer pra esse tipo de ot? Link para o comentário https://xtibia.com/forum/topic/97932-npc-que-envia-broadcast-msg/#findComment-636135 Compartilhar em outros sites More sharing options...
IcarooxDloll 1 Postado Janeiro 13, 2009 Share Postado Janeiro 13, 2009 bom .. esse Npc vai ajuda muitos Ot sever =X Link para o comentário https://xtibia.com/forum/topic/97932-npc-que-envia-broadcast-msg/#findComment-675092 Compartilhar em outros sites More sharing options...
Posts Recomendados