Make your own Slot Machine =D

Discussion in 'Code Snippets and Tutorials' started by ZOMG, Mar 7, 2007.

Thread Status:
Not open for further replies.
  1. ZOMG

    ZOMG Level I

    Joined:
    Feb 26, 2007
    Messages:
    122
    Likes Received:
    0
    Location:
    Hipocresy Land
    Code (Text):
    1. Private Declare Function GetTickCount Lib "kernel32" () As Long ' function for the wait sub
    2. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) ' function for the wait sub
    3.  
    4. Dim bet As Long
    5.  
    6. Private Sub Wait(ByVal seconds As Long) ' wait sub
    7.  
    8. Dim CurrentTime As Long, StopTime As Long ' variables
    9.     CurrentTime = GetTickCount() ' 'currenttimes value
    10.         Do Until GetTickCount() >= CurrentTime + seconds * 1000 ' how long to wait for
    11.             DoEvents ' do events
    12.             Sleep 1 ' wait
    13.         Loop '
    14.        
    15. End Sub
    16.  
    17. Private Sub AutoCheck_Click() 'autobet checkbox
    18.  
    19.     If Txtautobet.Text > 0 Then ' if bet entered is more than zero
    20.         AutoCheck.Value = 1 ' then enable it
    21.         Else: AutoCheck.Value = 0 ' if bet is less than zero, disable it
    22.     End If ' end if
    23.    
    24. End Sub
    25.  
    26. Private Sub imgbet_Click() ' bet button
    27.  
    28. If lblmoney.Caption < 5 Then ' if user doesn't have enough money to bet
    29.    
    30.     MsgBox "You are all out of money! Is there any in the bottom of the machine? Perhaps if you keep on looking you may find some!", , "you're broke!" ' tell them they're broke!
    31.  
    32. ElseIf lblmoney.Caption >= 5 Then ' if they do have enough to bet
    33.    
    34.     bet = bet + 5 ' then add 5 to their current bet
    35.     lblmoney.Caption = lblmoney.Caption - 5 ' take 5 from their money
    36.     lblbet.Caption = bet ' update their bet amount caption
    37.     lblmult.Caption = bet / 5 ' update their multiply bonus caption
    38.  
    39. End If
    40.  
    41. End Sub
    42.  
    43. Private Sub imgcol_Click() ' collection box image
    44.    
    45.     Dim moneyfind As Long ' the money variable
    46.     rand = Random(1, 10) ' chance of finding money = 1/10
    47.  
    48. If rand = 10 Then moneyfind = Random(5, 20) ' if rand = 10 then the user finds between 5 and 20 money
    49.     lblmoney.Caption = lblmoney.Caption + moneyfind ' update money
    50.     MsgBox "You found " & moneyfind & " in the collection box!", , "Money!" ' display message box saying how much they found
    51.  
    52. End Sub
    53.  
    54. Private Sub imgspin_Click() ' spin the slots go button image
    55.  
    56. If AutoCheck.Value = 1 Then ' if the user has autoselect selected
    57.  
    58. Dim currentmoney As Integer ' dim currentmoney
    59.     currentmoney = lblmoney.Caption ' store the money value in here to tell prog that the money amount is an integer
    60.  
    61. If currentmoney >= Txtautobet.Text Then ' check user has enough to bet
    62.  
    63.     lblmoney.Caption = lblmoney.Caption - Txtautobet.Text ' update money
    64.     bet = Txtautobet.Text ' update bet
    65.  
    66. ElseIf currentmoney < Txtautobet.Text Then ' if they dont have enough money
    67.  
    68.     bet = 0 ' they dont get to bet
    69.     MsgBox "You are all out of money! Is there any in the bottom of the machine? Perhaps if you keep on looking you may find some!", , "you're broke!" ' tell them they're broke
    70.     GoTo endit ' goto the end
    71.  
    72. End If 'end if
    73.  
    74. End If 'end if
    75.  
    76.  
    77. If bet <= 0 Then ' if they haven't got a bet
    78.  
    79.     MsgBox "You haven't made a bet yet!", , "make a bet" ' tell them to make one
    80.  
    81. ElseIf bet > 0 Then ' if they have made a bet
    82.  
    83.     Dim moneymult As Long ' dim moneymult
    84.  
    85.     moneymult = bet 'moneymult equals the value of bet
    86.     bet = 0 ' reset the bet value
    87.     lblbet.Caption = bet ' reset the bet amount caption
    88.  
    89.     Timer1.Enabled = True ' enable timer (scrolling changing num effects)
    90.     Wait (1) ' wait 1 second
    91.     Timer1.Enabled = False ' disable the timer
    92.  
    93.         lbl0.Caption = Random(1, 9) ' text bit on slot machine = a random number
    94.         lbl1.Caption = Random(1, 9) ' text bit on slot machine = a random number
    95.         lbl2.Caption = Random(1, 9) ' text bit on slot machine = a random number
    96.         lbl01.Caption = Random(1, 9) ' text bit on slot machine = a random number
    97.         lbl11.Caption = Random(1, 9) ' text bit on slot machine = a random number
    98.         lbl21.Caption = Random(1, 9) ' text bit on slot machine = a random number
    99.         lbl02.Caption = Random(1, 9) ' text bit on slot machine = a random number
    100.         lbl12.Caption = Random(1, 9) ' text bit on slot machine = a random number
    101.         lbl22.Caption = Random(1, 9) ' text bit on slot machine = a random number
    102.  
    103. If lbl12.Caption = lbl11.Caption = lbl1.Caption Then ' if three in a row across the middle equals the same amount then
    104.  
    105.     lblmoney.Caption = lblmoney.Caption + (moneymult * 2) ' update money with winnings
    106.     lblwins.Caption = lblwins.Caption + (moneymult * 2) ' update total winnings label
    107.  
    108. End If ' end if
    109.  
    110.     lblmult.Caption = "0" ' reset multiplier label
    111.  
    112. End If ' endif
    113.  
    114. endit: ' the goto bit from up there ^ :)
    115.  
    116. End Sub
    117.  
    118. Private Sub Timer1_Timer() ' interval 1
    119.  
    120. lbl0.Caption = Random(1, 9) ' create a random number to get changing effect
    121. lbl1.Caption = Random(1, 9) ' create a random number to get changing effect
    122. lbl2.Caption = Random(1, 9) ' create a random number to get changing effect
    123. lbl01.Caption = Random(1, 9) ' create a random number to get changing effect
    124. lbl11.Caption = Random(1, 9) ' create a random number to get changing effect
    125. lbl21.Caption = Random(1, 9) ' create a random number to get changing effect
    126. lbl02.Caption = Random(1, 9) ' create a random number to get changing effect
    127. lbl12.Caption = Random(1, 9) ' create a random number to get changing effect
    128. lbl22.Caption = Random(1, 9) ' create a random number to get changing effect
    129.  
    130. End Sub
    131.  
    132. Public Function Random(Min As Long, Max As Long) As Long ' a proper random generator
    133.  
    134. Static RandControl As Integer
    135.     RandControl = RandControl - 1
    136.  
    137. If RandControl < 0 Then
    138.    
    139.     Randomize Timer
    140.     RandControl = 999
    141.    
    142. End If
    143.  
    144.     Random = Int(Rnd * ((Max + 1) - Min)) + Min
    145.  
    146. End Function
    Well.. thats all.
    Im really bored, and i start to make this.
    This is nothing neo-related.
    But with practice, and learning codes, you can make veru usefull neopets programs =), enojoy. xD
     
  2. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    you should put an image of the gui to make it easier to make
     
  3. ZOMG

    ZOMG Level I

    Joined:
    Feb 26, 2007
    Messages:
    122
    Likes Received:
    0
    Location:
    Hipocresy Land
    I'll do.
    I'll do more tutorials.
    But now, im trying to do an AB :p
     
  4. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    do have any idea how to code it you have to find string in html go to different html get a picture onr a picture. But if you have found a how to make an autobuyer tutorial I would love to know where one is
     
  5. ZOMG

    ZOMG Level I

    Joined:
    Feb 26, 2007
    Messages:
    122
    Likes Received:
    0
    Location:
    Hipocresy Land
    Nope..
    Maybe, in the future (if i have the expon autorization (sorry mi sintax)) i'll make an How To Make an AB =D.
    But, i recommend, start learning with another non-AB related programms =)
     
  6. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    I am making other non main shop aber I am making an usab. What things are you making/made
    And I know how to make an autobuyer now
     
  7. marlene

    marlene Moderator
    Staff Member

    Joined:
    Dec 23, 2006
    Messages:
    1,492
    Likes Received:
    12
    Location:
    Somewhere under the Rainbow (Montreal)
    ZOMG - did you write that code yourself... or did you find it on another site?
     
Thread Status:
Not open for further replies.