;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[@LottoSystem_NPC]
{

#SAY
Sting Lotto Every Wednesday at 2130 GMT\
You must choose 3 Numbers between 0 and 4\
This Gives a 1 in 125 Chance of Winning!!!!!\\
A Ticket costs 1500 Gold.  I buy old tickets for 500 Gold\\
I will charge you a further 250000 Gold to Fill your\ numbers in, Just double click the ticket to enter your numbers, view the numbers you have entered
 or check \
if you have won!\\
<[ Check Lotto Results ]/@ComFirmLottoNumber>\
<[ Buy Lotto Ticket ]/@BuyLotto>\
<[ Sell Lotto Ticket ]/@SellLotto>\
<[ Exit ]/@exit>\\

[@SellLotto]
#IF
checkitem LottoTicket 1
#SAY
Are you sure you want to sell this ticket?\
<[ Sell it!! ]/@SellLotto1> \
<[ Exit ]/@exit> \

[@SellLotto1]
#IF
checkitem LottoTicket 1
#ACT
Give Gold 500
Take LottoTicket 1
#SAY
Thanks.. sell another one?\
<[ Sell it!! ]/@SellLotto1>\
<[ Back ]/@LottoSystem_NPC>\

#ELSESAY
You do not have a Lotto Ticket!
<[ Exit ]/@exit>\

[@ComFirmLottoNumber]
#ACT
ReadValueSql "TBL_LottoServer" "FLD_Name='Current'" "FLD_Sequence" @ComFirmLottoNumber_Sequence

[@ComFirmLottoNumber_Sequence()]
#ACT
Mov D0 %ARG(1)
Dec D0 1

#IF
Large D0 0
#ACT
FormatStr "FLD_Name='Lotto' and FLD_Sequence=%s" %D0
ReadValueSql "TBL_LottoServer" %A9 "FLD_Num1,FLD_Num2,FLD_Num3,FLD_HumanCount,FLD_TotalPrice,FLD_UserPrice" @ComFirmLottoNumber_Information

#ELSESAY
You cannot view the previous Lotto draw as this is the\
first one!\
<[ Exit ]/@exit>\

[@ComFirmLottoNumber_Information()]
#ACT
Mov D1 %ARG(1)
Mov D2 %ARG(2)
Mov D3 %ARG(3)
Mov D4 %ARG(4)
Mov D5 %ARG(5)
Mov D6 %ARG(6)

#IF
Equal D4 0

#SAY
Sting Lotto (Week <$OUTPUT(D0)>) Winning Numbers are <$OUTPUT(D1)>, <$OUTPUT(D2)>, <$OUTPUT(D3)>\
The prize was not won! <$OUTPUT(D5)> Gold Rolls Over to Next week!\
<[ Exit ]/@exit>\


#ELSESAY
Sting Lotto (Week <$OUTPUT(D0)>) Winning Numbers are <$OUTPUT(D1)>, <$OUTPUT(D2)>, <$OUTPUT(D3)>\
There were <$OUTPUT(D4)> winners, each receiving <$OUTPUT(D6)> Gold.  Total Prize = <$OUTPUT(D5)> Gold\
<[ Exit ]/@exit>\

[@BuyLotto]
#IF
CHECKBAGGAGE

#ELSESAY
You don't have the bag space\
<[ Exit ]/@exit>\

#ELSEACT
break

#IF
checkgold 1500
#ACT
ReadValueSql "TBL_LottoServer" "FLD_Name='Current'" "FLD_Sequence" @BuyLotto_Sequence

#ELSESAY
You don't have enough Gold!\
<[ Exit ]/@exit>\

[@BuyLotto_Sequence()]
#ACT
Mov D0 %ARG(1)

#IF
checkgold 1500
#ACT
sysmsg "You have purchased a go on the Sting Lotto (Week <$OUTPUT(D0)>)"
Take Gold 1500
Give LottoTicket 1
FormatStr "%s,%s,%s," %P9 %D0 100
Mov A8 %A9
FOrmatStr "%s,%s" 100 100
Addstr A8 %A9
FormatStr "FLD_MakeIdx=%s and FLD_Sequence=%s" %P9 %D0
WriteValueSql "TBL_LottoUser" %A9 "FLD_MakeIdx,FLD_Sequence,FLD_Num1,FLD_Num2,FLD_Num3" %A8
Close
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;