EW1611 Posted August 2, 2019 Posted August 2, 2019 eu estou querendo fazer um sistema de anuncios, como se aparecesse algo na tela, e com um voz narrando, como se fosse uma noticia de um jornal d tv, e qria saber quais funções eu deveria usar para dar play no audio e colocar o texto na tela, e qria q fossem textos e audios pré definidos. gostaria de saber apenas quais funções devo usar
Other Languages Moderators androksi Posted August 2, 2019 Other Languages Moderators Posted August 2, 2019 (edited) -- client-side local canvas = Vector2(guiGetScreenSize()) local ads = { -- ['Tipo'] = {caminho do arquivo de voz, texto} ['Welcome'] = {'sounds/voice1.mp3', 'Seja bem-vindo(a) ao servidor.'}, } local messageType local voiceElement local startTick addEvent('tts:play()', true) addEventHandler('tts:play()', root, function(type) if ads[type] then if not voiceElement then local voice = fileExists(ads[type][1]) and ads[type][1] or 'https://translate.google.com/translate_tts?ie=UTF-8&tl=pt-BR&client=tw-ob&q='..string.gsub(ads[type][2], ' ', '+') messageType = ads[type][2] startTick = {getTickCount(), 8} voiceElement = playSound(voice, false) addEventHandler('onClientRender', root, draw) end else if _debug then outputDebugString('Não foi possível reproduzir o som.') end end end) function draw() if messageType ~= nil then dxDrawText(messageType, 0, 0, canvas.x, canvas.y, 0xffffffff, 1.20, 'default-bold', 'center', 'center') if startTick[1] + (startTick[2] * 1000) < getTickCount() then messageType = nil startTick = nil voiceElement = nil removeEventHandler('onClientRender', root, draw) end end end -- server-side (apenas uma base de como você chamaria o evento) triggerClientEvent(player, 'tts:play()', player, 'Welcome') Fiz esse script sem testar, deve funcionar se você usar corretamente. Se o sistema não encontrar o arquivo de som, ele irá executar a voz do Google Tradutor. Edited August 2, 2019 by Lord Henry 1
Other Languages Moderators Lord Henry Posted August 2, 2019 Other Languages Moderators Posted August 2, 2019 @asrzkj na sua linha 14, era pra ser um addEventHandler.
Other Languages Moderators androksi Posted August 2, 2019 Other Languages Moderators Posted August 2, 2019 Percebi isso agora, Lord. Obrigado! (edite para mim se possível, eu não tenho a função de editar nessa thread)
Other Languages Moderators Lord Henry Posted August 2, 2019 Other Languages Moderators Posted August 2, 2019 Corrigido. 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now