Is there a way for my macro to react if somebody enters the zone?
Basically, i want to stop what i'm doing if there is anybody in the zone other than my 2 chars
Moderator: MacroQuest Developers

Code: Select all
#event Zone "There are 2 Players in Zone Name"
|* Edit above line to whatever the last line in a /who would be that tells /
total number of players in zone *|
Sub Main
/declare global JustYou
/varset JustYou 0
:Loop
/
|* I'm Not positive if the slash would work to do a who in the main EQ chat window or if it would error cause it's only a slash. Play with that if it doesn't work to see what would do a who in main text window, I know a /who would do it in the mq2 window but dunno if #event grab text from mq2 window, if it does you can do it with /who *|
/doevents
/if n @JustYou==1 {
|* Have this part /call the sub routine you have the code in for whatever it is your doing.
}
/delay 100
|* Delay will wait awhile before it checks to see if anyone else is still in zone, so your not scrolling /who's forever, dunno if it's detectable but why take the chance. *|
/goto :Loop
Sub event_Zone
/varset JustYou 1
/return

Code: Select all
#turbo 20
Sub Main
/declare pcid global
/declare firstpcid global
/declare lastpcid global
/declare pccount global
/varset pcid 0
/varset firstpcid 0
/varset lastpcid 0
/varset pccount 0
/varset pcid $searchspawn(pc)
:Loop
/if n @pcid==@firstpcid {
/if n @pccount>2 /endmacro
} else {
/if n @pccount==0 /varset firstpcid @pcid
/varset lastpcid @pcid
/varset pcid $searchspawn(pc,id:@lastpcid,next)
/varadd pccount 1
}
/goto :Loop
/return
Code: Select all
#turbo 20
Sub Main
/declare pccount global
:WaitForEmptyZone
/delay 1s
/call ZoneCount
/if n @pccount>2 /goto :WaitForEmptyZone
[color=red]Put your other stuff here...[/color]
/goto :WaitForEmptyZone
/return
Sub ZoneCount
/declare pcid local
/declare firstpcid local
/declare lastpcid local
/varset pcid 0
/varset firstpcid 0
/varset lastpcid 0
/varset pccount 0
/varset pcid $searchspawn(pc)
:Loop
/if n @pcid==@firstpcid {
/return
} else {
/if n @pccount==0 /varset firstpcid @pcid
/varset lastpcid @pcid
/varset pcid $searchspawn(pc,id:@lastpcid,next)
/varadd pccount 1
}
/goto :Loop
/return