Public feed
#599144
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, 32)
var %numNicks = $nick(#mafia, 0, v)
;; 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), 32)
inc %i
}
;; Now we'll randomize the nicks
%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) {
;; Show the roles and their respective nicks in a Role - Nick format
echo @mafia_Roles $gettok(%roles, %i, 32) - $gettok(%nicks, %i, 32)
;; We will send a PM to each person telling them their roles
query $gettok(%nicks, %i, 32) Your role is $chr(2) $+ $gettok(%roles, %i, 32)
;; And now add one to %i
inc %i
}
}