Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Need help with this script (https://forums.graalonline.com/forums/showthread.php?t=134259315)

Kamakaze 05-26-2010 04:48 AM

Need help with this script
 
I am placing this script on a door.. This door has many functions as in allowing everyone to pass, allowing certain accounts or disallowing all accounts.
For some reason the /allowall and /disallowall commands will not work, they do not work after said, can someone help me with this script,
Thanks :),
Joker

NPC Code:

const ALLOWALL = 0;
const ALLOWLIST = 1;
function onCreated(){
this.allowed = {"ACCT1","ACCT2","ACCT3"};
this.admins = {"ACCT1","ACCT2"};
this.cur_mode = ALLOWLIST;
show();
}

function onPlayerTouchsMe(){
if(this.cur_mode == ALLOWALL || (this.cur_mode == ALLOWLIST && player.account in this.allowed))
{
hide();
sleep(2);
show();
}
}

function onPlayerChats(){
if(player.account in this.admins)
{
if(player.chat == "/allowall")
this.mode = ALLOWALL;
else if (player.chat == "/disallowall")
this.mode = ALLOWLIST;
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!";
}
}
}


Deas_Voice 05-26-2010 11:38 AM

you are using different flag to set the mode in the PlayerChats function, i think.

TSAdmin 05-26-2010 11:46 AM

Looks to me you're setting this.mode when you're meant to set this.cur_mode perhaps, as Deas said.

xAndrewx 05-26-2010 08:25 PM

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...)

DrakilorP2P 05-26-2010 09:40 PM

Quote:

Originally Posted by xAndrewx (Post 1578801)
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.

fowlplay4 05-26-2010 09:52 PM

Since the script is server-side, and are using the hide/show method for the door it's still potentially allowing people (sneaking in behind someone who can) who aren't allowed in.

xAndrewx 05-26-2010 09:58 PM

Quote:

Originally Posted by DrakilorP2P (Post 1578810)
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.

Not really- this.d_open (door open...) lol

Fulg0reSama 05-27-2010 12:45 AM

Quote:

Originally Posted by fowlplay4 (Post 1578812)
Since the script is server-side, and are using the hide/show method for the door it's still potentially allowing people (sneaking in behind someone who can) who aren't allowed in.

Could easily make a level script to make it connect to the list perhaps and whoever isn't allowed will be sent outside the level or perhaps jail even?


All times are GMT +2. The time now is 12:52 AM.

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