Author Topic: A conditional that checks if there are any players in the area  (Read 377 times)

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0


               I wanted some variables to reset when a player leaves the area but only if there are no other players still in that area. Is there any function that can check whether the area is empty or not?

Thanks. '<img'>
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
A conditional that checks if there are any players in the area
« Reply #1 on: August 09, 2013, 02:38:01 pm »


               There's a bunch of ways to skin that cat. This is probably the best, given considerations of speed, reliability, and simplicity.

int GetIsAreaEmpty(object oArea) {

    object oPC = GetFirstPC();
    while (GetIsObjectValid(oPC)) {
        if (GetArea(oPC) == oArea)
            return FALSE;
        oPC = GetNextPC();
    }
    return TRUE;
}

Funky
               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
A conditional that checks if there are any players in the area
« Reply #2 on: August 09, 2013, 02:56:50 pm »


               Great! Just what I needed! Thank you '<img'>