Advertisement
CivReborn

For Brad

May 11th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance, Force
  2.  
  3.  
  4. /*
  5.  
  6.   Brad, I wrote this scirpt because I am under the impression that it is what you are looking for, if this is not what you
  7.   need let me know and i'll have a closer look
  8.  
  9.  
  10.  
  11.  
  12. */
  13.  
  14.  
  15. ;I assume that "admin", "bwsr", "crs" etc are litterial text
  16. ; if that is true, when you do a if statement that has () around what you are testing, the text needs to have quotes
  17. ; if(The_Info_Stored_In_My_Variable = "Litterial text")
  18.  
  19. ;I assume that when you have a if statement with () and the variables have %% around them, you don't mean that you are
  20. ; checking for the name of a variable stored in those variables. If that is the case it should be like this.
  21. ;if(Var1 = Var2)
  22.  
  23. ;Some things in AutoHotkey are not very straight forward, variables are one of them, and it will take time to know the ins and outs.
  24.  
  25.  
  26. ;Ok here is a dummy script that I think covers what you are trying to do. I am using my own values,
  27. ;so you would have to take how I do this and edit it for your own use
  28.  
  29.  
  30. ;List of vars used later:
  31.  
  32. Var1:= "Some random value 1"
  33. Var2:= "Some random value 2"
  34. Var3:= 1234 ;real numbers not text
  35. Var4:= 5678
  36.  
  37.  
  38.  
  39.  
  40. :C:Ryan::
  41.     i:= 0 ; This Variable will track how many times we have looped.
  42.     Loop 2
  43.         {
  44.             InputBox,User_Input,Getting User Input, Please enter your info
  45.             Sleep, 100
  46.             Msgbox, % User_Input
  47.             ;I don't know if you want case senstive or not. if you want case sensitive then in the if statement use == if not use =
  48.             ;because I don't know what you want, I am going with it not mattering how it is entered (Not case sensitive).
  49.             if(User_Input = "admin")
  50.                 {
  51.                     Output := "The output for this is 0001"  ;setting the output, can be w/e you want
  52.                     msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
  53.                     break ;because we found what we wanted we will exit the loop
  54.                 }
  55.             else if(User_Input = "bwsr")
  56.                 {
  57.                     Output := "The output for this is 0002" ;setting the output, can be w/e you want
  58.                     msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
  59.                     break ;because we found what we wanted we will exit the loop
  60.                 }
  61.             else if(User_Input = "crs")
  62.                 {
  63.                     Output := "The output for this is 0003" ;setting the output, can be w/e you want
  64.                     msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
  65.                     break ;because we found what we wanted we will exit the loop
  66.                 }
  67.                
  68.                
  69.             ;This next part will show how to compare the user input to the value of variables. I have placed the vars near the top of the script
  70.            
  71.            
  72.             else if(User_Input = Var1)
  73.                 {
  74.                     Output := "The output for this is 0004" ;setting the output, can be w/e you want
  75.                     msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
  76.                     break ;because we found what we wanted we will exit the loop
  77.                 }
  78.             else if(User_Input = Var2)
  79.                 {
  80.                     Output := "The output for this is 0005" ;setting the output, can be w/e you want
  81.                     msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
  82.                     break ;because we found what we wanted we will exit the loop
  83.                 }
  84.             else if(User_Input = Var3)
  85.                 {
  86.                     Output := "The output for this is 0006" ;setting the output, can be w/e you want
  87.                     msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
  88.                     break ;because we found what we wanted we will exit the loop
  89.                 }
  90.             else if(User_Input = Var4)
  91.                 {
  92.                     Output := "The output for this is 0007" ;setting the output, can be w/e you want
  93.                     msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
  94.                     break ;because we found what we wanted we will exit the loop
  95.                 }  
  96.                
  97.             ; Now that we are done all the tests, if the loop has not been broken by now we will pop up a message saying to retry.
  98.             ; I have set the loop to go twice, if after the second try we will show another message saying that they need to relaunch this to try again.
  99.            
  100.             ;The way I will set this up is by making a variable the has one added to it each time it goes through this, and depending on the value of that
  101.             ; variable, it will show the message that goes along with what is happening.
  102.            
  103.             i++  ;Adding 1 to the value of "i"
  104.             if(i=1)
  105.                 {
  106.                     msgbox, Your input didn't match what we were looking for.`nYou will now be brought back to the beginning to try again.
  107.                 }
  108.             else if(i = 2)
  109.                 {
  110.                     msgbox, Your input didn't match twice now.`nPlease contact so and so, or run the script again.`n`nThis part of the script will now exit.
  111.                 }
  112.         }
  113.  
  114.     MsgBox, we are now outside that part of the script. `n`nYou can do w/e you need to from here.
  115.  
  116.     return
  117.  
  118.  
  119.  
  120.  
  121. esc::ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement