IsVoiceEnabled: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Needs Example)
(added example)
Line 1: Line 1:
{{Server function}}
{{Server function}}
__NOTOC__  
__NOTOC__  
{{Needs Example}}
This function allows you to make the server reveal whether or not voice is currently enabled.
This function allows you to make the server reveal whether or not voice is currently enabled.


Line 16: Line 15:
<section name="Server" class="server" show="true">
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--TODO
-- only if voice enabled
if isVoiceEnabled() then
    -- adding handler for voice start event
    addEventHandler( 'onPlayerVoiceStart', root,
        function()
            -- if player is muted in chat
            -- do not broadcast his voice to other players
            if isPlayerMuted(source) then cancelEvent() end
        end
    )
end
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Revision as of 18:13, 19 November 2011

This function allows you to make the server reveal whether or not voice is currently enabled.

Syntax

bool isVoiceEnabled ()

Returns

Returns true if the voice is enabled on the server, false otherwise.

Example

Click to collapse [-]
Server
-- only if voice enabled
if isVoiceEnabled() then
    -- adding handler for voice start event
    addEventHandler( 'onPlayerVoiceStart', root,
        function()
            -- if player is muted in chat
            -- do not broadcast his voice to other players
            if isPlayerMuted(source) then cancelEvent() end
        end
    )
end

See Also