Kharaen2008-08-28 22:16:51
I am no coder, but I would like to do these once a month maybe and having a script to help make it as legit as possible would be nice.
As mentioned, I'm no coder and need a bit of help. This is the script I've slapped together from my meager ability:
What I'd like to be able do is have the DrawLotto alias to look through the LottoData variable, find the range of the winning number, and display the key containing that number. Is this possible?
As mentioned, I'm no coder and need a bit of help. This is the script I've slapped together from my meager ability:
CODE
#CLASS {Lottery}
#ALIAS DrawLotto {Lotto=%random(1,@TotalTickets)}
#ALIAS AddTic {#addkey LottoData %1 %2;#add TotalTickets %3}
#ALIAS RLotto {#var Lotto 0;#var TotalTickets 0;#unvar LottoData;#echo The Lottery is now finished, values have been reset.}
#var TotalTickets
#var Lotto
#CLASS 0
#ALIAS DrawLotto {Lotto=%random(1,@TotalTickets)}
#ALIAS AddTic {#addkey LottoData %1 %2;#add TotalTickets %3}
#ALIAS RLotto {#var Lotto 0;#var TotalTickets 0;#unvar LottoData;#echo The Lottery is now finished, values have been reset.}
#var TotalTickets
#var Lotto
#CLASS 0
What I'd like to be able do is have the DrawLotto alias to look through the LottoData variable, find the range of the winning number, and display the key containing that number. Is this possible?
Xenthos2008-08-28 22:28:54
QUOTE(Kharaen d @ Aug 28 2008, 06:16 PM) 551270
I am no coder, but I would like to do these once a month maybe and having a script to help make it as legit as possible would be nice.
Just as a note (though it's not exactly the mechanical-aspect you were looking for)-- the Glomdoring used to have a law against lotteries run to "fleece" commune-mates for one's own benefit (which the general 50-50 lottery setup is, and why most 50/50s IRL have the proceeds donated to charity/organizations, though I have no idea if you're looking to make a similar profit with yours). I also can't remember if that law is still on the books. There hasn't been any discussion about removing it as far as I'm aware, but that doesn't mean someone didn't excise it.
Something to keep in mind while you're looking into setting the thing up, at least.
Kharaen2008-08-28 23:25:16
Well, if it's a law, I can simply not offer the lottery to Glomdoring. There was going to be ticket limits though (500k lottery with 1k tickets, max purchase of 100 tickets, 100k lotto with 500g tickets, max purchase of 40 tickets). The benefits are worth the risks, I'd think. I COULD do a million, and emulate an actual anniversary lottery.
Lendren2008-08-29 15:44:37
Here's a zMUD script I whipped up long ago for guild raffles:
Very simple to use. RAFFLE RESET to start a new raffle. Every time someone buys a ticket, RAFFLE SELL to sell them a ticket. (It's your job to handle payment, do this once payment is satisfactory.) They get a tell with a ticket number, but they don't really need it. RAFFLE COUNT will show you how many tickets you sold so far. Then when you're done, RAFFLE AWARD will award a prize: it only shows this to you, and removes that raffle ticket from the pool in case you're giving out several prizes. You can announce and award prizes as you see fit. Easy-peasy.
This isn't really geared towards where single buyers buy 100 tickets (you could do it, but it'd be tedious as heck), nor towards counting limits on how many tickets someone has, though. I use it for performance raffles: do a performance at a guild gathering to enter, win prizes, just for fun at guild gatherings.
CODE
#CLASS {World|Guild|Raffle}
#ALIAS raffle {#if (%1 == reset) {#if (%2 != confirm) {#show To confirm, type RAFFLE RESET CONFIRM.} {lRaffleTickets = "";#show Raffle has been reset.}} {#if (%1 == sell and %2 <> "") {ScratchVar = %numitems( @lRaffleTickets)|;#add ScratchVar 1|;RaffleTickets = %additem( %concat( @ScratchVar, " ", %proper( %2)), @lRaffleTickets);tell %2 You bought raffle ticket ~#@ScratchVar.} {#if (%1 == award) {#if (@lRaffleTickets = "") {#show You should sell some tickets first!} {ScratchVar = %random( 1, %numitems( @lRaffleTickets));LabelVar = %item( @lRaffleTickets, @ScratchVar);#show The winner is ticket ~#%word( @LabelVar, 1) belonging to %word( @LabelVar, 2)!;#deln lRaffleTickets @ScratchVar}} {#show You've sold %numitems( @lRaffleTickets) raffle tickets so far.}}};#send ""}
#VAR lRaffleTickets {}
#CLASS 0
#ALIAS raffle {#if (%1 == reset) {#if (%2 != confirm) {#show To confirm, type RAFFLE RESET CONFIRM.} {lRaffleTickets = "";#show Raffle has been reset.}} {#if (%1 == sell and %2 <> "") {ScratchVar = %numitems( @lRaffleTickets)|;#add ScratchVar 1|;RaffleTickets = %additem( %concat( @ScratchVar, " ", %proper( %2)), @lRaffleTickets);tell %2 You bought raffle ticket ~#@ScratchVar.} {#if (%1 == award) {#if (@lRaffleTickets = "") {#show You should sell some tickets first!} {ScratchVar = %random( 1, %numitems( @lRaffleTickets));LabelVar = %item( @lRaffleTickets, @ScratchVar);#show The winner is ticket ~#%word( @LabelVar, 1) belonging to %word( @LabelVar, 2)!;#deln lRaffleTickets @ScratchVar}} {#show You've sold %numitems( @lRaffleTickets) raffle tickets so far.}}};#send ""}
#VAR lRaffleTickets {}
#CLASS 0
Very simple to use. RAFFLE RESET to start a new raffle. Every time someone buys a ticket, RAFFLE SELL
This isn't really geared towards where single buyers buy 100 tickets (you could do it, but it'd be tedious as heck), nor towards counting limits on how many tickets someone has, though. I use it for performance raffles: do a performance at a guild gathering to enter, win prizes, just for fun at guild gatherings.
Kharaen2008-08-29 15:54:49
Ooh, thanks. I'll give this a try.