View Single Post
  #5  
Old 05-26-2010, 09:40 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Quote:
Originally Posted by xAndrewx View Post
why are you using const flags? lol

HTML Code:
function onCreated(){
  this.allowed = {"ACCT1", "ACCT2", "ACCT3"};
  this.admins = {"ACCT1", "ACCT2"};
  
  this.d_open = true;
  this.show();
}

function onPlayerTouchsMe(){
  if(this.d_open == true || (this.d_open == null && player.account in this.allowed)) {
    this.hide();
    setTimer(2);
  }
}
  //For some reason, the timeout is less laggy (clientside, ever so slightly, thought I'd add it)
function onTimeout() {
  this.show();
}

function onPlayerChats(){
  if(!(player.account in this.admins)) return;

  if(player.chat == "/allowall") this.d_open = true;
  else if (player.chat == "/disallowall") this.d_open = false;
  else if(player.chat.starts("/allow")) {
      temp.act = player.chat.substring(7);
      this.allowed.add(temp.act);
      player.chat = temp.act SPC "is now allowed through!";
  }
}
(don't need a const...)
Maybe in the future he'll need to add mode = BANALL?
And I think it's easier to read it with several named constants instead of one vaguely named boolean.
Reply With Quote