Author Topic: SC/status while asleep?  (Read 2264 times)

Offline SonyUSA

  • Acquaintance
  • *
  • Posts: 36
    • View Profile
SC/status while asleep?
« on: April 29, 2008, 05:59:39 pm »
Hello, I tried to modify

Code: [Select]
   if(this_player()->GetSleeping() > 0) {
        if(verb != "wake") {
            this_player()->eventPrint("You are asleep.");
            return 1;
        }
    }

so that it was

Code: [Select]
   if(this_player()->GetSleeping() > 0) {
        if(verb != "wake", "sc", "status") {
            this_player()->eventPrint("You are asleep.");
            return 1;
        }
    }

but it didnt seem to like that... do i need to use the 'and' syntax or... ?

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: SC/status while asleep?
« Reply #1 on: April 29, 2008, 06:32:03 pm »
Quote
do i need to use the 'and' syntax

correct.

-Crat

Offline daelaskai

  • BFF
  • ***
  • Posts: 174
    • View Profile
Re: SC/status while asleep?
« Reply #2 on: April 29, 2008, 10:07:40 pm »
Heh,

While Cratylus is correct, I think an example of the correct code would be useful.  There are two ways that I know of that this can be done.  First:

Code: [Select]
   if(this_player()->GetSleeping() > 0) {
        if( verb != "wake" && verb != "sc" && verb != "status") {
            this_player()->eventPrint("You are asleep.");
            return 1;
        }
    }

The second way I actually like better but it's personal preference, really.

Code: [Select]
   if(this_player()->GetSleeping() > 0) {
        if( member_array( verb, ({ "wake", "sc", "status" }) ) == -1 ) {
            this_player()->eventPrint("You are asleep.");
            return 1;
        }
    }

Both have the same results.

Daelas

Offline SonyUSA

  • Acquaintance
  • *
  • Posts: 36
    • View Profile
Re: SC/status while asleep?
« Reply #3 on: April 30, 2008, 12:06:50 am »
Awesome, thanks :)