<config>

//////////////
//
//  Find Room v1.0 by Pri (26th of May 2012)
//  This script requires Metis v2.80 or higher & RoboMX v2.08
//  Please use Metis v2.82 or higher for the smoothest experience: http://bit.ly/ldk6C3
//  Website: http://www.renmx.com
//  Forum: http://www.mxpulse.com/board
//
///////  COMMANDS
//
//  !FindRoom [Query] - Find a room
//  !FindChan [Query] - Find a room (Alternative trigger)
//  !PrivateFindRoom - Set all output to Private, only those who use the commands see results (Default = On)
//  !PublicFindRoom - Set all output to Public, Whenever someone searches for a room, everyone sees the results
//  !SetFindRoomColour [number] - Set the colours of the script to something other than the default green, Use the custom settings file instead of this.
//
///////  SERVER SUPPORT
//
//  WCS, RCS, ZCS, RSWCS, FXServer and Ouka are all supported out of the box
//
//////////////

<command type="script">
<in>!findroom %PARAM%</in>
<in>!findchan %PARAM%</in>
// This script can detect a URL in any part of a sentence, but we don't want it to do that if the sentence begins with ! or /
<out type="push" extdata="CMD_REQ">%TRIGGER%</out>
<out type="push" extdata="CMD_REQ"><operator type="strleft" lvalue="$CMD_REQ$" rvalue="5"/></out>
<out type="break" condition="!_?" lvalue="$CMD_REQ$" rvalue="!find"></out>
// Check that the scripts folder and settings files have been setup. If they haven't then do so.
<out type="push" extdata="Find_Room_Setup_Check"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\.Find.Room.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Find_Room_Setup_Check$" rvalue="" type="exec" extdata="1">cmd.exe /c MD C:\Pri.Script.Dependencies\Find.Room</out>
<out condition="==" lvalue="$Find_Room_Setup_Check$" rvalue="" type="sleep" extdata="3000"></out>
<out condition="==" lvalue="$Find_Room_Setup_Check$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Find.Room\.Find.Room.ini" mode="t">1</out>
// If this is the first setup write the massive customisation settings file
<out condition="==" lvalue="$Find_Room_Setup_Check$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Find.Room\Customisation.Settings.File.ini" mode="t">### This is the Find Room settings file, you can customise many aspects of the Find Room Script from here ###\n### Using this file is simple, Just change the output text to what you want, you can use colour codes too! ###\n\n### Change these formats below to alter how things appear in-room, Changes happen as soon as you save this file ###\n\nBeginning of Results Message: #c4#Searching [Total Rooms] rooms based on your query#c63#: #c62#[Search Query]\nRoom Listing Format: #c4# · #c1#[Room Name] #c63#|#c62# [User Count]#c63#/#c62#[Maximum Users] #c63#|#c1# [Server Version]\nNo Rooms Found Format: #c4#[Find Room Name/Version] #c1#I'm sorry no rooms matching your query were found out of [Total Rooms] rooms.\nEnd of Results Message: #c4#You received #c62#[Result Number] #c4#Result[s]\n\n### Basic Variable Changes below ###\n\nMaximum Amount of Results to show: 20\n\n### You can use any of these variables below in your custom formats ###\n\n- [Room Name] [User Count] [Maximum Users] [Room Topic] [Server Version] [Result Number] [Search Query] [Total Rooms]\n\n### The variable [Server Version] may not always output a server due to some rooms running in offline mode ###</out>
// If this is the first time the script has been setup tell them how they can customise this script through the customisation file
<out condition="==" lvalue="$Find_Room_Setup_Check$" rvalue="">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#): #c9#A customisation file has been created#c63#: #c1#C:\Pri.Script.Dependencies\Find.Room\Customisation.Settings.File.ini</out>
<out condition="==" lvalue="$Find_Room_Setup_Check$" rvalue="">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#): #c62#Inside that file you can customise how this script looks including all text, colours and what information is displayed such as topic titles in room search results</out>
// Set the script up to use Private Mode by default
<out type="goto" extdata="10" condition="==" lvalue="$Find_Room_Setup_Check$" rvalue="1"></out>
<out type="push" extdata="Server_Private_Command">0</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="WCS">/hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="RCS">/hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="FXServer">/message :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="Ouka">#private :@:RAWNAME:@: #message:@:SPACE:@:</out>
// Because ZCS does not report itself as ZCS and instead as WinMX we are just going to assume that WinMX = ZCS
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="WinMX">/privnotice :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Find_Room_For_WCS" condition="?" lvalue="%SERVER%" rvalue="WinMX">1</out>
<out condition="?" lvalue="%SERVER%" rvalue="WinMX">/stats</out>
// Save the command for later use
<out type="file" mode="a" extdata="C:\Pri.Script.Dependencies\Find.Room\.Public.Private.Server.Settings.ini">1\n%USERVAR[Server_Private_Command]%</out>
// Check that the user has the correct version of Metis to run this script by querying my server and checking for a file, if this file doesn't display right tell the user to update
// The reason this code has Pulse in it is because it's just copy and pasted from the Pulse script and it uses less web queries to share the same variable name this way
<out type="push" extdata="Pulse_Metis_Check" condition="==" lvalue="%USERVAR[Pulse_Metis_Check]%" rvalue=""><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/metis.check.ini" lvalue="l" rvalue="1"/></out>
<out condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#): #c9#You appear to be running an outdated version of Metis.</out>
<out condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#): #c9#You can download the latest one here#c63#: #c62#http://bit.ly/ldk6C3</out>
<out condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#): #c9#To install this file replace your old Metis.r2x file located in your script plugins folder</out>
<out type="break" condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849"></out>
// Perform an online check to see if this version of Metis is supported by this script or not
<out type="push" extdata="Find_Room_Script_Compatability_Check" condition="==" lvalue="%USERVAR[Find_Room_Script_Compatability_Check]%" rvalue=""><operator type="readweb" nvalue="http://metis.mxpulse.com/script.compatibility.ini" lvalue="l" rvalue="6"/></out>
// The Find Room plugin requires version 2.80 of Metis or higher, however 2.82 or higher is recommended for optimum performance, We will now alert the user if their Metis is below v2.80
<out condition="!?" lvalue="%USERVAR[Find_Room_Script_Compatability_Check]%" rvalue="%VERSION%">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#): #c9#This script requires Metis v2.80 minimum, please upgrade from v%VERSION%#c63#: #c62#http://bit.ly/ldk6C3</out>
<out type="break" condition="!?" lvalue="%USERVAR[Find_Room_Script_Compatability_Check]%" rvalue="%VERSION%"></out>
// Check if the user is using Metis v2.80 or v2.81, if they are suggest to them upgrading to v2.82 or higher - Only make this recommendation once
<out type="push" extdata="ReminderCount" condition="==" lvalue="%VERSION%" rvalue="2.80"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\.Metis.Version.Reminder.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="ReminderCount" condition="==" lvalue="%VERSION%" rvalue="2.81"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\.Metis.Version.Reminder.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="ReminderCount" condition="==" lvalue="%VERSION%" rvalue="2.80"><operator type="+" lvalue="$ReminderCount$" rvalue="1"/></out>
<out type="push" extdata="ReminderCount" condition="==" lvalue="%VERSION%" rvalue="2.81"><operator type="+" lvalue="$ReminderCount$" rvalue="1"/></out>
<out condition="==" lvalue="%VERSION%" rvalue="2.80" type="file" extdata="C:\Pri.Script.Dependencies\Find.Room\.Metis.Version.Reminder.ini" mode="t">$ReminderCount$</out>
<out condition="==" lvalue="%VERSION%" rvalue="2.81" type="file" extdata="C:\Pri.Script.Dependencies\Find.Room\.Metis.Version.Reminder.ini" mode="t">$ReminderCount$</out>
<out type="goto" extdata="5" condition=">" lvalue="$ReminderCount$" rvalue="1"></out> 
<out condition="==" lvalue="%VERSION%" rvalue="2.80">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#): #c9#This script performs much faster with Metis v2.82 or higher, please upgrade from v%VERSION%#c63#: #c62#http://bit.ly/ldk6C3</out>
<out condition="==" lvalue="%VERSION%" rvalue="2.80">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#): #c9#Reminder #c62#1#c9# of 1</out>
<out condition="==" lvalue="%VERSION%" rvalue="2.81">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#): #c9#This script performs much faster with Metis v2.82 or higher, please upgrade from v%VERSION%#c63#: #c62#http://bit.ly/ldk6C3</out>
<out condition="==" lvalue="%VERSION%" rvalue="2.81">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#): #c9#Reminder #c62#1#c9# of 1</out>
// Pop some variables for later use
<out type="pop" extdata="Server_Private_Command"/>
// Load in the menucolour selected by the admins, if nothing found default is #c4#
<out type="push" extdata="Menu_Colour"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\.Menu.Colour.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Menu_Colour" condition="!?" lvalue="$Menu_Colour$" rvalue="#c"></out>
// Check if the script has been set to Public or Private Mode
<out type="push" extdata="Private_Public_Setting"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\.Public.Private.Server.Settings.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Server_Private_Command" condition="==" lvalue="$Private_Public_Setting$" rvalue="1"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\.Public.Private.Server.Settings.ini" lvalue="l" rvalue="2"/></out>
// If the user has selected to use private commands formulate how it should look for this query
<out type="push" extdata="Server_Private_Command"><operator type="strrep" nvalue="$Server_Private_Command$" lvalue=":@:RAWNAME:@:" rvalue="%RAWNAME%"/></out>
<out type="push" extdata="Server_Private_Command"><operator type="strrep" nvalue="$Server_Private_Command$" lvalue=":@:SPACE:@:" rvalue=" "/></out>
// Check for an updated version of this script
<out type="push" extdata="Version_Info">v1.0</out>
<out type="pop" extdata="Version_Release_Message"/>
<out type="push" extdata="Version_Check_Date"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\.Version.Check.Date.txt" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Version_Info" condition="!=" lvalue="%USERVAR[Version_Check_Date]%" rvalue="%DATE%"><operator type="readweb" nvalue="http://find.room.mxpulse.com/version.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Version_Release_Message" condition="!=" lvalue="%USERVAR[Version_Info]%" rvalue="v1.0"><operator type="readweb" nvalue="http://find.room.mxpulse.com/version.ini" lvalue="l" rvalue="2"/></out>
<out condition="!=" lvalue="%USERVAR[Version_Release_Message]%" rvalue="">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#): #c9#%USERVAR[Version_Release_Message]%</out>
<out condition="!=" lvalue="%USERVAR[Version_Release_Message]%" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Find.Room\.Version.Check.Date.txt" mode="t">%DATE%</out>
// Take the incoming parameter and form a url to query the MXPulse room API
<out type="push" extdata="URL">http://www.find.room.mxpulse.com/?search=%PARAM%</out>
// Load in the Customisation Settings File to get the format that the user selected
<out type="push" extdata="SETTINGS_LINE">0</out>
<out type="push" extdata="SETTINGS_LINE"><operator type="+" lvalue="$SETTINGS_LINE$" rvalue="1"/></out>
<out type="push" extdata="Custom_Format"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\Customisation.Settings.File.ini" lvalue="l" rvalue="$SETTINGS_LINE$"/></out>
<out type="push" extdata="Start_Results_Format" condition="?" lvalue="$Custom_Format$" rvalue="Beginning of Results Message: ">$Custom_Format$</out>
<out type="push" extdata="Room_Listing_Format" condition="?" lvalue="$Custom_Format$" rvalue="Room Listing Format: ">$Custom_Format$</out>
<out type="push" extdata="No_Rooms_Found_Amount" condition="?" lvalue="$Custom_Format$" rvalue="No Rooms Found Format: ">$Custom_Format$</out>
<out type="push" extdata="End_Results_Format" condition="?" lvalue="$Custom_Format$" rvalue="End of Results Message: ">$Custom_Format$</out>
<out type="push" extdata="Maximum_Amount_Of_Results" condition="?" lvalue="$Custom_Format$" rvalue="Maximum Amount of Results to show: ">$Custom_Format$</out>
<out type="goto" extdata="2" condition="?" lvalue="$Custom_Result_Amount$" rvalue="Maximum Amount of Results to show: "></out>
<out type="goto" extdata="-8" condition="!=" lvalue="$SETTINGS_LINE$" rvalue="20"></out>
// Clean up the formats removing human readable text
<out type="push" extdata="Start_Results_Format"><operator type="strrem" lvalue="$Start_Results_Format$" rvalue="Beginning of Results Message: "/></out>
<out type="push" extdata="Room_Listing_Format"><operator type="strrem" lvalue="$Room_Listing_Format$" rvalue="Room Listing Format: "/></out>
<out type="push" extdata="No_Rooms_Found_Amount"><operator type="strrem" lvalue="$No_Rooms_Found_Amount$" rvalue="No Rooms Found Format: "/></out>
<out type="push" extdata="End_Results_Format"><operator type="strrem" lvalue="$End_Results_Format$" rvalue="End of Results Message: "/></out>
<out type="push" extdata="Maximum_Amount_Of_Results"><operator type="strrem" lvalue="$Maximum_Amount_Of_Results$" rvalue="Maximum Amount of Results to show: "/></out>
<out type="push" extdata="Maximum_Amount_Of_Results"><operator type="+" lvalue="$Maximum_Amount_Of_Results$" rvalue="1"/></out>
// Get the count of how many rooms are currently listed by WinMXUnlimited.net
<out type="push" extdata="FR_Total_Rooms" condition="==" lvalue="$FR_Total_Rooms$" rvalue=""><operator type="readweb" nvalue="$URL$" lvalue="l" rvalue="2"/></out>
// Replace some of the chosen format options with their real values (Static)
<out type="push" extdata="Start_Results_Format"><operator type="strrep" nvalue="$Start_Results_Format$" lvalue="[Find Room Name/Version]" rvalue="%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#):"/></out>
<out type="push" extdata="Start_Results_Format"><operator type="strrep" nvalue="$Start_Results_Format$" lvalue="[Search Query]" rvalue="%PARAM%"/></out>
<out type="push" extdata="Start_Results_Format"><operator type="strrep" nvalue="$Start_Results_Format$" lvalue="[Total Rooms]" rvalue="%USERVAR[FR_Total_Rooms]%"/></out>
<out type="push" extdata="Room_Listing_Format"><operator type="strrep" nvalue="$Room_Listing_Format$" lvalue="[Find Room Name/Version]" rvalue="%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#):"/></out>
<out type="push" extdata="Room_Listing_Format"><operator type="strrep" nvalue="$Room_Listing_Format$" lvalue="[Search Query]" rvalue="%PARAM%"/></out>
<out type="push" extdata="Room_Listing_Format"><operator type="strrep" nvalue="$Room_Listing_Format$" lvalue="[Total Rooms]" rvalue="%USERVAR[FR_Total_Rooms]%"/></out>
<out type="push" extdata="Room_Listing_Format_Saved">$Room_Listing_Format$</out>
<out type="push" extdata="No_Rooms_Found_Amount"><operator type="strrep" nvalue="$No_Rooms_Found_Amount$" lvalue="[Find Room Name/Version]" rvalue="%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#):"/></out>
<out type="push" extdata="No_Rooms_Found_Amount"><operator type="strrep" nvalue="$No_Rooms_Found_Amount$" lvalue="[Search Query]" rvalue="%PARAM%"/></out>
<out type="push" extdata="No_Rooms_Found_Amount"><operator type="strrep" nvalue="$No_Rooms_Found_Amount$" lvalue="[Total Rooms]" rvalue="%USERVAR[FR_Total_Rooms]%"/></out>
<out type="push" extdata="End_Results_Format"><operator type="strrep" nvalue="$End_Results_Format$" lvalue="[Find Room Name/Version]" rvalue="%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#):"/></out>
<out type="push" extdata="End_Results_Format"><operator type="strrep" nvalue="$End_Results_Format$" lvalue="[Search Query]" rvalue="%PARAM%"/></out>
<out type="push" extdata="End_Results_Format"><operator type="strrep" nvalue="$End_Results_Format$" lvalue="[Total Rooms]" rvalue="%USERVAR[FR_Total_Rooms]%"/></out>
// Query the URL
<out type="push" extdata="API_Response"><operator type="readweb" nvalue="$URL$" lvalue="l" rvalue="1" /></out>
// Take the response and replace some seperators with newlines for reading back
<out type="push" extdata="API_Response"><operator type="strrep" nvalue="$API_Response$" lvalue="[:@:]" rvalue="\n"/></out>
// Check if the API gave any response and if didn't tell the user no result could be found
<out condition="==" lvalue="$API_Response$" rvalue="">%USERVAR[Server_Private_Command]%%USERVAR[No_Rooms_Found_Amount]%</out>
<out type="break" condition="==" lvalue="$API_Response$" rvalue=""></out>
// Save the API response for reading back
<out type="file" extdata="C:\Pri.Script.Dependencies\Find.Room\Cache.txt" mode="t">$API_Response$</out>
// Tell the user that the room search results are going to be sent now
<out>%USERVAR[Server_Private_Command]%%USERVAR[Start_Results_Format]%</out>
// Read through the saved API response and push them in to variables
<out type="push" extdata="FR_Result_Amount">1</out>
<out type="push" extdata="LINECOUNT_Master">-4</out>
<out type="push" extdata="LINECOUNT_Master"><operator type="+" lvalue="$LINECOUNT_Master$" rvalue="5"/></out>
<out type="push" extdata="FR_Room_Name"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\Cache.txt" lvalue="l" rvalue="$LINECOUNT_Master$"/></out>
<out type="push" extdata="LINECOUNT"><operator type="+" lvalue="$LINECOUNT_Master$" rvalue="1"/></out>
<out type="push" extdata="FR_User_Count"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\Cache.txt" lvalue="l" rvalue="$LINECOUNT$"/></out>
<out type="push" extdata="LINECOUNT"><operator type="+" lvalue="$LINECOUNT$" rvalue="1"/></out>
<out type="push" extdata="FR_Maximum_Users"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\Cache.txt" lvalue="l" rvalue="$LINECOUNT$"/></out>
<out type="push" extdata="LINECOUNT"><operator type="+" lvalue="$LINECOUNT$" rvalue="1"/></out>
<out type="push" extdata="FR_Room_Topic"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\Cache.txt" lvalue="l" rvalue="$LINECOUNT$"/></out>
<out type="push" extdata="LINECOUNT"><operator type="+" lvalue="$LINECOUNT$" rvalue="1"/></out>
<out type="push" extdata="FR_Server_Version"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Find.Room\Cache.txt" lvalue="l" rvalue="$LINECOUNT$"/></out>
// Replace some of the chosen format options with their real values (Dynamic)
<out type="push" extdata="Room_Listing_Format">$Room_Listing_Format_Saved$</out>
<out type="push" extdata="Room_Listing_Format"><operator type="strrep" nvalue="$Room_Listing_Format$" lvalue="[Room Name]" rvalue="%USERVAR[FR_Room_Name]%"/></out>
<out type="push" extdata="Room_Listing_Format"><operator type="strrep" nvalue="$Room_Listing_Format$" lvalue="[User Count]" rvalue="%USERVAR[FR_User_Count]%"/></out>
<out type="push" extdata="Room_Listing_Format"><operator type="strrep" nvalue="$Room_Listing_Format$" lvalue="[Maximum Users]" rvalue="%USERVAR[FR_Maximum_Users]%"/></out>
<out type="push" extdata="Room_Listing_Format"><operator type="strrep" nvalue="$Room_Listing_Format$" lvalue="[Room Topic]" rvalue="%USERVAR[FR_Room_Topic]%"/></out>
<out type="push" extdata="Room_Listing_Format"><operator type="strrep" nvalue="$Room_Listing_Format$" lvalue="[Server Version]" rvalue="%USERVAR[FR_Server_Version]%"/></out>
<out type="push" extdata="FR_Result_Amount" condition="<" lvalue="$FR_Result_Amount$" rvalue="10">0%USERVAR[FR_Result_Amount]%</out>
<out type="push" extdata="Room_Listing_Format"><operator type="strrep" nvalue="$Room_Listing_Format$" lvalue="[Result Number]" rvalue="%USERVAR[FR_Result_Amount]%"/></out>
// Output to the room the found results
<out condition="!=" lvalue="$FR_Room_Name$" rvalue="">%USERVAR[Server_Private_Command]%%USERVAR[Room_Listing_Format]%</out>
<out type="push" extdata="FR_Result_Amount" condition="!=" lvalue="$FR_Room_Name$" rvalue=""><operator type="+" lvalue="$FR_Result_Amount$" rvalue="1"/></out>
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Maximum_Amount_Of_Results]%" rvalue="%USERVAR[FR_Result_Amount]%"></out>
<out type="goto" extdata="-21" condition="!=" lvalue="" rvalue="%USERVAR[FR_Room_Name]%"></out>
// Do a final custom format replace
<out type="push" extdata="FR_Result_Amount"><operator type="-" lvalue="$FR_Result_Amount$" rvalue="1"/></out>
<out type="push" extdata="FR_Result_Amount" condition="<" lvalue="$FR_Result_Amount$" rvalue="10"><operator type="strrem" lvalue="$FR_Result_Amount$" rvalue="0"/></out>
<out type="push" extdata="End_Results_Format"><operator type="strrep" nvalue="$End_Results_Format$" lvalue="[Result Number]" rvalue="%USERVAR[FR_Result_Amount]%"/></out>
<out type="push" extdata="End_Results_Format"><operator type="strrep" nvalue="$End_Results_Format$" lvalue="[Total Rooms]" rvalue="%USERVAR[FR_Total_Rooms]%"/></out>
// Tell the user that the query has ended
<out>%USERVAR[Server_Private_Command]%%USERVAR[End_Results_Format]%</out>
</command>

<command type="script" condition="==" lvalue="$Find_Room_For_WCS$" rvalue="1">
<in>WCS Version: %PARAM%</in>
// Tell the user that WCS was detected and that they may have seen some temporary garbled text
<out>/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v1.0#c63#): #c9#WCS %PARAM% has been detected, You may have seen some /privnotice commands above this is normal during WCS %PARAM% detection due to a bug in the server</out>
// If WCS was detected then save that
<out type="file" mode="t" extdata="C:\Pri.Script.Dependencies\Find.Room\.Public.Private.Server.Settings.ini">1\n/hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@:</out>
// Push 0 to Checking for WCS
<out type="push" extdata="Find_Room_For_WCS">0</out>
</command>

<command type="script">
<in>!privatefindroom</in>
<in>!publicfindroom</in>
// Check if the command was typed at the start of a sentence, if not break
<out type="push" extdata="CMD_REQ">%TRIGGER%</out>
<out type="push" extdata="CMD_REQ"><operator type="strleft" lvalue="$CMD_REQ$" rvalue="2"/></out>
<out type="break" condition="!_?" lvalue="$CMD_REQ$" rvalue="!p"></out>
// Check if the Metis version is below v2.83 so we know that %USERMODE% works
<out type="push" extdata="Supports_Usermode">1</out>
<out type="push" extdata="Supports_Usermode" condition="?" lvalue="%VERSION%" rvalue="2.80">0</out>
<out type="push" extdata="Supports_Usermode" condition="==" lvalue="%VERSION%" rvalue="2.81">0</out>
<out type="push" extdata="Supports_Usermode" condition="==" lvalue="%VERSION%" rvalue="2.82">0</out>
<out type="goto" extdata="3" condition="!=" lvalue="%USERVAR[Supports_Usermode]%" rvalue="1"></out>
// If the user doesn't have an @ in the User List, tell them they need to login to use this command and break
<out condition="!=" lvalue="%USERMODE%" rvalue="@">#c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v0.3a#c63#): #c9#Login and show an #c62#@ #c9#in the userlist to use this command.</out>
<out type="break" condition="!=" lvalue="%USERMODE%" rvalue="@"></out>
// Process which command the user typed
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="!privatefindroom" extdata="C:\Pri.Script.Dependencies\Find.Room\.Public.Private.Server.Settings.ini">1\n</out>
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="!publicfindroom" extdata="C:\Pri.Script.Dependencies\Find.Room\.Public.Private.Server.Settings.ini">0</out>
// Output to the Admins if it was set to Public Mode
<out condition="_?" lvalue="%TRIGGER%" rvalue="!publicfindroom">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v0.3a#c63#): #c1#Find Room Has been set to Public Mode</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="!publicfindroom">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v0.3a#c63#): #c62#When this is set to Public, all Find Room results will be shown to the entire room</out>
// Break if the user selected to use Public
<out type="break" condition="_?" lvalue="%TRIGGER%" rvalue="!publicfindroom"></out>
// If the user selected PrivateFindRoom, work out which server is in use
<out type="push" extdata="Server_Private_Command">0</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="WCS">/hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="RCS">/hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="FXServer">/message :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="Ouka">#private :@:RAWNAME:@: #message:@:SPACE:@:</out>
// Because ZCS does not report itself as ZCS and instead as WinMX we are just going to assume that WinMX = ZCS
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="WinMX">/privnotice :@:RAWNAME:@::@:SPACE:@:</out>
// Save the command for later use
<out type="file" mode="a" extdata="C:\Pri.Script.Dependencies\Find.Room\.Public.Private.Server.Settings.ini">%USERVAR[Server_Private_Command]%</out>
// Server not recognised Message
<out condition="==" lvalue="$Server_Private_Command$" rvalue="0">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v0.3a#c63#): #c9#Find Room cannot be set to Private in your room as the Server #c63#(#c62#%SERVER%#c63#)#c9# is not supported by the script currently</out>
<out type="file" mode="t" condition="==" lvalue="$Server_Private_Command$" rvalue="0" extdata="C:\Pri.Script.Dependencies\Find.Room\.Public.Private.Server.Settings.ini">0</out>
<out type="break" condition="==" lvalue="$Server_Private_Command$" rvalue="0"></out>
// Output to the Admins if it was set to Private Mode
<out condition="_?" lvalue="%TRIGGER%" rvalue="!privatefindroom">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v0.3a#c63#): #c1#Find Room Has been set to Private Mode</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="!privatefindroom">/opmsg #c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v0.3a#c63#): #c62#When this is set to Private, only those who use the room searching commands will see results</out>
// Check that WCS 1.8.8 is in use if the Server is reporting itself as WinMX
<out type="push" extdata="Find_Room_For_WCS" condition="?" lvalue="%SERVER%" rvalue="WinMX">1</out>
<out condition="?" lvalue="%SERVER%" rvalue="WinMX">/stats</out>
</command>

<command type="script">
<in>!setfindroomcolour %PARAM%</in>
<in>!setfindroomcolor %PARAM%</in>
// Check if the command was typed at the start of a sentence, if not break
<out type="push" extdata="CMD_REQ">%TRIGGER%</out>
<out type="push" extdata="CMD_REQ"><operator type="strleft" lvalue="$CMD_REQ$" rvalue="16"/></out>
<out type="break" condition="!_?" lvalue="$CMD_REQ$" rvalue="!setfindroomcolo"></out>
// Check if the Metis version is below v2.83 so we know that %USERMODE% works
<out type="push" extdata="Supports_Usermode">1</out>
<out type="push" extdata="Supports_Usermode" condition="?" lvalue="%VERSION%" rvalue="2.80">0</out>
<out type="push" extdata="Supports_Usermode" condition="==" lvalue="%VERSION%" rvalue="2.81">0</out>
<out type="push" extdata="Supports_Usermode" condition="==" lvalue="%VERSION%" rvalue="2.82">0</out>
<out type="goto" extdata="3" condition="!=" lvalue="%USERVAR[Supports_Usermode]%" rvalue="1"></out>
// If the user doesn't have an @ in the User List, tell them they need to login to use this command and break
<out condition="!=" lvalue="%USERMODE%" rvalue="@">#c4#%USERVAR[Menu_Colour]%Find Room #c63#(#c62#v0.3a#c63#): #c9#Login and show an #c62#@ #c9#in the userlist to use this command.</out>
<out type="break" condition="!=" lvalue="%USERMODE%" rvalue="@"></out>
// Encapsulate parameter with colour tags if none are present and save to file
<out type="file" mode="t" condition="?" lvalue="%PARAM%" rvalue="#c" extdata="C:\Pri.Script.Dependencies\Find.Room\.Menu.Colour.ini">%PARAM%\n</out>
<out type="file" mode="t" condition="!?" lvalue="%PARAM%" rvalue="#c" extdata="C:\Pri.Script.Dependencies\Find.Room\.Menu.Colour.ini">#c%PARAM%#\n</out>
// Output to the Admins what colour it has been set to
<out condition="?" lvalue="%PARAM%" rvalue="#c">/opmsg #c4#%PARAM%Find Room #c63#(#c62#v0.3a#c63#): #c1#Find Room Has set its colours to#c63#: %PARAM% |||||</out>
<out condition="!?" lvalue="%PARAM%" rvalue="#c">/opmsg #c4##c%PARAM%#Find Room #c63#(#c62#v0.3a#c63#): #c1#Find Room Has set its colours to#c63#: #c%PARAM%# |||||</out>
// Tell them for full control they will need to use the new customisation file
<out>/opmsg #c4#%PARAM%Find Room #c63#(#c62#v0.3a#c63#): #c62#For full customisation of this script you will need to use the customisation file found here#c63#: #c1#C:\Pri.Script.Dependencies\Find.Room\Customisation.Settings.File.ini</out>
</command>

</config>