Author Topic: Problem with This Quote Script....  (Read 4361 times)

DarkStar

  • Full Member
  • ***
  • Posts: 135
  • Scripts for Praise
    • CorpseCorp
Problem with This Quote Script....
« on: October 18, 2006, 08:49:45 PM »
Okay, Im Writing this script and all, And I just cant seem to get one part working. The rest works correctly.

Features:
- when someone says "!quote" it randomly picks a quote. This works.
- when someone says "!quote <sub-category>" It picks a random quote from that sub category. This works.
- when someone says "!quote <sub-category> #<specific number>" It shows the specific quote from that sub-category. This does not work

I cant see what I am doing wrong, But here is the script:

Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)

if Instr(lcase(Message),"!quote") then
  if left(lcase(message),6) = "!quote" then
    if lcase(Message) = "!quote" then
      rndnum = Int(Rnd * GetIniFile("quote.ini","control","quotes","0")) + 1
      quote = GetIniFile("quote.ini","master","" & rndnum & "","NA")
      title = "Random Quote"
    end if
    if len(message) > 7 then
      if Instr(lcase(Message),"#") then
        temp1 = Mid(lcase(Message),8)
        temp2 = instr(lcase(Message),"#")
        if temp2 > 0 then
          num = Mid(temp1,temp2+1)
          tempvar = Mid(temp1, temp2 - 1)
          temp3 = GetIniFile("quote.ini","" & tempvar & "","" & num & "","NA")
          quote = GetIniFile("quote.ini","master","" & tmpvar & "","NA")
          title = "testing"
          if lcase(quote) = "na" then
            SendCommand "/msg " & Channel & " temp1: " & temp1 & "", ServerNumber
            SendCommand "/msg " & Channel & " temp2: " & temp2 & "", ServerNumber
            SendCommand "/msg " & Channel & " num: " & num & "", ServerNumber
            SendCommand "/msg " & Channel & " tempvar: " & tempvar & "", ServerNumber
            SendCommand "/msg " & Channel & " temp3: " & temp3 & "", ServerNumber
            SendCommand "/msg " & Channel & " quote: " & quote & "", ServerNumber
            SendCommand "/msg " & Channel & " title: " & title & "", ServerNumber
          end if
        end if
      else
      rndnum = Int(Rnd * GetIniFile("quote.ini","control","" & Mid(lcase(Message),8) & "","0")) + 1
      temp1 = GetIniFile("quote.ini","" & Mid(lcase(Message),8) & "","" & rndnum & "","NA")
      quote = GetIniFile("quote.ini","master","" & temp1 & "","NA")
      title = Mid(Lcase(Message),8)
      end if
    end if
    if quote = "NA" then
    else
      SendCommand "/msg " & Channel & " " & title & ": " & quote & "", ServerNumber
    end if
  end if
end if

End Sub

And here is the INI file I am using to test the system:

Code: [Select]
[control]
quotes= 4
test=2
test2=2
[master]
1=test Hi
2=test Bye
3=test2 Hi
4=test2 Bye
[test]
1=1
2=2
[test2]
1=3
2=4

If you see what I did wrong please tell, Thanks!
This message brought to you by the Wonderful Wizard of Oz.

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Problem with This Quote Script....
« Reply #1 on: October 19, 2006, 08:44:58 AM »
Ok.. checked it over, and saw a big mistake.

Code: [Select]
temp1 = Mid(lcase(Message),8)
temp2 = instr(lcase(Message),"#")
if temp2 > 0 then
   num = Mid(temp1,temp2+1)

The problem with that is, your getting the position of "#" from the Message variable, and then applying it to the temp1 variable [ num = mid(temp1, temp2+1) ].
That should be [ num = mid(Message, temp2+1) ]
You are then doing the same with the tempvar = line. That right there won't make it work.
The IceChat God

DarkStar

  • Full Member
  • ***
  • Posts: 135
  • Scripts for Praise
    • CorpseCorp
Re: Problem with This Quote Script....
« Reply #2 on: October 19, 2006, 08:39:03 PM »
Okay, It's Still not doing it correctly. It goes to the quote = GetIniFile ..... part and stops working from there. See anything else wrong with it?

Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)

if Instr(lcase(Message),"!quote") then
  if left(lcase(message),6) = "!quote" then
    if lcase(Message) = "!quote" then
      rndnum = Int(Rnd * GetIniFile("quote.ini","control","quotes","0")) + 1
      quote = GetIniFile("quote.ini","master","" & rndnum & "","NA")
      title = "Random Quote"
    end if
    if len(message) > 7 then
      if Instr(lcase(Message),"#") then
        temp1 = Mid(lcase(Message),8)
        temp2 = instr(lcase(Message),"#")
        if temp2 > 0 then
          num = Mid(Message,temp2+1)
          tmp = instr(lcase(temp1),"#")
          tempvar = Mid(Message,8,tmp - 2)
          temp3 = GetIniFile("quote.ini","" & tempvar & "","" & num & "","NA")
          quote = GetIniFile("quote.ini","master","" & tmpvar & "","NA")
          title = "testing"
          if lcase(quote) = "na" then
            SendCommand "/msg " & Channel & " temp1: " & temp1 & "", ServerNumber
            SendCommand "/msg " & Channel & " temp2: " & temp2 & "", ServerNumber
            SendCommand "/msg " & Channel & " num: " & num & "", ServerNumber
            SendCommand "/msg " & Channel & " tempvar: " & tempvar & "", ServerNumber
            SendCommand "/msg " & Channel & " temp3: " & temp3 & "", ServerNumber
            SendCommand "/msg " & Channel & " quote: " & quote & "", ServerNumber
            SendCommand "/msg " & Channel & " title: " & title & "", ServerNumber
          end if
        end if
      else
      rndnum = Int(Rnd * GetIniFile("quote.ini","control","" & Mid(lcase(Message),8) & "","0")) + 1
      temp1 = GetIniFile("quote.ini","" & Mid(lcase(Message),8) & "","" & rndnum & "","NA")
      quote = GetIniFile("quote.ini","master","" & temp1 & "","NA")
      title = Mid(Lcase(Message),8)
      end if
    end if
    if quote = "NA" then
    else
      SendCommand "/msg " & Channel & " " & title & ": " & quote & "", ServerNumber
    end if
  end if
end if

End Sub

Same INI file as before.
This message brought to you by the Wonderful Wizard of Oz.