QueryBegin is triggered when a property query (or the
first of a series of queries, as in the case of ProjectBackup) is
started. It can also be triggered during a query (especially in newer bots) if not all information has been received from the world server and the bot must send a new request. This behaviour is in revision and may change. To ensure that only one event is triggered, disable the event handler with OnQueryBeginEvent inside the event handler itself.
QueryComplete is triggered when a property query (or in the
case of a series, each partial query) is completed.
The result of a property query is stored in a survey collection.
Queries use a disk cache to speed up procedures, this may be disabled. See related
subject Projects.
To start or stop a property query, use the following statement:
QueryUseCache On|Off | QueryUseCache On tells the bot to load its object cache, if it has one, before it starts querying. QueryUseCache Off forces the bot to query the server without loading the cache. |
QueryAt @a QueryAt &a QueryAt ~a |
this stops any ongoing property query or live update and starts a property query at the coordinates of location @a, person &a or object ~a. Automatically selects a 5x5 sector query if the world server supports it (build 33 or higher), otherwise does a 3x3 sector query. Objects are stored in the Survey buffer. |
Query3x3At @a Query3x3At &a Query3x3At ~a |
xelagot 3.607 this stops any ongoing property query or live update and starts a property query at the coordinates of location @a, person &a or object ~a. Forces a 3x3 sector query even in worlds that support 5x5 sector queries. Objects are stored in the Survey buffer. |
QueryStop | this stops registering any ongoing property query or live update, and clears the Survey buffer. |
See also ProjectBackup for querying the server to back up property.
Before starting a property query, make sure to install the event handlers for QueryBegin and QueryComplete if you need them.
Installer: OnQueryBeginEvent <eventlabel>
Event type: 2000
Installer: OnQueryCompleteEvent <eventlabel>
Event type: 2100
Specific statements (must be inside this event handler):
GetEventType %a | stores the event type code in variable %a |
GetEventResult %a | stores the event result code in variable %a. 0 means success, other positive codes are equivalent to the rc codes of the SDK and the Windows codes. See SDK Error Codes. |
GetQueryLocation @a | stores the location coordinates of the property query in variable @a. These are the coordinates of the location where the last query was started (see Query Begin). |
Confused? An example...
[Head] Type=Script Version=2.0 [Settings] Origin=0.000n 0.000w 0.00a 0.0° [Script] # how to query: an example... OnQueryCompleteEvent QComplete OnWorldReconnectEvent ImBack Label QueryNow @a = 7n 5e %q = 1 QueryAt @a Label WaitForQuery IfInt %q = 1 Goto WaitForQuery # the bot now finished querying, # and receives any updates for the zone automatically # here the rest of your code... # notice that WorldReconnect event handler # is still active ! Label MainLoop Goto MainLoop End Event QComplete %q = 0 EndEvent Event ImBack ResetTo QueryNow EndEvent |
You may want to check the SkullCounter Bot and the NaugtsAndCrosses Bot scripts for more examples, and the Event handler for ObjectAdd, ObjectDelete for a longer version of this script.