Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 05-01-2009, 06:16 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Chompy View Post
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.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:08 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.