Results 1 to 6 of 6

Thread: !num game

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Posts
    12
    Here is my code:
    If Left(Text, InStr(Text, " ")) = "!num " Then
    End If

    If Val(Mid(Text, InStr(Text, " "))) = 0 Then
    Exit Sub
    End If

    If Number = 0 Then
    Number = (Rnd(Time) * 50) + 1
    End If

    If Val(Mid(Text, InStr(Text, " "))) = Number Then
    BRBot.SendText Handle & " guessed the right number"
    Number = 0
    End If

    If Val(Mid(Text, InStr(Text, " "))) > Number Then
    BRBot.SendText "Lower than " & Val(Mid(Text, InStr(Text, " ")))
    End If

    If Val(Mid(Text, InStr(Text, " "))) < Number Then
    BRBot.SendText "Higher than " & Val(Mid(Text, InStr(Text, " ")))
    End If


    When a person gets to say !num 6 it will say "higher then 6" and then they guess !num 8 and it will say "lower then 8" then they'd guess !num 7 and it would say "lower then 7" now thats obviously messed up. Someone help?

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Please let me know if this is otherwise, but I guess this is what you want & have done you a sample ..
    Attached Files Attached Files

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Posts
    12
    hmm... hehe no no.. you would type !num in the chat area and then a bot I loaded, would say if they were right or not

  4. #4
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    it's a simple bug, when you test the number, you set it to zero before you next if-then statements, thus when you get to the statements, the number is zero. this will fix it (note also that the first if then statement does nothing, it should include the whole chunk of code that follows):

    Code:
    If Left(Text, InStr(Text, " ")) = "!num " Then 
    
    If Val(Mid(Text, InStr(Text, " "))) = 0 Then 
    Exit Sub 
    End If 
    
    If Number = 0 Then 
    Number = (Rnd(Time) * 50) + 1 
    End If 
    
    'i rearanged the if-then statements so the equals one is last
    If Val(Mid(Text, InStr(Text, " "))) > Number Then 
    BRBot.SendText "Lower than " & Val(Mid(Text, InStr(Text, " "))) 
    End If 
    
    If Val(Mid(Text, InStr(Text, " "))) < Number Then 
    BRBot.SendText "Higher than " & Val(Mid(Text, InStr(Text, " "))) 
    End If 
    
    If Val(Mid(Text, InStr(Text, " "))) = Number Then 
    BRBot.SendText Handle & " guessed the right number" 
    Number = 0 
    End If 
    
    End If
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Posts
    12
    hey i still get the same error with that one.

  6. #6
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    works for me
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width