You can use ChatBar.onAction to prevent the player from chatting at all. I've re-factored your code:
PHP Code:
function onCreated() {
// Disable Muting
muteOff();
}
// Turns Mute Off
function muteOff() {
this.attr[2] = 0;
}
// Turns Mute On
function muteOn() {
this.attr[2] = 1;
for (temp.pl: players) {
temp.pl.chat = "...";
}
}
function isMuted() {
// Check if they're in a guild that can talk.
if (player.guild in {"Judge", "Preformer"}) {
// Return false to indicate they aren't muted.
return false;
} else {
// If attr[2] is equal to 1, the level is currently muted.
return (this.attr[2] == 1);
}
}
// Silence people entering the level.
function onPlayerEnters() {
if (this.attr[2] == 1) {
player.chat = " ";
}
}
// Your original code moved to the server-side
// Restyled to my liking.
function onPlayerChats() {
if (player.guild == "Judge") {
if (player.chat == ":muteon") {
muteOn();
player.chat = "Level-Mute Enabled";
}
else if ( player.chat == ":muteoff" ) {
muteOff();
player.chat = "Level-Mute Disabled";
}
}
else if (isMuted()) {
player.chat = "...";
}
}
//#CLIENTSIDE
// This is called when the ChatBar's text is submitted.
// Called before onPlayerChats, so you can completely silence them before they chat.
// Compared to the server-side where you might see a flicker of chat.
function ChatBar.onAction() {
// Check if muted.
if (isMuted()) {
// Clear ChatBar text if they're muted.
ChatBar.text = "";
}
}
function isMuted() {
// Check if they're in a guild that can talk.
if (player.guild in {"Judge", "Preformer"}) {
// Return false to indicate they aren't muted.
return false;
} else {
// If attr[2] is equal to 1, the level is currently muted.
return (this.attr[2] == 1);
}
}