Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="iso-8859-1"?>
- <!DOCTYPE muclient>
- <muclient>
- <plugin
- name="Friends_List"
- author="Fumino"
- id="8a1bb56bff11f9cdd21d98e3"
- language="Lua"
- purpose="Friends List"
- date_written="2016-07-23 00:10:31"
- requires="4.51"
- version="1.0"
- save_state="y"
- >
- <description trim="y">
- </description>
- </plugin>
- <triggers>
- <trigger
- enabled="n"
- keep_evaluating="y"
- match="*"
- name="whoRead"
- script="who_read"
- sequence="100">
- </trigger>
- </triggers>
- <aliases>
- <alias
- match="add friend *"
- send_to="12"
- enabled="y"
- sequence="100">
- <send>who = "%1"
- who_addF(who)</send>
- </alias>
- <alias
- match="remove friend *"
- send_to="12"
- enabled="y"
- sequence="100">
- <send>who = "%1"
- who_remF(who)</send>
- </alias>
- <alias
- match="add enemy *"
- send_to="12"
- enabled="y"
- sequence="100">
- <send>who = "%1"
- who_addE(who)</send>
- </alias>
- <alias
- match="remove enemy *"
- send_to="12"
- enabled="y"
- sequence="100">
- <send>who = "%1"
- who_remE(who)</send>
- </alias>
- <alias
- script="who_list"
- match="who"
- enabled="y"
- sequence="100">
- </alias>
- <alias
- script="whoToggle"
- match="who hud *"
- enabled="y"
- sequence="100">
- </alias>
- <alias
- script="who_help"
- match="who help"
- enabled="y"
- sequence="100">
- </alias>
- <alias
- script="showFriends"
- match="show friends"
- enabled="y"
- sequence="100">
- </alias>
- <alias
- script="showFriends"
- match="view friends"
- enabled="y"
- sequence="100">
- </alias>
- <alias
- script="showEnemies"
- match="show enemies"
- enabled="y"
- sequence="100">
- </alias>
- <alias
- script="showEnemies"
- match="view enemies"
- enabled="y"
- sequence="100">
- </alias>
- <alias
- script="clearFriends"
- match="clear friends list"
- enabled="y"
- sequence="100">
- </alias>
- <alias
- script="clearEnemies"
- match="clear enemies list"
- enabled="y"
- sequence="100">
- </alias>
- </aliases>
- <script>
- <![CDATA[
- function OnPluginInstall ()
- require "pairsbykeys"
- PLUGIN_VERSION = GetPluginInfo(GetPluginID(), 19)
- if PLUGIN_VERSION == 1 then
- PLUGIN_VERSION = 1 .. "." .. 0
- end -- PLUGIN_VERSION
- PLUGIN_NAME = GetPluginInfo(GetPluginID(), 1)
- wListStyles, wListRCN, wListRaces, wListClasses, wListNames = {}, {}, {}, {}, {}
- if GetVariable("friendsC") == nil then
- SetVariable("friendsC", ColourNameToRGB("steelblue"))
- else
- friendsC = GetVariable("friendsC")
- end -- friendsC
- if GetVariable("enemiesC") == nil then
- SetVariable("enemiesC", ColourNameToRGB("red"))
- else
- enemiesC = GetVariable("enemiesC")
- end -- enemiesC
- who_hud = "who_hud" -- Who List Heads-up Display Window
- --if GetVariable("wHud_pos") == nil then
- SetVariable("wHud_pos", "6")
- --end -- default to top right corner if first run
- -- Rebuild Friends & Enemies tables
- require "serialize"
- who_friends = {}
- assert (loadstring (GetVariable ("who_friends") or "")) ()
- who_enemies = {}
- assert (loadstring (GetVariable ("who_enemies") or "")) ()
- -- Dummy window to get font characteristics
- WindowCreate (who_hud, 0, 0, 1, 1, 12, 2, 0x000000)
- font = "f"
- WindowFont (who_hud, font, "November", 10)
- max_width = WindowTextWidth (who_hud, font, "W")
- -- Display welcome message.
- who_help ()
- end -- function OnPluginInstall
- function OnPluginSaveState ()
- SetVariable ("who_friends", serialize.save ("who_friends"))
- SetVariable ("who_enemies", serialize.save ("who_enemies"))
- end -- function OnPluginSaveState
- function OnPluginEnable ()
- if GetVariable("wHudWin_Visi") == "true" then
- WindowShow (who_hud, true)
- else
- SetVariable("wHudWin_Visi", "false") -- in case first run and nil
- WindowShow (who_hud, false)
- end -- wHudWin_Visi
- end -- function OnPluginEnable
- function OnPluginDisable ()
- WindowShow (who_hud, false)
- end -- function OnPluginDisable
- function OnPluginClose ()
- if GetPluginInfo (GetPluginID(), 17) then
- OnPluginDisable()
- end -- if enabled
- end -- function OnPluginClose
- ----/ Add a friend (who_addF) /----
- function who_addF (who)
- who_friends [who] = true
- print(who .. " has been added to the Friends List")
- who_win ()
- end -- function who_addF
- ----/ Remove a friend (who_remF) /----
- function who_remF (who)
- who_friends [who] = nil
- print(who .. " has been removed from the Friends List")
- who_win ()
- end -- function who_remF
- ----/ Add an enemy (who_addE) /----
- function who_addE (who)
- who_enemies [who] = true
- print(who .. " has been added to the Enemies List")
- who_win ()
- end -- function who_addE
- ----/ Remove an enemy (who_remE) /----
- function who_remE (who)
- who_enemies [who] = nil
- print(who .. " has been removed from the Enemies List")
- who_win ()
- end -- function who_remE
- ----/ Read & Store Who List /----
- function who_read (name, line, wildcards, styles)
- -- Stop reading at first blank line
- if string.match (line, "^$") then
- EnableTrigger("whoRead", false)
- if GetVariable("wHudWin_Visi") == "true" then
- who_win ()
- end -- wHudWin_Visi
- else
- -- Matching only up to name
- whoRCN = string.match (line, "^(.- %] %a+)") -- Race Classes Name
- if whoRCN == nil then
- whoRCN = line
- end -- whoRCN
- -- Matching each section out into own variables
- whoRa = string.match(whoRCN, "^(%a+ .-)") -- Race
- whoCl = string.match(whoRCN, "^.-(%[.*%])") -- Classes
- whoNa = string.match(whoRCN, " (%a+)$") -- Name
- -- Storing the styles for text color
- table.insert (wListStyles, styles)
- -- Storing everything else
- if whoRCN ~= nil then
- wListRCN [whoRCN] = true
- max_width = math.max (max_width, WindowTextWidth (who_hud, font, whoRCN))
- end -- whoRCN
- if whoRa ~= nil and whoCl ~= nil and whoNa ~= nil then
- wListRaces [whoRa] = true
- wListClasses [whoCl] = true
- wListNames [whoNa] = true
- end -- check before adding into tables
- -- work out max width
- end -- string.match
- end -- function who_read
- ----/ "who" alias script /----
- function who_list ()
- -- Clear all tables
- wListStyles, wListRCN, wListRaces, wListClasses, wListNames = {}, {}, {}, {}, {}
- Send "who"
- -- Start reading and storing every line
- EnableTrigger("whoRead", true)
- end -- function who_read
- ----/ Who List Heads-up Display Window /----
- function who_win ()
- if GetVariable("wHudWin_Visi") == "true" then
- local font_height = WindowFontInfo (who_hud, font, 1)
- local wHud_width = max_width + 10
- local wHud_height = font_height * (#wListRCN + 2) + 70
- wHud_left, wHud_top = GetInfo(264) - wHud_width, 0
- WindowCreate (who_hud, wHud_left, wHud_top, wHud_width + 20, wHud_height, 4, GetVariable("wHud_pos"), 0x000000)
- --WindowCreate (who_hud, wHud_left, wHud_top, wHud_left, 300, 4, GetVariable("wHud_pos"), ColourNameToRGB("darkgreen"))
- if wListStyles ~= nil then
- local y = font_height * 2 + 5
- for i, styles in ipairs (wListStyles) do
- local x = 3
- for _, style in ipairs (styles) do
- if style.text == string.match(style.text, "^(.*Total.*)") then
- x = x + WindowText (who_hud, font, style.text, 25, y + 1, 0, 0, ColourNameToRGB("gold"))
- else
- --/ Comparing Friends & Enemies list to current Who List and coloring accordingly /--
- for k, v in pairs (wListNames) do
- for c, h in pairs (wListClasses) do
- if who_friends [k] then
- -- color friends if online
- x = x + WindowText (who_hud, font, k, x, y + 15, 0, 0, friendsC)
- WindowText (who_hud, font, c, 80, y + 15, 0, 0, friendsC)
- elseif who_enemies [k] then
- -- color enemies if online
- x = x + WindowText (who_hud, font, whoNa, x, y + 15, 0, 0, enemiesC)
- WindowText (who_hud, font, c, 80, y + 15, 0, 0, enemiesC)
- else
- x = x + WindowText (who_hud, font, k, x, y + 15, 0, 0, style.textcolour)
- WindowText (who_hud, font, c, 80, y + 15, 0, 0, style.textcolour)
- end -- enemy check names
- end -- for c, h in pairs (wListClasses)
- end -- for k, v in pairs (wListNames)
- y = y + font_height
- end -- total players online
- end -- for _, style in ipairs (styles)
- end -- for i, styles in ipairs (wListStyles)
- else
- WindowText (who_hud, font, "Who List will show up here", 25, 1, 0, 0, ColourNameToRGB("gold"))
- end -- wListStyles not nil
- WindowShow (who_hud, true)
- else
- WindowShow (who_hud, false)
- end -- wHudWin_Visi
- end -- function who_win
- function showFriends ()
- if who_friends ~= nil then
- ColourNote ("white", "", "--------------------------")
- ColourNote ("steelblue", "", " Friends List ")
- ColourNote ("white", "", "--------------------------")
- for k, v in pairsByKeys (who_friends) do
- print (k)
- end -- for
- else
- ColourNote ("red", "", "Friends list empty!")
- end -- who_friends
- end -- function showFriends
- function showEnemies ()
- if who_enemies ~= nil then
- ColourNote ("red", "", "--------------------------")
- ColourNote ("orangered", "", " Enemies List ")
- ColourNote ("red", "", "--------------------------")
- for k, v in pairsByKeys (who_enemies) do
- print (k)
- end -- for
- else
- ColourNote ("red", "", "Enemies list empty!")
- end -- who_enemies
- end -- function showEnemies
- function whoToggle (name, line, wildcards, styles)
- if wildcards[1] == "on" then
- SetVariable("wHudWin_Visi", "true")
- who_list ()
- who_win ()
- elseif wildcards[1] == "off" then
- SetVariable("wHudWin_Visi", "false")
- who_win ()
- else
- ColourNote ("red", "", "Error! ", "silver", "", "commands are: ", "green", "", " who hud on ", "silver", "", "and ", "green", "", "who hud off")
- end -- wildcard on|off
- end -- function whoToggle
- function who_help ()
- Note("")
- ColourNote ("yellow", "", " W", "goldenrod", "", "ho ", "silver", "", "List - ", "green", "", "Friends ", "white", "", "& ", "red", "", "Enemies ", "white", "", "Tracker v1.0")
- ColourNote ("dodgerblue", "", " Plugin ", "silver", "", "Version: ", "green", "", "v" .. PLUGIN_VERSION, "white", "", " " .. PLUGIN_NAME)
- Note("")
- ColourNote ("lime", "", "[ WHO LIST HEADS-UP DISPLAY ]")
- Note("")
- ColourNote ("steelblue", "", "To ", "silver", "", "Activate: ", "green", "", "who hud on")
- ColourNote ("orangered", "", "To ", "silver", "", "Deactivate: ", "green", "", "who hud off")
- Note("")
- ColourNote ("steelblue", "", "[ FRIENDS ]")
- Note("")
- ColourNote ("steelblue", "", "To ", "silver", "", "Add a Friend: ", "green", "", "add friend NAME")
- ColourNote ("orangered", "", "To ", "silver", "", "Remove a Friend: ", "green", "", "remove friend NAME")
- Note("")
- ColourNote ("orangered", "", "[ FOES ]")
- Note("")
- ColourNote ("steelblue", "", "To ", "silver", "", "Add an Enemy: ", "green", "", "add enemy NAME")
- ColourNote ("orangered", "", "To ", "silver", "", "Remove an Enemy: ", "green", "", "remove enemy NAME")
- Note("")
- ColourNote ("white", "", "[ ", "orangered", "", "NAUGHTY ", "white", "", " OR ", "steelblue", "", " NICE ", "white", "", " ]")
- Note("")
- ColourNote ("steelblue", "", "To ", "silver", "", "View Friends List: ", "green", "", "show friends", "silver", "", " | ", "green", "", "view friends")
- ColourNote ("orangered", "", "To ", "silver", "", "View Enemies List: ", "green", "", "show enemies", "silver", "", " | ", "green", "", "view enemies")
- Note("")
- ColourNote ("orange", "", "To ", "silver", "", "Clear Friends List: ", "green", "", "clear friends list")
- ColourNote ("orange", "", "To ", "silver", "", "Clear Enemies List: ", "green", "", "clear enemies list")
- Note("")
- ColourNote ("white", "", "To view this welcome message again, type: ", "green", "", "who help", "white", "", " or view the readme file.")
- Note("")
- end -- function who_help
- function clearFriends ()
- who_friends = {}
- ColourNote ("steelblue", "", "Friends List has been cleared!")
- end -- function clearFriends
- function clearEnemies ()
- who_enemies = {}
- ColourNote ("orangered", "", "Enemies List has been cleared!")
- end -- function clearEnemies
- ]]>
- </script>
- </muclient>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement