vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Guild Event Manager by Kiki of European Cho'gall (Alliance)
3 Version 2.08
4 Home Page : http://christophe.calmejane.free.fr/wow/gem/
5  
6 ---
7 ChangeLog :
8 ----------------
9 - 2.08 :
10 - April, 11th 2006 :
11 - You can now configure channels from the options (but cannot see members from other channels yet)
12 - March, 31th 2006 :
13 - Updated TOC for 1.10
14 - Fixed 'N' text in minimap icon flashing sometimes, while there is no new event
15 - Increased date column width, and added date in the tooltip
16 - Added a new color code in Admin list : Blue=Connected but not grouped, Green=Connected and grouped
17 - 2.07 :
18 - March, 16th 2006 :
19 - Fixed lua error in New event if you load a template created before Auto-members additionnal code
20 - Finally fixed channels init errors. Password protected channels should work too.
21 - March, 15th 2006 :
22 - Fixed lua error in Admin list popup if not leader
23 - You can now force yourself into replacement queue
24 - Fixed force titular button not working, if the player was not in replacement queue before
25 - March, 13th 2006 :
26 - Handling "Force titular" param in Sorting of members
27 - March, 10th 2006 :
28 - Added possibility to ignore a closed event (new button)
29 - Fixed bug in the ignore option (a previously ignored event might reappear)
30 - March, 9th 2006 :
31 - Added confirmation dialog for Delete Template (New event tab)
32 - Fixed wrong reset instance day, around midnight
33 - Added possibility to Auto-add members to an event (NOT FINISHED YET !! NO CHECKS !)
34 - Saving Auto-members to templates
35 - Added possibility to move a member back and forth Replacement queue
36 - Added possibility to force a member in titular list
37 - 2.06 :
38 - March, 7th 2006 :
39 - Fixed : some events not removed from the list, when changing channel
40 - Auto-purging players that didn't connect since 1 month
41 - Fixed players not sending any data when they first log in the channel
42 - Added Events Calendar view (not finished yet)
43 - Possibility to show instances reset from the calendar view
44 - March, 3rd 2006 :
45 - Increased EventsList size (2 more items), needed to incoming new EventView
46  
47 [ Previous changes in readme.txt file ]
48  
49 ---
50 Description :
51 ----------------
52 This AddOn allows you to create/schedule/manage future raid instance directly in-game. Players can register (join) and reserve a room for your instance, or cancel subscription.
53 You can setup a maximum players for your event, as well as the min/max per class.
54 When a player wants to join and there is no room left for his class, he is put in a *substitute* queue, waiting for someone to cancel his subscription.
55  
56 The leader of an event does not have to be logged in for a player to subscribe.
57  
58 This addon has been designed to help guilds to schedule events, and its member to say *I'll be there*, and count the number of players that are ok for an instance.
59 It does work for multiple guilds (kind of Alliance of guilds), if you want, or even with your friend list.
60  
61 All dates are stored in universal time, and displayed in local time, so if someone creates an event in a different timezone than yours, you will see the correct time on your side.
62  
63  
64 ---
65 Installation :
66 ---------------
67  
68 1. Extract .zip file to WorldOfWarcraft\Interface\AddOns\
69 2. load up WoW check the Addon is enabled ("/gem help" should print infos)
70 3. Bind a key to GuildEventManager or type "/gem toggle"
71 4. in the options TAB set the channel to whichever you are going to use
72  
73  
74 ---
75 Notes :
76 --------
77  
78 COLOR CODE :
79 - Events List in Events Tab, Where column :
80 - White = Old event (already displayed)
81 - Green = New event (never seen)
82 - Events List in Events Tab, Leader column :
83 - White = Leader not connected
84 - Green = Leader connected
85 - Events List in Events Tab, Subscribers column :
86 - White = Not subscribed
87 - Purple = Level of your selected character does not match event's level range
88 - DarkGrey = Subscription sent, but not ACKed yet
89 - Bleu = Subscription ACKed but you are in Substitute queue
90 - Green = Subscription ACKed and you are in Titular list
91 - Yellow = Subscription ACKed and you are in Replacement list
92 - DarkRed = You have been kicked from event (and thus unsubscribed). You can re-subscribe
93 - LightRed = You have been banned from event (and thus unsubscribed). You cannot re-subscribe until you are unbanned
94 - Admin List in Events Tab, Place column :
95 - White = Normal subscriber
96 - Green = Leader or Assistant
97 - Admin List in Events Tab, Name column :
98 - White = Player not connected (or external)
99 - Blue = Player connected but not grouped
100 - Green = Player connected and grouped
101 - Members list, Guild column :
102 - Green = Guild leader
103 - Blue = Guild officer
104 - White = Guild member
105  
106 TODO :
107 - auto kick/ban peoples
108 - REVOIR le code de groupage (detection more raid/group), et virer le warning si je suis deja dans un grp
109 - Faire une verif qd on set un alias, qu'il n'existe pas deja pour un autre canal GEM
110 - Pouvoir changer de reroll dans un EditEvent
111 - Store ServerTimeStamp and os.time() at each startup, for each Realm
112 - WDS : Pour chaque event, envoyer os.time() et ServerTimeStamp
113 - Add a sorting plugin : By assigning points to someone (DKP like)
114 - Add a sorting plugin : By auto adding ppl on a list for the event (only when already created, by using AddExternal)
115 - Find a way to *block* people we don't want to subscribe (auto ban your ignore list, for example)
116 - Add an auto-banned list (in Create new Events tab ?)
117 - Option to limit event creation to officers (not possible but see CanViewOfficerNote() IsGuildLeader() )
118 - Handle event restrictions (guild only) -- Tag event with a bit 'guild only'
119 - Possibility to modify the subscription comment
120 - GEM_COM_JoinChannel() -> Change DEFAULT_CHAT_FRAME:GetID(), by a value specified in config
121 - New parameter for Events : "Can subscribe only when leader is online"
122 - Handle guild channel as GEM channel
123 - Add a new type of limit : Healers (priest/druid/paladin/shaman) Dps (rogue/mage/hunter) (v666.0)
124  
125 TODO GUI:
126 - Mettre l'option "Notify channel join/leave" par canal
127 - Possibility to remove offline members from the list (right clic on them)
128 - Panel transparency
129  
130 KNOWN BUGS:
131 - Impossible de rejoindre un canal si on reco a griffon (max count 100 reached)
132  
133 CODE TODO :
134 *--*--*--*
135 * To handle multiple channels :
136 GUI
137 -> GEM_Players.lua : GEMPlayers_GetPlayers() must handle multiple channels (and the GUI too)
138  
139  
140 ---
141 FAQ :
142 --------
143 Q : I don't see events of other people, and others don't see mine
144 A : Are you sure you are on the same channel (check GEM options) ? Are you sure you don't have joined more than 9 channels (there is a limit of 9 or 10 channels you can join) ? Are you sure your PC's clock is correctly set ?
145 If you still don't see events, try "/gem debug 1", it will show a new TAB, look at the debug log (screenshot it) for warnings or event related messages, then contact me.
146  
147 Q : I see garbage on my channels, like "<GEM-1>01..."
148 A : Check if the channel you see garbage is the same than the one in your GEM config. Maybe you have changed the channel with a character, and changed reroll. Leave the garbaged one with a /leave ChanNum. In v2.0, channel will be saved per char, so you will not have this problem anymore.
149  
150 Q : I just subscribed to an event, but I don't appear in the list, nor the titulars count has changed.
151 A : If the leader of the event is not logged, all commands (subscribe, unsubscribe, ...) are stored and broadcasted to every person in the channel (and each time someone logs in). In order to see your subscription in the list (and titulars count increased/decreased), you must wait until the leader logs. When he does, all commands are flushed and he processes them, in the order they were submitted.
152 Look at the color codes above, they help you know in which state you are.
153  
154 Q : All thoses stored commands don't flood the channel when someone (or the leader) logs in ?
155 A : No, there is an algorithm that makes people to sent commands at different time when someone joins, and if a known command has just been sent, the sent from your side is canceled. There is also a maximum of commands that can be sent per second, so you are not (less) flooded.
156  
157 Q : I don't like the subscribers sorting modes available. I want something else, custom.
158 A : Well, that's where the Sorting plugin system comes in ! Look at the "GEM_sort_stamp.lua" file, there is all you need to make your own plugin (there is no need for the plugin to be installed on each player's computer, only on the leader's one). Simply make a new addon with a .toc file, that depends on GuildEventManager, and you're done. The plugin will be loaded by GEM, and you'll be able to choose your custom sorting in GEM's "Create new Event" tab.
159  
160 Q : I have a lua error, but I cannot tell you the file/line it occured
161 A : Please install (even temporarily) ImprovedErrorFrame (http://www.curse-gaming.com/mod.php?addid=170), and you'll be able to see the full error text
162  
163 Q : When I link an item to the GEM channel, it displays the name only.
164 A : For links to be sent, you must use the SlashCmd specified in GEM config. If you speak using /# (# being GEM's channel number), it will not work.
165  
166 Q : I don't see anybody in the Members list, and the list populates very slowly. Also, I always see "N/A" for people's location.
167 A : This is to greatly reduce traffic in the channel. Each player sends his personal informations ONLY when he changes of zone, NOT when someone logs in (otherwise every single player will have to send his current info upon each login, which causes too much traffic).
168 Because of this, the first time you come to a channel, we don't see anybody, you must wait for each player to move to another zone. When this happens, the player is saved and stored in your variables, so the next time, only it's current location will show as 'N/A' until he moves.
169  
170 Q : I'm using SlashCmd and alias, and when I try to send a message, I don't see anything in my chatframe, nor I see messages from others.
171 A : Some addons are not hooking chatframe like they should.
172 - If you have GuildAds : Get the latest version, it has been fixed
173 - If you have flagRSP : Get the latest version, it has been fixed
174 - If you have Guilded : Why do you need this one anymore ? oO
175  
176 Q : I don't like the way Dates are displayed. How can I change that ?
177 A : Change the option "Displayed dates format" ingame, in the GEM Configuration tab with the value you want.
178 You can find help on the parameters here : http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html
179  
180 Q : I don't understand the 'time offset' option
181 A : When someone creates an event, the time/date for the event is (by default, if you don't change the offset in GEM config) relative to it's computer's clock (which uses international time).
182 Example :
183 My computer's clock is set at GMT+1, I play on a server where time is set to GMT.
184 I create an event for tonight 8pm, GEM will flag (create) the event for 8pm GMT+1 (and store it using universal time value), not 8pm GMT (so not the server time).
185 BUT the date will be displayed for eveybody, using their local time. For someone playing on a computer with clock set at GMT+2, the event will show for him at 9pm.
186 The offset value in GEM config, is for people who want events to be shown using server time (or any other time offset), not local time.
187 They can set an offset from local time to match server time. If you don't set anything, it will display/create events based on your computer time (local).
188  
189 Q : When are events removed from the list ?
190 A : Events are auto removed (not closed, removed completly from GEM) 1 hour after event's date for non-leader players, and 10 hours after event's date for leader.
191 Using the previous example, the event will disapear for eveybody at 9pm GMT+1 (so for the guy playing at GMT+2 time, it will disapear when his computer's clock will reachs 10pm).
192  
193 ]]
194  
195  
196 --------------- Default values (you can set to nil, or any string) ---------------
197 GEM_DEFAULT_CHANNEL = "GEMChannelDefault";
198 GEM_DEFAULT_PASSWORD = nil;
199 GEM_DEFAULT_ALIAS = nil;
200 GEM_DEFAULT_SLASH = nil;
201  
202 --------------- Saved variables ---------------
203 GEM_Events = {};
204 GEM_Templates = {};
205 GEM_Players = {};
206  
207 --------------- Shared variables ---------------
208 GEM_MAJOR = "2";
209 GEM_MINOR = "08";
210 GEM_VERSION = GEM_MAJOR.."."..GEM_MINOR;
211 GEM_PlayerName = nil;
212 GEM_Realm = nil;
213 GEM_DefaultSendChannel = nil;
214 GEM_NewMinorVersion = false;
215 GEM_OldVersion = false;
216 GEM_ConnectedPlayers = {};
217 GEM_YouAreDrunk = false;
218 GEM_ServerOffset = 666;
219  
220 --------------- Local variables ---------------
221 local _GEM_NeedInit = true;
222 local _GEM_MaxJoinRetry = 10;
223 local _GEM_WrongChanNotified = {};
224  
225 --------------- Internal functions ---------------
226  
227 local function _GEM_Commands(command)
228 local i,j, cmd, param = string.find(command, "^([^ ]+) (.+)$");
229 if(not cmd) then cmd = command; end
230 if(not cmd) then cmd = ""; end
231 if(not param) then param = ""; end
232  
233 if((cmd == "") or (cmd == "help"))
234 then
235 GEM_ChatPrint(GEM_TEXT_USAGE);
236 GEM_CMD_Help();
237 else
238 if(not GEM_CMD_Command(cmd,param))
239 then
240 GEM_ChatPrint(GEM_CHAT_CMD_UNKNOWN);
241 end
242 end
243 end
244  
245 local function _GEM_CheckForJoined(channel)
246 if(GEM_COM_Channels[channel].id ~= 0)
247 then
248 return;
249 end
250 -- Have we joined the channel ?
251 GEM_COM_Channels[channel].id = GetChannelName(channel);
252  
253 if(GEM_COM_Channels[channel].id == 0)
254 then
255 if(GEM_COM_Channels[channel].retries > (_GEM_MaxJoinRetry/2))
256 then
257 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"_GEM_CheckForJoined : Not in channel '"..channel.."' after "..GEM_COM_Channels[channel].retries.." retries, restarting sequence");
258 GEM_InitChannels(false);
259 -- Don't return, we need to reschedule
260 elseif(GEM_COM_Channels[channel].retries > _GEM_MaxJoinRetry)
261 then
262 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"_GEM_CheckForJoined : Not in channel '"..channel.."' after "..GEM_COM_Channels[channel].retries.." retries, aborting (channel password protected ?)");
263 GEM_COM_Channels[channel].retries = 0;
264 return;
265 end
266 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"_GEM_CheckForJoined : Not joined yet, reschedule in 0.25 sec");
267 GEM_COM_Channels[channel].retries = GEM_COM_Channels[channel].retries + 1;
268 GEMSystem_Schedule(0.25,_GEM_CheckForJoined,channel); -- Re schedule in 250 msec
269 else
270 GEM_COM_Channels[channel].retries = 0;
271 ListChannelByName(channel);
272 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"_GEM_CheckForJoined : Ok joined channel, time to bcast !");
273 GEM_COM_AliasChannel(channel,GEM_COM_Channels[channel].alias,GEM_COM_Channels[channel].slash);
274 if(GEM_COM_Channels[channel].already_bcast == nil)
275 then
276 GEM_QUE_BuildBroadcastQueues(channel,GEM_PlayerName);
277 GEM_COM_PlayerInfosSingle(channel);
278 GEM_COM_Channels[channel].already_bcast = 1;
279 end
280 end
281 end
282  
283 local function _GEM_CheckPlayerLeft(channel,pl_name)
284 if(GEM_ConnectedPlayers[channel] == nil)
285 then
286 GEM_ConnectedPlayers[channel] = {};
287 end
288 if(GEM_ConnectedPlayers[channel][pl_name] ~= nil)
289 then
290 local chaninfos = GEM_COM_Channels[channel];
291 if(chaninfos and chaninfos.notify)
292 then
293 local alias = channel;
294 if(chaninfos.alias and chaninfos.alias ~= "")
295 then
296 alias = chaninfos.alias;
297 end
298 GEM_ChatMsg(alias.." : "..string.format(GEM_TEXT_PLAYER_LEFT,pl_name));
299 end
300 if(GEM_Players[GEM_Realm] and GEM_Players[GEM_Realm][channel] and GEM_Players[GEM_Realm][channel][pl_name])
301 then
302 GEM_Players[GEM_Realm][channel][pl_name].lastleave = time();
303 end
304 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"_GEM_CheckPlayerLeft : Player "..pl_name.." left channel "..channel);
305 GEM_ConnectedPlayers[channel][pl_name] = nil;
306 GEMList_Notify(GEM_NOTIFY_MY_SUBSCRIPTION,"");
307 end
308 end
309  
310 local function _GEM_StartupInitVars()
311 local playerName = UnitName("player");
312 if((playerName) and (playerName ~= UNKNOWNOBJECT) and (playerName ~= UKNOWNBEING))
313 then
314 GEM_PlayerName = playerName;
315 GEM_Realm = GetCVar("realmName");
316 _GEM_NeedInit = false;
317 if(GEM_Events.realms == nil) -- First time module init (ever)
318 then
319 GEM_Events = {}; -- Reset everything
320 GEM_Events.next_event_id = 0;
321 GEM_Events.realms = {};
322 GEM_Events.MinimapRadiusOffset = 77;
323 GEM_Events.MinimapArcOffset = 296;
324 GEM_Events.MinimapTexture = "Spell_Nature_TimeStop";
325 GEM_Events.DateFormat = GEM_DATE_FORMAT;
326 --GEM_Events.debug = 1;
327 GEM_Events.debug = nil;
328 end
329 GEM_Events.my_bcast_offset = 2 + math.mod(time(),85); -- Change value each login
330 if(GEM_Events.realms[GEM_Realm] == nil) -- First time in this realm
331 then
332 GEM_Events.realms[GEM_Realm] = {};
333 GEM_Events.realms[GEM_Realm].events = {};
334 GEM_Events.realms[GEM_Realm].commands = {};
335 GEM_Events.realms[GEM_Realm].subscribed = {};
336 GEM_Events.realms[GEM_Realm].my_names = {};
337 GEM_Events.realms[GEM_Realm].ChannelPassword = nil;
338 GEM_Events.realms[GEM_Realm].kicked = {};
339 GEM_Events.realms[GEM_Realm].banned = {};
340 GEM_Events.realms[GEM_Realm].forward = {};
341 end
342 if(GEM_Events.realms[GEM_Realm].my_closed_events == nil) -- v2.02 addition
343 then
344 GEM_Events.realms[GEM_Realm].my_closed_events = {};
345 end
346 if(GEM_Events.realms[GEM_Realm].ignore == nil) -- v2.01 addition
347 then
348 GEM_Events.realms[GEM_Realm].ignore = {};
349 GEM_Events.realms[GEM_Realm].assistant = {};
350 end
351 if(GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName] == nil) -- First time with this toon in this realm
352 then
353 GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName] = {};
354 local _,class = UnitClass("player");
355 GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].class = class;
356 end
357 local playerGuild = GetGuildInfo("player"); -- Thanks to blizz 1.7 changes, this might not been initialized here
358 GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].level = UnitLevel("player");
359 GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].guild = playerGuild;
360 GEMOptions_LoadChannelsConfig(GEM_PlayerName); -- Load channels config
361 GEM_InitChannels(true); -- And init channels
362 GEM_COM_InitRoutines();
363 GEMMinimapButton_Update();
364 GEM_DBG_SetDebugMode(GEM_Events.debug,false);
365 end
366 end
367  
368  
369 --------------- From XML functions ---------------
370  
371 function GEM_OnEvent()
372 if(event == "VARIABLES_LOADED")
373 then
374 if(_GEM_NeedInit)
375 then
376 _GEM_StartupInitVars();
377 end
378 return;
379 end
380  
381 local channel = nil;
382 if(arg9)
383 then
384 channel = strlower(arg9);
385 end
386  
387 -- Check events
388 if(event == "CHAT_MSG_CHANNEL" and channel and GEM_Realm)
389 then
390 if(GEM_IsChannelInList(channel)) -- Channel joined, process
391 then
392 if(strsub(arg1, strlen(arg1)-7) == " ...hic!") then
393 arg1 = strsub(arg1, 1, strlen(arg1)-8);
394 end
395 if(string.find(arg1,"^<GEM")) -- Process only GEM messages
396 then
397 GEM_COM_ParseChannelMessage(channel,arg2,arg1);
398 elseif(UnitName("player") ~= arg2 and GEMOptions_MustBip(arg1))
399 then
400 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"Found your name in the channel, COIN !");
401 PlaySoundFile("Interface\\AddOns\\GuildEventManager2\\coin.wav");
402 end
403 --[[else
404 if(string.find(arg1,"^<GEM")) -- Got a GEM message on another channel ?
405 then
406 if(_GEM_WrongChanNotified[channel] == nil)
407 then
408 GEM_ChatPrint("Warning : Found a GEM command From "..tostring(arg2).." on Channel '"..channel.."' but it is not the channel set in GEM configuration. You can leave this chan, but if you have this message by mistake, please inform Kiki");
409 _GEM_WrongChanNotified[channel] = 1;
410 end
411 end]]
412 end
413 elseif(event == "CHAT_MSG_CHANNEL_NOTICE" and channel and GEM_Realm)
414 then
415 if(arg1 and GEM_COM_Channels and GEM_COM_Channels[channel])
416 then
417 if(arg1 == "YOU_LEFT" and GEM_COM_Channels[channel].id ~= 0)
418 then
419 GEM_COM_Channels[channel].id = 0;
420 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"Leaving by hand "..channel);
421 elseif(arg1 == "YOU_JOINED" and GEM_COM_Channels[channel].id == 0 and not GEM_COM_Channels[channel].already_bcast)
422 then
423 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"Re-joining by hand "..channel);
424 _GEM_CheckForJoined(channel);
425 elseif(arg1 == "WRONG_PASSWORD")
426 then
427 if(GEM_COM_Channels[channel].password and GEM_COM_Channels[channel].password ~= "") -- Had a password
428 then
429 if(GEM_COM_Channels[channel].retries and GEM_COM_Channels[channel].retries > 2) -- More than 2 retries, try without a password
430 then
431 GEM_ChatPrint("You set a password ("..GEM_COM_Channels[channel].password..") for channel '"..channel.."' but it is not correct, retrying without password...");
432 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"You set a password ("..GEM_COM_Channels[channel].password..") for channel '"..channel.."' but it is not correct, retrying without password...");
433 GEM_COM_Channels[channel].password = "";
434 GEMSystem_Schedule(1,GEM_InitChannels,false); -- Schedule retry in 1sec
435 end
436 else -- No password -> Print error
437 GEM_COM_Channels[channel].retries = _GEM_MaxJoinRetry + 1;
438 GEM_ChatPrint("Incorrect password for channel '"..channel.."'");
439 end
440 end
441 end
442 elseif(event == "UNIT_NAME_UPDATE")
443 then
444 if((arg1) and (arg1 == "player"))
445 then
446 GEM_CheckPlayerGuild();
447 end
448 elseif(event == "CHAT_MSG_CHANNEL_JOIN" and channel)
449 then
450 if(GEM_IsChannelInList(channel))
451 then
452 GEM_CheckPlayerJoined(channel,arg2,true);
453 GEM_QUE_BuildBroadcastQueues(channel,arg2);
454 end
455 elseif(event == "CHAT_MSG_CHANNEL_LEAVE" and channel)
456 then
457 if(GEM_IsChannelInList(channel))
458 then
459 _GEM_CheckPlayerLeft(channel,arg2);
460 end
461 elseif(event == "CHAT_MSG_CHANNEL_LIST" and channel)
462 then
463 if(GEM_IsChannelJoined(channel))
464 then
465 local users = {};
466 for value in string.gfind(arg1,"[^,]+") do
467 table.insert(users, value);
468 end
469 for k,v in users do
470 k2 = string.gsub(v, "%s*%@*%**([^%s]+)", "%1");
471 GEM_CheckPlayerJoined(channel,k2,false);
472 end
473 local count = 0;
474 for n in GEM_ConnectedPlayers[channel]
475 do
476 count = count + 1;
477 if(count >=2) then break; end
478 end
479 if(count == 1 and GEM_COM_Channels[channel].password and GEM_COM_Channels[channel].password ~= "") -- I'm alone, and there is a password for this channel
480 then
481 SetChannelPassword(channel,GEM_COM_Channels[channel].password);
482 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"I'm alone in channel '"..channel.."' and I must set a password... setting it to "..GEM_COM_Channels[channel].password);
483 end
484 end
485 elseif(event == "PARTY_MEMBERS_CHANGED")
486 then
487 if(GetNumPartyMembers() == 0)
488 then
489 GEMList_CurrentGroupIDMustReset = true;
490 else
491 GEMList_CurrentGroupIDMustReset = false;
492 end
493 if(GEMList_CurrentGroupID ~= nil and GEMList_CurrentGroupIDMustReset ~= true)
494 then
495 if(GEMList_MustConvertToRaid == true)
496 then
497 ConvertToRaid();
498 GEMList_CurrentGroupIsRaid = true;
499 GEM_ChatDebug(GEM_DEBUG_GLOBAL,"Converted to raid !");
500 GEMList_MustConvertToRaid = false;
501 end
502 if(GEMList_CurrentGroupIsRaid == false and GEM_Events.realms[GEM_Realm].events[GEMList_CurrentGroupID] and GEM_Events.realms[GEM_Realm].events[GEMList_CurrentGroupID].max_count > 5) -- A raid
503 then
504 GEMList_MustConvertToRaid = true;
505 GEM_ChatDebug(GEM_DEBUG_GLOBAL,"Must convert to raid !");
506 end
507 end
508 elseif(event == "ZONE_CHANGED_NEW_AREA")
509 then
510 GEM_COM_PlayerInfos(); -- Send an update of my infos
511 GEM_NotifyGUI(GEM_NOTIFY_PLAYER_INFOS);
512  
513 -- Check channel IDs
514 for name,chantab in GEM_COM_Channels
515 do
516 local id = GetChannelName(name);
517 if(GEM_COM_Channels[name].id ~= 0 and GEM_COM_Channels[name].id ~= id) -- If channel ID has changed
518 then
519 --GEM_ChatWarning("ZONE_CHANGED_NEW_AREA : ChannelID for '"..name.."' has changed from "..GEM_COM_Channels[name].id.." to "..id);
520 GEM_COM_Channels[name].id = id;
521 end
522 end
523 elseif(event == "CHAT_MSG_SYSTEM")
524 then
525 for i=1,GEM_DRUNK_MESSAGES_COUNT
526 do
527 if(arg1 == GEM_DRUNK_MESSAGES[i])
528 then
529 GEM_YouAreDrunk = true;
530 break;
531 end
532 end
533 if(arg1 == GEM_DRUNK_NORMAL)
534 then
535 GEM_YouAreDrunk = false;
536 end
537 end
538 end
539  
540 function GEM_OnLoad()
541 -- Print init message
542 GEM_ChatPrint("Version "..GEM_VERSION.." "..GEM_CHAT_MISC_LOADED);
543  
544 -- Register events
545 this:RegisterEvent("VARIABLES_LOADED");
546 this:RegisterEvent("ADDON_LOADED");
547 this:RegisterEvent("CHAT_MSG_CHANNEL");
548 this:RegisterEvent("CHAT_MSG_CHANNEL_NOTICE");
549 this:RegisterEvent("CHAT_MSG_CHANNEL_JOIN");
550 this:RegisterEvent("CHAT_MSG_CHANNEL_LEAVE");
551 this:RegisterEvent("CHAT_MSG_CHANNEL_LIST");
552 this:RegisterEvent("CHAT_MSG_SYSTEM");
553 this:RegisterEvent("UNIT_NAME_UPDATE");
554 this:RegisterEvent("PARTY_MEMBERS_CHANGED");
555 this:RegisterEvent("ZONE_CHANGED_NEW_AREA");
556  
557 -- Initialize Slash commands
558 SLASH_GEM1 = "/gem";
559 SlashCmdList["GEM"] = function(msg)
560 _GEM_Commands(msg);
561 end
562  
563 tinsert(UISpecialFrames, "GEMMainFrame");
564 tinsert(UISpecialFrames, "GEMCalendarFrame");
565 tinsert(UISpecialFrames, "GEMExternalFrame");
566 tinsert(UISpecialFrames, "GEMListBannedFrame");
567 tinsert(UISpecialFrames, "GEMNewAutoMembersFrame");
568 end
569  
570 --------------- Exported functions ---------------
571  
572 function GEM_ComputeServerOffset()
573 if(GEM_Events.realms[GEM_Realm] and GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName] and GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].ForceHourOffset)
574 then
575 GEM_ServerOffset = GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].ForceHourOffset;
576 return;
577 end
578 if(GEM_ServerOffset == 666)
579 then
580 local hour = GetGameTime();
581 if(hour == nil or tonumber(hour) == -1)
582 then
583 return;
584 end
585 local today = date("*t");
586 local offset = hour - today.hour;
587  
588 if(math.abs(offset) > 12)
589 then
590 if(offset > 0)
591 then
592 offset = offset - 24;
593 else
594 offset = offset + 24;
595 end
596 end
597 GEM_ServerOffset = offset;
598 end
599 end
600  
601 function GEM_ComputeHourOffset()
602 if(GEM_ServerOffset == 666)
603 then
604 GEM_ComputeServerOffset();
605 end
606 if(GEM_Events == nil or GEM_Events.realms == nil or GEM_Events.realms[GEM_Realm] == nil or GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].UseServerTime ~= 1 or GEM_ServerOffset == 666)
607 then
608 return 0;
609 end
610 return GEM_ServerOffset * 60 * 60;
611 end
612  
613 -- Checks if 'name' is one of my rerolls
614 function GEM_IsMyReroll(name)
615 if(GEM_Events.realms[GEM_Realm].my_names[name] ~= nil)
616 then
617 return true;
618 end
619 return false;
620 end
621  
622 function GEM_IsChannelInList(channel)
623 if(GEM_COM_Channels and GEM_COM_Channels[channel])
624 then
625 --[[if(GEM_COM_Channels[channel].id == 0)
626 then
627 if(GEM_COM_Channels[channel].already_bcast) -- Channel is in my list, but was left by hand !
628 then
629 return true;
630 end
631 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"GEM_IsChannelInList : ChannelID for '"..tostring(channel).."' not found, calling InitChannels(false)");
632 GEM_InitChannels(false);
633 end
634 return GEM_COM_Channels[channel].id ~= 0;]]
635 return true;
636 end
637 return false;
638 end
639  
640 function GEM_IsChannelInRerollList(pl_name,channel)
641 if(GEM_Events.realms[GEM_Realm].my_names[pl_name] and GEM_Events.realms[GEM_Realm].my_names[pl_name].channels)
642 then
643 for i,chantab in GEM_Events.realms[GEM_Realm].my_names[pl_name].channels
644 do
645 if(strlower(chantab.name) == channel)
646 then
647 return true;
648 end
649 end
650 end
651 return false;
652 end
653  
654 function GEM_IsChannelJoined(channel)
655 if(GEM_COM_Channels and GEM_COM_Channels[channel] and GEM_COM_Channels[channel].id ~= 0)
656 then
657 return true;
658 end
659 return false;
660 end
661  
662 function GEM_CheckEventHasChannel(event)
663 if(event and event.channel == nil) -- Never set, set it now
664 then
665 event.channel = GEM_DefaultSendChannel;
666 end
667 end
668  
669 function GEM_CheckCommandHasChannel(cmdstab)
670 if(cmdstab.channel == nil) -- Never set, set it now
671 then
672 cmdstab.channel = GEM_DefaultSendChannel;
673 end
674 end
675  
676 function GEM_CheckPlayerJoined(channel,pl_name,mustprint)
677 if(GEM_ConnectedPlayers[channel] == nil)
678 then
679 GEM_ConnectedPlayers[channel] = {};
680 end
681 if(GEM_ConnectedPlayers[channel][pl_name] == nil)
682 then
683 local chaninfos = GEM_COM_Channels[channel];
684 if(mustprint and chaninfos and chaninfos.notify)
685 then
686 local alias = channel;
687 if(chaninfos.alias and chaninfos.alias ~= "")
688 then
689 alias = chaninfos.alias;
690 end
691 GEM_ChatMsg(alias.." : "..string.format(GEM_TEXT_PLAYER_JOINED,pl_name));
692 end
693 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"GEM_CheckPlayerJoined : Player "..pl_name.." joined "..channel);
694 if(GEM_Players[GEM_Realm] and GEM_Players[GEM_Realm][channel] and GEM_Players[GEM_Realm][channel][pl_name])
695 then
696 GEM_Players[GEM_Realm][channel][pl_name].location = GEM_NA_FORMAT; -- Reset location
697 end
698 GEM_ConnectedPlayers[channel][pl_name] = 1;
699 GEM_COM_LastJoinerTime = time();
700 GEMList_Notify(GEM_NOTIFY_MY_SUBSCRIPTION,"");
701 end
702 end
703  
704 function GEM_IsPlayerConnected(channel,pl_name)
705 if(GEM_ConnectedPlayers[channel] and GEM_ConnectedPlayers[channel][pl_name] ~= nil)
706 then
707 return true;
708 end
709 return false;
710 end
711  
712 function GEM_CheckPlayerGuild()
713 if(GEM_Realm == nil)
714 then
715 GEM_ChatWarning("GEM_CheckPlayerGuild : GEM_Realm is nil. Aborting");
716 return;
717 end
718  
719 local playerName = UnitName("player");
720 if((playerName) and (playerName ~= UNKNOWNOBJECT) and (playerName ~= UKNOWNBEING))
721 then
722 local playerGuild = GetGuildInfo("player");
723 GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].level = UnitLevel("player");
724 GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].guild = playerGuild;
725 GEM_ChatDebug(GEM_DEBUG_GLOBAL,"GEM_CheckPlayerGuild : Player "..playerName.." level "..GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].level.." from guild "..tostring(GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].guild));
726 end
727 end
728  
729 local _GEM_ScheduledChannelsInitDone = false;
730 local _GEM_InitChannelsCount = 0;
731 function GEM_InitChannels(schedule)
732 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"GEM_InitChannels : Starting channel Initialization (reschedule="..tostring(schedule).." count=".._GEM_InitChannelsCount..")");
733 _GEM_InitChannelsCount = _GEM_InitChannelsCount + 1;
734  
735 if(_GEM_InitChannelsCount == 1000)
736 then
737 GEM_ChatWarning("GEM_InitChannels : _GEM_InitChannelsCount reached 1000, you might be in flight");
738 end
739  
740 if(schedule and _GEM_ScheduledChannelsInitDone)
741 then
742 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"GEM_InitChannels : Returning, schedule="..tostring(schedule).." and _GEM_ScheduledChannelsInitDone="..tostring(_GEM_ScheduledChannelsInitDone));
743 return;
744 end
745  
746 -- Check for general channels
747 local firstChannelNumber = GetChannelList();
748 if(firstChannelNumber == nil)
749 then
750 if(schedule)
751 then
752 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"GEM_InitChannels : Main channels not init yet, reschedule init in 2 sec");
753 GEMSystem_Schedule(2,GEM_InitChannels,schedule); -- Re schedule in 2 sec
754 else
755 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"GEM_InitChannels : Main channels not init yet, but not rescheduling.");
756 end
757 return;
758 end
759  
760 _GEM_InitChannelsCount = 0;
761 GEM_EVT_CheckExpiredEvents();
762 GEM_CMD_CheckExpiredCommands();
763  
764 -- Join our channels
765 for name,chantab in GEM_COM_Channels
766 do
767 GEMPlayers_CheckExpiredPlayers(name);
768 if(chantab.id == 0) -- If this channel is not init
769 then
770 GEM_COM_JoinChannel(name,chantab.password);
771 -- Wait for our channel joined
772 GEM_ChatDebug(GEM_DEBUG_CHANNEL,"GEM_InitChannels : Join request sent, prepare _GEM_CheckForJoined schedule ? : "..tostring(chantab.retries));
773 if(chantab.retries == 0) -- Not already in a schedule check
774 then
775 GEMSystem_Schedule(3,_GEM_CheckForJoined,name); -- Schedule in 3 sec
776 end
777 end
778 end
779 if(schedule)
780 then
781 _GEM_ScheduledChannelsInitDone = true;
782 end
783 end
784