SetPlayerMuted: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ {{Server function}} Use this function to mute or unmute the player. ==Syntax== <syntaxhighlight lang="lua">bool setPlayerMuted ( player thePlayer, bool state )</syntaxhighlight> ===Required Arguments===...) |
m (→See Also) |
||
(7 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
Use this function to mute or unmute the player. | Use this function to mute or unmute the player. Muted player won't be able to say anything in chat. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool setPlayerMuted ( player thePlayer, bool state )</syntaxhighlight> | <syntaxhighlight lang="lua">bool setPlayerMuted ( player thePlayer, bool state )</syntaxhighlight> | ||
{{OOP||[[player]]:setMuted|muted|isPlayerMuted}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePlayer:''' The [[player]] you are muting or unmuting. | *'''thePlayer:''' The [[player]] you are muting or unmuting. | ||
Line 14: | Line 14: | ||
==Example== | ==Example== | ||
This adds a /mute command that can be used to mute a player. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- create the function | |||
if ( not isPlayerMuted ( | function mutePlayer(player,command,victimName) | ||
-- if the player has specified a victim name to mute | |||
if victimName then | |||
-- get the victim player element from their name | |||
local victim = getPlayerFromName(victimName) | |||
-- if the player exists | |||
if victim then | |||
-- if they arent already muted | |||
if ( not isPlayerMuted(victim) ) then | |||
-- mute them and output a message to the chat | |||
setPlayerMuted(victim, true) | |||
outputChatBox("You have been muted.",victim) | |||
end | |||
else | |||
outputChatBox("Could not find player with name: "..tostring(victimName),player) | |||
end | |||
else | |||
outputChatBox("Usage: /mute <player name>",player) | |||
end | |||
end | end | ||
-- add the /mute command | |||
addCommandHandler("mute",mutePlayer) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions|server}} |
Latest revision as of 22:43, 6 September 2024
Use this function to mute or unmute the player. Muted player won't be able to say anything in chat.
Syntax
bool setPlayerMuted ( player thePlayer, bool state )
OOP Syntax Help! I don't understand this!
- Method: player:setMuted(...)
- Variable: .muted
- Counterpart: isPlayerMuted
Required Arguments
- thePlayer: The player you are muting or unmuting.
- state: Use true to mute and false to unmute the player.
Returns
Returns true if the player was successfully muted or unmuted, false otherwise.
Example
This adds a /mute command that can be used to mute a player.
-- create the function function mutePlayer(player,command,victimName) -- if the player has specified a victim name to mute if victimName then -- get the victim player element from their name local victim = getPlayerFromName(victimName) -- if the player exists if victim then -- if they arent already muted if ( not isPlayerMuted(victim) ) then -- mute them and output a message to the chat setPlayerMuted(victim, true) outputChatBox("You have been muted.",victim) end else outputChatBox("Could not find player with name: "..tostring(victimName),player) end else outputChatBox("Usage: /mute <player name>",player) end end -- add the /mute command addCommandHandler("mute",mutePlayer)
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