<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, October 29, 2018, 1:39 PM -->
<!-- MuClient version 5.06 - pre -->
<!-- Plugin "PK Alert Script" generated by Plugin Wizard -->
<muclient >
<plugin
name="PK_Alert"
author="Cytan_Method"
id="dc7103896128e00c34b21951"
language="Lua"
purpose="Notify to channel PK alert information."
save_state="y"
date_written="2018-10-29 13:37:21"
version="1.6"
>
<description trim= "y" >
< ![CDATA[
Description Here
]]>
</description>
</plugin>
<!-- Get our standard constants -->
<include name= "constants.lua" />
<!-- Triggers -->
<triggers >
<trigger
enabled="y"
match="^(\w+) disappears!$"
regexp="y"
sequence="100"
script="recalled"
>
</trigger>
<trigger
enabled="y"
match="^You grab hold of (.+?)\'s neck and choke \w+ to unconsciousness\!$"
regexp="y"
sequence="100"
script="sendStrangleAlert"
>
</trigger>
<trigger
enabled="y"
match="^(?<target > \w[\w\s]+) looks very uncomfortable\."
regexp="y"
sequence="100"
script="sendCursedAlert"
>
</trigger>
<!-- You switch targets and direct your attacks at Ralyn. -->
<!-- ** You can take revenge on Yatzi for 15 minutes -->
<trigger
enabled="y"
match="^\*\* For \w+ interference, you can take revenge on (.*?) for 15 minutes\.$"
regexp="y"
sequence="100"
script="sendPkAlert"
>
</trigger>
<trigger
enabled="y"
match="^\*\* You can take revenge on (.*?) for 15 minutes\.$"
regexp="y"
sequence="100"
script="sendPkAlert"
>
</trigger>
<trigger
enabled="y"
match="^\*\* (.*?) can now take revenge on you for 15 minutes\.$"
regexp="y"
sequence="100"
script="sendPkAlert"
>
</trigger>
<!--
The prefix characters '\' that YOU need to use are to be found in world properties -> scripts and then look at the top right for the characters in Script.
Room 10676 is in Kimr's Farm. safe room. test with
\Simulate("SuperBuff (Newbie member) tells the CLAN: 'PK Alert:Noddy in Farm [10676].'\n")
-->
<trigger
enabled="y"
match="^(?<clan > .+?)\s\(.+\)\s+tells the CLAN: 'PK Alert:\s+(?<attacker > .+)\s+in\s+(?<area > .+?)\s+\[(?<roomid > \d+)\](?: I am level \d+ \(\d+ - \d+\))?'$"
regexp="y"
sequence="100"
script="outputHyperLink"
ignore_case="y"
keep_evaluating="y"
>
</trigger>
</triggers>
<aliases >
<alias
enabled="y"
match="pkc *"
script="sendPkInfoClan"
sequence="100"
>
</alias>
<alias
enabled="y"
match="pkg *"
script="sendPkInfoGroup"
sequence="100"
>
</alias>
<alias
enabled="y"
sequence="100"
ignore_case="y"
regexp="y"
keep_evaluating="n"
match="^\s*(?:pkadmin|pkadmi|pkadm)\s+(?<Args > .+)?$"
script="COMMAND_PKAdmin"
>
</alias>
<alias
enabled="y"
sequence="100"
ignore_case="y"
regexp="y"
keep_evaluating="n"
match="^\s*(?:pkadmin|pkadmi|pkadm(?<Args > ))$"
script="COMMAND_PKAdmin"
>
</alias>
<alias
enabled="y"
sequence="100"
ignore_case="y"
regexp="y"
keep_evaluating="n"
match="^\s*pk\s*go\s*$"
script="runto_PK_room"
>
</alias>
</aliases>
<script >
< ![CDATA[
-- Settings Management
require 'serialize'
PKASettings = {}
PKASettings.volume = 100
PKASettings.alert = 1
PKASettings.sound = 1
PKASettings.enabled = 1
PKASettings.playerlevel = 1
defLevelRange = 10
PKASettings.levelrange = defLevelRange
local runto_roomid = 0
function SaveSettings()
SetVariable("PKSettings", serialize.save_simple(PKASettings))
end
function LoadSettings()
assert(loadstring("PKASettings = "..GetVariable("PKSettings"))) ()
end
]]></script>
<script >
< ![CDATA[
-- PKAdmin Commands
dofile (GetInfo(60) .. "aardwolf_colors.lua")
Prepend = "@GPKAdmin: @W"
function cnote(str)
AnsiNote(stylesToANSI(ColoursToStyles(str)))
end
-- Turn on the option to have Mushclient Play Sounds while minimized/background
SetOption ("play_sounds_in_background", 1)
PKAdminCommands = {
COMMAND_PKAdmin_Help = {"help", "hel", "he", "h"},
COMMAND_PKAdmin_Alert = {"alert", "aler", "ale" },
COMMAND_PKAdmin_Enable = {"enable", "enabl", "enab", "ena", "on"},
COMMAND_PKAdmin_Disable = {"disable", "disabl", "disab", "disa", "off"},
COMMAND_PKAdmin_Sound = {"sound", "soun", "soun", "sou" },
COMMAND_PKAdmin_Status = {"status", "statu", "stat" },
COMMAND_PKAdmin_Volume = {"volume", "volum", "volu", "vol" },
COMMAND_PKAdmin_LevelRange = {"levelrange", "levelr", "level",},
COMMAND_PKAdmin_Reset = {"reset"}
}
function COMMAND_PKAdmin(name, lines, wildcards)
local args, command = {}, nil
--split args, set first to "command", default to 'help'
for word in string.gmatch(wildcards.Args, "%w+") do table.insert(args, word) end
command = args[1]
if command then table.remove(args,1) else command = "help" end
--parse command
command = string.lower(command)
for func, list in pairs(PKAdminCommands) do
for _, item in ipairs(list) do
if command == item then
return _G[func](args)
end
end
end
OUTPUT_UnrecognizedCommand()
end
function COMMAND_PKAdmin_Help()
cnote("@GPKAdmin")
cnote("@WUsage:")
cnote(" @Gpkadmin help @w: @WThis menu")
cnote(" @Gpkadmin alert <yes / n o > @w: @WTurns on/off channel alerts ")
cnote(" @Gpkadmin sound <yes / n o > @w: @WTurns on/off sound alerts ")
cnote(" @Gpkadmin volume <0-100 > @w: @WSets the play volume for sound")
cnote(" @Gpkadmin levelrange <1-100 > @w: @WSet the range of levels displayed in the PK Alert")
cnote(" @Gpkadmin enable @w: @WEnables the script ")
cnote(" @Gpkadmin disable @w: @WDisables the script ")
Note()
cnote(" @Gpkgo @w: @W\"Runto\" help your clan mate out")
Note()
end
function COMMAND_PKAdmin_Enable()
cnote(Prepend.."PKAnnouncer is now @Genabled@W.")
PKASettings.enabled = 1
SaveSettings()
end
function COMMAND_PKAdmin_Disable()
cnote(Prepend.."PKAnnouncer is now @Rdisabled@W.")
PKASettings.enabled = 0
SaveSettings()
end
OnOffCommands = {
True = {"true", "t", "yes", "y"},
False = {"false", "f", "no", "n"}
}
function COMMAND_PKAdmin_Alert(args)
local enabled, ch = nil
if args and args[1] then
ch = string.lower(args[1])
for enabl, list in pairs(OnOffCommands) do
for _, trunc in ipairs(list) do
if trunc == ch then
enabled = enabl
break
end
end
if enabled then break end
end
if not enabled then --didn't understand arg
cnote(Prepend.."@R"..args[1].." is not a valid option.")
Note()
return
end
end
if enabled == "True" then
PKASettings.alert = 1
cnote(Prepend.."@wAlerts to clan channel are now @GEnabled@w.")
SaveSettings()
elseif enabled == "False" then
PKASettings.alert = 0
cnote(Prepend.."@wAlerts to clan channel are now @RDisabled@w.")
SaveSettings()
end
end
function COMMAND_PKAdmin_Sound(args)
local enabled, ch = nil
if args and args[1] then
ch = string.lower(args[1])
for enabl, list in pairs(OnOffCommands) do
for _, trunc in ipairs(list) do
if trunc == ch then
enabled = enabl
break
end
end
if enabled then break end
end
if not enabled then --didn't understand arg
cnote(Prepend.."@R"..args[1].." is not a valid option.")
Note()
return
end
end
if enabled == "True" then
PKASettings.sound = 1
cnote(Prepend.."@wSound alerts are now @GEnabled@w.")
SaveSettings()
elseif enabled == "False" then
PKASettings.sound = 0
cnote(Prepend.."@wSound alerts are now @RDisabled@w.")
SaveSettings()
end
end
function COMMAND_PKAdmin_Volume(args)
if not tonumber(args[1]) or (tonumber(args[1]) < 0 ) o r ( t o n u m b e r ( a r g s [ 1 ] ) > 100) then
cnote(Prepend.."@RVolume@w requires a number from 0-100." )
Note()
return
end
PKASettings.volume = tonumber(args[1])
SaveSettings()
cnote(Prepend.."@wVolume is now set to @Y"..tonumber(args[1]).."@w.")
end
function COMMAND_PKAdmin_LevelRange(args)
if not tonumber(args[1]) or (tonumber(args[1]) < 0 ) t h e n
cnote(Prepend.."@RLevel Range@w requires a number greater than zero.")
Note()
return
end
PKASettings.levelrange = tonumber(args[1])
SaveSettings()
cnote(Prepend.."@wLevel range is now set to @Y+/-"..PKASettings.levelrange.."@w.")
end
function COMMAND_PKAdmin_Status()
cnote( "@R+@w-----------------------------------------------------------------------------------------@R+@w" )
cnote( " " .. Prepend .. " PKAnnouncer's current status is " .. (PKASettings.enabled == 1 and "@GOn" or "@ROff") .. "@w" )
cnote( "@R+@w-----------------------------------------------------------------------------------------@R+@w" )
cnote( (" @x208Channel Alerts :@w %-30.30s " ):format( PKASettings.alert == 1 and "@GOn@w" or "@ROff@w"))
cnote( (" @x208Sound Alerts :@w %-30.30s " ):format( PKASettings.sound == 1 and "@GOn@w" or "@ROff@w"))
cnote( (" @x208Sound Volume :@w %-30.0d " ):format( PKASettings.volume ) )
cnote( (" @x208Level Range :@w +/-%-30.0d " ):format( PKASettings.levelrange) )
cnote( "@R+@w-----------------------------------------------------------------------------------------@R+@w" )
Note()
end
function COMMAND_PKAdmin_Reset()
PKASettings = {}
PKASettings.volume = 100
PKASettings.alert = 1
PKASettings.sound = 1
PKASettings.enabled = 1
PKASettings.levelrange = defLevelRange
PKASettings.playerlevel = tonumber(gmcp("char.status.level"))
cnote( Prepend.."PKASettings have been reset to defaults." )
SaveSettings()
end
function OUTPUT_UnrecognizedCommand()
cnote(Prepend.."Unrecognized command. Try @Ggadmin help@W for help.")
Note()
end
]]></script>
<script >
< ![CDATA[
require "gmcphelper"
local area = ""
local roomid = ""
local room = ""
local target = ""
local ingroup = false
local chan = "clan "
local varSoundFile = GetInfo(74) .. "redalert.wav"
GMCPPluginID = "3e7dedbe37e44942dd46d264"
function isEnabled()
if PKASettings.enabled == 1 then
return true
else
return false
end
end
function isSoundEnabled()
if PKASettings.sound == 1 then
return true
else
return false
end
end
function isAlertEnabled()
if PKASettings.alert == 1 then
return true
else
return false
end
end
function sendPkInfoClan(name, line, wildcards)
if isEnabled() then
getRoomInformation()
if isAlertEnabled() then
local msg = string.format(" @W%s@C ENGAGED @Win @x202%s @W[@x202%s@W]",wildcards[1], area, roomid)
msg = addLevelRangeText(msg)
SendNoEcho("clan "..msg)
end
target = wildcards[1]
end
end
function recalled(name, line, wildcards)
if isEnabled() and isAlertEnabled() then
if(wildcards[1] == target) then
if (ingroup == true) then
chan = "gt "
else
chan = "clan "
end
SendNoEcho(string.format(chan .. "@W%s@C Recalled!",wildcards[1], area, roomid))
end
end
end
function sendPkInfoGroup(name, line, wildcards)
if isEnabled() and isAlertEnabled() then
getRoomInformation()
local msg = string.format(" @W%s@C ENGAGED @Win @x202%s @W[@x202%s@W]",wildcards[1], area, roomid)
msg = addLevelRangeText(msg)
SendNoEcho("gt "..msg)
target = wildcards[1]
end
end
function sendPkAlert(name, line, wildcards)
if isEnabled() then
if isAlertEnabled() then
getRoomInformation()
if wildcards[1] ~= nil then
local msg = string.format(" @RPK Alert: @W%s @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid)
msg = addLevelRangeText(msg)
SendNoEcho("clan "..msg)
if ingroup == true then
SendNoEcho("gt "..msg)
end
target = wildcards[1]
end
end
--- Give the audio indicator
-- Sound( varSoundFile )
if isSoundEnabled() then
PlaySound( 9, varSoundFile, false, (0-(100-PKASettings.volume)), 0 )
end
end
end
function outputHyperLink(name, line, wildcards)
if wildcards.roomid ~= nil then
runto_roomid = wildcards.roomid
ColourTell("red", "", "RPK Alert: ", "goldenrod", "", "I'm getting attacked please help at ",
"white", "", "[")
Hyperlink("mapper goto "..wildcards.roomid, wildcards.roomid, "Click to run directly to then room Id"..roomid, "orangered", "", 0)
ColourNote("White", "", "]!")
end
end
function runto_PK_room()
if runto_roomid ~= 0 then
Execute("mapper goto "..runto_roomid)
end
end
function sendStrangleAlert(name, line, wildcards)
if isEnabled() and isAlertEnabled() then
getRoomInformation()
if(wildcards[1] ~= nil) then
local msg = string.format("@W%s@C STRANGLED @Win @x202%s @W[@x202%s@W]", wildcards[1], area, roomid)
msg = addLevelRangeText(msg)
SendNoEcho("clan "..msg)
if ingroup == true then
SendNoEcho("gt "..msg)
end
target = wildcards[1]
end
end
end
function sendCursedAlert(name, line, wildcards)
if isEnabled() and isAlertEnabled() then
if (ingroup == true) then
chan = "gt "
else
chan = "clan "
end
getRoomInformation()
if(wildcards.target ~= nil and wildcards.target ~= "") then
local msg = string.format("@W%s@C CURSED @Win @x202%s @W[@x202%s@W]", wildcards.target, area, roomid)
msg = addLevelRangeText(msg)
SendNoEcho("clan "..msg)
if ingroup == true then
SendNoEcho("gt "..msg)
end
target = wildcards.target
end
end
end
function getRoomInformation()
if IsConnected() then
Send_GMCP_Packet("request room")
end
-- get updated room information
gmcproom = gmcp("room")
area = gmcproom.info.zone
roomid = gmcproom.info.num
room = gmcproom.info.name
end
function addLevelRangeText(msg)
if PKASettings.playerlevel > 0 and PKASettings.levelrange > 0 then
local min = PKASettings.playerlevel - PKASettings.levelrange
if min < 1 t h e n min = 1 e n d
local max = PKASettings.playerlevel + PKASettings.levelrange
if max > 201 then max = 201 end
msg = msg.." I am level @x202"..PKASettings.playerlevel.." @W(@x202"..min.."@W - @x202"..max.."@W)"
end
return msg
end
function OnPluginBroadcast (msg, id, name, text)
if id == GMCPPluginID then
if text == "group" then
local res, membercount = CallPlugin(GMCPPluginID, "gmcpval", "group.count")
if membercount == "" then membercount = 0 end
if tonumber(membercount) >= 1 then
ingroup = true
end
elseif text == "char.status" then
PKASettings.playerlevel = tonumber(gmcp("char.status.level"))
end
end
end
function OnPluginInstall()
OnPluginEnable()
end
function OnPluginEnable()
local settings = GetVariable("PKSettings")
if settings and settings ~= "" then
assert(loadstring("PKASettings = "..GetVariable("PKSettings"))) ()
end
if PKASettings.levelrange == nil then PKASettings.levelrange = defLevelRange end
Send_GMCP_Packet("request char")
end
function OnHelp ()
world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script>
</muclient>