autolink.mac - Auto link storage/search - *New Parm Ready*

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

autolink.mac - Auto link storage/search - *New Parm Ready*

Post by ml2517 » Mon Jan 19, 2004 12:52 am

This macro will automatically store links that come through various chat channels. You can also manually add, edit(update), list, search and show links. Read the top of the macro to see examples.

This was inspired by a question someone had the other night about Kagonis' link.mac.

Code: Select all

|autolink.mac 
|Auto/Manual Link Storage/Lookup Utility 
|Version 1.26 
|Date:4/23/2004 7:00pm 
| 
|  Optional Paramaters available at start to make the automatic link adding silent and make the 
|  restarting of the mq2chatwnd every 30 minutes optional. 
| 
| Restart mq2chatwnd 0 is no(default), 1 is yes ---o 
| Silent: 0 is verbose, 1 is silent(default) ----o |  
|                                                | | 
|                                                v v                                
|                            /macro autolink.mac 1 0 
| 
|  
| 
|  NOTE: Currently there is a problem looking at item links in MQ2 so I have this script send to a password 
|        protected chat room that you specify below.  You can optionally send to other channels with ssearch 
|        but it is limited to only one result. 
| 
| 
|  This script by default will auto-add links that it sees in channels.  If you do not wish this to happen 
|  Comment out the #chat lines.  
| 
| 
|  Syntax: /echo <add|edit|list|search|ssearch|show|silent|restart|master> [link|name|firstletter] 
| 
| ------------------------------------------------------------------------------------------------------ 
|     To add a link manually: 
|     (You enter /echo add and a space then click your link.  Press Enter to add it.) 
|     Example: /echo add Some Item Link 
| ------------------------------------------------------------------------------------------------------ 
|     To manually update a link: 
|     (You enter /echo edit and a space then click your link.  Press Enter to update it.) 
|     Example: /echo edit Some Item Link 
| ------------------------------------------------------------------------------------------------------ 
|     To list all links: 
|     (You enter /echo list and then Enter and it will list all items in your database.) 
|     Example: /echo list 
| ------------------------------------------------------------------------------------------------------ 
|     To list links starting with a particular letter: 
|     (You enter /echo list and a space then one character to display the list that all start with 
|     that character.) 
|     Example: /echo list m 
| ------------------------------------------------------------------------------------------------------ 
|     To search for all entries containing a word: 
|     (You enter /echo search and a space then a partial name of the item you want to search for, 
|     then press Enter.) 
|     Example: /echo search Partial Link Name 
| ------------------------------------------------------------------------------------------------------ 
|     To search for all entries containing a word and display them to your private chat channel 
|     or a channel that you specify in an argument: 
|     (You enter /echo ssearch and a space then a partial name of the item you want to search for, 
|     then press Enter. You can also optionally pass an argument to direct it to a channel of your choice.) 
| 
|     NOTE: This will only display 6 records maximum to your private chat channel.  
| 
|     (This would only output all of the results to your private chat channel. Max of 6 records.) 
|     Example: /echo ssearch Partial Link Name 
| 
|     (This would only output 1 result and send it to your guild channel.) 
|     Example: /echo ssearch Partial Link Name /gu 
| 
|     (This would only output 1 result and send it via tell to john.) 
|     Example: /echo ssearch Partial Link Name /tell john 
| 
|     (This would only output 1 result and send it to chat room 'channelname'.) 
|     Example: /echo ssearch Partial Link Name /chat #channelname 
| 
|     (This would only output 1 result and send it to chat channel /1 but will allow you to put text before 
|     the link.) 
|     Example: /echo ssearch Partial Link Name /1 Any idea what this item is? 
|        Would Output: Any idea what this it is? ITEMLINK 
| 
|     (This would only output 1 result and send it to chat channel /1 but will allow you to put text before 
|     and after the link. You use the keyword itemlink to tell it where to put the link.) 
|     Example: /echo ssearch Partial Link Name /1 Any idea what this item is? itemlink I remember seeing it. 
|        Would Output: Any idea what this it is? ITEMLINK I remember seeing it. 
| ------------------------------------------------------------------------------------------------------ 
|     To send a specific link to your chat channel that you've specified so that you can actually view the 
|     link (**This will also let you redirect to other channels like ssearch): 
|     (You enter /echo show and a space then a list letter and then the key number. In order to find the list 
|     letter and key number you use the list or search functions.) 
|     Example: /echo show k 112 
| ------------------------------------------------------------------------------------------------------ 
|     To toggle suppression of output for automatic link additions: 
|     (You enter /echo silent and then enter. 
|     Example: /echo silent 
| ------------------------------------------------------------------------------------------------------ 
|     To toggle restarting of mq2chatwnd every 30 minutes: 
|     (You enter /echo restart and then enter. 
|     Example: /echo restart 
| ------------------------------------------------------------------------------------------------------ 
|     To add or remove a master from your authorization list, in order to allow/restrict remote searches: 
|     (You enter /echo master the player name and then enter. 
|     Example: /echo master Johnny 
|        Would add Johnny if he wasn't in the list or remove him if he was already on the list. 
| ------------------------------------------------------------------------------------------------------ 


#turbo 40
#define INIPART1 "Items-" 
#define INIPART2 ".ini" 
#define CHATROOM "rm967" 
#define CHATPASS "3f4dddfl" 

#Event LinkAdd "[MQ2] add" 
#Event LinkEdit "[MQ2] edit" 
#Event LinkList "[MQ2] list" 
#Event LinkNameSearch "[MQ2] search" 
#Event LinkShowSearch "[MQ2] ssearch" 
#Event LinkShow "[MQ2] show" 
#Event Silent "[MQ2] silent" 
#Event Restart "[MQ2] restart" 
#Event LootedA " has looted a " 
#Event LootedB " have looted a " 
#Event Master "[MQ2] master" 


#chat say 
#chat tell 
#chat ooc
#chat shout 
#chat auc 
#chat guild 
#chat group 
#chat chat 

Sub Main
/declare RemotePhrase global 
/declare RemoteSearchCount global 

| -------------------------------------------------------------------------------------------------- 
| This is the command that you would need to precede a remote search from a master to do a search.  
| Change it to your unique word or phrase. (Do not end this with a space.) 
| -------------------------------------------------------------------------------------------------- 
/varset RemotePhrase "Link me your" 

| -------------------------------------------------------------------------------------------------- 
| Change this to the maximum number of search results that will be sent to your master. 
| -------------------------------------------------------------------------------------------------- 
/varset RemoteSearchCount 3 


/join CHATROOM:CHATPASS 
/echo Autolink.mac by ml2517 started. 
/declare BusyEvent global 
/declare FlushTimer timer 
/declare SilentVar global 
/declare ItemList global 
/varset SilentVar 1 
/declare RestartWindow global 
/declare MasterList array
/declare LinkArray array2 
/varset RestartWindow 0 
/if (${Defined[Param0]}) /if (@Param0==0) /varset SilentVar 0 
/if (${Defined[Param1]}) /if (@Param1==1) /varset RestartWindow 1 
/varset BusyEvent 0 
/call LoadMasterList 
/call LoadLinkList

:MainLoop 
/if (@BusyEvent==0) /doevents
/delay 1s 
/if (@FlushTimer==0) {
    /if (@RestartWindow==1) {
        /plugin mq2chatwnd unload 
        /delay 2s 
        /plugin mq2chatwnd 
        /delay 2s 
        /clear 
        /varset FlushTimer 30m 
    } 
} 
/goto :MainLoop 
/return 


Sub LoadLinkList
/declare TempElements local 
/declare TempVar local 
/declare TempItem local 
/declare Letters local 
/declare ParseLetters local 
/varset TempVar 0 
/varset TempElements 0 
/varset Letters "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" 
/for ParseLetters 0 to ${Math.Calc[${String["@Letters"].Length}-1].Int}
    /varset TempVar 0 
    :ListLoadLoop 
    /varset TempItem "${Ini[INIPART1${String["@Letters"].Mid[${Math.Calc[@ParseLetters+1].Int},1]}INIPART2,Links,${Int[@TempVar]},NOTFOUND]}"
    /if (${String["@TempItem"].Equal["NOTFOUND"]}) /goto :DoneWithLoadLetter
    /varset LinkArray(@ParseLetters,@TempVar) "@TempItem"
    /varadd TempVar 1
    /goto :ListLoadLoop 
    :DoneWithLoadLetter 
/next ParseLetters 
/return


Sub INIAdd(AddName,Auto) 
/declare TempElements local 
/declare TempVar local 
/declare TempItem local 
/declare TempItem2 local 
/declare ParseLetters local
/varset TempVar 0 
/varset TempElements 0 

/declare Letters local 
/varset Letters "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" 
/for ParseLetters 0 to ${Math.Calc[${String["@Letters"].Length}-1].Int}
    /if (${String["@AddName"].Mid[47,1].Equal["${String["@Letters"].Mid[${Math.Calc[@ParseLetters+1].Int},1]}"]}) /goto :AddCheckLoop
/next ParseLetters

:AddCheckLoop 
/if (${String["@LinkArray(@ParseLetters,@TempVar)"].Equal["UNDEFINED-ARRAY-ELEMENT"]}) /goto :AddItem
/if (${String["@LinkArray(@ParseLetters,@TempVar)"].Equal["Empty"]}) /goto :AddItem

/if (${String["@AddName"].Find["${String["@LinkArray(@ParseLetters,@TempVar)"].Mid[47,${Math.Calc[${String["@LinkArray(@ParseLetters,@TempVar)"].Length}-47].Int}]}"]}) /if (${String[@AddName].Mid[2,7].Equal["${String["@LinkArray(@ParseLetters,@TempVar)"].Mid[2,7]}"]}) {
    /if (@SilentVar==0) {
        /echo "@AddName" already in INI file. 
    } else { 
        /if (@Auto==0) /echo "@AddName" already in INI file. 
    } 
    /goto :FoundInINI 
} 
/varadd TempVar 1 
/goto :AddCheckLoop 

:AddItem 
/varset LinkArray(@ParseLetters,@TempVar) "@AddName"
/ini "INIPART1${String["@AddName"].Mid[47,1]}INIPART2" "Links" "${Int[@TempVar]}" "'@AddName'" 
/if (@SilentVar==0) { 
    /echo "@AddName" added to INI file. 
} else { 
    /if (@Auto==0) /echo "@AddName" added to INI file. 
} 
:FoundInINI 
/return 

Sub INIEdit(EditName) 
/declare TempElements local 
/declare TempVar local 
/declare TempItem local 
/declare ParseLetters local
/varset TempVar 0 
/varset TempElements 0 
/declare Letters local 
/varset Letters "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" 
/for ParseLetters 0 to ${Math.Calc[${String["@Letters"].Length}-1].Int}
    /if (${String["@EditName"].Mid[47,1].Equal["${String["@Letters"].Mid[${Math.Calc[@ParseLetters+1].Int},1]}"]}) /goto :EditCheckLoop
/next ParseLetters
:EditCheckLoop

/if (${String["@EditName"].Find["${String["@LinkArray(@ParseLetters,@TempVar)"].Mid[47,${Math.Calc[${String["@LinkArray(@ParseLetters,@TempVar)"].Length}-47].Int}]}"]}) {
    /goto :EditItem 
} 
/if (${String["@LinkArray(@ParseLetters,@TempVar)"].Equal["UNDEFINED-ARRAY-ELEMENT"]}) /goto :NotFoundInINI
/varadd TempVar 1 
/goto :EditCheckLoop 

:EditItem 
/varset LinkArray(@ParseLetters,@TempVar) "@EditName"
/ini "INIPART1${String["@EditName"].Mid[47,1]}INIPART2" "Links" "${Int[@TempVar]}" "'@EditName'" 
/echo "@EditName" modified in INI file. 
/goto :EndINIEdit 
:NotFoundInINI 
/echo "@EditName" not found in INI file. 
:EndINIEdit 
/return 


Sub INIList(ListKeyName) 
/declare TempElements local 
/declare TempVar local 
/declare TempVar2 local
/declare TempItem local 
/declare Letters local 
/declare ParseLetters local 
/varset TempVar 0 
/varset TempVar2 0
/varset TempElements 0 
/varset Letters "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" 

/if (${Defined[ListKeyName]}) {
} else {
    /declare ListKeyName local 
    /varset ListKeyName "" 
}

/if (${String["@ListKeyName"].Length}==0) {
    /for ParseLetters 0 to ${Math.Calc[${String["@Letters"].Length}-1].Int}
        /varset TempVar 0 
        :ListCheckLoop 
        /if (${String["@LinkArray(@ParseLetters,@TempVar)"].Equal["UNDEFINED-ARRAY-ELEMENT"]}) /goto :DoneWithLetter
        /echo List:[ ${String["@Letters"].Mid[${Math.Calc[@ParseLetters+1]},1].Upper} ] Key:[ ${Int[@TempVar]} ] Name:[ @LinkArray(@ParseLetters,@TempVar) ]
        /varadd TempVar 1
        /varadd TempVar2 1 
        /goto :ListCheckLoop 
        :DoneWithLetter 
    /next ParseLetters 
} else { 
/echo ${Math.Calc[${String["@Letters"].Length}-1].Int}
    /for ParseLetters 0 to ${Math.Calc[${String["@Letters"].Length}-1].Int}
        /if (${String["@ListKeyName"].Equal["${String["@Letters"].Mid[${Math.Calc[@ParseLetters+1]},1]}"]}) /goto :ListCheckBreakOut
    /next ParseLetters
    :ListCheckBreakOut
    /varset TempVar 0 
    :ListCheckLoop2 
    /if (${String["@LinkArray(@ParseLetters,@TempVar)"].Equal["UNDEFINED-ARRAY-ELEMENT"]}) /goto :DoneWithLetter2
    /echo List:[ ${String[@Letters].Mid[${Math.Calc[@ParseLetters+1]},1].Upper} ] Key:[ ${Int[@TempVar]} ] Name:[ @LinkArray(@ParseLetters,@TempVar) ]
    /varadd TempVar 1
    /varadd TempVar2 1  
    /goto :ListCheckLoop2 
    :DoneWithLetter2 
} 
/if (@TempVar2==0) {
    /echo -(( No Entries Found! ))- 
} else { 
    /echo -[ Listing Complete ]- 
} 
/return 

Sub ININameSearch(SearchName) 
/declare TempElements local 
/declare TempVar local 
/declare TempItem local 
/declare Letters local 
/declare ParseLetters local 
/declare SearchCount local 
/varset SearchCount 0 
/varset TempVar 0 
/varset TempElements 0 
/varset Letters "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" 

/if (${Defined[SearchName]}) {
} else {
    /declare SearchName local 
    /varset SearchName ""
}

/if (${String["@SearchName"].Length}==0) {
    /echo -(( You must provide a name to search for! ))- 
} else {

    /for ParseLetters 0 to ${Math.Calc[${String["@Letters"].Length}-1].Int}
        /varset TempVar 0 
        :SearchCheckLoop 
        /if (${String["@LinkArray(@ParseLetters,@TempVar)"].Equal["UNDEFINED-ARRAY-ELEMENT"]}) /goto :DoneWithSearchLetter
        /if (${String["@LinkArray(@ParseLetters,@TempVar)"].Find["@SearchName"]}) {
            /echo List:[ ${String["@Letters"].Mid[${Math.Calc[@ParseLetters+1]},1].Upper} ] Key:[ ${Int[@TempVar]} ] Name:[ @LinkArray(@ParseLetters,@TempVar) ]
            /varadd SearchCount 1 
        } 
        /varadd TempVar 1 
        /goto :SearchCheckLoop 
        :DoneWithSearchLetter 
    /next ParseLetters 
    /echo -[ Search resulted in [${Int[@SearchCount]}] ${If[@SearchCount==1,record,records]}. ]- 
}

/if (@SearchCount==0) {
    /echo -(( No Entries Found! ))- 
} else { 
    /echo -[ Search Complete ]- 
} 
/return 


Sub INIShowSearch(SearchName,SendChannel) 
/declare TempElements local 
/declare TempVar local 
/declare TempItem local 
/declare Letters local 
/declare ParseLetters local 
/declare SearchCount local 
/if (${Defined[SendChannel]}) {
} else {
    /declare SendChannel local 
    /varset SendChannel "NULL" 
}
/varset ItemList "" 
/varset SearchCount 0 
/varset TempVar 0 
/varset TempElements 0 
/varset Letters "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" 

/if (${Defined[SearchName]}) {
} else {
    /declare SearchName local 
    /varset SearchName ""
}
/if (${String["@SearchName"].Length}==0) {
    /echo -(( You must provide a name to search for! ))- 
} else {
    /for ParseLetters 0 to ${Math.Calc[${String["@Letters"].Length}-1].Int}
        /varset TempVar 0 
        :SSearchCheckLoop 

        /if (${String["@LinkArray(@ParseLetters,@TempVar)"].Equal["UNDEFINED-ARRAY-ELEMENT"]}) /goto :DoneWithSSearchLetter 

        /if (${String["@LinkArray(@ParseLetters,@TempVar)"].Find["@SearchName"]}) {
            /if (${String["@SendChannel"].Equal["NULL"]}) {
                /varadd SearchCount 1 
                /if (@SearchCount>1) /if (@SearchCount<7) /varcat ItemList ", "
                /if (@SearchCount<7) /varcat ItemList "@LinkArray(@ParseLetters,@TempVar)"
            } else { 
                /varadd SearchCount 1 
                /if (@SearchCount>1) /if (@SearchCount<${Math.Calc[@RemoteSearchCount+1]}) /varcat ItemList ", "
                /if (@SearchCount<${Math.Calc[@RemoteSearchCount+1]}) /varcat ItemList "@LinkArray(@ParseLetters,@TempVar)"
                /if (@SearchCount>${Math.Calc[@RemoteSearchCount+1]}) /goto :SSearchBreakOut
            } 
        } 
        /varadd TempVar 1 
        /goto :SSearchCheckLoop 
        :DoneWithSSearchLetter 
    /next ParseLetters 
        :SSearchBreakOut 

    /if (${String["@SendChannel"].Equal["NULL"]}) {
        /if (@SearchCount>0) {
            /chat #CHATROOM @ItemList 
            /if (@SearchCount>6) {
                /echo -[ Search resulted in [${Int[@SearchCount]}] records, only 6 have been sent to your chat channel.  Please refine your search.]- 
            } else { 
                /echo -[ Search resulted in [${Int[@SearchCount]}] ${If[@SearchCount==1,record,records]}, ${If[@SearchCount==1,it has,they have]} been sent to your chat channel. ]- 
            } 
        } 
    } else { 
        /if (@SearchCount>0) {
            /call SendChatResult "@SendChannel" 
        } 
    } 
}
/if (@SearchCount==0) { 
    /echo -(( No Entries Found! ))- 
} else { 
    /echo -[ Search Complete ]- 
} 
/return 


Sub INIShow(List,Key,SendChannel) 
/varset ItemList ""
/if (${Defined[SendChannel]}) {
} else {
    /declare SendChannel local 
    /varset SendChannel "NULL" 
}
/declare TempItem local 
/declare ParseLetters local
/declare Letters local 
/varset Letters "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" 
/for ParseLetters 0 to ${Math.Calc[${String["@Letters"].Length}-1].Int}
    /if (${String["@List"].Equal["${String["@Letters"].Mid[${Math.Calc[@ParseLetters+1]},1]}"]}) /goto :BreakOutINIShow
/next ParseLetters

:BreakOutINIShow

/if (${String["@LinkArray(@ParseLetters,@Key)"].Equal["UNDEFINED-ARRAY-ELEMENT"]}) {
    /echo -(( Entry Not Found! ))- 
    /goto :DoneShow 
} 
/varset ItemList "@LinkArray(@ParseLetters,@Key)" 

/if (${String["@SendChannel"].Equal["NULL"]}) {
    /chat #CHATROOM @ItemList 
} else { 
    /call SendChatResult "@SendChannel"    
} 
/echo -[ Show Complete ]- 
:DoneShow 
/return 


Sub SendChatResult(MsgText) 
        /if (${String["@MsgText"].Left[5].Equal["/chat"]}) {
            /if (${String["@MsgText"].Find["itemlink"]}) {
                /chat ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to chat channel ${String["@MsgText"].Arg[2]}. ]- 
                /goto :DoneChannSend 
            } else { 
                /chat ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]} @ItemList 
                /echo -[ Search result sent to chat channel ${String["@MsgText"].Arg[2]}. ]- 
                /goto :DoneChannSend 
            } 
        } 
        /if (${String[${String["@MsgText"].Left[3]}].Equal["/gu"]}) {
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /gu ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to guild channel. ]- 
                /goto :DoneChannSend 
            } else { 
                /gu ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to guild channel. ]- 
                /goto :DoneChannSend 
            } 
        } 
        /if (${String[${String["@MsgText"].Left[2]}].Equal["/g"]}) {
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /gsay ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to group. ]- 
                /goto :DoneChannSend 
            } else { 
                /gsay ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to group. ]- 
                /goto :DoneChannSend 
            } 
        }
        /if (${String[${String["@MsgText"].Left[3]}].Equal["/sa"]}) {
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /say ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to say. ]- 
                /goto :DoneChannSend 
            } else { 
                /say ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to say. ]- 
                /goto :DoneChannSend 
            } 
        }
        /if (${String[${String["@MsgText"].Left[4]}].Equal["/ooc"]}) { 
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /ooc ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to ooc channel. ]- 
                /goto :DoneChannSend 
            } else { 
                /ooc ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to ooc channel. ]- 
                /goto :DoneChannSend 
            } 
        }
        /if (${String[${String["@MsgText"].Left[5]}].Equal["/shou"]}) {  
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /shout ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to shout channel. ]- 
                /goto :DoneChannSend 
            } else { 
                /shout ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to shout channel. ]- 
                /goto :DoneChannSend 
            } 
        }
        /if (${String[${String["@MsgText"].Left[2]}].Equal["/t"]}) {   
            /if (${String["@MsgText"].Find["itemlink"]}) {
                /tell ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent via tell to ${String["@MsgText"].Arg[2]}. ]- 
                /goto :DoneChannSend 
            } else { 
                /tell ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]} @ItemList 
                /echo -[ Search result sent via tell to ${String["@MsgText"].Arg[2]}. ]- 
                /goto :DoneChannSend 
            } 
        }
        /if (${String[${String["@MsgText"].Left[2]}].Equal["/m"]}) {    
            /if (${String["@MsgText"].Find["itemlink"]}) {
                /msg ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent via msg to ${String["@MsgText"].Arg[2]}. ]- 
                /goto :DoneChannSend 
            } else { 
                /msg ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]} @ItemList 
                /echo -[ Search result sent via msg to ${String["@MsgText"].Arg[2]}. ]- 
                /goto :DoneChannSend 
            } 
        }
        /if (${String[${String["@MsgText"].Left[4]}].Equal["/auc"]}) {    
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /auction ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to auction channel. ]- 
                /goto :DoneChannSend 
            } else { 
                /auction ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to auction channel. ]- 
                /goto :DoneChannSend 
            } 
        }
        /if (${String[${String["@MsgText"].Left[3]}].Equal["/rs"]}) {     
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /rsay ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to raid channel. ]- 
                /goto :DoneChannSend 
            } else { 
                /rsay ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to raid channel. ]- 
                /goto :DoneChannSend 
            } 
        }
        /if (${String[${String["@MsgText"].Left[3]}].Equal["/10"]}) { 
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /10 ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to chat channel 10. ]- 
                /goto :DoneChannSend 
            } else { 
                /10 ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to chat channel 10. ]- 
                /goto :DoneChannSend 
            } 
        } 
        /if (${String[${String["@MsgText"].Left[2]}].Equal["/1"]}) {
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /1 ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to chat channel 1. ]- 
                /goto :DoneChannSend 
            } else { 
                /1 ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to chat channel 1. ]- 
                /goto :DoneChannSend 
            } 
        }
        /if (${String[${String["@MsgText"].Left[2]}].Equal["/2"]}) { 
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /2 ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to chat channel 2. ]- 
                /goto :DoneChannSend 
            } else { 
                /2 ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to chat channel 2. ]- 
                /goto :DoneChannSend 
            } 
        }
        /if (${String[${String["@MsgText"].Left[2]}].Equal["/3"]}) { 
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /3 ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to chat channel 3. ]- 
                /goto :DoneChannSend 
            } else { 
                /3 ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to chat channel 3. ]- 
                /goto :DoneChannSend 
            } 
        }
        /if (${String[${String["@MsgText"].Left[2]}].Equal["/4"]}) { 
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /4 ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to chat channel 4. ]- 
                /goto :DoneChannSend 
            } else { 
                /4 ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to chat channel 4. ]- 
                /goto :DoneChannSend 
            } 

        }
        /if (${String[${String["@MsgText"].Left[2]}].Equal["/5"]}) { 
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /5 ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to chat channel 5. ]- 
                /goto :DoneChannSend 
            } else { 
                /5 ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to chat channel 5. ]- 
                /goto :DoneChannSend 
            } 

        }
        /if (${String[${String["@MsgText"].Left[2]}].Equal["/6"]}) { 
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /6 ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to chat channel 6. ]- 
                /goto :DoneChannSend 
            } else { 
                /6 ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to chat channel 6. ]- 
                /goto :DoneChannSend 
            } 

        }
        /if (${String[${String["@MsgText"].Left[2]}].Equal["/7"]}) { 
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /7 ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to chat channel 7. ]- 
                /goto :DoneChannSend 
            } else { 
                /7 ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to chat channel 7. ]- 
                /goto :DoneChannSend 
            } 

        } 
        /if (${String[${String["@MsgText"].Left[2]}].Equal["/8"]}) {
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /8 ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to chat channel 8. ]- 
                /goto :DoneChannSend 
            } else { 
                /8 ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to chat channel 8. ]- 
                /goto :DoneChannSend 
            } 

        }
        /if (${String[${String["@MsgText"].Left[2]}].Equal["/9"]}) { 
            /if (${String["@MsgText"].Find["itemlink"]}) { 
                /9 ${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Find["itemlink"]}-${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int}].Int}]} @ItemList ${If[${String["@MsgText"].Find["itemlink"]}>0,${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find["itemlink"]}+8].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find["itemlink"]}+8].Int}]},]}
                /echo -[ Search result sent to chat channel 9. ]- 
                /goto :DoneChannSend 
            } else { 
                /9 ${If[${String["@MsgText"].Find[" "]},${String["@MsgText"].Mid[${Math.Calc[${String["@MsgText"].Find[" "]}+1].Int},${Math.Calc[${String["@MsgText"].Length}-${String["@MsgText"].Find[" "]}].Int}]},]} @ItemList 
                /echo -[ Search result sent to chat channel 9. ]- 
                /goto :DoneChannSend 
            } 

        } 
:DoneChannSend 
/return 

Sub LoadMasterList 
/declare TempVar local 
/declare TempList local 
/varset TempVar 0 

:ClearMasters 

/varset TempList "${Ini[autolink.ini,Masters,${Int[@TempVar]},NOTFOUND]}"
/if (${String["@TempList"].Equal["NOTFOUND"]}) /goto :DoneClearMasters
/varset MasterList(@TempVar) "Empty" 
/varadd TempVar 1 
/goto :ClearMasters 

:DoneClearMasters 
/varset TempVar 0 
:LoadMasters 
/varset MasterList(@TempVar) "${Ini[autolink.ini,Masters,${Int[@TempVar]},NOTFOUND]}"
/if (${String["@MasterList(@TempVar)"].Equal["NOTFOUND"]}) /return
/varadd TempVar 1 
/goto :LoadMasters 
/return 


Sub Event_Master(EvtText) 
/varset BusyEvent 1 
/declare TempItem local 
/declare TempVar local 
/declare TempVar2 local 
/varset TempVar 0

/varset EvtText "${String["@EvtText"].Mid[14,${Math.Calc[${String["@EvtText"].Length}-13].Int}]}"

/if (${String["@EvtText"].Length}>0) {
    :MasterSearch 
    /varset TempItem "${Ini[autolink.ini,Masters,${Int[@TempVar]},NOTFOUND]}"
    /if (${String["@TempItem"].Equal["NOTFOUND"]}) /goto :AddMaster
    /if (${String["@TempItem"].Equal["@EvtText"]}) {
        /echo -[ @EvtText REMOVED from Master list. ]- 
        /ini "autolink.ini" "Masters" "${Int[@TempVar]}" "Empty" 
        /goto :DoneMaster 
    } 
    /varadd TempVar 1 
    /goto :MasterSearch 
    :AddMaster 
    /varset TempVar 0 
    :AddMasterLoop 
    /varset TempItem "${Ini[autolink.ini,Masters,${Int[@TempVar]},NOTFOUND]}"
    /if (${String["@TempItem"].Equal["Empty"]}) /goto :FoundMasterSlot
    /if (${String["@TempItem"].Equal["NOTFOUND"]}) /goto :FoundMasterSlot

    /varadd TempVar 1 
    /goto :AddMasterLoop 
    :FoundMasterSlot 
    /echo -[ @EvtText ADDED to Master list. ]- 
    /ini "autolink.ini" "Masters" "${Int[@TempVar]}" "@EvtText" 
} else { 
    /varset TempVar2 0 
    /echo -[ Allowed Masters ]- 
    :MasterList 

    /varset TempItem "${Ini[autolink.ini,Masters,${Int[@TempVar]},NOTFOUND]}"
    /if (${String["@TempItem"].Equal["NOTFOUND"]}) /goto :DoneMasterList 
    /varadd TempVar 1 
    /if (${String["@TempItem"].NotEqual["Empty"]}) {
        /varadd TempVar2 1 
        /echo -- Master[${Int[@TempVar2]}] @TempItem 
    } 
    /goto :MasterList 
    :DoneMasterList 
    /if (@TempVar2==0) /echo -( No Masters Found )- 
  
} 
:DoneMaster 
/call LoadMasterList 
/varset BusyEvent 0 
/return 


Sub Event_LinkAdd(EvtText) 
/varset BusyEvent 1 
/varset EvtText "${String["@EvtText"].Mid[11,${Math.Calc[${String["@EvtText"].Length}-10].Int}]}"
/if (${String["@EvtText"].Length}>0) /call INIAdd "@EvtText" 0 
/varset BusyEvent 0 
/return 

Sub Event_LinkEdit(EvtText) 
/varset BusyEvent 1 
/varset EvtText "${String["@EvtText"].Mid[12,${Math.Calc[${String["@EvtText"].Length}-11].Int}]}"
/if (${String["@EvtText"].Length}>0) /call INIEdit "@EvtText"
/varset BusyEvent 0 
/return 

Sub Event_LinkList(EvtText) 
/varset BusyEvent 1 
/varset EvtText "${String["@EvtText"].Mid[12,${Math.Calc[${String["@EvtText"].Length}-11].Int}]}"
/if (${String["@EvtText"].Length}==0) {
    /call INIList 
} else { 
    /call INIList "${String["@EvtText"].Arg[1]}" 
} 
/varset BusyEvent 0 
/return 

Sub Event_LinkNameSearch(EvtText) 
/varset BusyEvent 1 
/varset EvtText "${String["@EvtText"].Mid[14,${Math.Calc[${String["@EvtText"].Length}-13].Int}]}"
/if (${String["@EvtText"].Length}>0) {
    /call ININameSearch "@EvtText"
} else { 
    /echo -(( You must provide a name to search for! ))-    
} 
/varset BusyEvent 0 
/return 

Sub Event_LinkShowSearch(EvtText) 
/varset BusyEvent 1 
/declare ChannelArg local 
/varset EvtText "${String["@EvtText"].Mid[15,${Math.Calc[${String["@EvtText"].Length}-14].Int}]}"
/if (${String["@EvtText"].Length}>0) {
    /if (${String["@EvtText"].Find["/"]}) {
        /varset ChannelArg "${String["@EvtText"].Mid[${String["@EvtText"].Find["/"]},${Math.Calc[${String["@EvtText"].Length}-${String["@EvtText"].Find["/"]}+1].Int}]}"
        /varset EvtText "${String["@EvtText"].Mid[1,${Math.Calc[${String["@EvtText"].Find["/"]}-2].Int}]}"
        /call INIShowSearch "@EvtText" "@ChannelArg" 
    } else { 
        /call INIShowSearch "@EvtText" 
    } 
} else { 
    /echo -(( You must provide a name to search for! ))-    
} 
/varset BusyEvent 0 
/return 

Sub Event_LinkShow(EvtText) 
/varset BusyEvent 1 
/declare ChannelArg local 
/varset EvtText "${String["@EvtText"].Mid[12,${Math.Calc[${String["@EvtText"].Length}-11].Int}]}"

/if (${String["@EvtText"].Length}>0) {
    /if (${String["@EvtText"].Find["/"]}) {
        /if (${String["${String["@EvtText"].Arg[1]}"].Length}>0) {
            /if (${String["${String["@EvtText"].Arg[2]}"].Length}>0) {
                /varset ChannelArg "${String["@EvtText"].Mid[${String["@EvtText"].Find["/"]},${Math.Calc[${String["@EvtText"].Length}-${String["@EvtText"].Find["/"]}+1].Int}]}"
                /varset EvtText "${String["@EvtText"].Mid[1,${Math.Calc[${String["@EvtText"].Find["/"]}-2].Int}]}"
                /call INIShow "${String["@EvtText"].Arg[1].Left[1]}" "${String["@EvtText"].Arg[2]}" "@ChannelArg"     
            } 
        } 
    } else {
        /if (${String["@EvtText"].Arg[1].Length}>0) {
            /if (${String["@EvtText"].Arg[2].Length}>0) {
                /call INIShow "${String["@EvtText"].Arg[1].Left[1]}" "${String["@EvtText"].Arg[2]}"
            } 
        } 
    } 
} else { 
    /echo -(( You must provide a list letter and key number in order to display the link! ))-    
} 
/varset BusyEvent 0 
/return 

Sub Event_Silent 
/varset BusyEvent 1 
/if (@SilentVar==1) { 
    /varset SilentVar 0 
    /echo -[ Silent Mode OFF ]- 
} else { 
    /varset SilentVar 1 
    /echo -[ Silent Mode ON ]- 
} 
/varset BusyEvent 0 
/return 

Sub Event_Restart 
/varset BusyEvent 1 
/if (@RestartWindow==1) { 
    /varset RestartWindow 0 
    /echo -[ Restart Window Mode OFF ]- 
} else { 
    /varset RestartWindow 1 
    /echo -[ Restart Window Mode ON ]- 
} 
/varset BusyEvent 0 
/return 

Sub Event_LootedA(EvtText) 
/call Event_chat "null" "null" "@EvtText" 
/return 

Sub Event_LootedB(EvtText) 
/call Event_chat "null" "null" "@EvtText" 
/return 


Sub Event_chat(MsgType,MsgFrom,MsgText) 
/varset BusyEvent 1 
/declare ParseItems local 
/declare Item local 
/declare FirstPoint local 
/declare SecondPoint local 
/declare CheckForMarker local 
/declare TempVar local 


/varset TempVar 0 
:CheckAuth 
/if (${String["@MasterList(@TempVar)"].NotEqual["UNDEFINED-ARRAY-ELEMENT"]}) {
    /if (${String["@MasterList(@TempVar)"].Equal["@MsgFrom"]}) {
        /if (${String["${String["@MsgText"].Mid[1,${String["@RemotePhrase"].Length}]}"].Find["@RemotePhrase"]}) { 
            /echo -[ Remote Search from [@MsgFrom] searching for [${String["@MsgText"].Mid[${Math.Calc[${String["@RemotePhrase"].Length}+2].Int},${Math.Calc[${String["@MsgText"].Length}-${Math.Calc[${String["@RemotePhrase"].Length}+1].Int}].Int}]}] ]- 
            /call Event_LinkShowSearch "[MQ2] ssearch ${String["@MsgText"].Mid[${Math.Calc[${String["@RemotePhrase"].Length}+2].Int},${Math.Calc[${String["@MsgText"].Length}-${Math.Calc[${String["@RemotePhrase"].Length}+1].Int}].Int}]} /tell @MsgFrom Here ya go: itemlink :^)" 
            /varset BusyEvent 0 
            /return 
        } 
    } 
    /varadd TempVar 1 
    /goto :CheckAuth 
} 

:NextItem 
/varset CheckForMarker 99999999 
/if (${String["@MsgText"].Find[""]}) /varset CheckForMarker ${String["@MsgText"].Find[""]}
/if (@CheckForMarker!=99999999) { 
    /varset FirstPoint 0 
    /varset SecondPoint 0 
    /varset FirstPoint ${Math.Calc[${String["@MsgText"].Find[""]}-1].Int}

    /if (${String["@MsgText"].Mid[${Math.Calc[@FirstPoint+2].Int},${Math.Calc[${String["@MsgText"].Length}-1].Int}].Find[""]}) {
        /varset SecondPoint ${Math.Calc[${String["@MsgText"].Mid[${Math.Calc[@FirstPoint+2].Int},${Math.Calc[${String["@MsgText"].Length}-1].Int}].Find[""]}-1].Int}
        /varset Item "${String["@MsgText"].Mid[${Math.Calc[@FirstPoint+1].Int},${Math.Calc[@SecondPoint+2].Int}]}"
        /varset MsgText "${String["@MsgText"].Mid[${Math.Calc[@FirstPoint+@SecondPoint+3].Int},${Math.Calc[${String["@MsgText"].Length}-${Math.Calc[@FirstPoint+@SecondPoint+2].Int}].Int}]}"
     
        /if (${String["@Item"].Length}>0) {
            /if (${String["@Item"].Length}>46) { 
                /call INIAdd "@Item" 1
            } else { 
                /goto :SkipLink 
            } 
        } 
        :SkipLink 
        /if (${String["@MsgText"].Find[""]}) /goto :NextItem 
    } 
} 
/varset BusyEvent 0 
/return 
Last edited by ml2517 on Fri Apr 23, 2004 8:02 pm, edited 40 times in total.

User avatar
wilso132
Contributing Member
Contributing Member
Posts: 106
Joined: Thu Oct 17, 2002 11:53 am

Post by wilso132 » Mon Jan 19, 2004 1:56 am

Amazing... can't wait to try it out tomorrow. Great work as always.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Mon Jan 19, 2004 3:29 am

Fixed a possible duplicate entry issue, since there are all sorts of different flavors of a particular item with the advent of LDoN.

Added more channels to monitor. If there are any I missed please let me know.

Spanky_Monkey
a ghoul
a ghoul
Posts: 103
Joined: Wed Feb 19, 2003 3:10 pm

Now this is pimp...

Post by Spanky_Monkey » Mon Jan 19, 2004 5:19 am

I will never run my bazaar trader without this again... ever
Nice!

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Mon Jan 19, 2004 11:06 pm

Updated:
Fixed an issue that could cause your eq client to freeze up.

Changed the way the show command works. No longer does a search, you specify the list letter and the key number to display the link. These are found by doing a search or a list for the item.

I'm still trying to track down an issue that bogs your machine down after awhile. Not sure what it is yet but I'll post if/when I figure it out.

Edit: The bogging issue is with chat windows in EQ. As more and more gets echo'd to the MQ2 chat window it is bogging it down slower and slower. The solution is to minimize the MQ2 chat window when you are going to be leaving it running a long time. Unfortunately there doesn't appear to be a /clear type command for the MQ2 chat window.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Tue Jan 20, 2004 12:30 am

Update:

Where there is a will, there is a way. Figured out an interesting way to clear the MQ2 window. Not sure why it didn't jump out at me in the first place hehe. I now unload and re-load the chat window every 30 minutes to clear off the spam. For the hell of it I'm also flushing the /doevents queue and zapping all the vars as well.

From what I can tell its running nicely now.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Tue Jan 20, 2004 9:31 am

Update:

Fixed a looping situation that could cause some serious bogging down and figured out it is when people put a > in their messages it would completely bomb the macro. I'm now parsing > and < out and replacing them with harmless characters.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Tue Jan 20, 2004 6:58 pm

Update:

Ok.. still had problems parsing the bad characters so I instituted a fugly parsing method below. Its the only one that seems to actually work at parsing the <>=~ characters.

Seems to work great now.

I should also note that the slowly bogging down issue with the chat/mq2 window history filling up is still there. That is why I unload the plugin/clear the screen every 30 minutes still.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Tue Jan 20, 2004 10:58 pm

Update:

Added silent function at start and also toggle-able on the fly. This only suppresses the automatic link additions.

Added restart window every 30 minutes function and toggle-able on the fly.

I'm probably done with this unless someone finds a bug or thinks of a must have feature. Enjoy.

mcswanbeck
a lesser mummy
a lesser mummy
Posts: 70
Joined: Fri Jan 16, 2004 5:16 am

Post by mcswanbeck » Wed Jan 21, 2004 4:04 am

I tried this out yesterday and always love it :)
However there are a few things I'd like to ask about...

1) I tried to remove the /clear from the mainloop, which MAYBE resulted in some wierd errors at (line 412):

Code: Select all

/if "@MsgText"~~"" /varset CheckForMarker $instr("","@MsgText")
I'm not 100% sure that removing the /clear is the cause of this, but else there is something else wrong... I'll try to get the exact info when I get home from work.
I know you've written somethnig about the reload/clear thing, but isn't there a way around this?

2) Is there any chance to make some sort of combined partial search'n'show (let's call it sshow here), so if I make a /echo sshow shinai then it searches for shinai* and if it only finds one match, then it shows that match to the specified chat channel. Just an idea :)

It's not a major problem just a small idea as I like this macro alot and am in chat channels where links are often tossed around ;)
/mcswanbeck

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Wed Jan 21, 2004 4:35 am

Make sure you critique the current version I have posted. There were alot of bug fixes.

I have the 2 new options I'd just added tonight which should address your /clear issue.

If you aren't going to reload the windows every 30 minutes I'd make sure you have silent mode on.

You *will* see very slow degradation and there is nothing I can do about it if you aren't doing a /clear and reloading the window once in awhile. You might have a great machine though and could go a full day without doing this so thats why I made it optional now.

If you have alot of text history in your windows and would like to keep it there it also seems to help if you minimize your windows. Anyways, its either and EQ or MQ2 issue and nothing I can address via the macro except what I've come up with.

I *can* add a "show and search" type command, in fact I'd started it off opting for a search that yielded one result. The reason why I chose to change it to providing an index was for speed of lookup and for security knowing that I'm not going to spam a chat channel with 1000 links in a matter of a few seconds hehe.

I guess what I could do is have it link a maximum of say 5 links per "search and show". Maybe if you exceed 5 hits tell you the total your search actually resulted to your MQ2 window and tell you to refine your search.

I'll see what I can come up with.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Wed Jan 21, 2004 5:23 am

Updated:

Added the ssearch feature. This displays a maximum of 6 records to your chat channel. It will inform you of the total number of the search in your mq2 chat window.

Now displaying the total records returned in the normal search as well.

mcswanbeck
a lesser mummy
a lesser mummy
Posts: 70
Joined: Fri Jan 16, 2004 5:16 am

Post by mcswanbeck » Wed Jan 21, 2004 6:01 am

Wow... That was fast :)

It was version 1/20/2004 8:30am I saw the error in. I tried to remove the /clear simply to avoid loosing the text in my main chat window.

Looking forward to test it out...
/mcswanbeck

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Fri Jan 23, 2004 12:36 am

Updated:
Minor changes. Just corrected the output when returning 1 search result as opposed to searches that result in greater than one hit.

mcswanbeck
a lesser mummy
a lesser mummy
Posts: 70
Joined: Fri Jan 16, 2004 5:16 am

Post by mcswanbeck » Fri Jan 23, 2004 5:00 am

I simply love this - it works fine now and I don't even notice it's running :D

Another small request though:
Make an optional parameter to the ssearch function like:

Code: Select all

/echo ssearch shinai /gu (sends the output to /gu if exactly ONE item is found)
/echo ssearch shinai /3 (sends the output to chat channel 3 if exactly ONE item is found)
... and maybe even:

Code: Select all

/echo ssearch shinai /tell johndoe (sends the output as a tell to johndoe if exactly ONE item is found)
If nothing is specified after the search word, then just send the output to the channel specified in the macro file.

Does that make sense?
/mcswanbeck