Jump to content

I want clarification


Recommended Posts

Hi guys , I want clarification about this script , and why doesn't work 

P.S : should i add rights in ACpanel or something ? 

Client side :


addEvent("speak", true);
addEventHandler("speak", root, function(text, lang)
	if(type(text) == "string" and type(lang) == "string") then
		return playSound("http://translate.google.com/translate_tts?tl="..lang.."&q="..text, false) ~= false;
	end
	return false;
end)

--//
--|| Syntax: bool speak(string text, string lang)
--||
--|| Required Arguments:
--||  - text: Limited to 100 chars.
--||  - lang: Language code E.g. "en", "de", ... (Note: not every language is supported.)
--||
--|| Returns:
--||  - Returns a sound element if the sound gets played, false if invalid arguments were specified.
--\\
function speak(text, lang)
	if(text and type(text) == "string" and type(lang) == "string") then
		local cancelled = triggerEvent("onClientSpeech", root, text, lang);
		if(not cancelled) then
			return playSound("http://translate.google.com/translate_tts?tl="..lang.."&q="..text, false);
		end
	end
	return false;
end

--//
--|| Syntax: bool speak3D(string text, string lang, float x, float y, float z)
--||
--|| Required Arguments:
--||  - text: Limited to 100 chars.
--||  - lang: Language code E.g. "en", "de", ... (Note: not every language is supported.)
--||  - x:
--||  - y:
--||  - z:
--||
--|| Returns:
--||  - Returns a 3D sound element if the sound gets played, false if invalid arguments were specified.
--\\
function speak3D(text, lang, x, y, z)
	if((text and type(text) == "string") and (lang and type(lang) == "string") and (x and type(x) == "number")  and (y and type(y) == "number")  and (z and type(z) == "number")) then
		local cancelled = triggerEvent("onClientSpeech", root, text, lang);
		if(not cancelled) then
			return playSound3D("http://translate.google.com/translate_tts?tl="..lang.."&q="..text, x, y, z, false);
		end
	end
	return false;
end

 

Server Side : 


function speak(text, lang, triggerFor)
	if(text and type(text) == "string" and type(lang) == "string") then
		if(triggerFor == nil) then 
			triggerFor = root
		end
		if(isElement(triggerFor) and getElementType(triggerFor) == "player" or getElementType(triggerFor) == "root") then
			local cancelled = triggerEvent("onSpeech", triggerFor, text, lang);
			if(not cancelled) then
				return triggerClientEvent(triggerFor, "speak", resourceRoot, text, lang);
			end
		end
	end
	return false;
end

Thank you guys 

Link to comment

Okay, after researching (just one Google search lol) I found a way to overcome this - add &client=mtasa (or whatever, as long as there is &client=) and it'll let you use it, but your IP (or rather, the IP of the client which plays the sound) might be temporarily blocked if you abuse the service (or overuse it in a short period of time)

That is, the URL should look something like this: https://translate.google.com/translate_tts?ie=UTF-8&q=MESSAGE+TO+SPEAK&tl=LANG&client=mtasa

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...