<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Joaosilva099</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Joaosilva099"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Joaosilva099"/>
	<updated>2026-04-30T22:24:16Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DbPoll&amp;diff=49723</id>
		<title>DbPoll</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DbPoll&amp;diff=49723"/>
		<updated>2016-10-29T22:09:33Z</updated>

		<summary type="html">&lt;p&gt;Joaosilva099: affected rows and last insert id are also returned when using multiple statements&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function checks the progress of a database query.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table dbPoll ( handle queryHandle, int timeout[, bool multipleResults = false ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||queryHandle:poll}}&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''queryHandle:''' A query handle previously returned from [[dbQuery]]&lt;br /&gt;
*'''timeout:''' How many milliseconds to wait for a result. Use 0 for an instant response (which may return nil). Use -1 to wait until a result is ready. Note: A wait here will freeze the entire server just like the executeSQL* functions&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
{{New items|3.0160|1.5.2|&lt;br /&gt;
*'''multipleResults:''' Set to true to enable the return values from multiple statements&lt;br /&gt;
|7972}}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
*''nil:'' Returns nil if the query results are not yet ready. You should try again in a little while. (If you give up waiting for a result, be sure to call [[dbFree]])&lt;br /&gt;
*''false:'' Returns false if the query string contained an error, the connection has been lost or the query handle is incorrect. This automatically frees the query handle, so you do not have to call [[dbFree]].&lt;br /&gt;
** This also returns two extra values: (See the example on how the retrieve them)&lt;br /&gt;
***''int:'' error code&lt;br /&gt;
***''string'' error message&lt;br /&gt;
*''table:'' Returns a table when the query has successfully completed. This automatically frees the query handle, so you do not have to call [[dbFree]].&lt;br /&gt;
** This also returns extra values:&lt;br /&gt;
***''int:'' number of affected rows&lt;br /&gt;
***''int:'' last insert id&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example waits until a result is ready:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local result = dbPoll ( qh, -1 )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example shows the possible return values:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local result, num_affected_rows, last_insert_id = dbPoll ( qh, -1 )&lt;br /&gt;
&lt;br /&gt;
if result == nil then&lt;br /&gt;
    outputConsole( &amp;quot;dbPoll result not ready yet&amp;quot; )&lt;br /&gt;
elseif result == false then&lt;br /&gt;
    local error_code,error_msg = num_affected_rows,last_insert_id&lt;br /&gt;
    outputConsole( &amp;quot;dbPoll failed. Error code: &amp;quot; .. tostring(error_code) .. &amp;quot;  Error message: &amp;quot; .. tostring(error_msg) )&lt;br /&gt;
else&lt;br /&gt;
    outputConsole( &amp;quot;dbPoll succeeded. Number of affected rows: &amp;quot; .. tostring(num_affected_rows) .. &amp;quot;  Last insert id: &amp;quot; .. tostring(last_insert_id) )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example shows how to handle the result if the query selected data:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local result = dbPoll ( qh, -1 )&lt;br /&gt;
&lt;br /&gt;
if result then&lt;br /&gt;
    for _, row in ipairs ( result ) do&lt;br /&gt;
&lt;br /&gt;
        -- by using a second loop (use it if you want to get the values of all columns the query selected):&lt;br /&gt;
        for column, value in pairs ( row ) do&lt;br /&gt;
            -- column = the mysql column of the table in the query&lt;br /&gt;
            -- value = the value of that column in this certain row&lt;br /&gt;
        end&lt;br /&gt;
		&lt;br /&gt;
        -- or without a second loop (use it if you want to handle every value in a special way):&lt;br /&gt;
        outputChatBox ( row[&amp;quot;column&amp;quot;] ) -- it will output the value of the column &amp;quot;column&amp;quot; in this certain row&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{New items|3.0153|1.5.2|&lt;br /&gt;
This example shows how to handle the result of a multiple statement query: (See [[dbConnect]] option '''multi_statements''')&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local multiResults = dbPoll ( qh, -1, true )&lt;br /&gt;
&lt;br /&gt;
if multiResults then&lt;br /&gt;
    for sidx, statementResult in ipairs ( multiResults ) do&lt;br /&gt;
        local resultRows, numAffectedRows, lastInsertId = unpack(statementResult)&lt;br /&gt;
        for ridx, row in ipairs ( resultRows ) do&lt;br /&gt;
            for column, value in pairs ( row ) do&lt;br /&gt;
                outputDebugString( &amp;quot;&amp;quot;&lt;br /&gt;
                        .. &amp;quot; statement#&amp;quot; .. sidx&lt;br /&gt;
                        .. &amp;quot; row#&amp;quot; .. ridx&lt;br /&gt;
                        .. &amp;quot; column:&amp;quot; .. tostring(column)&lt;br /&gt;
                        .. &amp;quot; value:&amp;quot; .. tostring(value)&lt;br /&gt;
                        )&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|7972}}&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
{{Requirements|1.1.1-9.03328|n/a}}&lt;br /&gt;
&lt;br /&gt;
==Changelog==&lt;br /&gt;
{{ChangelogHeader}}&lt;br /&gt;
{{ChangelogItem|1.3.4-9.05862|Added 'last insert id' return value}}&lt;br /&gt;
{{ChangelogItem|1.5.2-9.07972|Added 'multipleResults' argument}}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Registry_functions}}&lt;/div&gt;</summary>
		<author><name>Joaosilva099</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=ConvertTextToSpeech&amp;diff=48897</id>
		<title>ConvertTextToSpeech</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ConvertTextToSpeech&amp;diff=48897"/>
		<updated>2016-08-23T22:52:13Z</updated>

		<summary type="html">&lt;p&gt;Joaosilva099: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&amp;lt;lowercasetitle/&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
'''THIS FUNCTION IS NOT WORKING ANYMORE DUE TO GOOGLE BLOCKING NON-USER CALLS TO THEIR TTS API'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This useful shared function converts some text to audible speech using Google's TTS.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;boolean, element, string convertTextToSpeech ( string text [, table/element broadcastTo = root, string language = &amp;quot;en&amp;quot; ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Required arguments==&lt;br /&gt;
* ''text'': the text to convert to speech.&lt;br /&gt;
&lt;br /&gt;
==Optional arguments==&lt;br /&gt;
* ''broadcastTo'': if it's a regular indexed table, the speech will be broadcasted to the players contained in it. If it's a element, the speech will be heard by the players which are children of that element. This parameter is '''ONLY''' serverside; if you're using this function clientside this will be considered as the ''language'' argument.&lt;br /&gt;
* ''language'': defines the language of the TTS output.&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
* This function returns ''[[nil]]'' and outputs an error if an argument it's not valid.&lt;br /&gt;
* If called serverside and if all arguments are valid, this function returns ''true'' if the client was successully told to play the TTS (althrough this doesn't mean that the client will always play the speech); ''false'' otherwise.&lt;br /&gt;
* If called clientside and if all arguments are valid, this function returns ''true'', the corresponding [[sound]] element and its URL if the sound could theorically be played (althrough it may not play); ''[[nil]]'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Function source==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEvent(&amp;quot;playTTS&amp;quot;, true) -- Add the event&lt;br /&gt;
&lt;br /&gt;
local function playTTS(text, lang)&lt;br /&gt;
    local URL = &amp;quot;http://translate.google.com/translate_tts?tl=&amp;quot; .. lang .. &amp;quot;&amp;amp;q=&amp;quot; .. text&lt;br /&gt;
    -- Play the TTS. BASS returns the sound element even if it can not be played.&lt;br /&gt;
    return true, playSound(URL), URL&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;playTTS&amp;quot;, root, playTTS)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Shared (server and client)&amp;quot; class=&amp;quot;both&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function convertTextToSpeech(text, broadcastTo, lang)&lt;br /&gt;
    -- Ensure first argument is valid&lt;br /&gt;
    assert(type(text) == &amp;quot;string&amp;quot;, &amp;quot;Bad argument 1 @ convertTextToSpeech [ string expected, got &amp;quot; .. type(text) .. &amp;quot;]&amp;quot;)&lt;br /&gt;
    assert(#text &amp;lt;= 100, &amp;quot;Bad argument 1 @ convertTextToSpeech [ too long string; 100 characters maximum ]&amp;quot;)&lt;br /&gt;
    if triggerClientEvent then -- Is this function called serverside?&lt;br /&gt;
        -- Ensure second and third arguments are valid&lt;br /&gt;
        assert(broadcastTo == nil or type(broadcastTo) == &amp;quot;table&amp;quot; or isElement(broadcastTo), &amp;quot;Bad argument 2 @ convertTextToSpeech [ table/element expected, got &amp;quot; .. type(broadcastTo) .. &amp;quot;]&amp;quot;)&lt;br /&gt;
        assert(lang == nil or type(lang) == &amp;quot;string&amp;quot;, &amp;quot;Bad argument 3 @ convertTextToSpeech [ string expected, got &amp;quot; .. type(lang) .. &amp;quot;]&amp;quot;)&lt;br /&gt;
        -- Tell the client to play the speech&lt;br /&gt;
        return triggerClientEvent(broadcastTo or root, &amp;quot;playTTS&amp;quot;, root, text, lang or &amp;quot;en&amp;quot;)&lt;br /&gt;
    else -- This function is executed clientside&lt;br /&gt;
        local lang = broadcastTo&lt;br /&gt;
        -- Ensure second argument is valid&lt;br /&gt;
        assert(lang == nil or type(lang) == &amp;quot;string&amp;quot;, &amp;quot;Bad argument 2 @ convertTextToSpeech [ string expected, got &amp;quot; .. type(lang) .. &amp;quot;]&amp;quot;)&lt;br /&gt;
        return playTTS(text, lang or &amp;quot;en&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
*Original author: ''Has[S]oN''.&lt;br /&gt;
*Skype: ''hassan.saad2000''&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example disables text chat and converts that text to a speech audible to nearby players. '''NOTE''': this example requires 1.4 in order to work.&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local function tellClientsToPlayTTS(text, type)&lt;br /&gt;
    if type == 0 and #text &amp;lt;= 100 then -- We only want to replace normal chat if possible&lt;br /&gt;
        local x, y, z = getElementPosition(source)&lt;br /&gt;
        local col = createColSphere(x, y, z, 30) -- We need this to get nearby players&lt;br /&gt;
        triggerClientEvent(getElementsWithinColShape(col, &amp;quot;player&amp;quot;), &amp;quot;playChatTTS&amp;quot;, source, text) -- Tell the nearby clients to play the sound&lt;br /&gt;
        destroyElement(col)&lt;br /&gt;
        cancelEvent() -- Replace text chat&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerChat&amp;quot;, root, tellClientsToPlayTTS)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEvent(&amp;quot;playChatTTS&amp;quot;, true) -- Add the event&lt;br /&gt;
&lt;br /&gt;
local function playChatTTS(text)&lt;br /&gt;
    local lang = (getLocalization().code):sub(1, 2) -- Output the TTS in the local player language, but don't bother about variants&lt;br /&gt;
    local _, speech, URL = convertTextToSpeech(text, lang)&lt;br /&gt;
    -- Convert that speech to a 3D sound&lt;br /&gt;
    destroyElement(speech)&lt;br /&gt;
    local x, y, z = getElementPosition(source)&lt;br /&gt;
    local speech = playSound3D(URL, x, y, z)&lt;br /&gt;
    attachElements(speech, source) -- Make the sound follow the player&lt;br /&gt;
    setElementDimension(speech, getElementDimension(source))&lt;br /&gt;
    setSoundMinDistance(speech, 15)&lt;br /&gt;
    setSoundMaxDistance(speech, 30)&lt;br /&gt;
    -- Tricky thing ahead: make the player mouth move, but without rendering him unable to move&lt;br /&gt;
    setPedAnimation(source, &amp;quot;ped&amp;quot;, &amp;quot;factalk&amp;quot;, 0, true)&lt;br /&gt;
    setPedAnimation(source, &amp;quot;ped&amp;quot;, &amp;quot;factalk&amp;quot;, 0, true)&lt;br /&gt;
    -- Reset the player mouth after the speech has ended&lt;br /&gt;
    setTimer(function(player)&lt;br /&gt;
        if isElement(player) then&lt;br /&gt;
            setPedAnimation(player) -- Clear the animation&lt;br /&gt;
        end&lt;br /&gt;
    end, math.max(getSoundLength(speech) * 1000, 50), 1, source)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;playChatTTS&amp;quot;, root, playChatTTS)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Joaosilva099</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=ConvertTextToSpeech&amp;diff=48896</id>
		<title>ConvertTextToSpeech</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=ConvertTextToSpeech&amp;diff=48896"/>
		<updated>2016-08-23T22:51:59Z</updated>

		<summary type="html">&lt;p&gt;Joaosilva099: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&amp;lt;lowercasetitle/&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
'''THIS FUNCTION IS NOT WORKING ANYMORE DUE TO GOOGLE BLOCKING NON-USER CALLS TO THEIR TTS API'''&lt;br /&gt;
&lt;br /&gt;
This useful shared function converts some text to audible speech using Google's TTS.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;boolean, element, string convertTextToSpeech ( string text [, table/element broadcastTo = root, string language = &amp;quot;en&amp;quot; ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Required arguments==&lt;br /&gt;
* ''text'': the text to convert to speech.&lt;br /&gt;
&lt;br /&gt;
==Optional arguments==&lt;br /&gt;
* ''broadcastTo'': if it's a regular indexed table, the speech will be broadcasted to the players contained in it. If it's a element, the speech will be heard by the players which are children of that element. This parameter is '''ONLY''' serverside; if you're using this function clientside this will be considered as the ''language'' argument.&lt;br /&gt;
* ''language'': defines the language of the TTS output.&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
* This function returns ''[[nil]]'' and outputs an error if an argument it's not valid.&lt;br /&gt;
* If called serverside and if all arguments are valid, this function returns ''true'' if the client was successully told to play the TTS (althrough this doesn't mean that the client will always play the speech); ''false'' otherwise.&lt;br /&gt;
* If called clientside and if all arguments are valid, this function returns ''true'', the corresponding [[sound]] element and its URL if the sound could theorically be played (althrough it may not play); ''[[nil]]'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Function source==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEvent(&amp;quot;playTTS&amp;quot;, true) -- Add the event&lt;br /&gt;
&lt;br /&gt;
local function playTTS(text, lang)&lt;br /&gt;
    local URL = &amp;quot;http://translate.google.com/translate_tts?tl=&amp;quot; .. lang .. &amp;quot;&amp;amp;q=&amp;quot; .. text&lt;br /&gt;
    -- Play the TTS. BASS returns the sound element even if it can not be played.&lt;br /&gt;
    return true, playSound(URL), URL&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;playTTS&amp;quot;, root, playTTS)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Shared (server and client)&amp;quot; class=&amp;quot;both&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function convertTextToSpeech(text, broadcastTo, lang)&lt;br /&gt;
    -- Ensure first argument is valid&lt;br /&gt;
    assert(type(text) == &amp;quot;string&amp;quot;, &amp;quot;Bad argument 1 @ convertTextToSpeech [ string expected, got &amp;quot; .. type(text) .. &amp;quot;]&amp;quot;)&lt;br /&gt;
    assert(#text &amp;lt;= 100, &amp;quot;Bad argument 1 @ convertTextToSpeech [ too long string; 100 characters maximum ]&amp;quot;)&lt;br /&gt;
    if triggerClientEvent then -- Is this function called serverside?&lt;br /&gt;
        -- Ensure second and third arguments are valid&lt;br /&gt;
        assert(broadcastTo == nil or type(broadcastTo) == &amp;quot;table&amp;quot; or isElement(broadcastTo), &amp;quot;Bad argument 2 @ convertTextToSpeech [ table/element expected, got &amp;quot; .. type(broadcastTo) .. &amp;quot;]&amp;quot;)&lt;br /&gt;
        assert(lang == nil or type(lang) == &amp;quot;string&amp;quot;, &amp;quot;Bad argument 3 @ convertTextToSpeech [ string expected, got &amp;quot; .. type(lang) .. &amp;quot;]&amp;quot;)&lt;br /&gt;
        -- Tell the client to play the speech&lt;br /&gt;
        return triggerClientEvent(broadcastTo or root, &amp;quot;playTTS&amp;quot;, root, text, lang or &amp;quot;en&amp;quot;)&lt;br /&gt;
    else -- This function is executed clientside&lt;br /&gt;
        local lang = broadcastTo&lt;br /&gt;
        -- Ensure second argument is valid&lt;br /&gt;
        assert(lang == nil or type(lang) == &amp;quot;string&amp;quot;, &amp;quot;Bad argument 2 @ convertTextToSpeech [ string expected, got &amp;quot; .. type(lang) .. &amp;quot;]&amp;quot;)&lt;br /&gt;
        return playTTS(text, lang or &amp;quot;en&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
*Original author: ''Has[S]oN''.&lt;br /&gt;
*Skype: ''hassan.saad2000''&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example disables text chat and converts that text to a speech audible to nearby players. '''NOTE''': this example requires 1.4 in order to work.&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local function tellClientsToPlayTTS(text, type)&lt;br /&gt;
    if type == 0 and #text &amp;lt;= 100 then -- We only want to replace normal chat if possible&lt;br /&gt;
        local x, y, z = getElementPosition(source)&lt;br /&gt;
        local col = createColSphere(x, y, z, 30) -- We need this to get nearby players&lt;br /&gt;
        triggerClientEvent(getElementsWithinColShape(col, &amp;quot;player&amp;quot;), &amp;quot;playChatTTS&amp;quot;, source, text) -- Tell the nearby clients to play the sound&lt;br /&gt;
        destroyElement(col)&lt;br /&gt;
        cancelEvent() -- Replace text chat&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerChat&amp;quot;, root, tellClientsToPlayTTS)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEvent(&amp;quot;playChatTTS&amp;quot;, true) -- Add the event&lt;br /&gt;
&lt;br /&gt;
local function playChatTTS(text)&lt;br /&gt;
    local lang = (getLocalization().code):sub(1, 2) -- Output the TTS in the local player language, but don't bother about variants&lt;br /&gt;
    local _, speech, URL = convertTextToSpeech(text, lang)&lt;br /&gt;
    -- Convert that speech to a 3D sound&lt;br /&gt;
    destroyElement(speech)&lt;br /&gt;
    local x, y, z = getElementPosition(source)&lt;br /&gt;
    local speech = playSound3D(URL, x, y, z)&lt;br /&gt;
    attachElements(speech, source) -- Make the sound follow the player&lt;br /&gt;
    setElementDimension(speech, getElementDimension(source))&lt;br /&gt;
    setSoundMinDistance(speech, 15)&lt;br /&gt;
    setSoundMaxDistance(speech, 30)&lt;br /&gt;
    -- Tricky thing ahead: make the player mouth move, but without rendering him unable to move&lt;br /&gt;
    setPedAnimation(source, &amp;quot;ped&amp;quot;, &amp;quot;factalk&amp;quot;, 0, true)&lt;br /&gt;
    setPedAnimation(source, &amp;quot;ped&amp;quot;, &amp;quot;factalk&amp;quot;, 0, true)&lt;br /&gt;
    -- Reset the player mouth after the speech has ended&lt;br /&gt;
    setTimer(function(player)&lt;br /&gt;
        if isElement(player) then&lt;br /&gt;
            setPedAnimation(player) -- Clear the animation&lt;br /&gt;
        end&lt;br /&gt;
    end, math.max(getSoundLength(speech) * 1000, 50), 1, source)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;playChatTTS&amp;quot;, root, playChatTTS)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Useful Functions}}&lt;/div&gt;</summary>
		<author><name>Joaosilva099</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=IsTextInGridList&amp;diff=48086</id>
		<title>IsTextInGridList</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsTextInGridList&amp;diff=48086"/>
		<updated>2016-07-17T03:29:38Z</updated>

		<summary type="html">&lt;p&gt;Joaosilva099: It needs to be -1 ! Check your other function &amp;quot;guiGridListGetRowIndexFromText&amp;quot; you did correctly there&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
&amp;lt;lowercasetitle/&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
As the tile says, this function checks if some text exist or not in the GridList.&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool isTextInGridList (element gridList,string text)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''gridList''': The grid list element.&lt;br /&gt;
* '''text''': The text that you are looking for.&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns true if the text exist in the GridList, false if otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
    function isTextInGridList(gridList, text)&lt;br /&gt;
      for i=0, guiGridListGetRowCount(gridlist)-1 do&lt;br /&gt;
	local t = guiGridListGetItemText(gridlist, i, 1)&lt;br /&gt;
	  if (t) then&lt;br /&gt;
	    if (t == text) then&lt;br /&gt;
	      return true&lt;br /&gt;
		end&lt;br /&gt;
	    end&lt;br /&gt;
	end&lt;br /&gt;
    return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
    addEventHandler(&amp;quot;onClientResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
function ()&lt;br /&gt;
    playerList = guiCreateGridList(0.80, 0.10, 0.15, 0.60, true)&lt;br /&gt;
    local column = guiGridListAddColumn(playerList, &amp;quot;Player&amp;quot;, 0.85)&lt;br /&gt;
    if (column) then&lt;br /&gt;
        for id, players in ipairs(getElementsByType(&amp;quot;player&amp;quot;)) do&lt;br /&gt;
            local row = guiGridListAddRow(playerList)&lt;br /&gt;
            guiGridListSetItemText(playerList, row, column, getPlayerName(players), false, false)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end)&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
function findText(cmd,text)&lt;br /&gt;
  if not tostring(text) then return end &lt;br /&gt;
    if isTextInGridList(playerList, tostring(text)) then&lt;br /&gt;
      outputChatBox(&amp;quot;Text exist!&amp;quot;,0,255,0) &lt;br /&gt;
   end &lt;br /&gt;
end &lt;br /&gt;
addCommandHandler(&amp;quot;check&amp;quot;,findText)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: Walid&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Joaosilva099</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=IsTextInGridList&amp;diff=48082</id>
		<title>IsTextInGridList</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsTextInGridList&amp;diff=48082"/>
		<updated>2016-07-15T23:16:53Z</updated>

		<summary type="html">&lt;p&gt;Joaosilva099: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
&amp;lt;lowercasetitle/&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
As the tile says, this function checks if some text exist or not in the GridList.&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool isTextInGridList (element gridList,string text)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Required arguments===&lt;br /&gt;
* '''gridList''': The grid list element.&lt;br /&gt;
* '''text''': The text that you are looking for.&lt;br /&gt;
&lt;br /&gt;
===Return===&lt;br /&gt;
Returns true if the text exist in the GridList, false if otherwise.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
    function isTextInGridList(gridList, text)&lt;br /&gt;
      for i=0, guiGridListGetRowCount(gridlist)-1 do --We need to remove 1 from the total row count because rows starts at 0 and not 1&lt;br /&gt;
	local t = guiGridListGetItemText(gridlist, i, 1)&lt;br /&gt;
	  if (t) then&lt;br /&gt;
	    if (t == text) then&lt;br /&gt;
	      return true&lt;br /&gt;
		end&lt;br /&gt;
	    end&lt;br /&gt;
	end&lt;br /&gt;
    return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
    addEventHandler(&amp;quot;onClientResourceStart&amp;quot;, resourceRoot,&lt;br /&gt;
function ()&lt;br /&gt;
    playerList = guiCreateGridList(0.80, 0.10, 0.15, 0.60, true)&lt;br /&gt;
    local column = guiGridListAddColumn(playerList, &amp;quot;Player&amp;quot;, 0.85)&lt;br /&gt;
    if (column) then&lt;br /&gt;
        for id, players in ipairs(getElementsByType(&amp;quot;player&amp;quot;)) do&lt;br /&gt;
            local row = guiGridListAddRow(playerList)&lt;br /&gt;
            guiGridListSetItemText(playerList, row, column, getPlayerName(players), false, false)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end)&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
function findText(cmd,text)&lt;br /&gt;
  if not tostring(text) then return end &lt;br /&gt;
    if isTextInGridList(playerList, tostring(text)) then&lt;br /&gt;
      outputChatBox(&amp;quot;Text exist!&amp;quot;,0,255,0) &lt;br /&gt;
   end &lt;br /&gt;
end &lt;br /&gt;
addCommandHandler(&amp;quot;check&amp;quot;,findText)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: Walid&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Joaosilva099</name></author>
	</entry>
</feed>