Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-26-2010, 04:48 AM
Kamakaze Kamakaze is offline
UN Levels Team Admin
Kamakaze's Avatar
Join Date: Sep 2008
Location: Virginia
Posts: 37
Kamakaze is on a distinguished road
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!";
}
}
}

Reply With Quote
  #2  
Old 05-26-2010, 11:38 AM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
you are using different flag to set the mode in the PlayerChats function, i think.
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #3  
Old 05-26-2010, 11:46 AM
TSAdmin TSAdmin is offline
Forum Moderator
TSAdmin's Avatar
Join Date: Aug 2006
Location: Australia
Posts: 1,980
TSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud of
Looks to me you're setting this.mode when you're meant to set this.cur_mode perhaps, as Deas said.
__________________
TSAdmin (Forum Moderator)
Welcome to the Official GraalOnline Forums! Where sharing an opinion may be seen as a declaration of war!
------------------------
· User Agreement · Code of Conduct · Forum Rules ·
· Graal Support · Administrative Contacts ·
Reply With Quote
  #4  
Old 05-26-2010, 08:25 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
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...)
__________________
Reply With Quote
  #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
  #6  
Old 05-26-2010, 09:52 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #7  
Old 05-26-2010, 09:58 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by DrakilorP2P View Post
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
__________________
Reply With Quote
  #8  
Old 05-27-2010, 12:45 AM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
Quote:
Originally Posted by fowlplay4 View Post
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?
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
Reply


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:52 PM.


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