Code:
[DEFNAME SETTINGS_LOTTERY]
TICKET_PRICE "20000"
TICKETS_4SALE "400" // total lottery amount
TICKET_ODUL_1 grand prize
TICKET_ODUL_2 prize
TICKET_ODUL_3 attendance prize
amorti 10 // the smallest prize percent
check_id = i_makbuz
[CHARDEF C_H_PIYANGO]
ID C_MAN
NAME #NAMES_HUMANMALE
CAN MT_wALK
ON=@CREATE
f_install_lottery
NPC=BRAIN_VENDOR
STR {25 67}
DEX {12 18}
COLOR COLORS_SKIN
ITEM=i_hair_long
COLOR 07a1
ITEM=I_ROBE
COLOR 0455
ATTR 04
ITEM=I_BOOTS_cALF
COLOR 0455
ATTR 04
ITEM=I_STAFF_BLACK
ITEM=I_APRON_HALF
COLOR 0455
ATTR 04
ON=@gethit
return 1
ON=@spelleffect
return 1
ON=@death
hits = <str>
return 1
ON=@CLICK
message @1153,,1 [Lottery Staff]
MESSAGE @1153,,1 <NAME>
RETURN 1
on=@dclick
SDIALOG D_buy_ticket
RETURN 1
ON=@NPCSEENEWPLAYER
dorand 3
sayu Hey <src.name>!
say_trk <src.name> do you want to try your change?
say_trk if you want to win many with easy way, you should find me!
ENDDO
[DIALOG d_buy_ticket]
0,0
page 0
resizepic 31 53 2550 281 211
if !(<db.connected>)
db.connect
endif
db.query "SELECT COUNT(TicketUid) FROM game_cekilis "
db.close
dhtmlgump 90 70 200 25 0 0 <DEF.BFONT_red><serv.servname> Lottery Draw
if (<var0.devreden>)
local.a (<db.row.0>*<def.ticket_price>)
local.b (<var.devreden>*<def.ticket_price>)
local.c <eval (<local.a>+<local.b>)>
else
local.c (<db.row.0>*<def.ticket_price>)
endif
dhtmlgump 75 100 200 200 0 0 <def.small><DEF.BFONT_RED><EVAL <SERV.AGE>/7>th week's<DEF.BFONT_BLACK> lottery is selling <DEF.BFONT_RED><ddef.tickets_4sale><DEF.BFONT_BLACK> coupon and <DEF.BFONT_RED><ddb.row.0><DEF.BFONT_BLACK> people bought lottery. This week's grand prize is <def.bfont_red><f_bolukayir <eval <dlocal.c>/2>><def.bfont_black>gp now. One coupon is <def.bfont_Red><f_bolukayir <ddef.ticket_price>> <def.bfont_black>gold.
dhtmlgump 80 200 200 23 0 0 <DEF.BFONT_BLACK>I want to buy one coupon.
button 55 200 5550 5551 1 0 1
resizepic 31 280 2550 281 100
dhtmlgump 50 300 240 70 0 0 <def.small><def.bfont_red><REGION.DTAG0.TICKET> <def.black>Coupons, which are bought here, toplam won<def.bfont_red><region.dtag0.BigPrize> grand prize, <region.dtag0.normalprize> prize, <region.dtag0.amortiprize><def.bfont_black> attendance prize.
[DIALOG D_BUY_TICKET BUTTON]
ON=1
if <src.account.tag0.aldiklarim> == 3
src.sysh_trk You can buy 3 coupons every week.
return 1
endif
if !(<db.connected>)
db.connect
endif
db.query "SELECT COUNT(TicketUid) as bilet FROM game_cekilis "
sysmessage @977a,,1 <db.row.0>
IF (<SRC.GOLD> < <DEF.TICKET_PRICE>)
SRC.sysh_trk you don't have enough money.
RETURN 1
ENDIF
IF (<DB.ROW.0.bilet> >= <DEF.TICKETS_4SALE>)
SRC.sysh_trk all coupons are sold.
RETURN 1
ENDIF
SERV.NEWITEM I_TICKET_LOTTERY,1,<SRC.UID>
DB.EXECUTE "INSERT INTO `game_cekilis` (`TicketUid` ,`ODUL`, `TicketRegion`) VALUES ('<NEW.UID>',0,'<SRC.P>');"
SRC.GOLD -=<DEF.TICKET_PRICE>
REGION.TAG0.TICKET ++
src.account.tag0.aldiklarim ++
db.close
[FUNCTION Cekilisbaslat]
if !(<db.connected>)
db.connect
endif
db.query "SELECT COUNT(TicketUid) as bilet FROM game_cekilis "
if (<db.row.0.bilet> < 10)
sysmessage @,,1 You must do lottery draw after because of not enough attendance.
return 1
endif
local.amorti = <db.row.0.bilet>
LOCAL.GREATPRIZE <qval (<var0.devreden>)?<eval <db.row.0.bilet>+<var0.devreden>>:<db.row.0.bilet>>
IF (<R1,3> = 1)
if (<var0.devreden>)
var.devreden +=<eval <db.row.0.bilet>/2>
else
var.devreden <eval <db.row.0.bilet>/2>
endif
serv.newitem i_gold
LOCAL.SERIAL <EVAL STRLEN(<NEW.UID>)>
serv.allclients sound 247
serv.allclients sysmessage @07a0,,1 Nimloth <eval <serv.age>/7>th week lottery's grand prize is won by <STRSUB <EVAL (<LOCAL.SERIAL>-4)> <DLOCAL.SERIAL> <NEW.UID>>. This coupon wasn't sold, so this prize is sended next week.
serv.allclients sysmessage @07a0,,1 Winner people, who won attendance prize, they take their prizes from us shop!
new.remove
else
DB.query "select * from game_cekilis WHERE ODUl= 0 order by rand() limit 1"
SERV.NEWITEM I_GOLD
NEW.P <DB.ROW.0.TicketRegion>
LOCAL.SERIAL <EVAL STRLEN(<db.row.0.TicketUid>)>
serv.allclients sound 247
serv.allclients sysmessage @07a0,,1 This week's winner copuon is in <new.region.name> towns <STRSUB <EVAL (<LOCAL.SERIAL>-4)> <DLOCAL.SERIAL> <db.row.0.TicketUid>> numbered coupon! Congratulation.
DB.EXECUTE "UPDATE game_cekilis SET ODUL=1 WHERE TicketUid='<DB.ROW.0.TicketUid>'"
UID.<DB.ROW.0.TicketUid>.COLOR 07AD
UID.<DB.ROW.0.TicketUid>.MOREY (<LOCAL.GREATPRIZE>/2)
NEW.REGION.TAG0.BigPrize ++
NEW.REMOVE
var.devreden
endif
/////////////////////////////////////////////////////////////////////////////////////
DB.query "select * from game_cekilis WHERE ODUl= 0 order by rand() limit 2"
UID.<DB.ROW.0.TicketUid>.COLOR 0810
UID.<DB.ROW.1.TicketUid>.COLOR 0810
DB.EXECUTE "UPDATE game_cekilis SET ODUL=2 WHERE TicketUid='<DB.ROW.0.TicketUid>'"
DB.EXECUTE "UPDATE game_cekilis SET ODUL=2 WHERE TicketUid='<DB.ROW.1.TicketUid>'"
UID.<DB.ROW.0.TicketUid>.MOREY (<LOCAL.GREATPRIZE>/5)
UID.<DB.ROW.1.TicketUid>.MOREY (<LOCAL.GREATPRIZE>/5)
SERV.NEWITEM I_GOLD
NEW.P <DB.ROW.0.TicketRegion>
NEW.REGION.TAG0.NormalPrize ++
NEW.P <DB.ROW.1.TicketRegion>
NEW.REGION.TAG0.NormalPrize ++
NEW.REMOVE
/////////////////////////////////////////////////////////////////////////////////////////
DB.query "select * from game_cekilis WHERE ODUl= 0 order by rand() limit <f_yuzde <def.amorti>,<dlocal.amorti>>"
FOR 0 <EVAL <DB.ROW.NUMROWS>-1>
UID.<DB.ROW.<DLOCAL._FOR>.TicketUid>.COLOR 080A
UID.<DB.ROW.<DLOCAL._FOR>.TicketUid>.morey = 1
DB.EXECUTE "UPDATE game_cekilis SET ODUL=3 WHERE TicketUid='<DB.ROW.<DLOCAL._fOR>.TicketUid>'"
SERV.NEWITEM I_GOLD
NEW.P <DB.ROW.<DLOCAL._FOR>.TicketRegion>
NEW.REGION.TAG0.AmortiPrize ++
NEW.REMOVE
ENDFOR
////////////////////////////////////////////////////////////////////////////////////////////////////
DB.QUERY "SELECT TicketUid FROM game_cekilis WHERE ODUL= 0 "
FOR 0 <eval <DB.ROW.NUMROWS>-1>
UID.<DB.ROW.<DLOCAL._FOR>.TicketUid>.REMOVE
ENDFOR
db.close
cleandatabase game_cekilis
for 0 <eval <serv.accounts>-1>
serv.account.<dlocal._for>.tag0.aldiklarim =
endfor
endif
[ITEMDEF I_TICKET_LOTTERY]
ID I_DEED
NAME piyango kuponu
WEIGHT 12
TYPE T_SCRIPT
ON=@CREATE
ATTR ATTR_NEWBIE
COLOR 02e2
ON=@CLICK
LOCAL.SERIAL <EVAL STRLEN(<UID>)>
IF (<MOREY>)
MESSAGE @,,1 [<f_bolukayir <EVAL <MOREY>*<DEF.TICKET_PRICE>>>]
endif
MESSAGE @63 [Bilet No :<STRSUB <EVAL (<LOCAL.SERIAL>-4)> <DLOCAL.SERIAL> <UID>>]
message lottery coupon
return 1
ON=@DCLICK
IF !(<color>=02e2)
TARGET @,,1 choose lottery staff.
return 1
endif
src.sysh_trk Weekly draws is drawn at 19:30.
return 1
ON=@TARGON_CHAR
IF (<SRC.TARG.BASEID>==C_H_PIYANGO)
IF (<MOREY>)
serv.newitem <def.check_id>,1,<src.uid>
new.more1 = <EVAL <MOREY>*<DEF.TICKET_PRICE>>
new.more2 = <src.targ.uid>
SRC.SYSMESSAGE @,,1 <EVAL <MOREY>*<DEF.TICKET_PRICE>> gold is being sended your bank.
REMOVE
ENDIF
ELSE
SRC.SYSMESSAGE @,,1 you can exchange your coupon every lottery staffs.
RETURN 1
ENDIF
return 1
ON=@destroy
if !(<db.connected>)
db.connect
endif
db.execute "delete from game_cekilis Where TicketUid = '<uid>';"
db.close
[function f_cekilis_recover]
db.query "select TicketUid from game_cekilis where Odul=0"
for 0 <eval <db.row.numrows>-1>
ref1=<db.row.<dlocal._for>.ticket_uid>
if !(<uid.<ref1.uid>>)
db.execute "delete from game_cekilis Where TicketUid = '<ref1.uid>';"
endif
endfor
[function cleandatabase]
if !(<db.connected>)
db.connect
endif
db.execute TRUNCATE TABLE `<args>`
db.close
sysh_trk <args> cleared!
[function kazananbul]
forinstances i_ticket_lottery
if <color> == 0810
src.go <topobj.p>
endif
endfor
[eof]