Quote:
Originally Posted by Chompy
Quite neat I must say.
I did a little edit to remove that timeout
PHP Code:
//#CLIENTSIDE
function onPlayerChats() {
switch (player.chat) {
case "filteron":
client.swearfilter = true;
player.chat = "Swear filter is now on!";
break;
case "filteroff":
client.swearfilter = false;
player.chat = "Swear filter is now off.";
break;
}
}
|
There is no need to use a switch() in this case and it's bad habit to do so. Not sure about how many other languages this applies to, but with Java you can't compare strings using switch(), so you wouldn't be able to apply the same method in Java. There are only select instances where it would actually make sense to use switch() instead of if-then-else, and this isn't one of them.
Also, it would benefit you to get into the habit of doing client.whatever = !client.whatever since it would save you an unnecessary clutter when doing something like this.