/PartyHardy
if not PartyHardyDB.whitelist then PartyHardyDB.whitelist = { [string.lower(UnitName("player"))] = true, } end |
StaticPopupDialogs["PARTYHARDY_NAMEADD"] = { |
text = "Write the name to add:", |
text = "Whitelist name in PartyHardy:", |
button1 = TEXT(ACCEPT), |
button2 = TEXT(CANCEL), |
OnAccept = function(self,data) |
local name = self.editBox:GetText() |
local name |
if data and data.Name then |
name = data.Name |
else |
name = self.editBox:GetText() |
end |
PartyHardyDB.whitelist[string.lower(name)] = true |
ChatFrame1:AddMessage("|cFFFF9900PartyHardy: "..string.lower(name).." added to trusted list.") |
StaticPopup_Hide("PARTYHARDY_NAMEADD") |
whileDead = true, |
hideOnEscape = true, |
preferredIndex = STATICPOPUP_NUMDIALOGS, |
OnShow = function (self,data) |
self.editBox:SetText("Player") |
OnShow = function(self,data) |
if data and data.Name then |
self.editBox:SetText(data.Name) |
else |
self.editBox:SetText("Player") |
end |
self.editBox:SetFocus(); |
self.editBox:HighlightText(); |
end, |
maxLetters = 12, |
exclusive = 1, |
EditBoxOnEnterPressed = function(self,data) |
local parent = self:GetParent(); |
local name = parent.editBox:GetText(); |
local name |
if data and data.Name then |
name = data.Name |
else |
local parent = self:GetParent(); |
name = parent.editBox:GetText(); |
end |
PartyHardyDB.whitelist[string.lower(name)] = true |
ChatFrame1:AddMessage("|cFFFF9900PartyHardy: "..string.lower(name).." added to trusted list.") |
StaticPopup_Hide("PARTYHARDY_NAMEADD") |
end, |
} |
local XPtable,orange,follow,faction,previouscommand = {},"|cFFFF9900" |
local orange,follow,faction,previouscommand = "|cFFFF9900" |
local PartyHardy = CreateFrame("Frame") |
PartyHardy:RegisterEvent("CHAT_MSG_PARTY") |
PartyHardy:RegisterEvent("CHAT_MSG_PARTY_LEADER") |
PartyHardy:RegisterEvent("PARTY_INVITE_REQUEST") |
PartyHardy:RegisterEvent("PLAYER_ENTERING_WORLD") |
--PartyHardy:RegisterEvent("CHAT_MSG_BN_WHISPER") -- todo? |
PartyHardy:RegisterEvent("CHAT_MSG_BN_WHISPER") -- todo? |
PartyHardy:RegisterEvent("CHAT_MSG_ADDON") |
PartyHardy:RegisterEvent("PLAYER_XP_UPDATE") |
PartyHardy:RegisterEvent("PLAYER_LEVEL_UP") |
if self[event] then return self[event](self, event, ...) end |
end) |
local XPtable = {} |
RegisterAddonMessagePrefix("PARTYHARDY") |
local function GetXP() |
local name = string.lower(name) |
local name = strsplit("-", name) |
local a, b = strsplit(" ", msg, 2) |
if a == "!follow" and PartyHardyDB.whitelist[name] and name ~= string.lower(UnitName("player")) and not UnitCastingInfo("player") then |
if a == "!follow" and name ~= string.lower(UnitName("player")) and not UnitCastingInfo("player") then |
if not PartyHardyDB.follow then |
if CheckInteractDistance(name, 4) then |
PartyHardy:RegisterEvent("AUTOFOLLOW_BEGIN") |
else |
SendChatMessage("Already following "..PartyHardyDB["follow"]..".", "PARTY", faction) |
end |
elseif a == "!followreset" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
elseif a == "!followreset" and UnitIsGroupLeader(UnitName("player")) then |
PartyHardyDB.follow = nil |
SendChatMessage("follow has been reset.", "PARTY", faction) |
elseif a == "!ffa" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
elseif a == "!ffa" and UnitIsGroupLeader(UnitName("player")) then |
SetLootMethod("freeforall") |
elseif a == "!gl" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
elseif a == "!gl" and UnitIsGroupLeader(UnitName("player")) then |
SetLootMethod("group") |
elseif a == "!ml" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
elseif a == "!ml" and UnitIsGroupLeader(UnitName("player")) then |
SetLootMethod("master", UnitName("player")) |
elseif a == "!pl" and PartyHardyDB.whitelist[name] then |
elseif a == "!pl" then |
if b == "on" then |
SetOptOutOfLoot(1) |
SendChatMessage("Passing loot: Yes.", "PARTY", faction) |
SetOptOutOfLoot(nil) |
SendChatMessage("Passing loot: No.", "PARTY", faction) |
end |
elseif a == "!leader" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
elseif a == "!leader" and UnitIsGroupLeader(UnitName("player")) then |
PromoteToLeader(name) |
elseif a == "!invite" and UnitIsGroupLeader(UnitName("player")) and PartyHardyDB.whitelist[name] then |
elseif a == "!invite" and UnitIsGroupLeader(UnitName("player")) then |
InviteUnit(b); |
elseif a == "!mount" and PartyHardyDB.whitelist[name] and not IsMounted() and not UnitCastingInfo("player") then |
elseif a == "!mount" and not IsMounted() and not UnitCastingInfo("player") then |
if InCombatLockdown() then |
previouscommand = "Your previous command was: !mount" |
SendChatMessage("Mounting failed, in combat.", "PARTY", faction) |
else |
C_MountJournal.Summon(0) |
end |
elseif a == "!dismount" and PartyHardyDB.whitelist[name] and not IsFlying() then |
elseif a == "!dismount" and not IsFlying() then |
Dismount() |
elseif a == "!emote" and PartyHardyDB.whitelist[name] then |
elseif a == "!emote" then |
DoEmote(b) |
elseif a == "!pet" and PartyHardyDB.whitelist[name] and not IsFlying() and not UnitCastingInfo("player") then |
elseif a == "!pet" and not IsFlying() and not UnitCastingInfo("player") then |
local pet = math.random(1,GetNumCompanions("CRITTER")) |
CallCompanion("CRITTER",pet) |
elseif a == "!accept" then |
for i=1,STATICPOPUP_NUMDIALOGS do |
local frame = _G["StaticPopup"..i] |
if frame:IsVisible() then |
if frame.which == "QUEST_ACCEPT" or frame.which == "DEATH" or frame.which == "RESURRECT" or frame.which == "RESURRECT_NO_SICKNESS" or frame.which == "RESURRECT_NO_TIMER" or frame.which == "DUEL_REQUESTED" or frame.which == "RECOVER_CORPSE" or frame.which == "CONFIRM_SUMMON" then |
if frame.which == "QUEST_ACCEPT" or frame.which == "DEATH" or frame.which == "RESURRECT" or frame.which == "RESURRECT_NO_SICKNESS" or frame.which == "RESURRECT_NO_TIMER" or frame.which == "DUEL_REQUESTED" or frame.which == "RECOVER_CORPSE" or frame.which == "CONFIRM_SUMMON" or frame.which == "PARTY_INVITE" or frame.which == "PARTY_INVITE_XREALM" then |
StaticPopup_OnClick(frame, 1) |
end |
end |
end |
end |
local function CheckFriend(chat,name) |
if chat == "normal" then |
for i = 1, GetNumFriends() do |
if (name == GetFriendInfo(i)) then |
return true |
end |
end |
elseif chat == "bnet" then |
for i = 1, BNGetNumFriends() do |
if (name == select(2,BNGetFriendInfo(i))) then |
return true |
end |
end |
end |
end |
function PartyHardy:CHAT_MSG_PARTY(self,msg,name) |
PartyCommands(self,msg,name) |
if PartyHardyDB.whitelist[string.lower(name)] then |
PartyCommands(self,msg,name) |
end |
end |
function PartyHardy:CHAT_MSG_PARTY_LEADER(self,msg,name) |
PartyCommands(self,msg,name) |
if PartyHardyDB.whitelist[string.lower(name)] then |
PartyCommands(self,msg,name) |
end |
end |
function PartyHardy:CHAT_MSG_BN_WHISPER(self,msg,name) |
if CheckFriend("bnet",name) then |
PartyCommands(self,msg,name) |
end |
end |
function PartyHardy:PARTY_INVITE_REQUEST(self,name) |
local name = string.lower(name) |
if PartyHardyDB.whitelist[name] then |
local name = strsplit("-", name) |
if CheckFriend("normal",name) then |
for i=1,STATICPOPUP_NUMDIALOGS do |
local frame = _G["StaticPopup"..i] |
if frame:IsVisible() and frame.which == "PARTY_INVITE" then StaticPopup_OnClick(frame, 1) end |
if frame:IsVisible() and frame.which == "PARTY_INVITE" or frame.which == "PARTY_INVITE_XREALM" then StaticPopup_OnClick(frame, 1) end |
end |
if not PartyHardyDB.whitelist[string.lower(name)] then |
StaticPopup_Show("PARTYHARDY_NAMEADD",nil,nil,{Name = name}) |
end |
end |
end |
else |
StaticPopup_Show("PARTYHARDY_NAMEADD") |
end |
elseif a == "del" then |
elseif a == "del" or a == "remove" then |
if #b < 13 then |
PartyHardyDB.whitelist[string.lower(b)] = nil |
ChatFrame1:AddMessage(orange.."PartyHardy: "..b.." removed from trusted list.") |
ItemRefTooltip:AddLine(k) |
end |
ItemRefTooltip:Show() |
else ChatFrame1:AddMessage(orange.."PartyHardy accepts these commands: 'add <name>', 'del <name>', 'list'.") end |
else ChatFrame1:AddMessage(orange.."PartyHardy accepts these commands: 'add <name>', 'del/remove <name>', 'list'.") end |
end |
SLASH_TNL1 = "/tnl" |