|
||
|
|||||||
| Custom Script Releases This forum is where you can release your custom scripts for other users to use. Please note: By releasing your scripts here you are submitting them to the public and as such agree to publish them under the GPL licensing terms. The RunUO Team has made its software GPL for you to use and enjoy you should do the same for anything based off of RunUO. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Novice
|
Description
*** The NEW WORKING version of the lottery system *** It's an automated lottery system which allows players to purchase lottery tickets from the lottery stone. The new version has been re-worked due to some errors in code which i made in the original version, sorry for any inconvienience it might have caused. The main cause of the problems were the lottery rules, which at the time i didn't totally get right which was why there were a few errors. The Rules to this system are... Players can purchase a lottery ticket with 5 numbers on it. The numbers are from 0-9 for each selection, each of the 5 selections must be different numbers, the new system removes each selection button from the selection gump to ensure the player cannot pick the same number twice. Players must also pick 5 numbers or use the lucky dip feature in order to get to the 'continue to ticket' option, this was to remove the ability to pick duplicated ticket selection numbers. The draw takes place... The system now generates 5 random numbers, each generated number cannot be duplicated... the system now does this correctly. The system then checks tickets for matching draw numbers and each ticket is checked and changed according to how many of the draw numbers are on the ticket, this is also colour coded now on the tickets. Players now have until the next lottery draw to claim their share of the jackpot amount from their winning tickets. Tickets... The lottery tickets are now colour coded to make things easier for players to identifiy winning tickets, rather than having to view each ticket there are colours to spot potential winners. The ticket colours are changed at the time of a draw. Newly purchased tickets are bright orange (blaze). Tickets with any of the draw numbers on them are shaded from light green through to a darker green, the more matched draw numbers means the lighter the green is. Tickets which did not match any lottery draw numbers are red. Tickets which had a lottery draw number match (green tickets) become light blue to show the ticket has paid out it's winning amount of gold, this is given to players in the form of a bankcheck into there backpacks. Any tickets which are green (had a match to some of the lottery draw numbers) that are not claimed by the time of the next lottery become red and void. The winnings from this ticket cannot be claimed because the next lottery has taken place. Payout... The lottery jackpot is divided up into 5 amounts, because theres 5 types of win avaliable... 5, 4, 3, 2 & 1 lottery draw numbers matched. In addition to this theres a Rollover too. The Rollover is increased each time theres a lottery draw IF no players get all 5 lottery draw numbers. The split amounts are calculated like this... 50% of the jackpot amount for a 5 lottery number match, plus any gold held on the rollover from previous lottery draws. 20% of the jackpot amount for a 4 lottery number match. 15% of the jackpot amount for a 3 lottery number match. 10% of the jackpot amount for a 2 lottery number match. 5% of the jackpot amount for a 1 lottery number match. The split amounts can be altered from the lottery stones [props, if you do decide to alter this just make sure all 5 split %'s total back up to 100%, these figures can also be viewed on the next lottery details gump from the lottery stone. The results for the last draw can also be viewed from the lottery stone via the previous draw results gump, this shows the last draws winning numbers and details about how many tickets for that draw actually won. Installing Installing this system will require 2 server re-starts. Unzip the attached file into the directory of your shards scripts folders and re-start the shard. At first startup the lottery timer is running but will be disabled due to the shard not having a lottery stone, just log in and place the lottery stone where you want it. The [add lotter comand should bring the stone up in the menu, place the stone and re-start the shard again. At the second re-start the timers are running, and should find the lottery stone and continue to run. DO NOT CREATE MORE THAN ONE LOTTERY STONE, if you do the timer will pick up on this and shut the timer down. All lottery information is stored on the stone and tickets even after a shard restart, so there should be no need to re-create another stone once you have one placed. The time for the next lottery draw will be set for 3 days from the stones creation in the game world. Commands [lotteryticketdelete This removes ALL lottery tickets from the shard, if you used the old version run this first to ensure theres nothing left from the previous lottery system. If you don't run it the system should still work ok, just added this to clean up the mess the last system created. Reserved For Updates Update : 25th Feb 2007 Added an instruction stone for it, further down in this thread. Update : 3rd March 2007 It's now Repaired. Theres also 2 extra gumps with this version, Next lottery draw details & Previous lottery draw details. I've set some of the variables access levels to admin or GM, this was to avoid GM's messing things up, a safeguard. Shard GM's can change the split %'s and the price of tickets via the [props commands, only admin has access to [lotteryticketdelete command. The instruction stone requires an update, on my to do list. The old version is included in the zip files tho. There is one minor issue i'm aware of. If a player is in the middle of selecting ticket numbers at the time of a lottery draw taking place the ticket will have the incorrect draw date on it. The system will clean up after the next draw but the player will loose his/her gold for that ticket. Possiably on a future repair list. Last edited by FingersMcSteal; 03-02-2007 at 07:16 PM. |
|
|
|
|
|
#9 (permalink) | |
|
Forum Novice
|
Quote:
You add the scripts to your scripts folders, so when you re-start the shard... the lottery timers running... so at the very start of a shard re-boot... the timer code checks the lottery stone... but because you have only just added the scripts... you haven't had time to create the lottery stone... so the timer code shuts the timer down. So... you log in and add one lottery stone where you want it... then... you have to restart the shard to re-start the lottery timer... The second shard re-start will start the timer again... and the code for the timer will find the stone and continue to run. I'll have a look at maybe adding a timer start and stop command later, for the moment this is the way it's working tho. I did want the result gump's into it next so i'm going to work on that part next i think. Theres also going to be an instruction stone, theres still a few people i've spoken to on my shard who didn't quite understand the rules of a lottery so hopefully that will also help to explain it. Glad you like it tho. |
|
|
|
|
|
|
#10 (permalink) |
|
Forum Novice
|
Just thrown this together for it... Instruction stone, explains a bit about how it works and what players need to do.
Just place the 2 scripts into the lottery system's folder, or anywhere in your scripts folders. Use [add lotteryinfostone and place it near the lottery stone if you want, you can also have more than one of these in the shard since it doesn't effect the game stone in any way. ugh... i hate gump designing ![]() Enjoy. |
|
|
|
|
|
#11 (permalink) |
|
Forum Expert
|
one thing i was curious about was this....is 10 numbers enough? Most state loteries have up to 50 something don't they??
and if someone picks 6....two or three times, do they need two or three 6's to get it for each then?? thanks and sorry about the questions/comments. My players are loving the idea of it so far |
|
|
|
|
|
#12 (permalink) |
|
Forum Novice
|
Yeah i did give this some thought about the numbering.
We have a lottery here in the UK where players pick 6 different numbers and the numbers range from 1-49. This gives a lot of combinations for a 6 matching number winner. I could have done the whole thing to allow for number selections from 1-49 and could have made it to allow up to 6 numbers to be selected, with a 7th number which is known as the Bonus Ball number. The reason i decided to go for a number 0-9 x 5 numbers was mainly for player numbers on a shard, with this limited number range it should mean that someone on the shard will always win something and although to get a 5 number match is a slim chance it's not entirely impossible. Think of it like on average how many players actually play on a shard at any given time 5, 10, maybe 30-40 at max, then think about the real world lottery's there are.. 1-49 x 6 combinations and 1000's of people playing it. If the shard lottery was setup with 1-49 numbers per choice there's a good chance that with only say 20 players per shard the jackpot's would never be won on a 5 or 6 number match, so i tried to bring it into line with a shards population (average 20 players playing a shard). With the numbering from 0-9 theres a good chance a lot of players will be winning at least 1 number matches, which is the 5% of the jackpot win. I just tried to keep it as fun for the players and as real as i could to a normal lottery, but yeah i get the point your making... This just seem'd like the way to go with it. |
|
|
|
|
|
#16 (permalink) | |
|
Forum Novice
|
Quote:
Something like... Lottery picks 1,3,1,3,5 Your ticket... 1,2,3,3,4 Two of your ticket numbers matched two of the lottery numbers. |
|
|
|
|
|
|
#17 (permalink) |
|
Forum Newbie
Join Date: Mar 2003
Posts: 37
|
Discover a problem Two
1.Lottery picks 2,3,7,3,5 Your ticket... 1,1,1,1,1 Point out all matching of 5 ticket numbers. Be able to draw the maximal bonus, Why?? 2.How reduce win prize rate and the bonus? My Server is RunUO2.0 RC1 |
|
|
|
|
|
#18 (permalink) | |
|
Forum Novice
|
Quote:
Point out all matching of 5 ticket numbers. <<< ??? and... Be able to draw the maximal bonus, Why?? <<< ??? Why what ?, Why you don't get the full 100% of the jackpot ? Thats because the jackpot has to be split up into 5 types on winner, the code for the split is in red and should always add up to 100 (100%) of the jackpot, it's the % of split the winers get, 5 matched gets 50% of the jackpot total, never the full amount. The calculations had me confused at the start of the design so i'll try to explain what it's doing. If theres NO tickets that matched say 5 numbers, the calculations are done on the basesplit... it uses 50% of the jackpot for the math. If there are 'some' 5 number matched tickets, it divide's the 50% by the amount of matching tickets, reducing the % it calculates from in order to place the full 100% of the jackpot amount to the stone depending on how many of that type (5 numbers matched) won. Confused... so am i again This is the formula for the calculations... Jackpot = Price Per Ticket X Ticket Sales 1% = Jackpot / 100 5 matched win = 1% X 50% (basesplit) or 1/2 the jackpot 4 matched win = 1% X 20% (basesplit) or 1/5th the jackpot 3 matched win = 1% X 15% (basesplit) or 15% of the jackpot ( 1/6-ish maybe 1/7th-sh... FingersMcSteal math here )2 matched win = 1% X 10% (basesplit) or 1/10th of jackpot 1 matched win = 1% X 5% (basesplit) or 1/20th of the jackpot so 100% of the jackpot gets spread over the 5 win types. At draw time if theres no 5 matched the code does this... tempwin5 = Jackpot Total - (( 1% X basesplit5 ) X tickets with 5 matched, broken down is like this... tempwin5 = 1% X 50% X how many tickets that matched = 1/2 jackpot or... x = 1 X 50 = 50 X 0 = 0... so x = 0... or no gold give to tempwin5 because no one matched 5 numbers At draw time if 2 had 5 matched the code does this... winnersplit5 = 50% divided by the number of 5 matched tickets (2) = 25% then... tempwin5 = Jackpot Total - (( 1% X 25% ) X tickets with 5 matced (2) = 50% x = 1 X 25 = 25 X 2 = 50... so x = 50%... or 50% of the jackpot is the 5 matched numebr win amount, because it divided the 50% split % by the amount of tickets that had a match. It basically reduces the split % by the amount of matching tickets to ensure it pays out the correct amounts to each win type, or in simple terms... makes sure it doesn't create more money than is taken (like the original version did...lol). The stone works like a gold sink also, unless theres a match in all types not all of the winnings goes back into circulation because it's got to be split for all the types of win in order to get the right amounts to put to the stone. Your question 2 would probably involve this code... Code:
// Calculate each tickets win value
int basesplit5 = 50;
int basesplit4 = 20;
int basesplit3 = 15;
int basesplit2 = 10;
int basesplit1 = 5;
int tempwin5 = 0;
int tempwin4 = 0;
int tempwin3 = 0;
int tempwin2 = 0;
int tempwin1 = 0;
int JackpotTotalGold = thislotteryjackpot + thisrolloveramount;
int onepercent = JackpotTotalGold / 100;
if (fivenumberwinners > 0)
{
double winnersplit5 = basesplit5 / (double) fivenumberwinners;
tempwin5 = JackpotTotalGold - ((onepercent * ((int)(winnersplit5 * 100 )) ) * fivenumberwinners);
}
else
{
tempwin5 = JackpotTotalGold - ((onepercent * basesplit5) * fivenumberwinners);
}
if (fournumberwinners > 0)
{
double winnersplit4 = basesplit4 / (double) fournumberwinners;
tempwin4 = tempwin5 - ((onepercent * ((int)(winnersplit4 * 100 )) ) * fournumberwinners);
}
else
{
tempwin4 = tempwin5 - ((onepercent * basesplit4) * fournumberwinners);
}
if (threenumberwinners > 0)
{
double winnersplit3 = basesplit3 / (double) threenumberwinners;
tempwin3 = tempwin4 - ((onepercent * ((int)(winnersplit3 * 100 )) ) * threenumberwinners);
}
else
{
tempwin3 = tempwin4 - ((onepercent * basesplit3) * threenumberwinners);
}
if (twonumberwinners > 0)
{
double winnersplit2 = basesplit2 / (double) twonumberwinners;
tempwin2 = tempwin3 - ((onepercent * ((int)(winnersplit2 * 100 )) ) * twonumberwinners);
}
else
{
tempwin2 = tempwin3 - ((onepercent * basesplit2) * twonumberwinners);
}
if (onenumberwinners > 0)
{
double winnersplit1 = basesplit1 / (double) onenumberwinners;
tempwin1 = tempwin2 - ((onepercent * ((int)(winnersplit1 * 100 )) ) * onenumberwinners);
}
else
{
tempwin1 = tempwin2 - ((onepercent * basesplit1) * onenumberwinners);
}
// Amount to give to the winners stored on stone
// Needs to have division of 100 later at payout
thislotterystone.WinAmount5 = JackpotTotalGold - tempwin5;
thislotterystone.WinAmount4 = tempwin5 - tempwin4;
thislotterystone.WinAmount3 = tempwin4 - tempwin3;
thislotterystone.WinAmount2 = tempwin3 - tempwin2;
thislotterystone.WinAmount1 = tempwin2 - tempwin1;
The code below that part puts the win amounts onto the tickets so you could make adjustments there i guess depending on what you wanted. P.S. Ask me some easy stargate questions next time... i hate maths ![]() Last edited by FingersMcSteal; 02-28-2007 at 10:16 PM. |
|
|
|
|
|
|
#20 (permalink) |
|
Forum Novice
|
The ticket number checking doesn't work right, i'll have to have another look at this later today.
I'll post once i get it fixed tho, and... sorry again to anyone using it, it's just made a few players happy on my shard but they can keep the gold ![]() i've remarked the section of code i need to have a look at but it's this part in the timer code... Code:
// Still to add ticket status checking
if (thisticket.TicketStatus == "Valid Ticket")
{
// **********************************
// **********************************
// *** THE IDIOT FIX GOES HERE :) ***
// **********************************
// **********************************
// CHECK 1ST TICKET DIGIT FOR A MATCH AGAINST THE DRAWN NUMBERS
if (thisticket.LotteryNumber1Ticket == winnumber1 | thisticket.LotteryNumber1Ticket == winnumber2 | thisticket.LotteryNumber1Ticket == winnumber3 | thisticket.LotteryNumber1Ticket == winnumber4 | thisticket.LotteryNumber1Ticket == winnumber5)
{
ticketmatches++;
}
// CHECK 2ND TICKET DIGIT FOR A MATCH AGAINST THE DRAWN NUMBERS
if (thisticket.LotteryNumber2Ticket == winnumber1 | thisticket.LotteryNumber2Ticket == winnumber2 | thisticket.LotteryNumber2Ticket == winnumber3 | thisticket.LotteryNumber2Ticket == winnumber4 | thisticket.LotteryNumber2Ticket == winnumber5)
{
ticketmatches++;
}
// CHECK 3RD TICKET DIGIT FOR A MATCH AGAINST THE DRAWN NUMBERS
if (thisticket.LotteryNumber3Ticket == winnumber1 | thisticket.LotteryNumber3Ticket == winnumber2 | thisticket.LotteryNumber3Ticket == winnumber3 | thisticket.LotteryNumber3Ticket == winnumber4 | thisticket.LotteryNumber3Ticket == winnumber5)
{
ticketmatches++;
}
// CHECK 4TH TICKET DIGIT FOR A MATCH AGAINST THE DRAWN NUMBERS
if (thisticket.LotteryNumber4Ticket == winnumber1 | thisticket.LotteryNumber4Ticket == winnumber2 | thisticket.LotteryNumber4Ticket == winnumber3 | thisticket.LotteryNumber4Ticket == winnumber4 | thisticket.LotteryNumber4Ticket == winnumber5)
{
ticketmatches++;
}
// CHECK 5TH TICKET DIGIT FOR A MATCH AGAINST THE DRAWN NUMBERS
if (thisticket.LotteryNumber5Ticket == winnumber1 | thisticket.LotteryNumber5Ticket == winnumber2 | thisticket.LotteryNumber5Ticket == winnumber3 | thisticket.LotteryNumber5Ticket == winnumber4 | thisticket.LotteryNumber5Ticket == winnumber5)
{
ticketmatches++;
}
// *******************************
// *******************************
// *** END OF THE IDIOT FIX :) ***
// *******************************
// *******************************
if (ticketmatches == 0)
{
thisticket.TicketStatus = "Void / Old Ticket";
}
if (ticketmatches == 1)
{
onenumberwinners++;
thisticket.TicketStatus = "1 Matched Number";
}
if (ticketmatches == 2)
{
twonumberwinners++;
thisticket.TicketStatus = "2 Matched Numbers";
}
if (ticketmatches == 3)
{
threenumberwinners++;
thisticket.TicketStatus = "3 Matched Numbers";
}
if (ticketmatches == 4)
{
fournumberwinners++;
thisticket.TicketStatus = "4 Matched Numbers";
}
if (ticketmatches == 5)
{
fivenumberwinners++;
thisticket.TicketStatus = "5 Matched Numbers";
}
}
ticketmatches = 0;
// Void all old tickets
if (thisticket.TicketStatus == "1 Matched Number" && thisticket.DateOfDrawOnTickets != thislotterystone.DateOfNextDraw)
{
thisticket.TicketStatus = "Void / Old Ticket";
}
if (thisticket.TicketStatus == "2 Matched Numbers" && thisticket.DateOfDrawOnTickets != thislotterystone.DateOfNextDraw)
{
thisticket.TicketStatus = "Void / Old Ticket";
}
if (thisticket.TicketStatus == "3 Matched Numbers" && thisticket.DateOfDrawOnTickets != thislotterystone.DateOfNextDraw)
{
thisticket.TicketStatus = "Void / Old Ticket";
}
if (thisticket.TicketStatus == "4 Matched Numbers" && thisticket.DateOfDrawOnTickets != thislotterystone.DateOfNextDraw)
{
thisticket.TicketStatus = "Void / Old Ticket";
}
if (thisticket.TicketStatus == "5 Matched Numbers" && thisticket.DateOfDrawOnTickets != thislotterystone.DateOfNextDraw)
{
thisticket.TicketStatus = "Void / Old Ticket";
}
}
|
|
|
|
|
|
#22 (permalink) |
|
Forum Expert
|
Kewl...thanks for the update...one question i had about the old one.
If someone wanted to, could they keep buying the same numbered tickets in hoping they get a draw for the 5 number list? thus giving them the 50% multiple time's? or any of the draw's for that matter? The lottery system i was working on was giong to be kinda a "raffel" system....in that each number was unique, and no ticket had a duplicate set of numbers...from 1 to 54....and you picked or got a random 6 numbers. You could adapt this to do a raffle system...raffle off items at events and what not....just a thought cause i dunno if i will get my system finished or not. great work though |
|
|
|
|
|
#23 (permalink) | |
|
Forum Novice
|
Quote:
Raffle's i think consist of one ticket with one number per ticket, 1 to xyz... xyz being the number of the last ticket bought, then a number is selected for the draw. Or you have 1st, 2nd & 3rd prizes and draw 3 numbers for the draw. I guess you could have 3 items for 1st, 2nd and 3rd place. Thinking about it probably an easier system to create. |
|
|
|
|
|
|
#25 (permalink) |
|
Forum Novice
|
I imagine it's probably an easy system to create for a raffle, maybe just how you handle the prizes might need some thought based on gold spent maybe. More gold spent on the raffle the better the prize, just a thought.
I suffer the same problems... never enough time in a day to do it. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|