Code:
--[[
InviteMe 1.1.5 Mod Lua file
New Author: Ki
]]
local IM_Version = "1.1.4";
local IM_Status = "off";
local IM_Range = false;
function InviteMe_OnLoad()
SlashCmdList["INVITEMECOMMAND"] = InviteMe_SlashHandler;
SLASH_INVITEMECOMMAND1 = "/InviteMe";
SLASH_INVITEMECOMMAND2 = "/IM";
this:RegisterEvent("VARIABLES_LOADED");
this:RegisterEvent("CHAT_MSG_WHISPER");
if( DEFAULT_CHAT_FRAME ) then
DEFAULT_CHAT_FRAME:AddMessage("InviteMe v" .. IM_Version .. " loaded");
end
--UIErrorsFrame:AddMessage("InviteMe ", 1.0, 1.0, 1.0, 1.0, UIERRORS_HOLD_TIME);
end
function InviteMe_OnEvent()
local OldTarget;
local OldTargetIsEnemy = false;
if (event == "VARIABLES_LOADED") then
if (IM_Passcode == nil or IM_Passcode == "") then
IM_Passcode="invite";
end
if (IM_PromoteCode == nil or IM_PromoteCode == "") then
IM_PromoteCode="promote";
end
end
if (event == "CHAT_MSG_WHISPER" and IM_Status == "on") then
if (string.find(arg1, IM_Passcode)) then
-- if (string.lower(arg1) == IM_Passcode ) then
if(IM_Range) then
if(UnitName("target")) then
OldTarget = UnitName("target", "player")
OldTargetIsEnemy = UnitIsEnemy("target", "player");
end
DEFAULT_CHAT_FRAME:AddMessage(arg2);
DEFAULT_CHAT_FRAME:AddMessage(arg1);
DEFAULT_CHAT_FRAME:AddMessage(IM_Passcode);
TargetByName(arg2);
if(UnitName("target") == arg2) then
guildinvite(arg2);
IM_Print("[IM] Adding ".. arg2 .. " to Raid. In range.",0,1,1);
else
SendChatMessage("You're out of range","WHISPER","COMMON",arg2);
end
if(OldTarget) then
if (OldTargetIsEnemy) then
TargetLastEnemy();
else
TargetLastTarget();
end
else
ClearTarget();
end
else
guildinvite(arg2);
IM_Print("[IM] Adding ".. arg2 .. " to Raid.",0,1,1);
end
end
if (string.find(arg1, IM_PromoteCode)) then
-- if (string.lower(arg1) == IM_PromoteCode ) then
if(IM_Range) then
if(UnitName("target")) then
OldTarget = UnitName("target", "player")
OldTargetIsEnemy = UnitIsEnemy("target", "player");
end
DEFAULT_CHAT_FRAME:AddMessage(arg2);
DEFAULT_CHAT_FRAME:AddMessage(arg1);
DEFAULT_CHAT_FRAME:AddMessage(IM_PromoteCode);
TargetByName(arg2);
if(UnitName("target") == arg2) then
PromoteToAssistant(arg2);
IM_Print("[IM] Promoting ".. arg2 .. " to Assistant. In range.",0,1,1);
else
SendChatMessage("You're out of range","WHISPER","COMMON",arg2);
end
if(OldTarget) then
if (OldTargetIsEnemy) then
TargetLastEnemy();
else
TargetLastTarget();
end
else
ClearTarget();
end
else
if IsRaidLeader() == 1 then
PromoteToAssistant(arg2);
IM_Print("[IM] Promoting ".. arg2 .. " to Assistant.",0,1,1);
else
SendChatMessage("InviteMe: "..UnitName("player").." is not the raid leader, and cannot promote.", "WHISPER", nil, name)
end
end
end
end
end
function ToggleRange()
if (IM_Range) then
IM_Range = false
IM_Print("[IM] Accepting all requests",0,1,1);
else
IM_Range = true
IM_Print("[IM] Only accepting requests in range",0,1,1);
end
end
function HandleStatusChange(status)
IM_Status=status;
if (status == "on") then
--this:RegisterEvent("CHAT_MSG_WHISPER");
else
--this:UnregisterEvent("CHAT_MSG_WHISPER");
end
IM_Print("[IM] InviteMe is now ".. IM_Status,0,1,1);
end
function IM_Print(msg,r,g,b)
if( DEFAULT_CHAT_FRAME ) then
DEFAULT_CHAT_FRAME:AddMessage(msg,r,g,b);
else
UIErrorsFrame:AddMessage("InviteMe couldn't print to default chat frame", 1.0, 1.0, 1.0, 1.0, UIERRORS_HOLD_TIME);
end
end
function InviteMe_SlashHandler(msg)
msg = string.lower(msg);
if (msg == "" or msg == nil) then
IM_Print("--InviteMe v" .. IM_Version .. " Help and Status",0,1,1);
IM_Print("/InviteMe off -- turns InviteMe off");
IM_Print("/InviteMe on -- turns InviteMe on");
IM_Print("/InviteMe passcode invite -- sets InviteMe's passcode to foozle");
IM_Print("InviteMe is currently ".. IM_Status);
IM_Print("Invite Passcode:".. IM_Passcode);
IM_Print("Invite PromoteCode:".. IM_PromoteCode);
elseif (msg == "off" or msg == "on") then
HandleStatusChange(msg);
elseif (msg == "range") then
ToggleRange(msg);
else
iStart, iEnd, command, args = string.find(msg, "^(%w+)%s*(.*)$");
if (string.lower(command) == "passcode") then
IM_Passcode = args;
IM_Print("Setting passcode to "..IM_Passcode,0,1,1);
end
if (string.lower(command) == "promotecode") then
IM_PromoteCode = args;
IM_Print("Setting promotecode to "..IM_PromoteCode,0,1,1);
end
end
end