2022-07-28 17:28:11 +00:00
--@name DECTalk
--@author Minori
--@include https://gist.githubusercontent.com/sr229/5e6f3a5b03181704a871207c14706499/raw/2ee5b6cfb3a875a5ad2024a38d0131cfb5278785/url-encode.lua as henke.txt
2022-11-25 17:11:36 +00:00
--@shared
2022-07-28 17:28:11 +00:00
local soundref
require ( " henke.txt " )
2022-11-25 17:11:36 +00:00
if SERVER then
-- haaugh
chip ( ) : setNoDraw ( true )
hook.add ( " PlayerSay " , " tts_msg " , function ( ply , txt )
-- instead of limiting to owner()
-- we do a little trolling and give it to everyone
if ply and string.sub ( txt , 1 , 1 ) == " ; " then
-- broadcast who sent it
net.start ( " aeiou " )
-- send user ID (32-bit)
net.writeInt ( ply : getUserID ( ) , 32 )
-- send user msg (string)
net.writeString ( string.sub ( txt , 2 ) )
net.send ( )
-- do not broadcast original msg to client
-- BUG: only works for owner()
--return ""
end
end )
end
if CLIENT then
if not hasPermission ( " bass.loadURL " , " https://tts.cyzon.us/tts " ) then return end
print ( " DECTalk loaded on client. Type ;<text> to use it. " )
2022-07-28 17:28:11 +00:00
2022-11-25 17:11:36 +00:00
net.receive ( " aeiou " , function ( )
local plyAuthor = player ( net.readInt ( 32 ) )
local msg = net.readString ( )
2022-07-28 17:28:11 +00:00
2022-11-25 17:11:36 +00:00
bass.loadURL ( " https://tts.cyzon.us/tts?text= " .. urlencode ( msg ) , " 3d " , function ( a , e , n )
if soundref then
soundref : destroy ( )
end
2022-07-28 17:28:11 +00:00
2022-11-25 17:11:36 +00:00
soundref = a
2022-07-28 17:28:11 +00:00
2022-11-25 17:11:36 +00:00
hook.add ( " Think " , " followSound " , function ( )
soundref : setPos ( plyAuthor : getPos ( ) )
end )
2022-07-28 17:28:11 +00:00
2022-11-25 17:11:36 +00:00
soundref : setVolume ( 1.3 )
soundref : play ( )
end )
2022-07-28 17:28:11 +00:00
end )
2022-11-25 17:11:36 +00:00
end