SphereCommunity
Lottery system - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Requests (/Forum-Script-Requests)
+--- Thread: Lottery system (/Thread-Lottery-system)



Lottery system - babazar - 12-15-2013 02:27 AM

Any one got a working lottery system Big Grin


RE: Lottery system - larmc20 - 01-12-2014 04:51 AM

PHP Code:
// Lottery system scripted by Rukk

[ITEMDEF i_stone_lottery]
DEFNAME=i_stone_lottery
NAME
=Lottery Stone
ID
=i_grave_stone

ON
=@create
    ATTR
=08014
    COLOR
=007cc
    tag
.amount 200000
    tag
.chance 1000

on
=@click
    message 
@67 Last winner: <tag.lotterywinner> ]
    
message @67 Pot: <eval <tag.amount> / 2GP ]

ON=@DCLICK
    
if (<distance> > 3)
        
src.sysmessage You are too far away!
        return 
1
    
endif

    
src.tag.lottery_stone = <uid>
    if (<eval <
tag.amount>> > 5000000)
        
tag.chance 20
    
elseif (<eval <tag.amount>> > 4000000)
        
tag.chance 30
    
elseif (<eval <tag.amount>> > 3000000)
        
tag.chance 40
    
elseif (<eval <tag.amount>> > 2000000)
        
tag.chance 50
    
elseif (<eval <tag.amount>> > 1000000)
        
tag.chance 60
    
elseif (<eval <tag.amount>> > 500000)
        
tag.chance 100
    
elseif (<eval <tag.amount>> > 250000)
        
tag.chance 150
    
elseif (<eval <tag.amount>> > 100000)
        
tag.chance 180
    
else
        
tag.chance 200
    
endif
    
Dialog d_lottery
    
RETURN 1

[DIALOG d_lottery]
100,100
src
.f_lotteryDialogs

resizepic 0 0 5054 300 200

resizepic 70 10 3000 160 20
htmlgump 73 10 160 20 0 0 0

resizepic 40 50 3000 220 20
htmlgump 43 50 220 20 1 0 0

resizepic 40 80 3000 220 20
htmlgump 43 80 220 20 2 0 0

resizepic 40 110 3000 220 20
htmlgump 43 110 220 20 3 0 0

button 40 150 5601 5605 1 0 1
htmlgump 60 150 220 20 4 0 0


[DIALOG d_lottery TEXT]
Lottery System
Current jackpot 
: <eval <tag.amount> / 2GP
Price to participate 
: <eval <eval <tag.amount> / 2> / 25GP
Chance to win 
1 on <eval <tag.chance>>
Click here to play!

[
DIALOG d_lottery BUTTON]
on=1
    obj 
= <src.tag.lottery_stone>

    if ( <
obj.distance> > )
        
src.sysmessage You are too far away!
        return 
1
    
endif

    
src.tag.lottery = <eval <eval <tag.amount> / 2> / 25>
    if (<
src.distance> > 5)
        
src.sysmessage You are too far away!
        return 
1
    
elseif (<src.rescount i_gold> < <eval <eval <tag.amount> / 2> / 25>)
        
src.sysmessage You need <eval <eval <tag.amount> / 2> / 25GP in your backpack to participate!
        return 
1
    
else 
        while (
0<src.tag.lottery> > 50000)
            
src.consume 50000 i_gold
            src
.tag.lottery = <eval <src.tag.lottery> - 50000>
        endwhile
        if (
0<src.tag.lottery> > 0)
            
src.consume <src.tag.lotteryi_gold
        
endif
        
src.tag.lottery =
        
tag.amount = <eval <tag.amount> + <eval <eval <tag.amount> / 2> / 25>>

        if !(
rand(<eval <tag.chance>>))
            
src.sysmessage You win <eval <tag.amount> / 2GP!
            
serv.allclients sysmessage @67 Lottery >> <src.namejust won <eval <tag.amount> / 2GP!
            
tag.lotterywinner = <src.name>
            
serv.newitem i_bank_check
            
new.tag.amount = <eval <tag.amount> / 2>
            new.
bounce
            serv
.log [Lottery] <src.name> (<src.account>) won <eval <tag.amount> / 2GP.
            
tag.amount 200000
        
else
            
src.tag.lottery 
            
src.sysmessage SorryBetter luck next time!            
        endif
    endif
    if (<eval <
tag.amount>> > 5000000)
        
tag.chance 20
    
elseif (<eval <tag.amount>> > 4000000)
        
tag.chance 30
    
elseif (<eval <tag.amount>> > 3000000)
        
tag.chance 40
    
elseif (<eval <tag.amount>> > 2000000)
        
tag.chance 50
    
elseif (<eval <tag.amount>> > 1000000)
        
tag.chance 60
    
elseif (<eval <tag.amount>> > 500000)
        
tag.chance 100
    
elseif (<eval <tag.amount>> > 250000)
        
tag.chance 150
    
elseif (<eval <tag.amount>> > 100000)
        
tag.chance 180
    
else
        
tag.chance 200
    
endif
    
Dialog d_lottery

[function f_lotteryDialogs]
    
dialogclose d_lottery 0