1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
|
------------------------------------------------------------------------------------------------------------ Auto Roll Call - AutoRC
--
-- written by Venor on the Govida server
-- released under the Creative Commons License By-Nc-Sa: http://creativecommons.org/licenses/by-nc-sa/3.0/
--
-- Thank you PetraAreon authour of ComeOnIn,
-- Your work has helped immensely in the creation of AutoRC
--
----------------------------------------------------------------------------------------------------------
-- local AutoRC = {} -- the addon namespace, all your functions should be placed inside here instead of as globals.
-- _G.AutoRC = AutoRC -- expose it to the global scope
-- local frame = _G.AutoRC_Manager -- made in the XML
tab_party = {}
function AutoRC_OnLoad()
AutoRC =
{
Addonname = "AutoRC",
Version = "0.2 Beta",
Author = "Venor",
ErrMsg = "";
Loaded = false,
Active = false,
Expiration = "",
Next_Announce = "",
ErrMsg = "",
Busy = false,
Defaults =
{
Revision = "0013",
Manager = false,
ManagerPosX = 0,
ManagerPosY = 0,
ConfigPosX = 0,
ConfigPosY = 0,
RollCallDuration = 40,
Announce = "PARTY",
AutoAnnounce = true,
AutoAnnounceInterval = 20,
UseKeyword = true,
Keyword = "!here",
Proximity = true,
Debug = false,
Silent = false,
AutoKick = false,
Color = "FF33CC"
};
};
AutoRC_Frame:RegisterEvent("VARIABLES_LOADED");
end;
function AutoRC_OnEvent(event,message,arg2,arg3,user)
if(event=="VARIABLES_LOADED" and not AutoRC.Loaded) then
DEFAULT_CHAT_FRAME:AddMessage("AutoRC OnEvent VARIABLES_LOADED")
if not(AutoRC_Settings) then
AutoRC_Settings = AutoRC.Defaults;
end;
local func, err = loadfile("Interface/Addons/AutoRC/Locales/Languages.lua");
if (not err) then
dofile("Interface/Addons/AutoRC/Locales/Languages.lua");
if (AutoRC_Settings.Language == nil) then
AutoRC_Settings.Language = string.upper(string.sub(GetLanguage(),1,2));
end;
local func, err = loadfile("Interface/Addons/AutoRC/Locales/"..AutoRC_Settings.Language..".lua");
if (err) then
AutoRC.ErrMsg = "\n\n|cffff0000No Locales found for your language ""..AutoRC_Settings.Language.."", switching to fallback "EN"|r";
AutoRC_Settings.Language = "EN";
end;
dofile("Interface/Addons/AutoRC/Locales/"..AutoRC_Settings.Language..".lua");
SLASH_AutoRC1 = "/AutoRC";
SlashCmdList['AutoRC'] = AutoRC_Config_Toggle_Visible;
if (AutoRC_Settings.Revision ~= AutoRC.Defaults.Revision) then
AutoRC_Settings = AutoRC.Defaults;
end;
AutoRC_Manager:ClearAllAnchors();
AutoRC_Manager:SetAnchor("CENTER", "CENTER", UIParent, AutoRC_Settings.ManagerPosX, AutoRC_Settings.ManagerPosY);
AutoRC_Config_Frame:ClearAllAnchors();
AutoRC_Config_Frame:SetAnchor("CENTER", "CENTER", UIParent, AutoRC_Settings.ConfigPosX, AutoRC_Settings.ConfigPosY);
AutoRC_SetConfigFrame();
UIDropDownMenu_Initialize(AutoRC_Config_Frame_ActiveQueue , AutoRC_Menu_Queue);
UIDropDownMenu_Initialize(AutoRC_Manager_ActiveQueue , AutoRC_Menu_Queue);
AutoRC_SetLanguage();
if AddonManager then
local addon =
{
name = AutoRC.Addonname,
description = AutoRC.Strings.GUI_AddonManagerDescription..AutoRC.ErrMsg,
category = "Social",
configFrame = AutoRC_Config_Frame,
slashCommands = SLASH_AutoRC1,
version = AutoRC.Version.." rev"..AutoRC_Settings.Revision,
author = AutoRC.Author,
icon = "",
}
if AddonManager.RegisterAddonTable then
AddonManager.RegisterAddonTable(addon)
else
AddonManager.RegisterAddon(addon.name, addon.description, addon.icon, addon.category, addon.configFrame, addon.slashCommands, addon.miniButton, addon.onClickScript)
end
end
AutoRC_Announce(2,"AutoRC "..AutoRC.Version.." rev"..AutoRC_Settings.Revision.." written by "..AutoRC.Author)
AutoRC_Frame:RegisterEvent("PARTY_MEMBER_CHANGED")
AutoRC_Frame:RegisterEvent("CHAT_MSG_WHISPER");
AutoRC_Frame:RegisterEvent("CHAT_MSG_SAY");
AutoRC_Frame:RegisterEvent("CHAT_MSG_PARTY");
AutoRC_Frame:RegisterEvent("CHAT_MSG_ZONE");
AutoRC_Frame:RegisterEvent("CHAT_MSG_GUILD");
AutoRC_Frame:RegisterEvent("CHAT_MSG_CHANNEL");
AutoRC.Loaded = true;
SaveVariables("AutoRC_Settings");
end;
elseif (ComeOnIn.Loaded) then
-- store original eventvalues
local _event = event;
local _arg1 = arg1;
local _arg2 = arg2;
local _arg3 = arg3;
local _arg4 = arg4;
if((event ~= "CHAT_MSG_SYSTEM") and string.find(event,"^CHAT_MSG") ~= nil and type(message)=="string" and type(user)=="string") then
message = string.upper(message)
keyword = string.upper(AutoRC_Settings.Keyword)
AutoRC_Announce(3,user.." "..event.." "..message);
if (AutoRC.Active and AutoRC_UnitInParty(user)) then
AutoRC_Announce(3,"AutoRC running check message!");
if (message:find(keyword)) then
AutoRC_Announce(3,"Player Check in");
AutoRC_RemoveFromQueue(user);
end;
end;
elseif(event=="PARTY_MEMBER_CHANGED") then
if(AutoRC.Active) then
if(GetNumRaidMembers()==0 and GetNumPartyMembers()==0) then
AutoRC.Active = false
AutoRC_Announce(2, "Roll Call Canceled your not in a party anymore")
elseif(GetNumRaidMembers()>1) then
local counter = 1;
while(counter<=table.getn(tab_party)) do
if(not InRaidyByName(tab_party[counter]) and not tab_party[counter]:find(UnitName("player"))) then
local b , i = AutoRC_InEventTab(tab_party[counter]);
table.remove(tab_party,counter);
break;
end;
counter = counter + 1;
end;
elseif(GetNumRaidMembers()==0) then
local counter = 1;
while(counter<=table.getn(tab_party)) do
if(not InPartyByName(tab_party[counter]) and not tab_party[counter]:find(UnitName("player"))) then
local b , i = AutoRC_InEventTab(tab_party[counter]);
table.remove(tab_party,counter);
break;
end;
counter = counter + 1;
end;
end;
end;
end;
-- reset to stored eventvalues
event = _event;
arg1 = _arg1;
arg2 = _arg2;
arg3 = _arg3;
arg4 = _arg4;
end;
end;
function AutoRC_OnUpdate()
if (AutoRC.Active) then
local timeremaining = math.ceil(AutoRC.Expiration - GetTime())
if ((GetTime() >= AutoRC.Expiration) or (0==table.getn(tab_party))) then
AutoRC.Active = false
AutoRC_SetupManager();
if (not (0==table.getn(tab_party))) then
table.sort(tab_party);
AutoRC_Announce(1,"The Following users have NOT checked in: "..table.concat(tab_party," "))
end;
if (AutoRC_Settings.AutoKick) then AutoRC_Kick(); end;
AutoRC_Announce(1,"Roll Call is done!")
AutoRC_Announce(1,"AutoRC "..AutoRC.Version.." rev"..AutoRC_Settings.Revision.." by Venor")
end;
-- Routine to automatically check in users who are present and w/i tab targeting distance, one per tick
if (not AutoRC.Busy and AutoRC_Settings.Proximity) then
AutoRC.Busy = true
TargetNearestFriend();
user = UnitName("target");
if (UnitInParty("target") or UnitInRaid("target")) then AutoRC_RemoveFromQueue(UnitName("target")) end; -- Is the 'target' in our party or raid if not skip
AutoRC.Busy = false;
end;
if (AutoRC.Active and (GetTime() >= AutoRC.Next_Announce) and (AutoRC_Settings.AutoAnnounce) and not AutoRC.Busy) then
AutoRC.Busy = true
AutoRC_Announce(3,"List players");
if (not (0==table.getn(tab_party))) then
table.sort(tab_party);
AutoRC_Announce(1,"AutoRC: Roll Call: "..timeremaining.." Keyword: ""..AutoRC_Settings['Keyword'].."" Users: "..table.concat(tab_party," "))
end;
AutoRC.Next_Announce = AutoRC.Next_Announce + AutoRC_Settings.AutoAnnounceInterval
AutoRC.Busy = false;
end;
end;
end;
function AutoRC_SetupManager()
AutoRC_Manager_Header:SetText (AutoRC.Strings.GUI_Manager_Title);
AutoRC_Manager_Config:SetText (AutoRC.Strings.GUI_Manager_Config);
if (AutoRC.Active==true) then AutoRC_Manager_StartStop:SetText(AutoRC.Strings.GUI_Manager_off);
else AutoRC_Manager_StartStop:SetText(AutoRC.Strings.GUI_Manager_on); end;
end;
-- AutoRC_SetupManager, function to populate the menu text for our Manager Interface --]]
function AutoRC_Manager_Toggle_Visible()
if (AutoRC_Manager:IsVisible()) then
AutoRC_Manager:Hide();
if (AutoRC_Config_Frame:IsVisible()) then AutoRC_Config_Frame:Hide(); end;
AutoRC_Settings.Manager = false;
else
AutoRC_Manager:Show();
AutoRC_Settings.Manager = true;
end;
end;
function AutoRC_Config_Toggle_Visible()
if (AutoRC_Config_Frame:IsVisible()) then
AutoRC_Config_Frame:Hide();
else
AutoRC_Config_Frame:Show();
end;
end;
function AutoRC_Announce(type, s)
if(type==1 and not AutoRC_Settings.Silent) then
if(AutoRC_Settings.Announce == "ZONE" or AutoRC_Settings.Announce == "SAY" or AutoRC_Settings.Announce == "GUILD" or AutoRC_Settings.Announce == "PARTY") then
SendChatMessage("|Hitem|h|cf"..AutoRC_Settings.Color.." |h"..s,AutoRC_Settings.Announce)
end;
-- SendChatMessage("|Hitem|h|cf"..AutoRC_Settings.Color.." |h"..s,PARTY)
-- SendChatMessage("|Hitem|h|cf"..AutoRC_Settings.Color.." |h"..s,GUILD)
elseif(type==1 and AutoRC_Settings.Silent) then
DEFAULT_CHAT_FRAME:AddMessage("|Hitem|h|cf"..AutoRC_Settings.Color.." |h"..AutoRC.Addonname.." "..AutoRC_Settings.Announce.." msg: "..s)
elseif(type==2) then
DEFAULT_CHAT_FRAME:AddMessage("|Hitem|h|cf"..AutoRC_Settings.Color.." |h"..AutoRC.Addonname..": "..s)
elseif(type==3 and AutoRC_Settings.Debug) then
DEFAULT_CHAT_FRAME:AddMessage("|Hitem|h|cf"..AutoRC_Settings.Color.." |h"..AutoRC.Addonname.." debug: "..s)
end;
end;
function AutoRC_InEventTab(name)
local c = 1;
while(c<=table.getn(tab_party)) do
if(tab_party[c][1]:find(name)) then
return true, c;
end;
c = c + 1
end;
return false, -1;
end;
function AutoRC_Slash(a, add)
add = string.upper(add);
if(add=="") then
AutoRC_Config_Toggle_Visible();
end;
end;
function AutoRC_Start()
AutoRC_SaveConfig()
AutoRC_Announce(3,"Start Roll Call!");
if((GetNumPartyMembers()>1) or (GetNumRaidMembers()>1)) then
AutoRC_Announce(3,"In Pary or RAID Revisioning potential kick list");
if (AutoRC.Active) then
AutoRC.Active = false
AutoRC_Announce(1,"Roll Call cancelled")
else
tab_party = {}
if(GetNumRaidMembers()>1) then
AutoRC_Announce(3,"Populate Raid Table");
counter = 1
while((table.getn(tab_party))<(GetNumRaidMembers()-1) and (counter<=35)) do
if(UnitExists("raid"..counter) and not (UnitName("player") == UnitName("raid"..counter))) then
table.insert(tab_party,UnitName("raid"..counter))
end;
counter = counter + 1
end;
else
AutoRC_Announce(3,"Populate Party Table");
counter = 1
while((table.getn(tab_party))<(GetNumPartyMembers()-1)) do
if(UnitExists("party"..counter)) then table.insert(tab_party,UnitName("party"..counter)) end;
counter = counter + 1
end;
end;
AutoRC_Announce(3,"Say what must be said! ");
AutoRC_Announce(1,"AutoRC "..AutoRC.Version.." rev"..AutoRC_Settings.Revision.." by Venor")
AutoRC_Announce(1,"ROLL CALL IS NOW!")
AutoRC_Announce(1,"Follow "..UnitName("player").." Or Check in: ""..AutoRC_Settings.Keyword..""")
-- AutoRC_Announce(1,"If you do not check in you will be kicked")
-- AutoRC_Announce(1,"type: !HERE or !OMW to check in!")
AutoRC_Announce(1,"Roll Call you have "..AutoRC_Settings.RollCallDuration.." sec!")
AutoRC.Expiration = math.ceil(GetTime() + AutoRC_Settings.RollCallDuration)
AutoRC.Next_Announce = math.ceil(GetTime() + AutoRC_Settings.AutoAnnounceInterval)
AutoRC.Active = true
end;
else
AutoRC_Announce(2,"You are not in a party")
end;
end;
function AutoRC_SetConfigFrame()
AutoRC_Config_Frame_Debug:SetChecked(AutoRC_Settings.Debug);
AutoRC_Config_Frame_Silent:SetChecked(AutoRC_Settings.Silent);
AutoRC_Config_Frame_Proximity:SetChecked(AutoRC_Settings.Proximity);
AutoRC_Config_Frame_AutoKick:SetChecked(AutoRC_Settings.AutoKick);
AutoRC_Config_Frame_RollCallDuration:SetText(tostring(AutoRC_Settings.RollCallDuration));
AutoRC_Config_Frame_AutoAnnounce:SetChecked(AutoRC_Settings.AutoAnnounce);
AutoRC_Config_Frame_AutoAnnounceInterval:SetText(tostring(AutoRC_Settings.AutoAnnounceInterval));
AutoRC_Config_Frame_KeyWord:SetText(AutoRC_Settings['Keyword']);
AutoRC_Config_Frame_KeyWordBox:SetChecked(AutoRC_Settings['UseKeyword']);
-- AutoRC_DisplayElements();
-- AutoRC_ColorControl();
end;
function AutoRC_SetLanguage(button)
--[[
if (button ~= nil) then
for index,entry in pairs(AutoRC.Languages) do
if (entry==button:GetText()) then
AutoRC_Settings.Language = index;
local func, err = loadfile('Interface/Addons/AutoRC/Locales/'..AutoRC_Settings.Language..'.lua');
if (not err) then dofile ('Interface/Addons/AutoRC/Locales/'..AutoRC_Settings.Language..'.lua'); end;
break;
end;
end;
end;
--]]
AutoRC_Config_Frame_SettingsTitle :SetText(AutoRC.Strings.GUI_SettingsTitle..":");
AutoRC_Config_Frame_KeywordTitle :SetText(AutoRC.Strings.GUI_Keywords..":");
AutoRC_Config_Frame_Debug_Text :SetText(AutoRC.Strings.GUI_Debug);
AutoRC_Config_Frame_Silent_Text :SetText(AutoRC.Strings.GUI_Silent);
AutoRC_Config_Frame_Proximity_Text :SetText(AutoRC.Strings.GUI_Proximity);
AutoRC_Config_Frame_AutoKick_Text :SetText(AutoRC.Strings.GUI_AutoKick);
AutoRC_Config_Frame_Kick :SetText(AutoRC.Strings.GUI_Kick);
AutoRC_Config_Frame_AutoAnnounce_Text :SetText(AutoRC.Strings.GUI_AutoAnnounce);
AutoRC_Config_Frame_Announce :SetText(AutoRC.Strings.GUI_Announce);
--[[
AutoRC_Config_Frame_ :SetText(AutoRC.Strings.GUI_);
--]]
UIDropDownMenu_SetText(AutoRC_Config_Frame_ActiveQueue,AutoRC.Strings.GUI_Queue)
UIDropDownMenu_SetText(AutoRC_Manager_ActiveQueue,AutoRC.Strings.GUI_Queue)
if (AutoRC.Active==true) then AutoRC_Config_Frame_StartOrStop:SetText(AutoRC.Strings.GUI_off);
else AutoRC_Config_Frame_StartOrStop:SetText(AutoRC.Strings.GUI_on); end;
AutoRC_SetupManager();
end;
function AutoRC_SaveConfig()
AutoRC_Settings.Debug = AutoRC_Config_Frame_Debug :IsChecked();
AutoRC_Settings.Silent = AutoRC_Config_Frame_Silent :IsChecked();
AutoRC_Settings.Proximity = AutoRC_Config_Frame_Proximity :IsChecked();
AutoRC_Settings.AutoKick = AutoRC_Config_Frame_AutoKick :IsChecked();
AutoRC_Settings.AutoAnnounce = AutoRC_Config_Frame_AutoAnnounce :IsChecked();
if (string.len(AutoRC_Config_Frame_AutoAnnounceInterval:GetText())>0)
then AutoRC_Settings.AutoAnnounceInterval = tonumber(AutoRC_Config_Frame_AutoAnnounceInterval:GetText());
else AutoRC_Settings.AutoAnnounceInterval = 20; end;
if (AutoRC_Settings.AutoAnnounceInterval<20) then AutoRC_Settings.AutoAnnounceInterval=20; end;
if (string.len(AutoRC_Config_Frame_RollCallDuration:GetText())>0)
then AutoRC_Settings.RollCallDuration = tonumber(AutoRC_Config_Frame_RollCallDuration:GetText());
else AutoRC_Settings.RollCallDuration = 60; end;
if (AutoRC_Settings.RollCallDuration<60) then AutoRC_Settings.RollCallDuration=60; end;
AutoRC_Settings.UseKeyword = AutoRC_Config_Frame_KeyWordBox:IsChecked();
AutoRC_Settings.Keyword = string.gsub(string.gsub(AutoRC_Config_Frame_KeyWord:GetText(),"^ *","")," *$","");
AutoRC_SetConfigFrame();
end;
function AutoRC_Kick()
for k,v in pairs(tab_party) do
if (not v:find(UnitName("player"))) then
UninviteByName(v);
end;
end;
end;
function AutoRC_Menu_Queue()
local menuitem = {};
menuitem.notCheckable = 1;
if (table.maxn(tab_party)>0) then
-- menuitem.text = "|cffF4C800"..AutoRC.Strings.GUI_QueueClear.."|r";
menuitem.text = "|cffF4C800".."Clear Queue".."|r";
menuitem.func = AutoRC_Menu_Queue_Func;
UIDropDownMenu_AddButton(menuitem,UIDROPDOWNMENU_MENU_LEVEL);
for n=1,table.maxn(tab_party) do
menuitem.text = " "..n..": "..tab_party[n].."|r";
menuitem.func = AutoRC_Menu_Queue_Func;
UIDropDownMenu_AddButton(menuitem,UIDROPDOWNMENU_MENU_LEVEL);
end;
end;
end;
function AutoRC_Menu_Queue_Func(Selection)
if (Selection:GetID()==1) then
tab_party = {}
else
AutoRC_RemoveFromQueue(string.gsub(Selection:GetText(),"^[^:]*: (.*)|r","%1"),false);
end;
end;
-- remove player from queue
function AutoRC_RemoveFromQueue(Name)
for n=1,table.maxn(tab_party) do
if (n>0 and n<=table.maxn(tab_party)) then
if (tab_party[n]==Name) then
table.remove(tab_party,n);
break;
end;
end;
end;
AutoRC_SetupManager();
end;
----- search chatmessage for keyword, returns:
-- 1) found keyword
-- 2) true, if player wants to be removed from queue
-- 3) false, if no keyword was found
function AutoRC_Search(message)
if (message ~= nil and type(message) == "string") then
if (string.len(AutoRC_Settings.Keyword) > 1 and AutoRC_Settings.UseKeyword) then
-- if(string.find(string.lower(message),"! *"..string.lower(AutoRC_Settings.Keyword)) ~= nil) then
-- return true;
-- elseif(string.find(string.lower(message),string.lower(AutoRC_Settings.Keyword)) ~= nil) then
if(string.lower(message):find(string.lower(AutoRC_Settings.Keyword))) then
return AutoRC_Settings.Keyword;
end;
end;
end;
return false;
end;
function AutoRC_UnitInParty(Name)
if (Name==nil) then return false; end;
if (UnitName("player")==Name) then return true; end;
if (GetNumRaidMembers()>0) then if (InRaidByName(Name)==true) then return true; end; end;
if (GetNumPartyMembers()>0) then if (InPartyByName(Name)==true) then return true; end; end;
return false;
end;
AutoRC_OnLoad();--AutoRC_OnEvent("VARIABLES_LOADED"); -- Some dirty little hacks to populate text
|