/op /mode # +ooo $$1 $2 $3 /dop /mode # -ooo $$1 $2 $3 /j /join #$$1 $2- /p /part # /n /names #$$1 /w /whois $$1 /k /kick # $$1 $2- /q /query $$1 /send /dcc send $1 $2 /chat /dcc chat $1 /ping /ctcp $$1 ping /s /server $$1- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Alan's super cool mafia role assigning script;; ;;;;;;;;;;;;;;;;;;;VERSION 1.1;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; randomizetoken { ;; This'll be the token variable we'll use var %token = $$1 ;; This'll be the character the token uses var %tokenChr = $$2 ;; This'll be the length of the above token var %tokenLength = $numtok(%token, %tokenChr) ;; These will help randomize the token...more on this later var %randomTriesUsed var %randomTry ;; This'll eventually be the randomized token var %newToken ;; This'll be used in the while loop var %i = 1 ;; We need to loop for the length of the token while (%i <= %tokenLength) { ;; We'll try to make a random token (hence %randomTry) ;; It has to be between 1 and however many tokens there are %randomTry = $rand(1, %tokenLength) ;; Here it gets complicated...If that random token (%randomTry) was already used ;; it would be in the %randomTriesUsed token....if it's already used we're going ;; to keep trying until we get one that hasn't already been used...got it :) while ($istok(%randomTriesUsed, %randomTry, %tokenChr)) { ;; As stated above...this'll get a new try %randomTry = $rand(1, %tokenLength) } ;; Now we'll add the random token into the new token list %newToken = $addtok(%newToken, $gettok(%token, %randomTry, %tokenChr), %tokenChr) ;; And now we'll add the random token (%randomTry) into the random tokens used ;; list (%randomTriesUsed) %randomTriesUsed = $addtok(%randomTriesUsed, %randomTry, %tokenChr) ;; We're getting closer to the end of the loop inc %i } ;; Finally we can return the script requesting the randomized token what they wanted return %newToken } /mafiaroles { ;; The roles token is taken from the information you supply var %roles = $$1- ;; Find the number of roles and number of nicks var %numRoles = $numtok(%roles, 44) var %numNicks = $nick(#mafia, 0, v, ohr) ;; Make sure the number of nicks is the same as the number of roles if (%numRoles != %numNicks) { echo 4 You need to supply the same number of roles as nicks; you supplied %numRoles roles but there are %numNicks nicks halt } ;; Now we'll make the nick token var %i = 1 var %nicks while (%i <= %numNicks) { %nicks = $addtok(%nicks, $nick(#mafia, %i, v, ohr), 32) inc %i } ;; Now we'll randomize the nicks %nicks = $randomizetoken(%nicks, 32) %nicks = $randomizetoken(%nicks, 32) %nicks = $randomizetoken(%nicks, 32) %nicks = $randomizetoken(%nicks, 32) %nicks = $randomizetoken(%nicks, 32) ;; Open up a window to show the roles window -k0 @Mafia_Roles ;; Now we'll show the entry stuff into the window echo 4 @Mafia_Roles Roles for %numNicks players created at $asctime(hh:nn) ;; We're starting another loop so set %i to 1 %i = 1 while (%i <= %numNicks) { ;; Check to see if there are no parenthesis in this role if ($count($gettok(%roles, %i, 44), $chr(40)) == 0) { ;; We will send a PM to each person telling them their roles query $gettok(%nicks, %i, 32) Your role is $chr(2) $+ $remove($gettok(%roles, %i, 44), $chr(32)) ;; Show the roles and their respective nicks in a Role - Nick format echo @mafia_Roles $gettok(%roles, %i, 44) - $gettok(%nicks, %i, 32) ;; Now continue the while loop after increasing %i inc %i continue } ;; Check to see if the syntax is correct if ($regex($gettok(%roles, %i, 44), / ?(\((.+?)\) ?)?([^\x28]+)( ?\((.+?)\))?/) == $false) { echo 4 There is an error with the syntax of role number %i } ;; This checks to see if it was for example "Townie (Miller)" or "(Miller) Townnie" if ($left($regml(1), 1) != $chr(40)) { ;; We will send a PM to each person telling them their roles query $gettok(%nicks, %i, 32) Your role is $chr(2) $+ $regml(1) ;; Show the roles and their respective nicks in a Role - Nick format echo @mafia_Roles $regml(3) - $gettok(%nicks, %i, 32) } else { ;; We will send a PM to each person telling them their roles query $gettok(%nicks, %i, 32) Your role is $chr(2) $+ $regml(3) ;; Show the roles and their respective nicks in a Role - Nick format echo @mafia_Roles $regml(2) - $gettok(%nicks, %i, 32) } ;; And now add one to %i inc %i } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;Released Under the;;;;;;;;;;;;;;; ;;Creative Commons Attribution-Share Alike 3.0;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;