PHP Code:
Script("Name") = "HngMan"
Script("Author") = "IAreConnection"
Script("Major") = 1
Script
("Minor") = 0
Script
("Revision") = 0
Script
("Description") = "Hangman. Modified by oblivious to restart the game automatically and end by choice and added in a score system."



        
Public hngWordhngClueshngPartshngWrong

        
'-> How many "body parts" they can get before the man is complete.
        Const hngPartsToLose = 8

        '
-> Access required to start/resign (froma hangman game
        
Const hngAccess 40
        
'-> Access required to play
        Const hngPlay = 20
Sub Event_UserTalk(Username, Flags, Message, Ping)
            
            If Message = BotVars.Trigger & "hangman score" Then
                GetDBEntry Username, a, f
                If a < hngAccess Then Exit Sub
                     
                    If (GetSettingsEntry(Username) = vbNullString) Then WriteSettingsEntry Username, 0
                    f = GetSettingsEntry(Username): AddQ Username & " your score is: " & f
                Exit Sub
            End If
            If Message = BotVars.Trigger & "hangman" Then
                GetDBEntry Username, a, f
                If a < hngAccess Then Exit Sub
                If hngWord = "" Then
                        hngWord = LCase(Split(Split(SciNet.OpenUrl("" & _
                                "creativitytools/RandomWord/RandomWordPlus.aspx"), _
                                "<span id=""tmpl_main_lblWord"" class=""randomWord"">")(1), "<")(0))
                        hngClues = String(Len(hngWord), "_")
                        hngParts = 0
                        hngWrong = ""
                        AddChat vbCyan, hngWord
                        AddQ "Starting hangman... --> " & hngClues & " [" & Len(hngClues) & "]"
                Else
                        AddQ "Stopping hangman..."
                        hngWord = ""
                End If
        End If
        If Len(Message) = 1 Then
                GetDBEntry Username, a, f
                If a < hngPlay Then Exit Sub
                If hngWord = "" Then Exit Sub
                l = LCase(Message)
                a = False
                For i = 1 to Len(hngWord)
                        If Mid(hngWord, i, 1) = l Then
                                s=s & l
                                a=True
                        Else
                                s=s & Mid(hngClues, i, 1)
                        End If
                Next
                hngClues = s
                If Not a Then hngParts = hngParts + 1 : hngWrong = hngWrong & l & ", "
                If hngParts = hngPartsToLose Then
                        Command BotVars.Username, "/cq", True
                        AddQ "You couldn'
t guess itIt was """ & hngWord & """new word will be chosen."
                        hngWord = "" : NewGame : Exit Sub
                Else
                        If Len(hngWrong) > 2 Then w = Left(hngWrong, Len(hngWrong) - 2)
                        AddQ hngClues & " 
[" & hngParts & "/" & hngPartsToLose & "] [Guessed" & w & "]
                End If
        ElseIf LCase(Message) = hngWord Then
                AddQ Username & " 
got itOMFG!! Type """ & BotVars.Trigger & "hangman"" to stop the game."
                If (GetSettingsEntry(Username) = vbNullString) Then WriteSettingsEntry Username, 0
                WriteSettingsEntry Username, (GetSettingsEntry(Username) + 1)
                hngWord = ""
                NewGame
        End If
End Sub

Sub NewGame()
hngWord = LCase(Split(Split(SciNet.OpenUrl("" & _
                                "
creativitytools/RandomWord/RandomWordPlus.aspx"), _
                                "
<span id=""tmpl_main_lblWord"" class=""randomWord"">")(1), "<")(0))
                        hngClues = String(Len(hngWord), "
_")
                        hngParts = 0
                        hngWrong = ""
                        AddChat vbCyan, hngWord
                        AddQ "
Starting a new hangman... --> " & hngClues & " [" & Len(hngClues) & "]"
End Sub