SimpleGather: Difference between revisions

From Scriptwiki
Jump to navigation Jump to search
Shenghi (talk | contribs)
m Simple gather script
 
fixed readability + small bugs, not tested yet
Line 17: Line 17:


== The code ==
== The code ==
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
<code>
;;  SimpleGather 1.0 by Shenghi  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  #help.script @ irc.quakenet.org  
;;  SimpleGather 1.0 by Shenghi
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
;;  #help.script @ irc.quakenet.org
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;
 
;; Return hash table name. Crazy name to prevent interferance with other scripts
alias -l htname { return SG.hash }
 
;; Return gather channel name.
alias -l gatherchannel { return %SG.channel }
 
alias -l maxplayers { return %SG.maxplayers }
 
alias -l serverinfo { return %SG.serverinfo }
 
alias -l resetgather {
  if ($hget($htname)) { hfree $htname }
  .timer 1 1 msg $!gatherchannel A new gather can be started now.
}
 
 
;;;;;;;;;;;;;;;;;;;; TRIGGERS ;;;;;;;;;;;;;;;;;;;;
 
;; !start
;; Starts a gather. Only a channel op can start a gather.
on *:TEXT:!start:$gatherchannel:{
  if ($nick !isop #) { .notice $nick You are not allowed to start a gather. | return }
    
    
;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;  
  ;; check to see if we are already gathering (the hashtable will exist if we are)
  if ($hget($htname)) { .notice $nick A gather is already going on. | return }
    
    
;; Return hash table name. Crazy name to prevent interferance with other scripts
  ;; if we get here, start the gather.
alias -l htname !return htGather-e064-e6ac-679f-c8b3-20070710073819
  hmake $htname
  msg # Starting a gather with $maxplayers players. Type !add to add yourself to the list of players or !remove to quit.
}
 
;; !stop
;; Stops a gather. Only a channel op can stop a gather.
on *:TEXT:!stop:$gatherchannel:{
  if ($nick !isop #) { .notice $nick You are not allowed to stop a gather. | return }
    
    
;; Return gather channel name.
  ;; check to see if there is a gather we can stop
alias -l gatherchannel !return %gatherchannel-1172-df51-b4b6-313e-20070710100156
  if (!$hget($htname)) { .notice $nick There is currently no gather going on. | return }
    
    
alias -l maxplayers !return %gatherplayercount-e7ab-d273-a5f9-6ae2-20070710094110
  ;; if we get here we have to stop what's going on!
  hfree $htname
  msg # Gather stopped. Type !start to start a new gather.
}
 
;; !add
;; Adds a player to a running gather. Everyone can enter, but never more than 10 players.
on *:TEXT:!add:$gatherchannel:{
  ;; if there's no gathering going on, we can hardly add the player
  if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | return }
    
    
alias -l serverinfo !return %serverinfo-da91-c1fb-b6c7-8f8b-20070710105309
  ;; up to 10 players can add themselves, never more.
  if ($hget($htname,0).item == $maxplayers) { .notice $nick This gather is already full. | return }
    
    
alias -l resetgather { 
  ;; if the player is already part of the gather, there's no point in adding them again.
  .timer 1 30 if ($!hget($!htname)) !hfree $htname 
  if ($hget($htname,$nick)) { .notice $nick You are already taking part in this gather. | return }
  .timer 1 31 msg $!gatherchannel A new gather can be started now.  
}  
    
    
  ;; clones can't join...
  if ($hfind($htname,$mask($fulladdress,1),1).data) { .notice $nick Clones are not allowed to join a gather. | return }
    
    
;;;;;;;;;;;;;;;;;;;; TRIGGERS ;;;;;;;;;;;;;;;;;;;;  
  ;; if we get here, add the player
  hadd $htname $nick $mask($fulladdress,1)
  .notice $nick You have been added to the gather.
    
    
;; !start
  ;; if the player who just joined was the 10th we end the gathering
;; Starts a gather. Only a channel op can start a gather.  
  ;; and notify the players of the information
on *:TEXT:!start:%gatherchannel-1172-df51-b4b6-313e-20070710100156: {  
  if ($hget($htname,0).item == $maxplayers) {
  if ($nick !isop #) { .notice $nick You are not allowed to start a gather. | !return }  
    .disable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
    msg # Gather full. If you joined this gather, please do not change your name until you received server information.
    msg # Please wait until teams are generated and information is sent to players.
   
    var %i = $maxplayers, %teamA, %teamB
    while %i {
      if (($rand(0,1)) && ($numtok(%teamA,44) < $calc($maxplayers / 2))) || ($numtok(%teamB,44) >= $calc($maxplayers / 2)) { var %teamA = $addtok(%teamA,$chr(32) $+ $hget($htname,%i).item,44) }
      else { var %teamB = $addtok(%teamB,$chr(32) $+ $hget($htname,%i).item,44) }
      dec %i
    }
    msg # Team A: %teamA
    msg # Team B: %teamB
    .msg $remove(%teamA,$chr(32)) Team: A > %teamA -- Server: $serverinfo
    .msg $remove(%teamB,$chr(32)) Team: B > %teamB -- Server: $serverinfo
    .enable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
    .timer 1 30 resetgather
  }
}
 
;; !remove
;; Removes a player from a running gather. Everyone can remove themselves.
on *:TEXT:!remove:$gatherchannel:{
  ;; if there's no gathering going on, we can hardly remove the player
  if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | return }
    
    
  ;; check to see if we are already gathering (the hashtable will exist if we are)
  ;; if the player was no part of this gather, we can't remove him either
  if ($hget($htname)) { .notice $nick A gather is already going on. | !return }  
  if (!$hget($htname,$nick)) { .notice $nick You are not taking part in this gather. | return }
    
    
  ;; if we get here, start the gather.  
  ;; if we get here, remove the player from the gather
  !hmake $htname
  hdel $htname $nick
  msg # Starting a gather with $maxplayers players. Type !add to add yourself to the list of players or !remove to quit.  
  .notice $nick You have been removed from the gather.
}  
}
 
;; !remove <player>
;; Removes a player from a running gather. Only a channel op can remove another player.
on *:TEXT:!remove &:$gatherchannel:{
  if ($nick !isop #) { .notice $nick You are not allowed to remove another player. | return }
    
    
;; !stop
  ;; if there's no gathering going on, we can hardly remove the player
;; Stops a gather. Only a channel op can stop a gather.
  if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | return }
on *:TEXT:!stop:%gatherchannel-1172-df51-b4b6-313e-20070710100156: {
  if ($nick !isop #) { .notice $nick You are not allowed to stop a gather. | !return }  
    
    
  ;; check to see if there is a gather we can stop
  ;; if the player was no part of this gather, we can't remove him either
  if (!$hget($htname)) { .notice $nick There is currently no gather going on. | !return }  
  if (!$hget($htname,$2)) { .notice $nick That player is not taking part in this gather. | return }
    
    
  ;; if we get here we have to stop what's going on!
  ;; if we get here, remove the player from the gather
  !hfree $htname  
  hdel $htname $2
  msg # Gather stopped. Type !start to start a new gather.  
  .notice $nick $2 has been removed from the gather.
}  
}
 
;; !players
;; Shows the current players in a running gather. Only channel operators can use this trigger
on *:TEXT:!players:$gatherchannel:{
  if ($nick !isop #) { .notice $nick You are not allowed to dump the playerlist. | return }
    
    
;; !add
  ;; if there is no gather going on, there is no list of players to dump.
;; Adds a player to a running gather. Everyone can enter, but never more than 10 players.  
  if (!$hget($htname)) { msg # There is no gather going on at this moment. Use !start to start one. | return }
on *:TEXT:!add:%gatherchannel-1172-df51-b4b6-313e-20070710100156: {  
  var %i = $hget($htname,0).item
  ;; if there's no gathering going on, we can hardly add the player
  if (!%i) { msg # There are currently no players participating in this gather. | return }
  if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | !return }  
  var %players
  while %i {
    %players = $addtok(%players,$chr(32) $+ $hget($htname,%i).item,44)
    dec %i
  }
  msg # Current players: %players
}
 
#numplayers-afeb-6ac1-6b3a-7606-20070710103913 on
;; !numplayers
;; Sets the amount of players.
on *:TEXT:!numplayers &:$gatherchannel:{
  ;; first arg has to be a number
  if ($2 !isnum 1-) { .notice $nick Wrong usage of trigger. | return }
    
    
  ;; up to 10 players can add themselves, never more.
  if ($calc($2 % 2)) { .notice $nick Number of players must be even. | return }
  if ($hget($htname,0).item == $maxplayers) { .notice $nick This gather is already full. | !return }  
    
    
  ;; if the player is already part of the gather, there's no point in adding them again.
  if ($hget($htname,$nick)) { .notice $nick You are already taking part in this gather. | !return }
    
    
  ;; clones can't join...  
  set %SG.maxplayers $2
  ;;if ($hfind($htname,$gettok($fulladdress,2,33)).data) { .notice $nick Clones are not allowed to join a gather. | !return }
  msg # Amount of players for gather set to $2 $+ .
    
    
  ;; if we get here, add the player
  if ($hget($htname,0).item >= $maxplayers) {
  !hadd $htname $nick $gettok($fulladdress,2,33)  
    ;; form teams and start...
  .notice $nick You have been added to the gather.  
    .disable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
    msg # Gather full. If you joined this gather, please do not change your name until you received server information.
    msg # Please wait until teams are generated and information is sent to players.
   
    var %i = $maxplayers, %teamA, %teamB
    while %i {
      if (($rand(0,1)) && ($numtok(%teamA,44) < $calc($maxplayers / 2))) || ($numtok(%teamB,44) >= $calc($maxplayers / 2)) %teamA = $addtok(%teamA,$chr(32) $+ $hget($htname,%i).item,44)
      else %teamB = $addtok(%teamB,$chr(32) $+ $hget($htname,%i).item,44)
      dec %i
    }
    msg # Team A: %teamA
    msg # Team B: %teamB
    .msg $remove(%teamA,$chr(32)) :Team: A > %teamA -- Server: $serverinfo
    .msg $remove(%teamB,$chr(32)) :Team: B > %teamB -- Server: $serverinfo
    .enable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
    .timer 1 30 resetgather
  }
}
#numplayers-afeb-6ac1-6b3a-7606-20070710103913 end
 
;; !gatherchan
;; Changes gather channel to a new one
on *:TEXT:!gatherchan &:$gatherchannel:{
  if ($nick !isop #) { .notice $nick Only a channel operator on both old and new channel can change the channel. | return }
  if ($hget($htname)) { .notice $nick Cannot change gather channel while a gather is running. | return }
  if ($left($2,1) !isin $chantypes) { .notice $nick Not a valid channelname. | return }
  if ($me !ison $2) { .notice $nick Cannot change the gather channel to a channel I am not on. | return }
  if ($nick !isop $2) { .notice $nick Only a channel operator on both old and new channel can change the channel. | return }
    
    
  ;; if the player who just joined was the 10th we end the gathering
  set %SG.channel $2
  ;; and notify the players of the information
  .notice $nick Gather channel set to $2
  if ($hget($htname,0).item == $maxplayers) {  
}
    .disable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
 
    msg # Gather full. If you joined this gather, please do not change your name until you received server information.
;; !serverinfo
    msg # Please wait until teams are generated and information is sent to players.  
;; Changes the server info. Only a channel operator can use this.
on *:TEXT:!serverinfo *:$gatherchannel:{
  if ($nick !isop #) { .notice $nick You are not allowed to change the server info | return }
  if ($hget($htname)) { .notice $nick Server info cannot be changed during a gather. | return }
    
    
    var %i = $maxplayers, %teamA, %teamB
   set %SG.serverinfo $2-
    while %i { 
   .notice $nick Server information changed.
      if (($rand(0,1)) && ($numtok(%teamA,44) < $calc($maxplayers / 2))) || ($numtok(%teamB,44) >= $calc($maxplayers / 2)) %teamA = $addtok(%teamA,$chr(32) $+ $hget($htname,%i).item,44)
}
      else %teamB = $addtok(%teamB,$chr(32) $+ $hget($htname,%i).item,44)
 
      dec %i
;;;;; Some overhead. When a player quits, parts or is kicked they are removed from the gather.
    }
;;;;; When the bot quits or is disconnected the gather is terminated.
    msg # Team A: %teamA
;;;;; When a user changes his nick it's automatically updated
    msg # Team B: %teamB
on *:KICK:$gatherchannel:{ if ($hget($htname,$knick)) { hdel $htname $knick } }
    .raw PRIVMSG $remove(%teamA,$chr(32)) :Team: A > %teamA -- Server: $serverinfo
on *:PART:$gatherchannel:{ if ($hget($htname,$nick)) { hdel $htname $nick } }
    .raw PRIVMSG $remove(%teamB,$chr(32)) :Team: B > %teamB -- Server: $serverinfo
on *:QUIT: {
    .enable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
  if ($nick == $me) && ($hget($htname)) { hfree $htname }
    resetgather
  elseif ($hget($htname,$nick)) { hdel $htname $nick }
  }
}
}
on *:DISCONNECT:{ if ($hget($htname)) { hfree $htname } }
    
 
;; !remove
on *:NICK:{
;; Removes a player from a running gather. Everyone can remove themselves.
  if ($nick == $me) || ($nick == $newnick) { return }
on *:TEXT:!remove:%gatherchannel-1172-df51-b4b6-313e-20070710100156:{
  if ($hget($htname,$nick)) {
  ;; if there's no gathering going on, we can hardly remove the player
    hadd $htname $newnick $v1
  if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | !return }
    hdel $htname $nick
 
  }
  ;; if the player was no part of this gather, we can't remove him either
}
  if (!$hget($htname,$nick)) { .notice $nick You are not taking part in this gather. | !return }
 
 
on *:LOAD:{
  ;; if we get here, remove the player from the gather
  set %SG.channel #channel
  !hdel $htname $nick
  set %SG.maxplayers 10
  .notice $nick You have been removed from the gather.
  set %SG.serverinfo cs.someserver.com:12345
}
}
 
</code>
;; !remove <player>
;; Removes a player from a running gather. Only a channel op can remove another player.
on *:TEXT:!remove &:%gatherchannel-1172-df51-b4b6-313e-20070710100156:{
  if ($nick !isop #) { .notice $nick You are not allowed to remove another player. | !return }
 
  ;; if there's no gathering going on, we can hardly remove the player
  if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | !return }
 
  ;; if the player was no part of this gather, we can't remove him either
  if (!$hget($htname,$2)) { .notice $nick That player is not taking part in this gather. | !return }
 
  ;; if we get here, remove the player from the gather
  !hdel $htname $2
  .notice $nick $2 has been removed from the gather.
}
 
;; !players
;; Shows the current players in a running gather. Only channel operators can use this trigger
on *:TEXT:!players:%gatherchannel-1172-df51-b4b6-313e-20070710100156:{
  if ($nick !isop #) { .notice $nick You are not allowed to dump the playerlist. | !return }
 
  ;; if there is no gather going on, there is no list of players to dump.
  if (!$hget($htname)) { msg # There is no gather going on at this moment. Use !start to start one. | !return }
  var %i = $hget($htname,0).item
  if (!%i) { msg # There are currently no players participating in this gather. | !return }
  var %players
  while %i { 
    %players = $addtok(%players,$chr(32) $+ $hget($htname,%i).item,44)
    dec %i 
  }
  msg # Current players: %players
}
 
#numplayers-afeb-6ac1-6b3a-7606-20070710103913 on
;; !numplayers
;; Sets the amount of players.
on *:TEXT:!numplayers &:%gatherchannel-1172-df51-b4b6-313e-20070710100156:{
  ;; first arg has to be a number
  if ($2 !isnum) { .notice $nick Wrong usage of trigger. | !return }
 
  if ($calc($2 % 2)) { .notice $nick Number of players must be even. | !return }
 
 
  !set %gatherplayercount-e7ab-d273-a5f9-6ae2-20070710094110 $2
  msg # Amount of players for gather set to $2 $+ .
 
  if ($hget($htname,0).item >= $maxplayers) {
    ;; form teams and start...
    .disable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
    msg # Gather full. If you joined this gather, please do not change your name until you received server information.
    msg # Please wait until teams are generated and information is sent to players.
 
    var %i = $maxplayers, %teamA, %teamB
    while %i { 
      if (($rand(0,1)) && ($numtok(%teamA,44) < $calc($maxplayers / 2))) || ($numtok(%teamB,44) >= $calc($maxplayers / 2)) %teamA = $addtok(%teamA,$chr(32) $+ $hget($htname,%i).item,44)
      else %teamB = $addtok(%teamB,$chr(32) $+ $hget($htname,%i).item,44)
      dec %i
    }
    msg # Team A: %teamA
    msg # Team B: %teamB
    .raw PRIVMSG $remove(%teamA,$chr(32)) :Team: A > %teamA -- Server: $serverinfo
    .raw PRIVMSG $remove(%teamB,$chr(32)) :Team: B > %teamB -- Server: $serverinfo  
    .enable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
    resetgather
  }
}
#numplayers-afeb-6ac1-6b3a-7606-20070710103913 end
 
;; !gatherchan
;; Changes gather channel to a new one
on *:TEXT:!gatherchan &:%gatherchannel-1172-df51-b4b6-313e-20070710100156:{
  if ($nick !isop #) { .notice $nick Only a channel operator on both old and new channel can change the channel. | !return }
  if ($hget($htname)) { .notice $nick Cannot change gather channel while a gather is running. | !return }
  if ($left($2,1) !isin $chantypes) { .notice $nick Not a valid channelname. | !return }
  if ($me !ison $2) { .notice $nick Cannot change the gather channel to a channel I am not on. | !return }
  if ($nick !isop $2) { .notice $nick Only a channel operator on both old and new channel can change the channel. | !return }
 
  !set %gatherchannel-1172-df51-b4b6-313e-20070710100156 $2
  .notice $nick Gather channel set to $2
}
 
;; !serverinfo
;; Changes the server info. Only a channel operator can use this.
on *:TEXT:!serverinfo *:%gatherchannel-1172-df51-b4b6-313e-20070710100156:{
  if ($nick !isop #) { .notice $nick You are not allowed to change the server info | !return }
  if ($hget($htname)) { .notice $nick Server info cannot be changed during a gather. | !return }
    
  !set %serverinfo-da91-c1fb-b6c7-8f8b-20070710105309 $2-
  .notice $nick Server information changed.  
}  
 
;;;;; Some overhead. When a player quits, parts or is kicked they are removed from the gather.  
;;;;; When the bot quits or is disconnected the gather is terminated.  
;;;;; When a user changes his nick it's automatically updated  
on *:KICK:%gatherchannel-1172-df51-b4b6-313e-20070710100156: if ($hget($htname,$nick)) !hdel $htname $nick
on *:PART:%gatherchannel-1172-df51-b4b6-313e-20070710100156: if ($hget($htname,$nick)) !hdel $htname $nick  
on *:QUIT: {  
  if ($nick == $me) && ($hget($htname)) !hfree $htname  
  else if ($hget($htname,$nick)) !hdel $htname $nick  
}  
on *:DISCONNECT: if ($hget($htname)) !hfree $htname  
 
on *:NICK:{  
  if ($nick != $me) && ($nick != $newnick) {  
    if ($hget($htname,$nick)) {  
      !hadd $htname $newnick $v1  
      !hdel $htname $nick  
    }  
  }  
}
 
on *:LOAD:{  
  !set %gatherchannel-1172-df51-b4b6-313e-20070710100156 #channel  
  !set %gatherplayercount-e7ab-d273-a5f9-6ae2-20070710094110 10  
  !set %serverinfo-da91-c1fb-b6c7-8f8b-20070710105309 cs.someserver.com:12345  
}
[[Category:Script Archive]]
[[Category:Script Archive]]

Revision as of 23:04, 16 July 2007

SimpleGather is a fairly basic gather script mainly created because so many beginners are trying to make one, while even a very basic gather script is not that simple. The aim of SimpleGather is simplicity: it can run only one gather at a time, works only on a single channel, and multiple servers is out of the question. Setting it up is easy:

  • Copy and paste the script into a new script file, load it and make sure you run the initialization commands;
  • Go to the variables tab in the script editor;
  • Change "%gatherchannel-1172-df51-b4b6-313e-20070710100156" to your gather channel;
  • Change "%gatherplayercount-e7ab-d273-a5f9-6ae2-20070710094110" to the amount of players (defaults to 10);
  • Change "%serverinfo-da91-c1fb-b6c7-8f8b-20070710105309" to your server IP/Port.

The triggers

  • !start - Starts a new gather. Only available to channel ops.
  • !stop - Stops an ongoing gather. Only available to channel ops.
  • !add - Adds the typer to the gather. Available to everyone.
  • !remove - Removes the typer from the gather. Available to everyone.
  • !remove <nick> - Removes the specified player from the gather. Only available to channel ops.
  • !numplayers <num> - Sets the amount of participating players to <num>. If a gather is already past this amount then it will be flagged as full right away. Only available to channel ops.
  • !gatherchan <chan> - Sets the gatherchan to <chan>. Cannot be used while gathering is in progress. Only available to channel ops on both the current and the new channel.
  • !serverinfo <info> - Sets the server information to <info>. Cannot be used while gathering is in progress. Only available to channel ops.

The code

SimpleGather 1.0 by Shenghi
#help.script @ irc.quakenet.org
PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;
Return hash table name. Crazy name to prevent interferance with other scripts

alias -l htname { return SG.hash }

Return gather channel name.

alias -l gatherchannel { return %SG.channel }

alias -l maxplayers { return %SG.maxplayers }

alias -l serverinfo { return %SG.serverinfo }

alias -l resetgather {

 if ($hget($htname)) { hfree $htname }
 .timer 1 1 msg $!gatherchannel A new gather can be started now.

}


TRIGGERS ;;;;;;;;;;;;;;;;;;;;
!start
Starts a gather. Only a channel op can start a gather.

on *:TEXT:!start:$gatherchannel:{

 if ($nick !isop #) { .notice $nick You are not allowed to start a gather. | return }
 
 ;; check to see if we are already gathering (the hashtable will exist if we are)
 if ($hget($htname)) { .notice $nick A gather is already going on. | return }
 
 ;; if we get here, start the gather.
 hmake $htname
 msg # Starting a gather with $maxplayers players. Type !add to add yourself to the list of players or !remove to quit.

}

!stop
Stops a gather. Only a channel op can stop a gather.

on *:TEXT:!stop:$gatherchannel:{

 if ($nick !isop #) { .notice $nick You are not allowed to stop a gather. | return }
 
 ;; check to see if there is a gather we can stop
 if (!$hget($htname)) { .notice $nick There is currently no gather going on. | return }
 
 ;; if we get here we have to stop what's going on!
 hfree $htname
 msg # Gather stopped. Type !start to start a new gather.

}

!add
Adds a player to a running gather. Everyone can enter, but never more than 10 players.

on *:TEXT:!add:$gatherchannel:{

 ;; if there's no gathering going on, we can hardly add the player
 if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | return }
 
 ;; up to 10 players can add themselves, never more.
 if ($hget($htname,0).item == $maxplayers) { .notice $nick This gather is already full. | return }
 
 ;; if the player is already part of the gather, there's no point in adding them again.
 if ($hget($htname,$nick)) { .notice $nick You are already taking part in this gather. | return }
 
 ;; clones can't join...
 if ($hfind($htname,$mask($fulladdress,1),1).data) { .notice $nick Clones are not allowed to join a gather. | return }
 
 ;; if we get here, add the player
 hadd $htname $nick $mask($fulladdress,1)
 .notice $nick You have been added to the gather.
 
 ;; if the player who just joined was the 10th we end the gathering
 ;; and notify the players of the information
 if ($hget($htname,0).item == $maxplayers) {
   .disable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
   msg # Gather full. If you joined this gather, please do not change your name until you received server information.
   msg # Please wait until teams are generated and information is sent to players.
   
   var %i = $maxplayers, %teamA, %teamB
   while %i {
     if (($rand(0,1)) && ($numtok(%teamA,44) < $calc($maxplayers / 2))) || ($numtok(%teamB,44) >= $calc($maxplayers / 2)) { var %teamA = $addtok(%teamA,$chr(32) $+ $hget($htname,%i).item,44) }
     else { var %teamB = $addtok(%teamB,$chr(32) $+ $hget($htname,%i).item,44) }
     dec %i
   }
   msg # Team A: %teamA
   msg # Team B: %teamB
   .msg $remove(%teamA,$chr(32)) Team: A > %teamA -- Server: $serverinfo
   .msg $remove(%teamB,$chr(32)) Team: B > %teamB -- Server: $serverinfo
   .enable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
   .timer 1 30 resetgather
 }

}

!remove
Removes a player from a running gather. Everyone can remove themselves.

on *:TEXT:!remove:$gatherchannel:{

 ;; if there's no gathering going on, we can hardly remove the player
 if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | return }
 
 ;; if the player was no part of this gather, we can't remove him either
 if (!$hget($htname,$nick)) { .notice $nick You are not taking part in this gather. | return }
 
 ;; if we get here, remove the player from the gather
 hdel $htname $nick
 .notice $nick You have been removed from the gather.

}

!remove <player>
Removes a player from a running gather. Only a channel op can remove another player.

on *:TEXT:!remove &:$gatherchannel:{

 if ($nick !isop #) { .notice $nick You are not allowed to remove another player. | return }
 
 ;; if there's no gathering going on, we can hardly remove the player
 if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | return }
 
 ;; if the player was no part of this gather, we can't remove him either
 if (!$hget($htname,$2)) { .notice $nick That player is not taking part in this gather. | return }
 
 ;; if we get here, remove the player from the gather
 hdel $htname $2
 .notice $nick $2 has been removed from the gather.

}

!players
Shows the current players in a running gather. Only channel operators can use this trigger

on *:TEXT:!players:$gatherchannel:{

 if ($nick !isop #) { .notice $nick You are not allowed to dump the playerlist. | return }
 
 ;; if there is no gather going on, there is no list of players to dump.
 if (!$hget($htname)) { msg # There is no gather going on at this moment. Use !start to start one. | return }
 var %i = $hget($htname,0).item
 if (!%i) { msg # There are currently no players participating in this gather. | return }
 var %players
 while %i {
   %players = $addtok(%players,$chr(32) $+ $hget($htname,%i).item,44)
   dec %i
 }
 msg # Current players: %players

}

  1. numplayers-afeb-6ac1-6b3a-7606-20070710103913 on
!numplayers
Sets the amount of players.

on *:TEXT:!numplayers &:$gatherchannel:{

 ;; first arg has to be a number
 if ($2 !isnum 1-) { .notice $nick Wrong usage of trigger. | return }
 
 if ($calc($2 % 2)) { .notice $nick Number of players must be even. | return }
 
 
 set %SG.maxplayers $2
 msg # Amount of players for gather set to $2 $+ .
 
 if ($hget($htname,0).item >= $maxplayers) {
   ;; form teams and start...
   .disable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
   msg # Gather full. If you joined this gather, please do not change your name until you received server information.
   msg # Please wait until teams are generated and information is sent to players.
   
   var %i = $maxplayers, %teamA, %teamB
   while %i {
     if (($rand(0,1)) && ($numtok(%teamA,44) < $calc($maxplayers / 2))) || ($numtok(%teamB,44) >= $calc($maxplayers / 2)) %teamA = $addtok(%teamA,$chr(32) $+ $hget($htname,%i).item,44)
     else %teamB = $addtok(%teamB,$chr(32) $+ $hget($htname,%i).item,44)
     dec %i
   }
   msg # Team A: %teamA
   msg # Team B: %teamB
   .msg $remove(%teamA,$chr(32)) :Team: A > %teamA -- Server: $serverinfo
   .msg $remove(%teamB,$chr(32)) :Team: B > %teamB -- Server: $serverinfo
   .enable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
   .timer 1 30 resetgather
 }

}

  1. numplayers-afeb-6ac1-6b3a-7606-20070710103913 end
!gatherchan
Changes gather channel to a new one

on *:TEXT:!gatherchan &:$gatherchannel:{

 if ($nick !isop #) { .notice $nick Only a channel operator on both old and new channel can change the channel. | return }
 if ($hget($htname)) { .notice $nick Cannot change gather channel while a gather is running. | return }
 if ($left($2,1) !isin $chantypes) { .notice $nick Not a valid channelname. | return }
 if ($me !ison $2) { .notice $nick Cannot change the gather channel to a channel I am not on. | return }
 if ($nick !isop $2) { .notice $nick Only a channel operator on both old and new channel can change the channel. | return }
 
 set %SG.channel $2
 .notice $nick Gather channel set to $2

}

!serverinfo
Changes the server info. Only a channel operator can use this.

on *:TEXT:!serverinfo *:$gatherchannel:{

 if ($nick !isop #) { .notice $nick You are not allowed to change the server info | return }
 if ($hget($htname)) { .notice $nick Server info cannot be changed during a gather. | return }
 
 set %SG.serverinfo $2-
 .notice $nick Server information changed.

}

Some overhead. When a player quits, parts or is kicked they are removed from the gather.
When the bot quits or is disconnected the gather is terminated.
When a user changes his nick it's automatically updated

on *:KICK:$gatherchannel:{ if ($hget($htname,$knick)) { hdel $htname $knick } } on *:PART:$gatherchannel:{ if ($hget($htname,$nick)) { hdel $htname $nick } } on *:QUIT: {

 if ($nick == $me) && ($hget($htname)) { hfree $htname }
 elseif ($hget($htname,$nick)) { hdel $htname $nick }

} on *:DISCONNECT:{ if ($hget($htname)) { hfree $htname } }

on *:NICK:{

 if ($nick == $me) || ($nick == $newnick) { return }
 if ($hget($htname,$nick)) {
   hadd $htname $newnick $v1
   hdel $htname $nick
 }

}

on *:LOAD:{

 set %SG.channel #channel
 set %SG.maxplayers 10
 set %SG.serverinfo cs.someserver.com:12345

}