IsVoiceEnabled: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (+ description to example)
m (removed `section` tag around example)
Line 14: Line 14:
==Example==  
==Example==  
This example shows how to forbid use voice for muted (in chat) players
This example shows how to forbid use voice for muted (in chat) players
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- only if voice enabled
-- only if voice enabled
Line 28: Line 27:
end
end
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Player_functions}}
{{Player_functions}}

Revision as of 18:24, 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

This example shows how to forbid use voice for muted (in chat) players

-- 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