mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2017
Posts: 32
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 32
Hi! Could someone help me with this giveaway script for Twitch?

I'm trying to make it so that it doesn't clear the names after I stop the raffle so I could just keep picking multiple winners with the names that are already in it. This makes it easier so people don't have to keep entering the raffle. Could really use some assistance on making this possible ;-;! (I'm such a noob at scripting haha)


Quote
on *:TEXT:*:#: {
if ($1 == !raffle) {
if (!$($+(%,joinraf,$nick),2)) {
set $+(%,joinraf,$nick) 1
if (%open == 1) {
write raffle.txt $nick
msg #name /me $nick entered the raffle!
}
elseif (!%open) { msg #name /me There is not an active raffle. }
}
elseif ($1 == !people) {
if (%open) {
msg #name /me There are currently $lines(raffle.txt) users in the raffle!
}
}
}
if ($1 == !startraffle) {
if ($nick isop #) || ($nick == name) {
start_raffle
}
}
if ($1 == !stopraffle) {
if ($nick isop #) || ($nick == name) {
end_raffle
}
}
}
alias start_raffle {
if (!%open) {
unset %joinraf*
write -c raffle.txt
set %open 1
msg #name /me --[[ A NEW RAFFLE HAS BEGUN ]]--
msg #name /me You have 5 minutes to enter. Type !raffle
.timerraffle1 1 120 msg #name 3 minutes left for the raffle to close. Type !raffle
.timerraffle2 1 290 msg #name 1 minute left to enter the raffle! Hurry! Type !raffle
.timerraffle3 1 350 end_raffle
}
elseif (%open) { msg #name /me There is an active raffle already. }
}
alias end_raffle {
if (%open) {
.timerraffle* off
var %user = $read(raffle.txt,n)
write -c raffle.txt
unset %open
unset %joinraf*
msg #name /me --[[ %user $+ ]]-- HAS WON THE RAFFLE! --[[ CONGRATULATIONS ]]--
}
elseif (!%open) { msg #name /me There is not an active raffle. }
}
}



Last edited by kouyachi; 14/12/20 03:45 AM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
write -c raffle.txt

... is a command which wipes raffle.txt into being a zero size file. Your script has this command both when the raffle starts and when it stops, so if you don't want the list of nicks cleared, you can put a REM or a semi-colon in front of these commands to turn them into a comment. I assume you'll eventually want to wipe this file, so you can have another alias to specifically delete the file, or you can modify the alias so that it starts while also clearing it if it's started like: !startraffle clear

changing from:

Code
if ($1 == !startraffle) {
  if ($nick isop #) || ($nick == name) {
  start_raffle
  }
}

to:
Code
if ($1 == !startraffle) {
  if ($nick isop #) || ($nick == name) {
    if ($2 == clear) write -c raffle.txt
    elseif ($lines(raffle.txt)) msg $chan raffle started with $v1 entries!
    start_raffle
  }
}


Just to be safe, your ON TEXT should begin with a line to make sure it does nothing if you are in a different channel when someone uses a !trigger. On the line below the ON TEXT, have something like:

Code
if ($chan != #name) return


Also, by default the timers are deleted if you disconnect from that server, and the end-raffle won't happen if the timer dies. For the 3 timer commands, you should make sure the 3rd one allows that timer to execute while offline, changing it to be:

Code
.timerraffle3 -o 1 350 end_raffle


Also, to defend against the client crashing and restarting with %open set to 1, have the raffle set to not-open when mirc starts up. A line outside an alias:

Code
ON *:START:{ unset %open }


You probably need to have rules about how someone can be eligible to win. i.e. do they need to be in channel when the winning ticket is chosen. Also, what will you do if I change nicks

/nick maroon
!raffle
/nick maroon2
!raffle
/nick maroon3
!raffle
/nick maroon4
!raffle
/nick maroon

... and one of these is the winner.

Joined: Sep 2017
Posts: 32
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 32
ooh okay, thank u very much smile


and for the rules, no they wouldn't have to be in the channel if they're chosen, but if they didn't speak up i would just draw another name.
do i need to change anything for that?

Last edited by kouyachi; 14/12/20 05:55 AM.
Joined: Sep 2017
Posts: 32
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 32
oh gosh i just ran into another issue that i didn't realize in the beginning.
i do want to make a !draw command where it picks a winner, but i need to also make it so that it kicks them out of the list after being picket so they can't win again during this raffle session


Link Copied to Clipboard