WiseRock Posted March 28, 2013 Author Share Posted March 28, 2013 Ever wanted this in your Game to Block away the damn ducking Bots?>! ![](http://i47.tinypic.com/1zohgdi.png)Here's Your Chance This is a Fairly Small Tut so here we go1.First go and create a new mod called modCaptchaAdd this in the new mod```Option ExplicitPrivate Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal H As Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, ByVal W As Long, ByVal i As Long, ByVal u As Long, ByVal S As Long, ByVal C As Long, ByVal OP As Long, ByVal CP As Long, ByVal Q As Long, ByVal PAF As Long, ByVal F As String) As LongPrivate Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As LongPrivate Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongPrivate Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As LongPrivate Const LOGPIXELSY = 90 ' Logical pixels/inch in YPublic Sub MakeCaptchaImage(ByVal pic As PictureBox, ByVal txt As String, ByVal min_size As Integer, ByVal max_size As Integer)Dim wid As SingleDim hgt As SingleDim ch_wid As SingleDim i As IntegerDim font_size As SingleDim ch As StringDim X As SingleDim Y As SingleDim prev_angle As SingleDim angle As SingleDim x1 As SingleDim y1 As SingleDim x2 As SingleDim y2 As Single' See how much room is available for each character.wid = pic.ScaleWidthhgt = pic.ScaleHeightch_wid = wid / Len(txt)' Draw each character.prev_angle = 0pic.ClsRandomizeFor i = 1 To Len(txt)' Get the character and font size.ch = Mid$(txt, i, 1)font_size = min_size + Rnd * (max_size - min_size)' Get the position.X = (i - 0.75 + Rnd * 0.5) * ch_widY = hgt / 2 + Rnd * (hgt - pic.ScaleY(font_size, vbPoints, vbTwips))' Get the angle.angle = prev_angleDo While Abs(angle - prev_angle) < 10angle = -20 + Rnd * (20 - -20)Loopprev_angle = angle' Draw the next character.DrawCenteredRotatedText frmMenu.picCaptcha, ch, X, Y, angle, font_sizeNext i' Mess things up a bit.For i = 1 To 10x1 = Rnd * widy1 = Rnd * hgtx2 = Rnd * widy2 = Rnd * hgtpic.Line (x1, y1)-(x2, y2)Next iFor i = 1 To 10x1 = Rnd * widy1 = Rnd * hgtx2 = Rnd * widy2 = Rnd * hgtpic.Line (x1, y1)-(x2, y2), vbWhiteNext iEnd SubPrivate Sub DrawCenteredRotatedText(ByVal pic As PictureBox, ByVal txt As String, ByVal X As Single, ByVal Y As Single, ByVal angle As Single, ByVal font_points As Integer)Const CLIP_LH_ANGLES As Long = 16 ' Needed for tilted fonts.Const PI As Single = 3.14159265Dim font_units As SingleDim escapement As LongDim oldfont As LongDim newfont As LongDim wid As SingleDim hgt As SingleDim wx As SingleDim wy As SingleDim hx As SingleDim hy As SingleDim theta As SingleDim ox As SingleDim oy As Singlefont_units = font_points * GetDeviceCaps(pic.hdc, LOGPIXELSY) / 72escapement = CLng(angle * 10)newfont = CreateFont(CLng(font_units), 0, escapement, escapement, 700, _False, False, False, 0, 0, CLIP_LH_ANGLES, 0, 0, "Times New Roman")' Select the new font.oldfont = SelectObject(pic.hdc, newfont)' Get the text width.wid = pic.TextWidth(txt)' Convert the font height in points into twips.hgt = pic.ScaleY(font_points, vbPoints, vbTwips)theta = -angle * PI / 180 ' Negate because y increases downward.wx = wid * Cos(theta) / 2wy = wid * Sin(theta) / 2hx = -hgt * Sin(theta) / 2hy = hgt * Cos(theta) / 2' Find the rotated origin.ox = X - wx - hxoy = Y - wy - hy' Display the text.pic.CurrentX = oxpic.CurrentY = oypic.Print txt' Restore the original font.newfont = SelectObject(pic.hdc, oldfont)' Free font resources (important!)DeleteObject newfont' Draw the center point.' pic.Circle (X, Y), 30, vbRed' Draw the rotated bounding box.' pic.CurrentX = X - wx - hx' pic.CurrentY = Y - wy - hy' pic.Line -(X + wx - hx, Y + wy - hy), vbBlue' pic.Line -(X + wx + hx, Y + wy + hy), vbBlue' pic.Line -(X - wx + hx, Y - wy + hy), vbBlue' pic.Line -(X - wx - hx, Y - wy - hy), vbBlueEnd Sub[size][/size][size]Then next go to [color]modGeneral [/color]in the [color]Sub Main[/color] after[/size][size][/size][code]EngineInitFontSettings[/code]Insert[code]Call MakeCaptchaImage(frmMenu.picCaptcha, "My Text", 30, 35)[/code][color]TIP: REPLACE MY TEXT WITH YOUR OWN COSTUM TEXT [/color] [img]http://www.touchofdeathforums.com/community/public/style_emoticons/default/smile.png[/img]Next Go to frmMenu[img]http://i50.tinypic.com/bgtpu0.png[/img]Hit F7 to Reveal CodeAdd[code]Private Sub picCaptcha_Click()Call MakeCaptchaImage(picCaptcha, "AMETHYST13", 30, 35)End Sub[size][/size][size]to the Bottom of the mod[/size][size]Next goto[/size][size][/size][code]If isLoginLegal(Name, Password) ThenIf Password <> PasswordAgain ThenCall MsgBox("Passwords don't match.")Exit SubEnd If[/code][size]add this after the end if[/size][size][/size][code]If Code <> "MY TEXT" ThenCall MsgBox("Captcha Incorrect!")Call MakeCaptchaImage(frmMenu.picCaptcha, "MY TEXT[size]", 30, 35)Exit SubEnd If[/size][size][size]Now go to Form Load then[/size][size]add this before the End Sub[/size][size][/size][code]picCaptcha.AutoRedraw = True[/code][size]Now You Should have a cool looking Captcha[/size]I did not make this. I really don't who made I found this in 2009 on some fourms.[/size][/code][/code]``` Link to comment Share on other sites More sharing options...
abhi2011 Posted March 28, 2013 Share Posted March 28, 2013 ```If Code <> "MY TEXT" Then Call MsgBox("Captcha Incorrect!") Call MakeCaptchaImage(frmMenu.picCaptcha, "MY TEXT", 30, 35) Exit Sub End If```I fixed the sub. And you should give credits to the person who made the sub that creates the actual captcha. And use a RandomString function to make a random string. (Randomness of captcha is what makes it special) Link to comment Share on other sites More sharing options...
DMF Posted March 28, 2013 Share Posted March 28, 2013 intresting hope this works for those dat want it. Link to comment Share on other sites More sharing options...
tslusny Posted March 28, 2013 Share Posted March 28, 2013 RandomString function:```Public Function RandomString( _ByVal length As Long, _Optional charset As String = "abcdefghijklmnopqrstuvwxyz0123456789" _) As StringDim chars() As Byte, value() As Byte, chrUprBnd As Long, i As LongIf length > 0& ThenRandomizechars = charsetchrUprBnd = Len(charset) - 1&length = (length * 2&) - 1&ReDim value(length) As ByteFor i = 0& To length Step 2&value(i) = chars(CLng(chrUprBnd * Rnd) * 2&)NextEnd IfRandomString = valueEnd Function``` Link to comment Share on other sites More sharing options...
cheatking Posted March 28, 2013 Share Posted March 28, 2013 Wait, people get bots in their games? Link to comment Share on other sites More sharing options...
tslusny Posted March 28, 2013 Share Posted March 28, 2013 > Wait, people get bots in their games?I had bots probably in my game. Link to comment Share on other sites More sharing options...
WiseRock Posted March 29, 2013 Author Share Posted March 29, 2013 > RandomString function:> > ```> > Public Function RandomString( _> > ByVal length As Long, _> > Optional charset As String = "abcdefghijklmnopqrstuvwxyz0123456789" _> > ) As String> > Dim chars() As Byte, value() As Byte, chrUprBnd As Long, i As Long> > If length > 0& Then> > Randomize> > chars = charset> > chrUprBnd = Len(charset) - 1&> > length = (length * 2&) - 1&> > ReDim value(length) As Byte> > For i = 0& To length Step 2&> > value(i) = chars(CLng(chrUprBnd * Rnd) * 2&)> > Next> > End If> > RandomString = value> > End Function> > ```I'll update the tutorial in a sec thanks Link to comment Share on other sites More sharing options...
DMF Posted March 29, 2013 Share Posted March 29, 2013 looking good ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) debuged yet? 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