Guest User

Naliz

a guest
Mar 18th, 2013
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 8.63 KB | None | 0 0
  1. ;;;;;;;;;;;;;;;;;;;; PRIVATE ALIASES ;;;;;;;;;;;;;;;;;;;;
  2.  
  3. ;; Return hash table name. Crazy name to prevent interferance with other scripts
  4. alias -l htname { return SG.hash }
  5.  
  6. ;; Return gather channel name.
  7. alias -l gatherchannel { return %SG.channel }
  8.  
  9. alias -l maxplayers { return %SG.maxplayers }
  10.  
  11. alias -l serverinfo { return %SG.serverinfo }
  12.  
  13. alias -l resetgather {
  14.   if ($hget($htname)) { hfree $htname }
  15.   .timer 1 1 msg $!gatherchannel 14(5!14) 5Another gather can now be started.
  16. }
  17.  
  18.  
  19. ;;;;;;;;;;;;;;;;;;;; TRIGGERS ;;;;;;;;;;;;;;;;;;;;
  20.  
  21. ;; !start
  22. ;; Starts a gather. Only a channel op can start a gather.
  23. on *:TEXT:!start:$($gatherchannel):{
  24.   ;; check to see if we are already gathering (the hashtable will exist if we are)
  25.   if ($hget($htname)) { .notice $nick A gather is already going on. | return }
  26.  
  27.   ;; if we get here, start the gather.
  28.   hmake $htname
  29.   msg # 14(5!14) 5Starting a gather with7 $maxplayers 5players.
  30. }
  31.  
  32. ;; !stop
  33. ;; Stops a gather. Only a channel op can stop a gather.
  34. on *:TEXT:!stop:$($gatherchannel):{
  35.   if ($nick !isop #) { .notice $nick You are not allowed to stop a gather. | return }
  36.  
  37.   ;; check to see if there is a gather we can stop
  38.   if (!$hget($htname)) { .notice $nick There is currently no gather going on. | return }
  39.  
  40.   ;; if we get here we have to stop what's going on!
  41.   hfree $htname
  42.   msg # 14(5!14) 5The gather has been cancelled.
  43. }
  44.  
  45. ;; !add
  46. ;; Adds a player to a running gather. Everyone can enter, but never more than 10 players.
  47. on *:TEXT:!add:$($gatherchannel):{
  48.   ;; if there's no gathering going on, we can hardly add the player
  49.   if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | return }
  50.  
  51.   ;; up to 10 players can add themselves, never more.
  52.   if ($hget($htname,0).item == $maxplayers) { .notice $nick This gather is already full. | return }
  53.  
  54.   ;; if the player is already part of the gather, there's no point in adding them again.
  55.   if ($hget($htname,$nick)) { .notice $nick You are already taking part in this gather. | return }
  56.  
  57.   ;; clones can't join...
  58.   if ($hfind($htname,$mask($fulladdress,1),1).data) { .notice $nick Clones are not allowed to join a gather. | return }
  59.  
  60.   ;; if we get here, add the player
  61.   hadd $htname $nick $mask($fulladdress,1)
  62.   .notice $nick You have been added to the gather.
  63.  
  64.   ;; if the player who just joined was the 10th we end the gathering
  65.   ;; and notify the players of the information
  66.   if ($hget($htname,0).item == $maxplayers) {
  67.     .disable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
  68.     msg # 14(5!14) 5Gather full. 5Hold on while teams are generated, 5do not change your username.
  69.  
  70.     var %i = $maxplayers, %teamA, %teamB
  71.     while %i {
  72.       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) }
  73.       else { var %teamB = $addtok(%teamB,$chr(32) $+ $hget($htname,%i).item,44) }
  74.       dec %i
  75.     }
  76.     msg # 4Alpha:7 %teamA 
  77.     msg # 12Bravo:7 %teamB 
  78.     .msg $remove(%teamA,$chr(32)) 4A >7 %teamA - Server: $serverinfo
  79.     .msg $remove(%teamB,$chr(32)) 12B >7 %teamB - Server: $serverinfo
  80.     .enable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
  81.     .timer 1 30 resetgather
  82.   }
  83. }
  84.  
  85. ;; !del
  86. ;; Removes a player from a running gather. Everyone can remove themselves.
  87. on *:TEXT:!del:$($gatherchannel):{
  88.   ;; if there's no gathering going on, we can hardly remove the player
  89.   if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | return }
  90.  
  91.   ;; if the player was no part of this gather, we can't remove him either
  92.   if (!$hget($htname,$nick)) { .notice $nick You are not taking part in this gather. | return }
  93.  
  94.   ;; if we get here, remove the player from the gather
  95.   hdel $htname $nick
  96.   .notice $nick You have been removed from the gather.
  97. }
  98.  
  99. ;; !del <player>
  100. ;; Removes a player from a running gather. Only a channel op can remove another player.
  101. on *:TEXT:!del &:$($gatherchannel):{
  102.   if ($nick !isop #) { .notice $nick You are not allowed to remove another player. | return }
  103.  
  104.   ;; if there's no gathering going on, we can hardly remove the player
  105.   if (!$hget($htname)) { .notice $nick There is no gather going on at the moment. | return }
  106.  
  107.   ;; if the player was no part of this gather, we can't remove him either
  108.   if (!$hget($htname,$2)) { .notice $nick That player is not taking part in this gather. | return }
  109.  
  110.   ;; if we get here, remove the player from the gather
  111.   hdel $htname $2
  112.   .notice $nick $2 has been removed from the gather.
  113. }
  114.  
  115. ;; !list
  116. ;; Shows the current players in a running gather. Only channel operators can use this trigger
  117. on *:TEXT:!list:$($gatherchannel):{
  118.   ;; if there is no gather going on, there is no list of players to dump.
  119.   if (!$hget($htname)) { msg # 10There is no gather going on at this moment. Use 7!start 10to start one. | return }
  120.   var %i = $hget($htname,0).item
  121.   if (!%i) { msg # 14(5!14) 5There are currently no players participating in this gather. | return }
  122.   var %players
  123.   while %i {
  124.     %players = $addtok(%players,$chr(32) $+ $hget($htname,%i).item,44)
  125.     dec %i
  126.   }
  127.   msg # 14(5!14) 5Current players:7 %players 
  128. }
  129.  
  130. #numplayers-afeb-6ac1-6b3a-7606-20070710103913 on
  131. ;; !numplayers
  132. ;; Sets the amount of players.
  133. on *:TEXT:!numplayers &:$($gatherchannel):{
  134.   ;; first arg has to be a number
  135.   if ($2 !isnum 1-) { .notice $nick Wrong usage of trigger. | return }
  136.  
  137.   if ($calc($2 % 2)) { .notice $nick Number of players must be even. | return }
  138.  
  139.  
  140.   set %SG.maxplayers $2
  141.   msg # Amount of players for gather set to $2 $+ .
  142.  
  143.   if ($hget($htname,0).item >= $maxplayers) {
  144.     ;; form teams and start...
  145.     .disable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
  146.     msg # 14(5!14) 5Gather full. 5Hold on while teams are generated, 5do not change your username.
  147.  
  148.     var %i = $maxplayers, %teamA, %teamB
  149.     while %i {
  150.       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)
  151.       else %teamB = $addtok(%teamB,$chr(32) $+ $hget($htname,%i).item,44)
  152.       dec %i
  153.     }
  154.     msg # 4Alpha:7 %teamA 
  155.     msg # 12Bravo:7 %teamB 
  156.     .msg $remove(%teamA,$chr(32)) :4A >7 %teamA - 10Server:7 $serverinfo 
  157.     .msg $remove(%teamB,$chr(32)) :4A >7 %teamB - 10Server:7 $serverinfo 
  158.     .enable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
  159.     .timer 1 30 resetgather
  160.   }
  161. }
  162. #numplayers-afeb-6ac1-6b3a-7606-20070710103913 end
  163.  
  164. ;; !gatherchan
  165. ;; Changes gather channel to a new one
  166. on *:TEXT:!gatherchan &:$($gatherchannel):{
  167.   if ($nick !isop #) { .notice $nick Only a channel operator on both old and new channel can change the channel. | return }
  168.   if ($hget($htname)) { .notice $nick Cannot change gather channel while a gather is running. | return }
  169.   if ($left($2,1) !isin $chantypes) { .notice $nick Not a valid channelname. | return }
  170.   if ($me !ison $2) { .notice $nick Cannot change the gather channel to a channel I am not on. | return }
  171.   if ($nick !isop $2) { .notice $nick Only a channel operator on both old and new channel can change the channel. | return }
  172.  
  173.   set %SG.channel $2
  174.   .notice $nick Gather channel set to $2
  175. }
  176.  
  177. ;; !serverinfo
  178. ;; Changes the server info. Only a channel operator can use this.
  179. on *:TEXT:!serverinfo *:$($gatherchannel):{
  180.   if ($nick !isop #) { .notice $nick You are not allowed to change the server info | return }
  181.   if ($hget($htname)) { .notice $nick Server info cannot be changed during a gather. | return }
  182.  
  183.   set %SG.serverinfo $2-
  184.   .notice $nick Server information changed.
  185. }
  186.  
  187. ;;;;; Some overhead. When a player quits, parts or is kicked they are removed from the gather.
  188. ;;;;; When the bot quits or is disconnected the gather is terminated.
  189. ;;;;; When a user changes his nick it's automatically updated
  190. on *:KICK:$($gatherchannel):{ if ($hget($htname,$knick)) { hdel $htname $knick } }
  191. on *:PART:$($gatherchannel):{ if ($hget($htname,$nick)) { hdel $htname $nick } }
  192. on *:QUIT: {
  193.   if ($nick == $me) && ($hget($htname)) { hfree $htname }
  194.   elseif ($hget($htname,$nick)) { hdel $htname $nick }
  195. }
  196. on *:DISCONNECT:{ if ($hget($htname)) { hfree $htname } }
  197.  
  198. on *:NICK:{
  199.   if ($nick == $me) || ($nick == $newnick) { return }
  200.   if ($hget($htname,$nick)) {
  201.     hadd $htname $newnick $v1
  202.     hdel $htname $nick
  203.   }
  204. }
  205.  
  206. on *:LOAD:{
  207.   set %SG.channel #YOURCHANNELHERE
  208.   set %SG.maxplayers 10
  209.   set %SG.serverinfo https://poc.kag2d.com/joinserver/joinserver.php?IPAdress=5.39.93.105&port=10001
  210. }
Advertisement
Add Comment
Please, Sign In to add comment