Gambler Cent Toss Script

*Created by Taz.*

```
Using "RC_Core.rcm"
; testingrc1 1.26
; Date/Time: 5:20:59 PM on 7/12/2010
; By Naddaz on TAZCO
;25 cent toss gambling game.
;Textures
  ;Idle 429
  ;Heads 430
  ;Tails 430

  Function Main()
  Player = Actor()
  Target = ContextActor()
  PMoney% = Money(Player)
  BetPicked% = 0 ;variable to hold players heads or tails choice will end if/when script ends.
  ChatBox = OpenDialog(Player, Target, "25 Cent Toss", 429) ;set number to main menu media id in editor

          DialogOutPut(Player, ChatBox, "Hey there can I interest ", 230, 145, 23) ;Chat
        DialogOutPut(Player, ChatBox, "you in a game of chance?", 230, 145, 23) ;Chat
        DialogOutPut(Player, ChatBox, "So what do you say?", 230, 145, 23) ;Chat
        Tosshelp% = DialogInPut(Player, ChatBox, "Lets Play,Wait how to play?,Is this Legal?,Close")

            If (Tosshelp = 1) ; Lets play start the game
                CloseDialog(Player, ChatBox)
                ChatBox = OpenDialog(Player, Target, "25 Cent Toss", 429) ;set number to main menu media id in editor
                DialogOutPut(Player, ChatBox, "Enter an amount that you would like to bet.", 230, 145, 23)
                DialogOutPut(Player, ChatBox, "You currently have " + Pmoney + " Cash on hand", 230, 145, 23)
                GambleAmount% = Input(Player, "How much to bet?", "Total", 2) ;get player to add amount to bet

                      If (GambleAmount > PMoney) ;if player don`t have enough money for bet end script.
                         DialogOutPut(Player, ChatBox, "You do not have enough money for this bet.", 230, 145, 23)
                         DialogOutPut(Player, ChatBox, "Dont waste my time!!", 255, 255, 255)
                         DOEvents(2300)
                         CloseDialog(Player, ChatBox)
                         Return
                       EndIf

                 DialogOutPut(Player, ChatBox, "You have bet " + GambleAmount, 230, 145, 23)
                 BetChoice% = DialogInPut(Player, ChatBox, "Bet Heads,Bet Tails")
                    ;1 = heads  2 = tails
                    If (BetChoice = 1) ;player bet heads
                        BetPicked% = 1
                    ElseIf (BetChoice = 2) ;Player, bet tails
                         BetPicked% = 2
                    EndIf

                    ;---------------------------------------------
                    ;do coin flip animation
                    ;---------------------------------------------
                    Ticks% = Rand(5, 8) ;Set to amount that coin should flip
                    ; Note the coin side that is landed on will be the winning side.
                    Flip% = Rand(1, 2) ;set coin side to a random side to start on. 1 = Heads 2 = Tails

                    Repeat

                       Ticks% = Ticks - 1

                        If (Flip = 1)
                            CloseDialog(Player, Chatbox)
                            ChatBox = OpenDialog(Player, Target, "25 Cent Toss", 430)   ;set number to Heads media id in editor
                            DialogOutPut(Player, ChatBox, "Please Wait - - - Coin Fliping", 130, 246, 23)
                            Flip% = 2 ;set flip back to 2 so it will show tails next.
                            If (Ticks <= 0) ;if repeat is ending then set coin to last side it was.
                                Flip% = 1
                            EndIf
                            DoEvents(500)
                         ElseIf (Flip = 2)
                            CloseDialog(Player, ChatBox)
                            ChatBox = OpenDialog(Player, Target, "25 Cent Toss", 431)   ;set number to tails media id in editor
                            DialogOutPut(Player, ChatBox, "Please Wait - - - Coin Fliping", 130, 246, 23)
                            Flip% = 1 ;set flip back to 1 to show heads next.
                            If (Ticks <= 0) ;if repeat is ending then set coin to last side it was.
                                Flip% = 2
                            EndIf
                           DoEvents(500)
                         EndIf

                        DoEvents(500)

                    Until(Ticks = 0)

                    ;--------------------------------------------
                    ;End coin flip animation
                    ;---------------------------------------------

                        PMoney% = Money(Player) ;Player total money
                        GambleFlip% =  Flip ;heads = 1 tails = 2
                        JackPot% = GambleAmount * 3 ;jackpot to win amount player added * 3
                        ;OutPut(Player, "Total jackpot amount is " + JackPot, 245, 214, 43) ;Debug
                        ;Check if player won
                        If (GambleFlip = 1) ;fliped heads
                            If (BetPicked = 1) ;if player picked 1
                              CloseDialog(Player, ChatBox)
                              DoEvents(500)
                              ChatBox = OpenDialog(Player, Target, "25 Cent Toss", 430)      ;set number to Heads media id in editor

                                If (BetPicked = 1) ;tell player if they picked heads or tails.
                                DialogOutPut(Player, ChatBox, "You picked Heads.", 230, 145, 23)
                                ElseIf (BetPicked = 2)
                                DialogOutPut(Player, ChatBox, "You picked Tails.", 230, 145, 23)
                                EndIf
                              DoEvents(1000)
                              DialogOutPut(Player, ChatBox, "Great Job you have won the Jackpot.", 230, 245, 23)
                              DialogOutPut(Player, ChatBox, "You win a total of " + JackPot + " this round", 230, 245, 23)
                              Winbet% = PMoney + JackPot
                              SetMoney(Player, Winbet)
                              DialogInput(Player, ChatBox, "Close")
                              CloseDialog(Player, Chatbox)
                              Return
                            Else ;player picked 2
                                CloseDialog(Player, ChatBox)
                                DoEvents(500)
                                ChatBox = OpenDialog(Player, Target, "25 Cent Toss", 430) ;set number to Heads media id in editor

                                If (BetPicked = 1) ;tell player if they picked heads or tails.
                                    DialogOutPut(Player, ChatBox, "You picked Heads.", 230, 145, 23)
                                ElseIf (BetPicked = 2)
                                    DialogOutPut(Player, ChatBox, "You picked Tails.", 230, 145, 23)
                                EndIf

                                DoEvents(1000)
                                DialogOutPut(Player, ChatBox, "Dam to bad you lost that one.", 230, 245, 23)
                                Losebet% = Pmoney - GambleAmount ;amount player will pay
                                SetMoney(Player, Losebet) ; take bet money from player.
                                DialogOutPut(Player, ChatBox, "You have lost " + GambleAmount, 230, 245, 23)
                                DialogInput(Player, ChatBox, "Close")
                                DoEvents(500)
                                CloseDialog(Player, ChatBox)
                                Return
                            EndIf

                        ElseIf (GambleFlip = 2) ;fliped tails
                             If (BetPicked = 2) ;if player picked 2
                              CloseDialog(Player, ChatBox)
                              DoEvents(500)
                              ChatBox = OpenDialog(Player, Target, "25 Cent Toss", 431) ;set number to tails media id in editor

                                If (BetPicked = 1) ;tell player if they picked heads or tails.
                                    DialogOutPut(Player, ChatBox, "You picked Heads.", 230, 145, 23)
                                ElseIf (BetPicked = 2)
                                    DialogOutPut(Player, ChatBox, "You picked Tails.", 230, 145, 23)
                                EndIf
                                DoEvents(1000)
                              DialogOutPut(Player, ChatBox, "Great Job you have won the Jackpot.", 230, 245, 23)
                              DialogOutPut(Player, ChatBox, "You win a total of " + JackPot + " this round", 230, 245, 23)
                              Winbet% = PMoney + JackPot
                              SetMoney(Player, Winbet)
                              DialogInput(Player, ChatBox, "Close")
                              CloseDialog(Player, Chatbox)
                              Return
                            Else ;player picked 1

                                CloseDialog(Player, ChatBox)
                                DoEvents(500)
                                ChatBox = OpenDialog(Player, Target, "25 Cent Toss", 431) ;set number to tails media id in editor

                                If (BetPicked = 1) ;tell player if they picked heads or tails.
                                    DialogOutPut(Player, ChatBox, "You picked Heads.", 230, 145, 23)
                                ElseIf (BetPicked = 2)
                                    DialogOutPut(Player, ChatBox, "You picked Tails.", 230, 145, 23)
                                EndIf
                                    DoEvents(1000)
                                DialogOutPut(Player, ChatBox, "Dam to bad you lost that one.", 230, 245, 23)
                                Losebet% = Pmoney - GambleAmount ;amount player will pay
                                SetMoney(Player, Losebet) ; take bet money from player.
                                DialogOutPut(Player, ChatBox, "You have lost " + GambleAmount, 230, 245, 23)
                                DialogInput(Player, ChatBox, "Close")
                                DoEvents(500)
                                CloseDialog(Player, ChatBox)
                                Return
                            EndIf

                        EndIf

            ElseIf (TossHelp = 2) ; Explain how to play and what to do.
            CloseDialog(Player, ChatBox)
            ChatBox = OpenDialog(Player, Target, "25 Cent Toss", 429) ;set number to main menu media id in editor
            DialogOutPut(Player, ChatBox, "Well its simple, put in an amount you would like to bet. Then you pick Heads or Tails if your choice is picked you win.", 230, 145, 23)
            DialogInput(Player, ChatBox, " I think I got it.")
            CloseDialog(Player, ChatBox)
            Return
            Elseif (TossHelp = 3) ; Answer is legal question
            CloseDialog(Player, ChatBox)
            ChatBox = OpenDialog(Player, Target, "25 Cent Toss", 429) ;set number to main menu media id in editor
            DialogOutPut(Player, ChatBox, "Well between us, sure it is.", 230, 145, 23)
            DialogInPut(Player, ChatBox, "Thats what i was thinking.")
            CloseDialog(Player, ChatBox)
            Return

            Elseif (TossHelp = 4) ;End script
            DialogOutPut(Player, ChatBox, "Come Back anytime.", 230, 145, 23)
            DoEvents(1500)
            CloseDialog(Player, ChatBox)
            Return
            EndIf

```

```
End Function

```