Author Topic: Special entrances  (Read 2216 times)

Offline Aell

  • Acquaintance
  • *
  • Posts: 1
    • View Profile
Special entrances
« on: June 18, 2008, 08:29:46 pm »
I want to be able to make the exit from this room only accessible to creators and those with a pt badge. I still want normal players to be able to get into that room, just not from this exit. I've been trying to get this to work, but what I have bellow still allows normal players into the room. Could anyone give me a few pointers in the right direction, please?

Code: [Select]
#include <lib.h>
#include <rooms.h>

inherit LIB_ROOM;

static void create() {
    object ob;
    room::create();
    SetClimate("indoors");
    SetAmbientLight(30);
    SetShort("Avenue");
    SetLong("An avenue");
    SetExits( ([
        "north" : "/realms/aell/area/room/main1",
      ]) );
}

int go_north() {
    object ob = this_player();
    if(ob && !creatorp(ob) || !present("pt pass",ob)) {
        write("You are blocked by some form of forcefield.");
        say("" + this_player()->GetCapName()+" is blocked by a forcefield.",
this_player());
        return 0;
    }
    return 1;
}

void init(){
    ::init();
}

Offline tay

  • Acquaintance
  • *
  • Posts: 23
    • View Profile
Re: Special entrances
« Reply #1 on: June 19, 2008, 07:03:42 am »
Instead of using SetExits, you have to use AddExit with three instead of the standard two arguments - in your example, you'd want to use
Code: [Select]
AddExit("north","/realms/aell/area/room/main1",(:go_north:))
Also, you should have the go_north() function ahead of your create function, or have int go_north() somewhere before it.  And your check to let creators, playtesters, and npcs through should be :
Code: [Select]
if(living(ob) && !creatorp(ob) && !present("pt pass",ob) && interactive(ob))
If you don't want to let NPCs use the exit, use
Code: [Select]
if(living(ob) && !creatorp(ob) && !present("pt pass",ob) && !interactive(ob))or
Code: [Select]
if(!creatorp(ob) && !present("pt pass",ob))
Hope that helps

- tay@CanLAND

Offline percussor

  • Acquaintance
  • *
  • Posts: 5
    • View Profile
Re: Special entrances
« Reply #2 on: June 19, 2008, 02:25:50 pm »
Here. Use a CanReceive, as demonstrated by this code:

Code: [Select]
int CanReceive(object ob) {
if(!wizardp(ob) || !present("pt badge",ob) && ob->GetProperty("LastLocation") == "the/room/you/dont/want/entry/from") { return 0; }
return room::CanReceive(ob);
}
Good luck,
Percussor @ CanLAND