I had a case where I needed to check for (and disable) multiple instances of an NPC. That may be very close to what you require. I do not have that script handy at the moment, but something like this may work for you. Of course, since it is a local script the player will have to enter the cell of more than one such script before it will detect others.
short localVarshort messageOnceif ( var == 0 ) set localVar to 1 set globalVar to 1endifif ( messageOnce == 0 ) if ( globalVar > 1 ) set messageOnce to 1 messagebox "We are legion." endifendif