Cliff hanger Visual Basic tutorial.
This tutorial is using a wrapper that I have made using Winsock API. You will need to convert the wrapper calls to the particular wrapper you are using.
Onward with the tutorial

.
We have a couple things to think about when we design this program. First and foremost we need a list of all the answers. This is easy enough with a Google search.
Second we need to know how we are going to determine what the solution is.
Since this is the heart of the trainer I will go over it first.
What you need to try and visualize is how is each puzzle unique?
We could do a len test and compare it against a list of answers.
Unforutanetly this will not work, since a couple puzzles have the same length.
We could start guessing letters and base our solution on that.
Too time consuming.
We could check the position of the “spaces†between the words and check that against a list.
This may work lets test it.
Open a new VB project.
On our form lets add two list boxes and a button.
In the first list box we want to load our list of cliffhanger answers that we found on Google, so lets add the following code to do that for us.
Code:
Public Function LoadListFromFile(ByRef SourceFile As String, _
ByRef ToFormList As ListBox)
On Error GoTo ErrEvt
Dim TextLine As String, FN As Integer
ToFormList.Clear
FN = FreeFile
Open SourceFile For Input As #FN ' Open file.
Do While Not EOF(FN)
Line Input #FN, TextLine
If TextLine <> LineToRem Then
ToFormList.AddItem (TextLine)
End If
Loop
Close #FN ' Close file.
Exit Function
ErrEvt:
Select Case Err.Number
Case 51
Err.Clear
Case
End Select
Resume Next
End Function This function will load a text file to a list box. It is not my code it but is freely available on the web.
Name your text file with the cliffhanger answers the following “cliffhanger.txt†and put the following code in the form load of our project.
CODE
Call LoadListFromFile("cliffhanger.txt", List1)
We now have our answer list loaded.
We now have to figure out what to do about the spaces, and how we are going to compare them.
I thought that if we got each space position and added them together to get a collective number string, that this may accomplish our goal. So I built a function to go through a string and at every space get the position then record it.
For an example in the following “Test test test†There is a space at position 5, 10, and 15.
My function would need to go through this string, get the position of the space and return the space positions combined as one string of numbers. So the above would give me the following result 51015. Pretty unique wouldn’t you agree?
So here is my code for that function.
Code:
Public Function CheckForSpaces(source As String) As String
Dim tmpSrc
Dim x As Integer
Dim z As String
Dim srcCode As String
tmpSrc = source
source = ""
For x = 1 To Len(tmpSrc)
z = Right(Left(tmpSrc, x), 1)
If z = " " Then
srcCode = srcCode & x
End If
Next
CheckForSpaces = srcCode
End Function I explained what the function does above. To break it down a little more is its going through every character in the string. If it sees a space it marks the position using the x as a count then adds it to the end of a string. This whole process will leave us with hopefully a unique identifier for each answer. Now lets build list two by putting all the lines from list1 through this function and see if in fact they are all unique.
Lets add the following code below our previous code in the form load sub.
Code:
For x = 0 To List1.ListCount - 1
List2.AddItem (CheckForSpaces(List1.List(x)))
Next Now save our project. Making sure the txt file is in the same directory, and run the project.
If you go down through the list you will see that every single answer gives us a different identifier !!! We now have a way to solve every single puzzle correctly.
Now all we need to do is find the puzzle string on the page and get an identifier from it and then compare it against our list.
So what I like to do is go to the page I need.
Note:I also like to open ether detect as I am doing this to see what get and post commands are being sent.
Once at the page I like to view the source, copy it and open it in dreamweaver in split view. The reason being is that I can hi-lite the very first blank and figure out my getbetween statement a lot easier and quicker.
Doing this I find out what steps I need to go thru in order to get to the game page and what my getbetween is. So lets add two textboxes name one strhtml and leave the other text1. Add the following code to the project.
Code:
strhtml = wrapper.NGet("games/play.phtml?game_id=29")
strhtml = wrapper.NGet("games/cliffhanger/index.phtml")
strhtml = wrapper.NPost("games/cliffhanger/process_cliffhanger.phtml", "start_game=true&game_skill=" & diff)
strhtml = wrapper.NGet("games/cliffhanger/cliffhanger.phtml")
Text1.Text = wrapper.GetBetween(strhtml, "colspan=" & ChrW(34) & "2" & ChrW(34) & "><br><b", "</b><br><br>")
If Text1.Text = "" Then Text1.Text = wrapper.GetBetween(strhtml, "colspan=" & ChrW(34) & "2" & ChrW(34) & "><br><b", " <br><br>") What this code is doing is going to the game page and returning our puzzle string. You will notice the if text1.text = Ҡas the last line of code. I found out through testing that there are two different options for this page, so I had to add the check for it.
Now you need to add a login I will assume you know how to do that and you should do it now.
Once you have your login run the project again. You will get something like the following for text1.†<b>_<b>   <b>_<b><b>_<b><b>_<b> â€ etc…
Alright now the _ are the blanks in the game of course and the nbsp and every br is a space(the br’s are actually returns but if our puzzle was all on one line it would be a space).
Now we need to convert this all to a unique number and compare the number we get with the list of answers. To convert this we need to build another function to convert it into something more usable for my checkspaces function.
Every space starts with an n or a br so I will build a function to run through the string and make every “_†a blank line and every “nâ€, and “r†a space and eliminate every thing else. This will give us the exact structure for our puzzle, then we can run this through our previous function and compare it with our list2.
Here is my function.
Code:
Public Function FormatPuzzle(source As String) As String
Dim tmpSrc
Dim x As Integer
Dim z As String
Dim srcCode As String
tmpSrc = source
source = ""
For x = 1 To Len(tmpSrc)
z = Right(Left(tmpSrc, x), 1)
If z = "_" Then
srcCode = srcCode & z
ElseIf z = "n" Then
srcCode = srcCode & " "
ElseIf z = "r" Then
srcCode = srcCode & " "
End If
Next
FormatPuzzle = srcCode
End Function There you go now we can work with the string we receive with the getbetween function.
Lets make a text box on our form and add the following code after our getbetween call in the button code.
Code:
Text2.Text = FormatPuzzle(Text1)
Text2 = CheckForSpaces(Text2)
Press run. Now we should have a unique number to use to check against our answer list.
So let’s check it against our list with the following code. Add another text box to our form and the following code. Our answer to the puzzle will appear in this box.
Code:
For x = 0 To List2.ListCount - 1
If text2 = List2.List(x) Then
Text3.Text = List1.List(x)
End If
Next Now we need to find out the post command for submitting an answer, so using what we have already built, with a browser go to the game and post the answer we have. Ether detect, if your using it, captures this pretty easily and displays that the answer is displayed with a plus in between each word. I already made a function for this when I made a message board spammer so all you need to do is add the following function and run your answer thru it.
Code:
Public Function AddPlus(source As String) As String
Dim tmpSrc
Dim x As Integer
Dim z As String
Dim srcCode As String
tmpSrc = source
source = ""
For x = 1 To Len(tmpSrc)
z = Right(Left(tmpSrc, x), 1)
If z = " " Then
srcCode = srcCode & "+"
Else: srcCode = srcCode & z
End If
Next
AddPlus = srcCode
End Function All you need to do now is build the code to post the answer and wash rinse and repeat.
Comments welcome.
BTW if someone sees this and thinks I ripped it trust me I have not I am nitemares66.