My Ez2 Lotto script for Eathena

Started by themon, Apr 27, 2013, 06:51 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

themon

//Ez2 by teamcars of [email protected]

//===== eAthena Script =======================================
//= Ez2 Lottery Script
//===== By: ==================================================
//= chan - teamcars1broglobal.blogspot.com
//===== Current Version: =====================================
//= 1.1.1a
//===== Compatible With: =====================================
//= Any eAthena Version
//===== Description: =========================================
//= Ez2 lottery draw.
//= Just like in Ez2 Lotto in the Philippines
//===== Additional Comments: =================================
//= Numbers drawn daily every 11:00am, 4:00pm and 9:00pm 
//============================================================

prontera,162,194,5   script   lotterygenerator   111,{

OnInit:
waitingroom "Let's Play Ez2 Lotto",0;
set $L_TicketPrice,1000; // TICKET COST
set $L_Prize_Money,1000000; // JACKPOT AMOUNT
set $L_Prize_Money_Small,500000; // SECONDARY PRIZE
if ($LID == 0) goto L_GenID;
end;

//Modify for own time
OnClock1100:
set $S_LastDr$,"11:00 AM";
goto C_Ez2;

OnClock1600:
set $S_LastDr$,"04:00 PM";
goto C_Ez2;

OnClock2100:
set $S_LastDr$,"09:00 PM";
goto C_Ez2;


C_Ez2:
// CHECKS IF LOTTERY IS RIGGED
if ($L_Rigged == 1) goto L_Rigged_Draw;
// GENERATES RANDOM NUMBERS 1-31
Pick1:
set $LW1,rand (1,31);
Pick2:
set $LW2,rand (1,31);



// BROADCASTS DRAW
L_Broadcast:
Announce "Welcome to Ez2 Lotto " + $S_LastDr$ + " Draw!",8;
Announce "The numbers are as follows: [" + $LW1 + "] [" + $LW2 + "]",8;
Announce "Congratulations to the winners of Ez2 Lotto!",8;


// GENERATES DRAW ID CODE
L_GenID:
set $LID2,$LID;
// SETS Next ID NUMBER
set $LID,rand (100000,999999);
end;

// SETS DRAW TO RIGGED NUMBERS
L_Rigged_Draw:

set $LW1,$LR1;
set $LW2,$LR2;
set $L_Rigged,0;
goto L_Broadcast;

}

// BEGIN LOTTERY SCRIPT
-   script   lottery   76,{
L_Begin:
mes "[Ez2 Teller]";
mes "Winning EZ2 Lotto Numbers ("+$LID2+"):";
mes "The Last Draw ^0000FF[" + $S_LastDr$ + "]^000000";
mes "^0000FF[" + $LW1 + "] [" + $LW2 + "]^000000";
if ($LID > 99999) mes "Your Ticket ("+#LID+"):";
if ($LID > 99999) mes "^FF0000[" + #LW1 + "] [" + #LW2 + "]^000000";
mes "Next Draw-ID: ^FF0000" + $LID + "^000000.";
next;
if (getgmlevel() > 2) goto L_GM;
menu "Claim Prize",L_Claim,"Buy New Ticket",L_Buy,"Cancel",L_Cancel;

// PURCHASE TICKET
L_Buy:
if (#LID == $LID && #LW1 != 0) goto L_DoubleTicket;
mes "[Ez2 Teller]";
mes "Tickets cost ^0000FF" + $L_TicketPrice + "z^000000.";
mes "The Jackpot is ^FF0000" + $L_Prize_Money + "z^000000.";
next;
menu "Buy Ticket",-,"Cancel",L_Cancel;
if (zeny < $L_TicketPrice) goto L_NoZeny;
set zeny,zeny-$L_TicketPrice;
mes "[Ez2 Teller]";
mes "Would you like your numbers Hand Picked or Lucky Picked?";
next;
menu "Lucky Picked",L_ComputerGen,"Hand Picked",L_HandPick,"Renew Ticket",L_Renew;

// RENEW LAST TICKET
L_Renew:
if ($LID < 99999) goto L_Invalid;
set #LID,$LID;
goto L_Confirm2;

L_ComputerGen:
// SELECTS RANDOM NUMBERS
set @L1,0;
set @L2,0;

Pick1:
set @L1,rand (1,31);
Pick2:
set @L2,rand (1,31);


mes "[Ez2 Teller]";
mes "The computer has selected the following numbers:";
mes "^0000FF" + @L1 + " " + @L2 + "^000000";
next;
menu "Confirm",L_Confirm,"Re-Generate",L_ComputerGen;

// HAND PICK LOTTERY NUMBERS
L_HandPick:
mes "[Ez2 Teller]";
mes "Please pick your numbers (1-31):";
set @L1,0;
set @L2,0;

Input1:
input @L1;
if (@L1 < 1 || @L1 > 31) goto Input1;
mes @L1;
Input2:
input @L2;
if (@L2 < 1 || @L2 > 31) goto Input2;

mes @L2;

next;
mes "[Ez2 Teller]";
mes "Your numbers are:";
mes "^0000FF" + @L1 + " " + @L2 + "^000000";
next;
menu "Confirm",L_Confirm,"Re-Pick",L_HandPick;

L_Confirm:
set #LW1,@L1;
set #LW2,@L2;
set #LID,$LID;
L_Confirm2:
mes "[Ez2 Teller]";
mes "The live broadcasted draw are at 11am, 4pm and 9pm";
mes "You can claim your ticket between then and the next draw.";
next;
mes "[Ez2 Teller]";
mes "Good luck!";
close;

L_Claim:
// CHECKS TICKET VALIDILITY
if (#LID != $LID2) goto L_Invalid;
// CHECKS HOW MANY NUMBERS MATCHED
set @LPrize,0;
if (#LW1 == $LW1) set @LPrize,@LPrize+1;
if (#LW2 == $LW2) set @LPrize,@LPrize+1;
if (@LPrize == 2) goto LWinBig;
if (#LW1 == $LW2) set @LPrize,@LPrize+2;
if (#LW2 == $LW1) set @LPrize,@LPrize+2;
if (@LPrize == 4) goto LWinSmall;

// NO WINNER
mes "[Ez2 Teller]";
mes "Bad luck, it appears you do not hold a winning ticket.";
next;
mes "[Ez2 Teller]";
mes "Better luck next time!.";
close;

// MATCHED TWO IN EXACT ORDER
LWinBig:
mes "[Ez2 Teller]";
mes "You have matched Two Numbers in Exact Order";
mes "Jackpot!";
mes "You've won ^0000FF" + $L_Prize_Money + "z^000000.";
set zeny,zeny+$L_Prize_Money;
Announce "Ez2 Teller: " + strcharinfo(0) + " has won the JACKPOT of " + $L_Prize_Money + "z!",8;
set #LID,0;
close;

// MATCHED TWO I RANDOM ORDER
LWinSmall:
mes "[Ez2 Teller]";
mes "You have matched Two numbers in Random Order";
mes "You've won ^0000FF" + $L_Prize_Money_Small + "z^000000.";
set zeny,zeny+$L_Prize_Money_Small;
Announce "Ez2 Teller: " + strcharinfo(0) + " has won a prize of " + $L_Prize_Money_Small + "z!",8;
set #LID,0;
close;

// NO ZENY
L_NoZeny:
mes "[Ez2 Teller]";
mes "You can't afford a Ez2 Lottery ticket.";
close;

// INVALID TICKET
L_Invalid:
mes "[Ez2 Teller]";
mes "I'm sorry but it appears that you have an invalid ticket.";
close;

// DOUBLE TICKET
L_DoubleTicket:
mes "[Ez2 Teller]";
mes "It appears that you already have a ticket for today.";
mes "You may only purchase one ticket per draw.";
close;

L_Cancel:
mes "[Ez2 Teller]";
mes "Come back soon!";
close;

// GM MENU (Lets you manually do draws)
L_GM:
menu "Claim Prize",L_Claim,"Buy New Ticket",L_Buy,"[GM]Do Draw Now",-,"[GM]Rig the Ez2 Lottery",L_GM_Rig,"Cancel",L_Cancel;

// CHECKS IF Lottery IS RIGGED
if ($L_Rigged == 1) goto L_Rigged_Draw;
// GENERATES RANDOM NUMBERS 1-31
GMPick1:
set $LW1,rand (1,31);

GMPick2:
set $LW2,rand (1,31);



// BROADCASTS DRAW
L_Broadcast:
Announce "Ez2 Teller: Welcome to the Special GM's Ez2 Lotto draw!",8;
Announce "The numbers are as follows: [" + $LW1 + "] [" + $LW2 + "]",8;
Announce "Congratulations to the Ez2 Lotto winners!",8;

// GENERATES DRAW ID CODE
L_GenID:
set $LID2,$LID;
// SETS Next ID NUMBER
set $LID,rand (100000,999999);
set $S_LastDr$,"Special GM's draw!";
close;

// SETS DRAW TO RIGGED NUMBERS
L_Rigged_Draw:
set $LW1,$LR1;
set $LW2,$LR2;
set $L_Rigged,0;
goto L_Broadcast;

// ALLOWS GM TO DO A RIGGED DRAW
L_GM_Rig:
mes "[Lottery]";
mes "Please pick your numbers (1-31):";
set $LR1,0;
set $LR2,0;
GMInput1:
Input $LR1;
if ($LR1 < 1 || $LR1 > 31) goto GMInput1;
mes $LR1;
GMInput2:
Input $LR2;
if ($LR2 < 1 || $LR2 > 31) goto GMInput2;

mes $LR2;
next;
mes "[Ez2 Teller]";
mes "Lottery rigged for next draw.";
set $L_Rigged,1;
close;
}

prontera,162,194,5   duplicate(lottery)   Ez2 Lotto Teller   76