Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-27-2011, 10:16 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Simple level restriction

Heya, i was wondering if you guys could help me with this. Im making a simple lvl restriction system, but i want it to be easily editable with account names that can access it. First i thought if i use a weapon as a keycard and if the player doesn't have the weapon, he/she will be warped elsewhere but its not efficient enough. Any ideas?
__________________
Reply With Quote
  #2  
Old 04-27-2011, 10:21 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
Use a database NPC to store flags of rights within the level, including who can access it.
__________________
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
  #3  
Old 04-27-2011, 10:25 AM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
You could simply make a class holding the restriction and a list of accounts, and join it to the level.
EDIT: Or what TSA said
Reply With Quote
  #4  
Old 04-27-2011, 04:28 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
I am new to scripting and, i know what your saying, but i don;t know where to start doing that. I like the use of a database NPC to keep it simple but any advance on that?
Most appreciated.
__________________
Reply With Quote
  #5  
Old 04-27-2011, 05:20 PM
Bell Bell is offline
Registered User
Bell's Avatar
Join Date: Feb 2007
Posts: 1,824
Bell has much to be proud ofBell has much to be proud ofBell has much to be proud ofBell has much to be proud ofBell has much to be proud ofBell has much to be proud ofBell has much to be proud of
I'm not positive this is what you're looking for but there is a tutorial in the wiki explaining how to make database NPC's.

http://wiki.graal.net/index.php/Crea..._Communication
Reply With Quote
  #6  
Old 04-27-2011, 09:57 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Ignore Bell's post (sorry Bell), that's not relevant to what you want to do.

If you create a database NPC named, say, AccessControl, you can access public functions in the script simply by calling them from any serverside script:

PHP Code:
AccessControl.myFunction(); 
Inside the AccessControl script, you'd want to have something like this:

PHP Code:
public function addAccountToLevel(levelNameaccount) {
  
this.access.(@ levelName).add(account);
  
this.save();
}

public function 
removeAccountFromLevel(levelNameaccount) {
  
this.access.(@ levelName).remove(account);
  
this.save();
}

public function 
accountHasAccess(levelNameaccount) {
  return (
account in this.access.(@ levelName));
}

// this seems to prevent the DB NPC from rolling back
function save() {
  
this.trigger("update");

Now you'll want to place a script inside the level that allows you to control this. You don't have to do it by level, either, as long as you're using something consistent like "house_cbk1994" throughout all levels you want to have the same access.

An example of the level script:

PHP Code:
function onPlayerEnters() {
  if (! 
AccessControl.accountHasAccess(this.level.nameplayer.account)) {
    
player.chat "I'm not allowed here!";
    
player.setLevel2("osl.nw"3232);
  }

__________________
Reply With Quote
  #7  
Old 04-28-2011, 12:32 AM
Bell Bell is offline
Registered User
Bell's Avatar
Join Date: Feb 2007
Posts: 1,824
Bell has much to be proud ofBell has much to be proud ofBell has much to be proud ofBell has much to be proud ofBell has much to be proud ofBell has much to be proud ofBell has much to be proud of
Quite alright Chris, I was attempting to guess what he was hunting for. I knew someone would correct me if I was wrong .
Reply With Quote
  #8  
Old 04-28-2011, 11:26 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Thanks CBK. I know know that DPNCS can be used for much more than storing data. Thanks. Im not gonna copy and past the script but use it as a template for my own. That way i will learn more and be happier with the outcome, if any. Thanks guys.
__________________
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 07:12 AM.


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