Project

General

Profile

[Script] Random slap without any double slaps

Added by Per Amundsen almost 10 years ago

Useful if you want random slaps to never show the same slap twice.

Code:

alias slap {
  var %lines = $lines(slaps.txt)

  if ($numtok(%used_slaps, 32) >= %lines) {
    unset %used_slaps
  }

  var %s $rand(1, %lines)

  while ($istok(%used_slaps, %s, 32)) {
      %s = $rand(1, %lines)
  }

  set %used_slaps %used_slaps %s

  me $eval($replace($read(slaps.txt, n, %s), $ $+ nick, $ $+ 1-), 2)
}