SetPlayerVoiceBroadcastTo: Difference between revisions
Jump to navigation
Jump to search
| Line 20: | Line 20: | ||
<section name="Server" class="server" show="true"> | <section name="Server" class="server" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | function getPlayerFromName(...) | ||
if( ... ) then | |||
local foundList = {} | |||
for i,v in ipairs( ... ) do | |||
for i,p in ipairs( getElementsByType 'player' ) do | |||
if( string.find( getPlayerName(p):lower(), tostring(v):lower(), 1, true ) then | |||
table.insert( foundList, p ) | |||
end | |||
end | |||
end | |||
return unpack( foundList ) | |||
end | |||
return false | |||
end | end | ||
function | function setBroadcastTo( p, cmd, p1, p2 ) | ||
if( p1 and p2 ) then | |||
p1, p2 = getPlayerFromName( p1, p2 ) | |||
if | if( p1 and p2 ) then | ||
setPlayerVoiceBroadcastTo ( | setPlayerVoiceBroadcastTo( p1, p2 ) | ||
else | else | ||
outputChatBox( | outputChatBox( p1 == false and 'Player to change broadcast could not be found!' or p2 == false and 'Players to hear player 1 could not be found!', p, 255, 0, 0, false ) | ||
end | end | ||
end | end | ||
addCommandHandler( | addCommandHandler( 'bt', setBroadcastTo ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Revision as of 13:05, 8 September 2012
Note: This function should only be used as a low-level function for advanced users. For typical Voice scripting, please see the Voice Resource
This function allows you to change who can hear the voice of a player.
Syntax
bool setPlayerVoiceBroadcastTo ( element thePlayer, mixed broadcastTo )
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 getPlayerFromName(...)
if( ... ) then
local foundList = {}
for i,v in ipairs( ... ) do
for i,p in ipairs( getElementsByType 'player' ) do
if( string.find( getPlayerName(p):lower(), tostring(v):lower(), 1, true ) then
table.insert( foundList, p )
end
end
end
return unpack( foundList )
end
return false
end
function setBroadcastTo( p, cmd, p1, p2 )
if( p1 and p2 ) then
p1, p2 = getPlayerFromName( p1, p2 )
if( p1 and p2 ) then
setPlayerVoiceBroadcastTo( p1, p2 )
else
outputChatBox( p1 == false and 'Player to change broadcast could not be found!' or p2 == false and 'Players to hear player 1 could not be found!', p, 255, 0, 0, false )
end
end
addCommandHandler( 'bt', setBroadcastTo )
See Also
- 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