Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;;;;;;;;;;;;;;;;;; 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 14(5!14) 5Another gather can now be started.
- }
- ;;;;;;;;;;;;;;;;;;;; TRIGGERS ;;;;;;;;;;;;;;;;;;;;
- ;; !start
- ;; Starts a gather. Only a channel op can start a gather.
- on *:TEXT:!start:$($gatherchannel):{
- ;; 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 # 14(5!14) 5Starting a gather with7 $maxplayers 5players.
- }
- ;; !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 # 14(5!14) 5The gather has been cancelled.
- }
- ;; !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 # 14(5!14) 5Gather full. 5Hold on while teams are generated, 5do not change your username.
- 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 # 4Alpha:7 %teamA
- msg # 12Bravo:7 %teamB
- .msg $remove(%teamA,$chr(32)) 4A >7 %teamA - Server: $serverinfo
- .msg $remove(%teamB,$chr(32)) 12B >7 %teamB - Server: $serverinfo
- .enable #numplayers-afeb-6ac1-6b3a-7606-20070710103913
- .timer 1 30 resetgather
- }
- }
- ;; !del
- ;; Removes a player from a running gather. Everyone can remove themselves.
- on *:TEXT:!del:$($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.
- }
- ;; !del <player>
- ;; Removes a player from a running gather. Only a channel op can remove another player.
- on *:TEXT:!del &:$($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.
- }
- ;; !list
- ;; Shows the current players in a running gather. Only channel operators can use this trigger
- on *:TEXT:!list:$($gatherchannel):{
- ;; if there is no gather going on, there is no list of players to dump.
- if (!$hget($htname)) { msg # 10There is no gather going on at this moment. Use 7!start 10to start one. | return }
- var %i = $hget($htname,0).item
- if (!%i) { msg # 14(5!14) 5There 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 # 14(5!14) 5Current players:7 %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 }
- 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 # 14(5!14) 5Gather full. 5Hold on while teams are generated, 5do not change your username.
- 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 # 4Alpha:7 %teamA
- msg # 12Bravo:7 %teamB
- .msg $remove(%teamA,$chr(32)) :4A >7 %teamA - 10Server:7 $serverinfo
- .msg $remove(%teamB,$chr(32)) :4A >7 %teamB - 10Server:7 $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 }
- 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 #YOURCHANNELHERE
- set %SG.maxplayers 10
- set %SG.serverinfo https://poc.kag2d.com/joinserver/joinserver.php?IPAdress=5.39.93.105&port=10001
- }
Advertisement
Add Comment
Please, Sign In to add comment