mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2015
Posts: 4
K
Self-satisified door
OP Offline
Self-satisified door
K
Joined: Jul 2015
Posts: 4
I'm pretty new to using Mirc and the scripts in general and have used youtube to find most of the things I need. I have a raffle system that looks like this
Code:
on 5:text:!raffleOpen:#: {
  if (%raffleIsOn == $false) {
    %raffleIsOn = $true
    write -c %raffleFile
    %raffleID = 0
    msg $chan /me The raffle is now open, you can enter the raffle by saying !raffle in the chat.
  }
  elseif (%raffleIsOn == $true) {
    msg $chan /me The raffle is already open!
  }
}

on 5:text:!raffleClose:#: {
  if (%raffleIsOn == $true) {
    %raffleIsOn = $false
    msg $chan /me The raffle is now closed.
  }
  elseif (%raffleIsOn == $false) {
    msg $chan /me The raffle is already closed.
  }
}

on *:text:!raffle:#: {
  if (%raffleIsOn == $false) {
    msg $chan /me You cannot enter the raffle until it is opened.
  }
  else {
    if ($findID(%raffleFile, %raffleID, $nick) == 0) {
      writeini -n %raffleFile $calc(%raffleID + 1) name $nick
      writeini -n %raffleFile $calc(%raffleID + 1) hasWon false
      inc %raffleID
    }
    else {
      msg $chan /me $nick is already in the raffle!
    }
  }
}

on 3:text:!winner:#: {
  if (%raffleID != 0 && $isViableRaffle == $true) {
    var %winnerChosen = $false
    while (%winnerChosen == $false) {
      var %winnerID = $rand(1, %raffleID)
      if ($readini(%raffleFile, %winnerID, hasWon) == false) {
        var %winner = $readini(%raffleFile, %winnerID, name)
        msg $chan /me The winner is... %winner !
        writeini -n %raffleFile %winnerID hasWon true
        %winnerChosen = $true
      }
    }
  }
  else {
    msg $chan /me The raffle is not currently viable.
  }
}
//-------------------------------------------------------------------------------------------------------------------------
// Format: $findID([file], [.ini sections], [name])
// Returns the ID of a person in the specified file. If the person does not exist, returns 0
alias -l findID {
  var %file = $1
  var %ID = $2
  var %user = $3

  var %i = 1
  while (%i <= %ID) {
    if ($readini(%file, %i, name) == %user) {
      return %i
    }
    inc %i
  }
  return 0
}

// Format: $isViableRaffle
// Checks the raffle to make sure there is someone who can win. Returns either $true or $false
alias -l isViableRaffle
var %i = 1
while (%i <= %raffleID) {
  if ($readini(%raffleFile, %i, hasWon) == false) {
    return $true
  }
  inc %i
}
return $false
}


I can start and stop raffles fine. I can also have people enter the raffle fine with the rafflefile being made. The problem is when I try to pick a winner it says the raffle is not currently viable.

Why on the command !winner is it not able to pick a winner. From what I can see the alias returns that the raffle is viable but a winner is still not chosen. I got this script off the internet and fixed a few things in it, but not sure what is wrong with this part of it.

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
If you want you can use my (working) raffle script instead https://forums.mirc.com/ubbthreads.php/topics/253766/%5BTwitch_Help%5D_Raffle_Twitch_wi#254040

Joined: Jul 2015
Posts: 4
K
Self-satisified door
OP Offline
Self-satisified door
K
Joined: Jul 2015
Posts: 4
Thanks a lot I just have one question. You said it only picks people who follow. Do I need to change something for it to work with the channel I'm using it on, or does the code already take into account what channel it's in and who is following that channel.

Edit: Another question, The raffle works in my channel, but the bot I'm using is for a channel I'm a mod in. It doesn't work in the other channel so I assume it has something about only working if the broadcaster says !raffle start. I'm not sure what I would change to allow mods to also start raffles.

Last edited by killagod47; 25/08/15 09:31 PM.
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
It works in as many chans as you want, but only the streamer can start one. If you want mods to be able to then

change

if ($2 == start) && ($nick == $remove(#,$chr(35))) {

to

if ($2 == start) && ($nick isop #) {


Link Copied to Clipboard