gottygolly Posted March 3, 2014 Share Posted March 3, 2014 I'm working on a big project ( a game but bare with me. ) I started to look through the help file trying to find something to help me with my other script but I didn't find anything then I looked through the example scripts and found one named "dice.au3" I opened it and was amazed at how accurate it works so I tried to make my own. I managed to make one but now i'm turning it into a gambling game (With fake money inside the acutal game...). The problem I am having is happening between the lines 143-202. It keeps saying the variabl $show is not found and I know why it's not happening so I tried to add it to the global at the top of the script but that didn't work. Originally I had the whole bottom part (The gui) on top of all the if/then statements but then the "Congratulations" wasnt working properly. Heres the scripts. expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> Global $bankbalk,$radiod2,$dicegui,$betgui, $guid2, $guid4, $guid6, $guid8, $guid10, $guid12, $guid14, $guid16, $guid18, $guid20, $2b1, $2b2, $2input, $4b1, $4b2, $4b3, $4b4, $4input45, $gz, $result $gui1 = GUICreate("",300,240) $bankbal = "$100" $bank = GUICtrlCreateLabel("Bank: "&$bankbal,0,0) $bet20 = GUICtrlCreateButton("Bet $20",200,0,100,30) $bet50 = GUICtrlCreateButton("Bet $50",200,30,100,30) $bet100 = GUICtrlCreateButton("Bet $100",200,60,100,30) $bet150 = GUICtrlCreateButton("Bet $150",200,90,100,30) $bet200 = GUICtrlCreateButton("Bet $200",200,120,100,30) $bet250 = GUICtrlCreateButton("Bet $250",200,150,100,30) $bet500 = GUICtrlCreateButton("Bet $500",200,180,100,30) $betany = GUICtrlCreateButton("Make your own bet",200,210,100,30) $group = GUICtrlCreateGroup("Select A Dice",30,50,143,120) $radiod2 = GUICtrlCreateRadio("2 Sided",35,65) $radiod4 = GUICtrlCreateRadio("4 Sided",105,65) $radiod6 = GUICtrlCreateRadio("6 Sided",35,85) $radiod8 = GUICtrlCreateRadio("8 Sided",105,85) $radiod10 = GUICtrlCreateRadio("10 Sided",35,105) $radiod12 = GUICtrlCreateRadio("12 Sided",105,105) $radiod14 = GUICtrlCreateRadio("14 Sided",35,125) $radiod16 = GUICtrlCreateRadio("16 Sided",105,125) $radiod18 = GUICtrlCreateRadio("18 Sided",35,145) $radiod20 = GUICtrlCreateRadio("20 Sided",105,145) $gz = GUICtrlCreateLabel("",0,50) ;$radiobox = GUICtrlCreateCombo("Dice",0,100,100,100) ;$combo = GUICtrlSetData($radiobox,"2 Sided|4 Sided|6 Sided|8 Sided|10 Sided|12 sided|14 Sided|16 Sided|18 Sided|20 Sided") GUISetState() while 1 $msg = GUIGetMsg(1) Switch $msg[1] Case $gui1 Switch $msg[0] Case -3 Exit Case $bet20 $20 = MsgBox(4,"Betting $20","Are you sure that you want to bet $20?") If $20 = 6 Then Call(betting()) EndIf Case $bet50 $20 = MsgBox(4,"Betting $50","Are you sure that you want to bet $50?") If $20 = 6 Then Call(betting()) EndIf Case $bet100 $20 = MsgBox(4,"Betting $100","Are you sure that you want to bet $100?") If $20 = 6 Then Call(betting()) EndIf Case $bet150 $20 = MsgBox(4,"Betting $150","Are you sure that you want to bet $150?") If $20 = 6 Then Call(betting()) EndIf Case $bet200 $20 = MsgBox(4,"Betting $200","Are you sure that you want to bet $200?") If $20 = 6 Then Call(betting()) EndIf Case $bet250 $20 = MsgBox(4,"Betting $250","Are you sure that you want to bet $250?") If $20 = 6 Then Call(betting()) EndIf Case $bet500 $20 = MsgBox(4,"Betting $500","Are you sure that you want to bet $500?") If $20 = 6 Then Call(betting()) EndIf EndSwitch Case $dicegui Switch $msg[0] Case -3 GUIDelete($dicegui) EndSwitch Case $betgui Switch $msg[0] Case -3 GUIDelete($betgui) EndSwitch Case $guid2 Switch $msg[0] Case -3 GUIDelete($guid2) Case $2b1 $2b1t = ("1") Call(bet()) EndSwitch Case $guid4 Switch $msg[0] Case -3 GUIDelete($guid4) EndSwitch Case $guid6 Switch $msg[0] Case -3 GUIDelete($guid6) EndSwitch Case $guid8 Switch $msg[0] Case -3 GUIDelete($guid8) EndSwitch Case $guid10 Switch $msg[0] Case -3 GUIDelete($guid10) EndSwitch Case $guid12 Switch $msg[0] Case -3 GUIDelete($guid12) EndSwitch Case $guid14 Switch $msg[0] Case -3 GUIDelete($guid14) EndSwitch Case $guid16 Switch $msg[0] Case -3 GUIDelete($guid16) EndSwitch Case $guid18 Switch $msg[0] Case -3 GUIDelete($guid18) EndSwitch Case $guid20 Switch $msg[0] Case -3 GUIDelete($guid20) EndSwitch EndSwitch WEnd Func bet() ;If $result = ;MsgBox(4096,"","hi") If GUICtrlRead($radiod2) = 1 Then $result = Random(1,2,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod4) = 1 Then $result = Random(1,4,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod6) = 1 Then $result = Random(1,6,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod8) = 1 Then $result = Random(1,8,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod10) = 1 Then $result = Random(1,10,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod12) = 1 Then $result = Random(1,12,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod14) = 1 Then $result = Random(1,14,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod16) = 1 Then $result = Random(1,16,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod18) = 1 Then $result = Random(1,18,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod20) = 1 Then $result = Random(1,20,1) GUICtrlSetData($show,$result) EndIf $dicegui = GUICreate("",200,100) GUISetFont(16,700,2,"Minion Pro") $rolling = GUICtrlCreateLabel("Rolling...",10,0) GUISetState() Sleep(2000) GUISetFont(16,700,2,"Minion Pro") $showroll = GUICtrlCreateLabel("You have rolled a:",10,0) $show = GUICtrlCreateLabel("",170,0,25,30) If $2b1t = "1" Then If $result = "1" Then GUICtrlCreateLabel("Congratulations, You won!",0,50,200,50) EndIf EndIf GUICtrlSetColor($show,0xB43D01) EndFunc Func betting() If GUICtrlRead($radiod2) = 1 Then radiod2() EndIf If GUICtrlRead($radiod4) = 1 Then radiod4() EndIf If GUICtrlRead($radiod6) = 1 Then radiod6() EndIf If GUICtrlRead($radiod8) = 1 Then radiod8() EndIf If GUICtrlRead($radiod10) = 1 Then radiod10() EndIf If GUICtrlRead($radiod12) = 1 Then radiod12() EndIf If GUICtrlRead($radiod14) = 1 Then radiod14() EndIf If GUICtrlRead($radiod16) = 1 Then radiod16() EndIf If GUICtrlRead($radiod18) = 1 Then radiod18() EndIf If GUICtrlRead($radiod20) = 1 Then radiod20() EndIf EndFunc Func radiod2() $guid2 = GUICreate("",200,300) $2b1 = GUICtrlCreateButton("1",0,0,100,30) $2b2 = GUICtrlCreateButton("2",0,30,100,30) GUISetState() EndFunc Func radiod4() $guid4 = GUICreate("",200,300) $4b1 = GUICtrlCreateButton("1",0,0,100,30) $4b2 = GUICtrlCreateButton("2",0,30,100,30) $4b3 = GUICtrlCreateButton("3",0,60,100,30) $4b4 = GUICtrlCreateButton("4",0,90,100,30) GUISetState() EndFunc Func radiod6() $guid6 = GUICreate("",200,300) $6b1 = GUICtrlCreateButton("1",0,0,100,30) $6b2 = GUICtrlCreateButton("2",0,30,100,30) $6b3 = GUICtrlCreateButton("3",0,60,100,30) $6b4 = GUICtrlCreateButton("4",0,90,100,30) $6b5 = GUICtrlCreateButton("5",0,120,100,30) $6b6 = GUICtrlCreateButton("6",0,150,100,30) GUISetState() EndFunc Func radiod8() $guid8 = GUICreate("",200,300) $8b1 = GUICtrlCreateButton("1",0,0,100,30) $8b2 = GUICtrlCreateButton("2",0,30,100,30) $8b3 = GUICtrlCreateButton("3",0,60,100,30) $8b4 = GUICtrlCreateButton("4",0,90,100,30) $8b5 = GUICtrlCreateButton("5",0,120,100,30) $8b6 = GUICtrlCreateButton("6",0,150,100,30) $8b7 = GUICtrlCreateButton("7",0,180,100,30) $8b8 = GUICtrlCreateButton("8",0,210,100,30) GUISetState() EndFunc Func radiod10() $guid10 = GUICreate("",200,300) $10b1 = GUICtrlCreateButton("1",0,0,100,30) $10b2 = GUICtrlCreateButton("2",0,30,100,30) $10b3 = GUICtrlCreateButton("3",0,60,100,30) $10b4 = GUICtrlCreateButton("4",0,90,100,30) $10b5 = GUICtrlCreateButton("5",0,120,100,30) $10b6 = GUICtrlCreateButton("6",0,150,100,30) $10b7 = GUICtrlCreateButton("7",0,180,100,30) $10b8 = GUICtrlCreateButton("8",0,210,100,30) $10b9 = GUICtrlCreateButton("9",0,240,100,30) $10b10 = GUICtrlCreateButton("10",0,270,100,30) GUISetState() EndFunc Func radiod12() $guid12 = GUICreate("",200,300) $12b1 = GUICtrlCreateButton("1",0,0,100,30) $12b2 = GUICtrlCreateButton("2",0,30,100,30) $12b3 = GUICtrlCreateButton("3",0,60,100,30) $12b4 = GUICtrlCreateButton("4",0,90,100,30) $12b5 = GUICtrlCreateButton("5",0,120,100,30) $12b6 = GUICtrlCreateButton("6",0,150,100,30) $12b7 = GUICtrlCreateButton("7",0,180,100,30) $12b8 = GUICtrlCreateButton("8",0,210,100,30) $12b9 = GUICtrlCreateButton("9",0,240,100,30) $12b10 = GUICtrlCreateButton("10",0,270,100,30) $12b11 = GUICtrlCreateButton("11",100,0,100,30) $12b12 = GUICtrlCreateButton("12",100,30,100,30) GUISetState() EndFunc Func radiod14() $guid14 = GUICreate("",200,300) $14b1 = GUICtrlCreateButton("1",0,0,100,30) $14b2 = GUICtrlCreateButton("2",0,30,100,30) $14b3 = GUICtrlCreateButton("3",0,60,100,30) $14b4 = GUICtrlCreateButton("4",0,90,100,30) $14b5 = GUICtrlCreateButton("5",0,120,100,30) $14b6 = GUICtrlCreateButton("6",0,150,100,30) $14b7 = GUICtrlCreateButton("7",0,180,100,30) $14b8 = GUICtrlCreateButton("8",0,210,100,30) $14b9 = GUICtrlCreateButton("9",0,240,100,30) $14b10 = GUICtrlCreateButton("10",0,270,100,30) $14b11 = GUICtrlCreateButton("11",100,0,100,30) $14b12 = GUICtrlCreateButton("12",100,30,100,30) $14b13 = GUICtrlCreateButton("13",100,60,100,30) $14b14 = GUICtrlCreateButton("14",100,90,100,30) GUISetState() EndFunc Func radiod16() $guid16 = GUICreate("",200,300) $16b1 = GUICtrlCreateButton("1",0,0,100,30) $16b2 = GUICtrlCreateButton("2",0,30,100,30) $16b3 = GUICtrlCreateButton("3",0,60,100,30) $16b4 = GUICtrlCreateButton("4",0,90,100,30) $16b5 = GUICtrlCreateButton("5",0,120,100,30) $16b6 = GUICtrlCreateButton("6",0,150,100,30) $16b7 = GUICtrlCreateButton("7",0,180,100,30) $16b8 = GUICtrlCreateButton("8",0,210,100,30) $16b9 = GUICtrlCreateButton("9",0,240,100,30) $16b10 = GUICtrlCreateButton("10",0,270,100,30) $16b11 = GUICtrlCreateButton("11",100,0,100,30) $16b12 = GUICtrlCreateButton("12",100,30,100,30) $16b13 = GUICtrlCreateButton("13",100,60,100,30) $16b14 = GUICtrlCreateButton("14",100,90,100,30) $16b15 = GUICtrlCreateButton("15",100,120,100,30) $16b16 = GUICtrlCreateButton("16",100,150,100,30) GUISetState() EndFunc Func radiod18() $guid18= GUICreate("",200,300) $18b1 = GUICtrlCreateButton("1",0,0,100,30) $18b2 = GUICtrlCreateButton("2",0,30,100,30) $18b3 = GUICtrlCreateButton("3",0,60,100,30) $18b4 = GUICtrlCreateButton("4",0,90,100,30) $18b5 = GUICtrlCreateButton("5",0,120,100,30) $18b6 = GUICtrlCreateButton("6",0,150,100,30) $18b7 = GUICtrlCreateButton("7",0,180,100,30) $18b8 = GUICtrlCreateButton("8",0,210,100,30) $18b9 = GUICtrlCreateButton("9",0,240,100,30) $18b10 = GUICtrlCreateButton("10",0,270,100,30) $18b11 = GUICtrlCreateButton("11",100,0,100,30) $18b12 = GUICtrlCreateButton("12",100,30,100,30) $18b13 = GUICtrlCreateButton("13",100,60,100,30) $18b14 = GUICtrlCreateButton("14",100,90,100,30) $18b15 = GUICtrlCreateButton("15",100,120,100,30) $18b16 = GUICtrlCreateButton("16",100,150,100,30) $18b17 = GUICtrlCreateButton("17",100,180,100,30) $18b18 = GUICtrlCreateButton("18",100,210,100,30) GUISetState() EndFunc Func radiod20() $guid20 = GUICreate("",200,300) $20b1 = GUICtrlCreateButton("1",0,0,100,30) $20b2 = GUICtrlCreateButton("2",0,30,100,30) $20b3 = GUICtrlCreateButton("3",0,60,100,30) $20b4 = GUICtrlCreateButton("4",0,90,100,30) $20b5 = GUICtrlCreateButton("5",0,120,100,30) $20b6 = GUICtrlCreateButton("6",0,150,100,30) $20b7 = GUICtrlCreateButton("7",0,180,100,30) $20b8 = GUICtrlCreateButton("8",0,210,100,30) $20b9 = GUICtrlCreateButton("9",0,240,100,30) $20b10 = GUICtrlCreateButton("10",0,270,100,30) $20b11 = GUICtrlCreateButton("11",100,0,100,30) $20b12 = GUICtrlCreateButton("12",100,30,100,30) $20b13 = GUICtrlCreateButton("13",100,60,100,30) $20b14 = GUICtrlCreateButton("14",100,90,100,30) $20b15 = GUICtrlCreateButton("15",100,120,100,30) $20b16 = GUICtrlCreateButton("16",100,150,100,30) $20b17 = GUICtrlCreateButton("17",100,180,100,30) $20b18 = GUICtrlCreateButton("18",100,210,100,30) $20b19 = GUICtrlCreateButton("19",100,240,100,30) $20b20 = GUICtrlCreateButton("20",100,270,100,30) GUISetState() EndFunc Any help would be great to have because i've spent like 2 hours so far trying to figure this one part out. Thanks in advance. Link to comment Share on other sites More sharing options...
Danyfirex Posted March 3, 2014 Share Posted March 3, 2014 what $show should do? Do You want fill $show with some value? Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
gottygolly Posted March 3, 2014 Author Share Posted March 3, 2014 (edited) $show already is assigned to something. $show = GUICtrlCreateLabel("",170,0,25,30) I want that to stay but is there any way to also get it above all the if then statements above the gui? Im on my phone right now so I cant give the clearist explanation. Ill post what I really need in a few minutes just try to understand what I said if you can. Sorry Edited March 3, 2014 by gottygolly Link to comment Share on other sites More sharing options...
Danyfirex Posted March 3, 2014 Share Posted March 3, 2014 mmm I see. the mistake is when you try to set data to the control. you've not created the control. try to Create first you control in the functions bet. something like this: expandcollapse popupFunc bet() $dicegui = GUICreate("",200,100) GUISetFont(16,700,2,"Minion Pro") $rolling = GUICtrlCreateLabel("Rolling...",10,0) GUISetState() Sleep(2000) GUISetFont(16,700,2,"Minion Pro") $showroll = GUICtrlCreateLabel("You have rolled a:",10,0) $show = GUICtrlCreateLabel("",170,0,25,30) If $2b1t = "1" Then If $result = "1" Then GUICtrlCreateLabel("Congratulations, You won!",0,50,200,50) EndIf EndIf GUICtrlSetColor($show,0xB43D01) ;If $result = ;MsgBox(4096,"","hi") If GUICtrlRead($radiod2) = 1 Then $result = Random(1,2,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod4) = 1 Then $result = Random(1,4,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod6) = 1 Then $result = Random(1,6,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod8) = 1 Then $result = Random(1,8,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod10) = 1 Then $result = Random(1,10,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod12) = 1 Then $result = Random(1,12,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod14) = 1 Then $result = Random(1,14,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod16) = 1 Then $result = Random(1,16,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod18) = 1 Then $result = Random(1,18,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod20) = 1 Then $result = Random(1,20,1) GUICtrlSetData($show,$result) EndIf EndFunc Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
gottygolly Posted March 3, 2014 Author Share Posted March 3, 2014 Thanks for the reply with very little information given to you. I copied and pasted what you put there and it works but it's being goofy. It says "You have rolled a 1" and wont say anything then if I get 1 again then it says "Congratulations". Sometimes it also says Congrats. when I roll a 2. I'll work on it but if anyone wishes to help me anymore I would not deny the info you give to me because every little bit helps . Link to comment Share on other sites More sharing options...
gottygolly Posted March 3, 2014 Author Share Posted March 3, 2014 Sorry for the double post but I just figured out a pattern with it. Not sure how to fix this so im just going to ask someone on here that is willing to help me. The code is set up at the moment to say "Congratulations, you won!" when you roll a 1, but it doesn't. As I said in the post before this one it was being goofy but I figured out a pattern with it. If you roll lets say a 2 the next roll won't say anything even if it is a 1 but if you roll a 1 the next roll will say "Congratulations" not matter what kind of roll it is. Can someone figure out why it's doing this because i'm clueless. Link to comment Share on other sites More sharing options...
gottygolly Posted March 4, 2014 Author Share Posted March 4, 2014 Sorry for triple posting here (I'm not trying to bump or anything I am really sorry I just don't know how to add this to anything else). I FINALLY FIGURED IT OUT Here's the dumb code that's been giving me a headache all day. expandcollapse popupFunc bet() $dicegui = GUICreate("",200,100) GUISetFont(16,700,2,"Minion Pro") $rolling = GUICtrlCreateLabel("Rolling...",10,0) GUISetState() Sleep(2000) GUISetFont(16,700,2,"Minion Pro") $showroll = GUICtrlCreateLabel("You have rolled a:",10,0) $show = GUICtrlCreateLabel("",170,0,25,30) GUICtrlSetColor($show,0xB43D01) ;If $result = ;MsgBox(4096,"","hi") If GUICtrlRead($radiod2) = 1 Then $result = Random(1,2,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod4) = 1 Then $result = Random(1,4,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod6) = 1 Then $result = Random(1,6,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod8) = 1 Then $result = Random(1,8,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod10) = 1 Then $result = Random(1,10,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod12) = 1 Then $result = Random(1,12,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod14) = 1 Then $result = Random(1,14,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod16) = 1 Then $result = Random(1,16,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod18) = 1 Then $result = Random(1,18,1) GUICtrlSetData($show,$result) EndIf If GUICtrlRead($radiod20) = 1 Then $result = Random(1,20,1) GUICtrlSetData($show,$result) EndIf ;From here. If $2b1t = "1" Then If $result = "1" Then GUICtrlCreateLabel("Congratulations, You won!",0,50,200,50) EndIf EndIf ;To here. EndFunc All I had to freaking do was put the code (inside the ";From here" to ";To here") below all the other if statements and it works perfect now. I just have to repeat this process like 50 more times and then add in a system to buy ranks to be able to do bigger bets and use bigger dice . Thanks again Danyfirex Danyfirex 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now