mIRC Home    About    Download    Register    News    Help

Print Thread
#170883 16/02/07 01:09 AM
Joined: Feb 2007
Posts: 10
E
Pikka bird
OP Offline
Pikka bird
E
Joined: Feb 2007
Posts: 10
I need help making a script.

A generator script.

A random generator script, actually.

I plan on using a few variables, like a Victim, witnesses, Murder weapon, time, Method, Location, and Actual Killer.

I know how to do this all separately;
I could make a random Victim or something, but it would be better to have an actual generator to do it.
I want to have all this, but I want to know the identity of the killer, but no one else know.

This would be great with a bot, which I could put onto mine.

I'm sure this is possible to do, but I don't know how to. >_>

To sum everything up:
I need a generator. Please.

Joined: Dec 2002
Posts: 1,541
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Dec 2002
Posts: 1,541
well, you could simple put all the different information into various txt files then use the $read function to randomly pick a value and store it in a variable as one method


Those who fail history are doomed to repeat it
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
One method would be to use custom identifiers for each:

Code:
alias weapon {
  var %weapons = knife,axe,gun,rope
  var %rand = $rand(1,$numtok(%weapons,44))
  return $gettok(%weapons,%rand,44)
}
alias location {
  var %location = bedroom,dining room,kitchen,study
  var %rand = $rand(1,$numtok(%location,44))
  return $gettok(%location,%rand,44)
}
alias murdertime {
  return $rand(1,12) $+ : $+ $rand(1,60) $+ $iif($rand(1,2) == 1,am,pm)
}


Etc.

Then, when you want to use a piece of data, you just use the identifier. For example:

//echo -a $murdertime
//echo -a $weapon
//echo -a $location

You can, of course, combine these into one //echo -a //msg or whatever.

If you're storing the data for later use, then put it into a variable when you first generate the information:

//set %weapon $weapon

For the victim, witnesses, and killer, I'm sure you probably want to use people in the room. So you'd use $nick($chan,$rand(1,$nick($chan,0))) to get a random person. Then compare that to others so you don't have the same person in 2 different roles.


Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2007
Posts: 10
E
Pikka bird
OP Offline
Pikka bird
E
Joined: Feb 2007
Posts: 10
Originally Posted By: Riamus2
One method would be to use custom identifiers for each:

Code:
alias weapon {
  var %weapons = knife,axe,gun,rope
  var %rand = $rand(1,$numtok(%weapons,44))
  return $gettok(%weapons,%rand,44)
}
alias location {
  var %location = bedroom,dining room,kitchen,study
  var %rand = $rand(1,$numtok(%location,44))
  return $gettok(%location,%rand,44)
}
alias murdertime {
  return $rand(1,12) $+ : $+ $rand(1,60) $+ $iif($rand(1,2) == 1,am,pm)
}


Etc.

Then, when you want to use a piece of data, you just use the identifier. For example:

//echo -a $murdertime
//echo -a $weapon
//echo -a $location

You can, of course, combine these into one //echo -a //msg or whatever.

If you're storing the data for later use, then put it into a variable when you first generate the information:

//set %weapon $weapon

For the victim, witnesses, and killer, I'm sure you probably want to use people in the room. So you'd use $nick($chan,$rand(1,$nick($chan,0))) to get a random person. Then compare that to others so you don't have the same person in 2 different roles.


Okay. Well, uh. Wow. I thought this would be a little more simpler. D:

So, uh, how do I make one thing do it all at once?

Like, a generator? It takes out one of each and it performs it all at the same time where people can see.
And would I be able to !rcase to start it up? If not only me, but other people as well...

I'm not very good with scripting, and I've tried to read about it, but I don't really understand it that much... D:

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Just replace the weapons and locations with whatever ones you want. Also, this assumes you're using the people in the channel for the victim/murderer/witnesses. If that's not the case, just say so. Also, replace the %number_of_witnesses number with however many witnesses you want. I put 3 there, but you can change that. If there are fewer people in the channel than the number you enter + 2 (victim and murderer), it will automatically reduce the number to 2 less than the total people in the channel to prevent errors.

Code:
on *:text:!rcase:#: {
  echo -a Murderer: $murderer
  msg $chan Weapon: $weapon - Location: $location - Victim: $victim - Witnesses: $witnesses
}
on *:input:#: {
  if ($1 == !rcase) {
    echo -a Murderer: $murderer
    msg $chan Weapon: $weapon - Location: $location - Victim: $victim - Witnesses: $witnesses
  }
}
alias weapon {
  var %weapons = knife,axe,gun,rope
  var %rand = $rand(1,$numtok(%weapons,44))
  return $gettok(%weapons,%rand,44)
}
alias location {
  var %location = bedroom,dining room,kitchen,study
  var %rand = $rand(1,$numtok(%location,44))
  return $gettok(%location,%rand,44)
}
alias murdertime {
  return $rand(1,12) $+ : $+ $rand(1,60) $+ $iif($rand(1,2) == 1,am,pm)
}
alias victim {
  ; You need to get the victim BEFORE witnesses.
  unset %victim
  while (!%victim || %victim == %murderer) {
    set %victim $nick($chan,$rand(1,$nick($chan,0)))
  }
  return %victim
}
alias murderer {
  ; You need to get the murderer BEFORE the witnesses.
  unset %murderer
  while (!%murderer || %murderer == %victim) {
    set %murderer $nick($chan,$rand(1,$nick($chan,0)))
  }
  return %murderer
}
alias witnesses {
  ; You need to get the witnesses AFTER the victim and murderer are chosen.
  var %cnt = 1, %number_of_witnesses = 3
  if (%number_of_witnesses > $calc($nick($chan,0) - 2)) { var %number_of_witnesses = $v2 }
  if (%witnesses) { unset %witnesses }
  while (%cnt <= %number_of_witnesses) {
    while (!%witness || $istok(%witness,%murderer,32) || $istok(%witness,%victim,32) || %witness isin %witnesses) {
      var %witness = $nick($chan,$rand(1,$nick($chan,0)))
    }
    set %witnesses %witnesses %witness
    inc %cnt
  }
  return $replace(%witnesses,$chr(32),$chr(44) $+ $chr(32))
}


That will display the information if anyone types it. The murderer's name will be echoed instead of displayed in the channel as I'm sure you don't want that to be known to everyone.

Just remember that if people know the witnesses and the victim, unless you have many people in the channel, it may be obvious who the murderer is.

*EDIT* Fixed a typo.

Last edited by Riamus2; 17/02/07 03:20 AM.

Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
echo -a $weapon($rand(1,4))

alias weapon {
if ($1 == 1) return knife
elseif ($1 == 2) return rope
elseif ($1 == 3) return candlestick
else return gun
}

This is another way and you can see how riamuses would be less lines.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Especially if you have many choices instead of only 4. laugh


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Thats what I meant...


Link Copied to Clipboard