SetPlayerVoiceBroadcastTo: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{Server function}} __NOTOC__ This function allows you to change the who a can hear the voice of a player ==Syntax== <syntaxhighlight lang="lua"> bool setPlayerVoiceBroadcastTo ( element th...") |
m (→See Also) |
||
(16 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
{{Server function}} | {{Server function}} | ||
__NOTOC__ | __NOTOC__ | ||
This function allows you to change | |||
This function allows you to change who can hear the voice of a player. | |||
{{Important Note|This function should only be used as a low-level function for advanced users. For typical Voice scripting, please see the [[Resource:Voice|Voice Resource]]}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool setPlayerVoiceBroadcastTo ( element thePlayer, mixed broadcastTo | bool setPlayerVoiceBroadcastTo ( element thePlayer, mixed broadcastTo ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[player]]:setVoiceBroadcastTo|voiceBroadcastTo|}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePlayer:''' The [[player]] you wish to change | *'''thePlayer:''' The [[player]] you wish to change | ||
*'''broadcastTo :''' Element or table of elements who should hear the voice from this player | *'''broadcastTo :''' Element or table of elements who should hear the voice from this player | ||
===Returns=== | ===Returns=== | ||
Line 22: | Line 21: | ||
<section name="Server" class="server" show="true"> | <section name="Server" class="server" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function getPlayer( ... ) | |||
if ( ... ) then | |||
local elements = {}; | |||
for _, string in ipairs( { ... } ) do | |||
for _, element in ipairs( getElementsByType( 'player' ) ) do | |||
if ( string.find( string:lower(), getPlayerName(element):lower(), 1, true ) ) then | |||
table.insert( elements, element ); | |||
end | |||
end | |||
end | |||
return elements; | |||
end | |||
return false | |||
end | |||
addCommandHandler( 'broadcast', | |||
function( player, command, target, target_ ) | |||
if ( target and target_ ) then | |||
target, target_ = getPlayer( target, target_ ); | |||
if ( target and target_ ) then | |||
setPlayerVoiceBroadcastTo( target, target_ ); | |||
else | |||
outputChatBox( not target and "Target 1 not found!" or not target_ and "Target 2 not found!", root, 255, 0, 0, false ); | |||
end | |||
end | |||
end | |||
) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
==See Also== | ==See Also== | ||
{{ | {{Player functions|server}} |
Latest revision as of 22:44, 6 September 2024
This function allows you to change who can hear the voice of a player.
Important Note: This function should only be used as a low-level function for advanced users. For typical Voice scripting, please see the Voice Resource |
Syntax
bool setPlayerVoiceBroadcastTo ( element thePlayer, mixed broadcastTo )
OOP Syntax Help! I don't understand this!
- Method: player:setVoiceBroadcastTo(...)
- Variable: .voiceBroadcastTo
Required Arguments
- thePlayer: The player you wish to change
- broadcastTo : Element or table of elements who should hear the voice from this player
Returns
Returns true if the value was set successfully, false otherwise.
Example
Click to collapse [-]
Serverfunction getPlayer( ... ) if ( ... ) then local elements = {}; for _, string in ipairs( { ... } ) do for _, element in ipairs( getElementsByType( 'player' ) ) do if ( string.find( string:lower(), getPlayerName(element):lower(), 1, true ) ) then table.insert( elements, element ); end end end return elements; end return false end addCommandHandler( 'broadcast', function( player, command, target, target_ ) if ( target and target_ ) then target, target_ = getPlayer( target, target_ ); if ( target and target_ ) then setPlayerVoiceBroadcastTo( target, target_ ); else outputChatBox( not target and "Target 1 not found!" or not target_ and "Target 2 not found!", root, 255, 0, 0, false ); end end end )
See Also
- getAlivePlayers
- getDeadPlayers
- getPlayerACInfo
- getPlayerAnnounceValue
- getPlayerCount
- getPlayerIdleTime
- getPlayerIP
- getPlayerVersion
- getRandomPlayer
- isPlayerMuted
- redirectPlayer
- resendPlayerACInfo
- resendPlayerModInfo
- setPlayerAnnounceValue
- setPlayerMuted
- setPlayerScriptDebugLevel
- setPlayerTeam
- setPlayerVoiceBroadcastTo
- setPlayerVoiceIgnoreFrom
- setPlayerWantedLevel
- spawnPlayer
- takePlayerScreenShot
- Shared
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState