我正在尝试制作一个不让玩家说话的静音脚本。目前我正在告诉脚本中的哪个玩家没有命令,但我无法解决或者找不到如何运行我在特定播放器上创建的这个功能,而不仅仅是将整个服务器静音。
sv_mute.lua:
util.AddNetworkString( "mute_message" )
ismuted == false
targetPlayer == "Xx_Player_xX"
function checkmute()
function SendMessage( ply, txt, pub )
net.Start( "mute_message" )
net.WriteString( "YOU ARE MUTED, SHUT UP" )
net.Send( ply )
return ""
end
hook.Add( "PlayerSay", "SendMessage", SendMessage, )
end
Player:checkmute(()targetPlayer)
cl_mute.lua:
function ReceiveMessage()
local txt = net.ReadString()
chat.AddText( Color( 0, 255, 0), txt)
end
我到目前为止使用Player:checkmute(()targetPlayer)但我认为这是错误的
答案 0 :(得分:0)
首先,我在第一眼看到的一些错误。
GM:PlayerSay( Player sender, string text, boolean teamChat )
Player:PrintMessage( number type, string message )
-- sv_mute.lua
-- a list of muted players, you need to get them from somewhere (not part of this answer)
mutedPlayers = {
"StupidMan" = true,
"AnnoyingKid" = true,
"ExGirlfriend" = true
}
-- the function that will check if a user is muted
local function checkMuted(--[[ string ]] playername)
return mutedPlayers[playername]
-- you probably need to change the code to something else
-- based on how you store your muted players
end
hook.Add("PlayerSay", "VosemMute_PlayerSay", function(sender, message, teamChat)
if ( checkMuted(sender:GetName()) ) then
sender.PrintMessage(HUD_PRINTTALK, "You are muted!")
return "" -- this will suppress the message
end
end)
HUD_PRINTTALK
) Player:GetName()
hook.Add( string eventName, any identifier, function func )
这段代码完全没有经过测试,并且是我的想法。如果这不起作用并抛出一些错误让我知道。我会纠正它。