View Single Post
  #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