mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2015
Posts: 2
T
Bowl of petunias
OP Offline
Bowl of petunias
T
Joined: Aug 2015
Posts: 2
I am trying to create a raffle script and I am having a few problems with a couple of parts.
the first problem I have having is restricting the number of tickets one person can buy per raffle to a limit of 10 tickets.(lines 3-5) I have managed to make the script limit tickets bought at once to 10 but this can be repeated. A floodgate will not work as views will be able to buy one tickets then more later on in the raffle if they want but no more then 10 total tickets per raffle.
the second problem I am having is the script telling people they can't afford the tickets they requested to buy, the script currently says they can't afford tickets every time they buy some even if they could afford them (they still get the tickets they could afford) (lines 18-24)
the code I have so far is below any help will be amazing thank you

on *:TEXT:!buyticket &:#:{
if (%raffle == 1) {
if ($2 > 10) {
msg $chan Sorry $nick but you can only up to 10 tickets
}
if ($2 < 11) {
var %i = 0
var %ticket = $2
var %topic = $+(#,.,$nick)
var %user = $readini(Points.ini,%topic,Points)
var %end = 10 * %ticket
var %delete = %user - %end
if (%delete > 0) {
writeini -n Points.ini %topic Points %delete
while (%i < %ticket) {
write Raffle.txt $nick
%i = %i + 1
}
msg $chan $nick You Have Bought %ticket Tickets For %end Points.
}
if (%topic,points < 0) {
msg $chan Sorry $nick You Don't Have Enough Points To Buy %ticket Tickets!
}
}
}
if (%raffle == 0) {
msg $chan Raffle is currently closed!
}
}
on *:TEXT:!raffle open:#:{
if ($nick isop #) {
if (%raffle == 0) {
msg $chan RAFFLE IS NOW OPEN!!
set %raffle 1
}
}
}

on *:TEXT:!raffle close:#:{
if ($nick isop #) {
if (%raffle == 1) {
msg $chan RAFFLE IS NOW CLOSED!!
set %raffle 0
}
}
}
on *:TEXT:!roll:#:{
if ($nick isop #) {
if (%raffle == 1) {
set %raffle 0
var %user = $read(Raffle.txt, n)
msg $chan RAFFLE IS NOW BEING ROLLED, GOOD LUCK!!
.timerOne 1 1 msg $chan /me 5!
.timerTwo 1 2 msg $chan /me 4!
.timerThree 1 3 msg $chan /me 3!
.timerFour 1 4 msg $chan /me 2!
.timerFive 1 5 msg $chan /me 1!
.timerSix 1 6 msg $chan AND THE WINNER IS:
.timerSeven 1 7 msg $chan %user
}
}
}

on *:TEXT:!reroll:#:{
if ($nick isop #) {
var %user = $read(Raffle.txt, n)
msg $chan RAFFLE IS NOW BEING REROLLED, GOOD LUCK!!
.timerOne 1 1 msg $chan /me 5!
.timerTwo 1 2 msg $chan /me 4!
.timerThree 1 3 msg $chan /me 3!
.timerFour 1 4 msg $chan /me 2!
.timerFive 1 5 msg $chan /me 1!
.timerSix 1 6 msg $chan AND THE WINNER IS:
.timerSeven 1 7 msg $chan %user
}
}

0n *:Text:!raffle reset:#:{
set %raffle 0
msg $chan RAFFLE HAS NOW BEEN RESET
write -c Raffle.txt
}

Joined: Jul 2015
Posts: 42
J
Ameglian cow
Offline
Ameglian cow
J
Joined: Jul 2015
Posts: 42
Maby set a variable on the user with how many tickets, if its above the max you have set (10) then he is not allowed to buy, but if the first time he bought tickets + the secound is under or 10 then it allows. (im using alot of this for my own scripts)

Joined: Aug 2015
Posts: 2
T
Bowl of petunias
OP Offline
Bowl of petunias
T
Joined: Aug 2015
Posts: 2
Thank you for the advice I am finding varible scripts rather hard can you please give me a base example to work off?

Joined: Jul 2015
Posts: 42
J
Ameglian cow
Offline
Ameglian cow
J
Joined: Jul 2015
Posts: 42
Yes sure
Code:
on *:TEXT:!buyticket &:#:{
if (%raffle == 1) {
var %max = %maxticket. $+ $nick
var %maxtest = %max + $2
if (%maxtest > 10) { 
msg $chan Sorry $nick but you can only up to 10 tickets 
/halt
}
if ($2 > 10) {
msg $chan Sorry $nick but you can only up to 10 tickets
}
if ($2 < 11) {
var %i = 0
var %ticket = $2
var %topic = $+(#,.,$nick)
var %user = $readini(Points.ini,%topic,Points)
var %end = 10 * %ticket
var %delete = %user - %end
if (%delete > 0) {
writeini -n Points.ini %topic Points %delete
while (%i < %ticket) {
write Raffle.txt $nick
%i = %i + 1
}
msg $chan $nick You Have Bought %ticket Tickets For %end Points.
set %maxticket. $+ $nick %maxtest
}
if (%topic,points < 0) {
msg $chan Sorry $nick You Don't Have Enough Points To Buy %ticket Tickets!
}
}
}

This should work, then you just need to clear all those to start a new one, (if you wanna know how to remove more than 1 variable that contains word you need to ask someone else, i don't know if it even works)
This script has not been tested, but it should work
--
set %maxticket. $+ $nick %maxtest Makes a variable %maxticket.thename
--
if (%maxtest > 10) {
msg $chan Sorry $nick but you can only up to 10 tickets
/halt
} This checks and stops if its above 10
--
var %max = %maxticket. $+ $nick
var %maxtest = %max + $2
This calculate the numbers to check if its above 10

Last edited by Joveice; 03/08/15 03:05 PM.

Link Copied to Clipboard