|-------------------------------------------------------------------------------
| Name: : Invite.mac
| Author : EvenLessSpam
| Useage : /macro Invite.mac
| Description : Automated group invite handling. Will auto accept invites if
| person giving invite is on the GroupLeaders list, and give
| invites to people if they're giving the correct password.
|-------------------------------------------------------------------------------
| Changes:
| 1.0.0
| + Initial release
| 1.0.1
| * Forgot to add /disband (decline) if invitee wasn't in GroupLeaders array
|-------------------------------------------------------------------------------
#Define MacroName Invite.mac
#Define MacroVersion 1.0.1
#Event GotInvite "#1# invites you to join a group."
#Event NeedInvite "#1# tells you, 'Invite (#2#)'"
#Event NoTaskInvite "You can not add #1# because they are already assigned to another shared task."
#Event NoGroupInvite "#1# is already in another group."
Sub Main
/echo MacroName vMacroVersion started...
|---------------------------------------------------------------------------
| Various declares/variables which is customizable
|---------------------------------------------------------------------------
/declare InvitePassword string outer password
/declare GroupLeaders[4] string outer N/A
/varset GroupLeaders[1] Group_Leader_001
/varset GroupLeaders[2] Group_Leader_002
/varset GroupLeaders[3] Group_Leader_003
/varset GroupLeaders[4] Group_Leader_004
:Loop
/doevents
/delay 1s
/goto :Loop
/return
|-------------------------------------------------------------------------------
| Sub Event_GotInvite: Someone wants me to join their group.
|-------------------------------------------------------------------------------
Sub Event_GotInvite(string Line, string Toon)
|---------------------------------------------------------------------------
| Check to see if I'm in a group already.
|---------------------------------------------------------------------------
/if (${Group.Members} > 0) /return
|---------------------------------------------------------------------------
| If GroupLeaders array size is set to 0, then we accept invite from anyone.
|---------------------------------------------------------------------------
/if (${GroupLeaders.Size} > 0) {
/declare i int local 0
|-----------------------------------------------------------------------
| Loop through the accepted group leaders array
|-----------------------------------------------------------------------
/for i 1 to ${GroupLeaders.Size}
|-------------------------------------------------------------------
| Check if person inviting is in the GroupLeaders list, if yes then
| accept the invite and exit this sub routine.
|-------------------------------------------------------------------
/if (${GroupLeaders[${i}].Equal[${Toon}]}) {
/invite
/return
}
/next i
|-----------------------------------------------------------------------
| Apparently we're still in this sub routine, so no matches were fount.
| Declining group invite.
|-----------------------------------------------------------------------
/decline
} else {
/invite
}
/return
|-------------------------------------------------------------------------------
| Sub Event_NeedInvite: Someone wants to get an invite to the group.
|-------------------------------------------------------------------------------
Sub Event_NeedInvite(string Line, string Toon, string Password)
|---------------------------------------------------------------------------
| Check password, if I'm leader and if there's room in group.
|---------------------------------------------------------------------------
/if ((!${Defined[Password]}) || (${Password.NotEqual[${InvitePassword}]}) || (${Group.Leader.NotEqual[${Me}]}) || (${Group.Members} > 4)) /return
/invite ${Toon}
/doevents
/taskadd ${Toon}
/doevents
/return
|-------------------------------------------------------------------------------
| Sub Event_NoTaskInvite: Player asking invite, already to another task.
|-------------------------------------------------------------------------------
Sub Event_NoTaskInvite(string Line, string Toon)
/tell ${Toon} I can not add you because you are already assigned to another shared task.
/return
|-------------------------------------------------------------------------------
| Sub Event_NoGroupInvite: Player asking invite, already in another group.
|-------------------------------------------------------------------------------
Sub Event_NoGroupInvite(string Line, string Toon)
/tell ${Toon} You are already in another group.
/return