Valhalla Legends Forums Archive | Battle.net Bot Development | Access / Command trouble

AuthorMessageTime
^
Hello everyone.


Ok, my problem starts with:


I have set the access level of "100" for me. And i have the code of

[code]
If intAccess >= 50 and <What goes here for saying the name> and Mid(strtext, 1 , 9) = frmConfig.Trigger.text & "trigger"
[/code]


I dont know what to put to say if the name is right, explained:
My bot will search for the name, check the access and see if its over 50, and if its not over 50, or it has no access, do nothing?

Could somebody please help me on the lines to this?
February 15, 2005, 5:47 PM
Spilled[DW]
Honestly i cant say much because you havent supplied enough code but the best way i figured to add access/commands to a bot is load a txt to a listbox and use a get access Function for example like this one

[code]
Public Function getaccess(user1 As String) As Integer
On Error Resume Next
Static X As Integer
For X = 0 To Form2.List1.ListCount - 1
Dim User() As String
User() = Split(Form2.List1.List(X), " ")
If LCase(User(0)) = LCase(user1) Then
    getaccess = User(1)
End If
Next X
End Function
[/code]

Some kind of function like that would be sufficient, so your coding would be something like If Getaccess(username) >= 50 Then do w/e

Hope this helps, anymore questions ask away or PM me :D
February 15, 2005, 6:39 PM
^
I wrote code like that but i put

[code]
  For i = 0 to frmConfig.List1.ListCount + 1
[/code]


Is + 1 wrong?
February 15, 2005, 6:45 PM
Quarantine
[code] For i = 0 to frmConfig.List1.ListCount Step 1[/code] ??
February 15, 2005, 6:46 PM
^
Huh? Sorry, but why did you put "Step" instead of "1" ?
February 15, 2005, 6:47 PM
tA-Kane
Why did you put + 1? That will make it crash when it goes out of the bounds of the listbox (which is .ListCount).

"Step 1" tells the for loop to increment by one for each run through the loop.

Try setting to "Step 2" to see a difference.
February 15, 2005, 6:51 PM
^
Yeah, k.

Umm back to my problem:

I have now made it save to a txt file and it reads

[code]
    Dim strCompare as string

getaccess = Right(strCompare , 3)

[/code]

Thats part of it.
strCompare , 1 = Username
strCompare , 2 = A space..
strCompare , 3 = The access of the name

And i have
[code]
If getaccess >= 50 and username = Right(strCompare , 1) and Mid(strText, 1, 8) = "+trigger" then
[/code]
But it doesnt work? Ahh help :(
February 15, 2005, 6:55 PM
Spilled[DW]
... just use a split of " " to get the access of the username so it would be something like this...

[code]
Public function GetAccess(username as string)
Dim splt() as String
  With YOURLISTBOX
    For i = 0 to .listcount
      splt = Split(.list(i), " ")
       if splt(0) = lcase(username) then
           getaccess = splt(1)
       end if
   next i
end with
End function
[/code]
somethign like that would be very simple...
February 15, 2005, 7:11 PM
^
Omfg i see how simple it is, but whats the " " mean / for :(
February 15, 2005, 7:25 PM
UserLoser.
[quote author=^OwnaGe~ link=topic=10574.msg99871#msg99871 date=1108495527]
Omfg i see how simple it is, but whats the " " mean / for :(
[/quote]

It's the delimeter (what you're splitting the string up by).

If you split: "Hi, my name is whatever", it would put:

Hi,
my
name
is
whatever

all into the return array

If you were to split that by "i", then the array containing the result of Split() would hold:

H
, my name
s whatever.
February 15, 2005, 7:33 PM
^
Oooh thanks!  ;D

Thanks all for explaining, going to go try some more commands now hehehe

I bet i come back though needing more help :(


Edit:

There is just one more thing, how do i get the ping? All i know is it you can get it at login, but how do i request it?  :-\
February 15, 2005, 7:47 PM
Spilled[DW]
You cant request it (or i never heard of that way) you get it as the person joins the channel or when you join the channel in the packet &HF (chat event), to keep record of it you must add it to a listbox to keep record of it and when you want to ping someone (ex: 'ping Spilled[DW]) you much search taht listbox and obtain the record of there ping.

Ill be sure to checkback because im sure you will need help again :), any questions feel free to ask.
February 15, 2005, 8:14 PM
^
Umm, what would i put to store it in a listbox ?


[code]
List1.Additem <What here>
[/code]

:'(
February 15, 2005, 8:26 PM
Spilled[DW]
Simple, on join chat event listbox.additem username & " " & Ping and on leave write a function to find that username that leaves and remove them from the listbox, and also on the users here chat event add everyone in the channel with the same format ( listbox.additem username & " " & Ping)

Hope this helps, feel free to ask any questions you make have :D

Edit: o and forgot to get the ping just write a simple function that uses a split to split the text in the listbox with the delimeter of " "
February 15, 2005, 8:32 PM
^
Hmm im kind of a newb for getting ping, could you write a demo code or something for me to get a little idea ?
February 15, 2005, 8:35 PM
Spilled[DW]
Sure bro, ok in your parsep under Packet &HF this is where all your chat events happen, there should be a line of code that creates the ping from the packet it recieves (&HF) and that is what the ping of the person who joins or w/e chat event is happening... so simply under &HF on &H2 (user joins) put listbox.additem username & " " & ping and under &HF on &H3 (user leaves) write a function to remove that user from the listbox your using to store the pings and under &HF on &H1 (users here) put the same thing you put when they join ( listbox.additem username & " " & ping)

The remove Function would look something like this:
[code]
Public Function PingRemove(username as string)
With YOURLISTBOX
Dim splt() As String
For i = 0 to .listcount
splt = split(.list(i), " ", 2)
If lcase(splt(0)) = Lcase(username) Then
.removeitem (i)
end if
next i
end with
end function
[/code]

Hope this Helps! gl bro, school just got out so ill check back later tonight when i get off work, feel free to post w/e questions you may have :D
February 15, 2005, 8:43 PM
^
Yeah, but what do i put for Ping

[code]
Ping = ??
[/code]

Hmm, im struggling :'(
February 15, 2005, 8:44 PM
Quarantine
Haha, I was at school and didn't read your post I was just trying to see if that is what you meant :P
February 15, 2005, 8:46 PM
^
Oh no, im stuck!

I have an error in my code
[code]
If splt(0) = LCase(username) Then
[/code]
With an error message: "Subscript out of range"
How can i fix this?

Edit:

Was writing something else:

Would this work?
[code]
Public Sub recacc()
Dim strCompare As String
Open (App.Path & "\users.txt") For Input As #1
recacc = Right(strCompare, 3)
msgbox recacc

End Sub
[/code] ?

Edit #2: I tried it and recacc came out as "" but it should of came out as " 1 " Ideas? Also please answer my first question please!  :P   ::)

Edit #3: Ok after some work, ive made it so ANYBODY can do the commands. Now how do i make it so only the certain access can? I have this

[code]
getaccess = access

Function GetAccess()
'Dim GetAccess As Integer
Dim Username As String
            On Error Resume Next
            Dim strCompare As String
            Dim s As String
            s = Dir$(App.Path & "\users.txt")
            If s = "" Then
                GoTo theend
            End If
            Open (App.Path & "\users.txt") For Input As #1
            Do
                Input #1, strCompare
                Call PrepareCheck(strCompare)
                Call PrepareCheck(Username)
                If StrComp(LCase(Username), LCase(Left(strCompare, Len(Username))), vbTextCompare) = 0 Then
                    GetAccess = Right(strCompare, 3)
                End If
            Loop Until EOF(1)
        Close #1
theend:
End Function

Public Sub PrepareCheck(ByRef tocheck As String)
    tocheck = Replace(tocheck, "[", "a")
    tocheck = Replace(tocheck, "]", "x")
    tocheck = Replace(tocheck, "#", "y")
    tocheck = Replace(tocheck, "-", "z")
    tocheck = Replace(tocheck, "&", "b")
End Sub

[/code]

And one example of something

[code]
            ElseIf access >= 10 And LCase(Mid(strText, 1, 6)) = frmConfig.trigger.Text & "join " Then
[/code]

But anybody can do it?
If Somebody says "!join Op [vL]", i want my bot to check if they have 10 or 10+ access, and if they do, then do it, if they dont, dont do it. Help? :(
February 15, 2005, 10:14 PM
BaDDBLooD
just have your Function return there access as a byte, assuming your access will be 1-100
February 16, 2005, 2:41 AM
^
Return it as a byte, yeah i get that.

But im a bit of a 'newbie' for this kind of terms, could you explain and give a example code?

I think its
[code]
Dim username as Byte
[/code]
Something like that?
February 16, 2005, 11:24 AM
Quarantine
...Dude. Why would you return a Username as a byte
February 16, 2005, 12:09 PM
^
No no, i am not doing that, it was an example, im stuck!

My problem explainined a bit more:

Ok, all my commands WORK but anybody can do them.

[code]
Access = Getaccess


Function GetAccess()
'Dim GetAccess As Integer
Dim Username As String
            On Error Resume Next
            Dim strCompare As String
            Dim s As String
            s = Dir$(App.Path & "\users.txt")
            If s = "" Then
                GoTo theend
            End If
            Open (App.Path & "\users.txt") For Input As #1
            Do
                Input #1, strCompare
                Call PrepareCheck(strCompare)
                Call PrepareCheck(Username)
                If StrComp(LCase(Username), LCase(Left(strCompare, Len(Username))), vbTextCompare) = 0 Then
                    GetAccess = Right(strCompare, 3)
                End If
            Loop Until EOF(1)
        Close #1
theend:
End Function

Public Sub PrepareCheck(ByRef tocheck As String)
    tocheck = Replace(tocheck, "[", "a")
    tocheck = Replace(tocheck, "]", "x")
    tocheck = Replace(tocheck, "#", "y")
    tocheck = Replace(tocheck, "-", "z")
    tocheck = Replace(tocheck, "&", "b")
End Sub

[/code]

And one example of a command

[code]

            ElseIf access >= 20 And Mid(strText, 1, 8) = "+trigger" Then
           
            Packet.InsertNTString "Trigger is: " & frmConfig.trigger.Text
            Packet.SendPacket bnetsocket, &HE
            Packet.Clear
            'frmConfig.trigger.Text = Lcase(Mid(Strtext, 13))
[/code]

Im thinking my [code] Mid(strtext, 1, 8) [/code] is wrong


Omg, Helpp ahh  :o  :o  :o
February 16, 2005, 12:17 PM
Spilled[DW]
Why make everything so complicated? simply just load the Database.txt into a listbox and use a simple getaccess function like this:

[code]
Public Function GetAccess(username as string)
Dim Splt() As String
With lbDatabase
For i = 0 to .listcount
Splt = Split(.list(i), " ", 2)
If lcase(splt(0)) = lcase(username) then
getaccess = splt(1)
Exit function
end if
next i
end with
end function
[/code]

Don't  make everything so complicated, you would simply use this function like this:
[code]
Access = getaccess("Spilled[DW]")
[/code]
that line would get the access of Spilled[DW] and store that access in the variable Access....

Hope this helps, ill check back soon gl
February 16, 2005, 3:31 PM
^
[quote author=^OwnaGe~ link=topic=10574.msg99899#msg99899 date=1108505681]
Oh no, im stuck!

I have an error in my code
[code]
If splt(0) = LCase(username) Then
[/code]
With an error message: "Subscript out of range"
[/quote]

I get that! argh.
February 16, 2005, 6:21 PM
Spilled[DW]
when you call the get access function are you passing the username as a string?

EX: VARIABLE = getaccess(USERNAME)

Post me some code and let me see -.-

Edit: Actually subscript out of range is a splitting error,  let me see the line where you split the .list of the listbox.
February 16, 2005, 6:39 PM
^
I have

[code]
Access = Getaccess
[/code]

Should it be
[code]
Access = GetAccess(Username)
[/code]
?
February 16, 2005, 6:40 PM
Spilled[DW]
-.- yes you have to pass the username of the person you wanna get's access...

Edit: Paste me your get access function and yoru code where you call the function.
February 16, 2005, 6:43 PM
^
[code]
Access = GetAccess(Username)

            ElseIf access >= 20 And Mid(strText, 1, 8) = "+trigger" Then
           
             Packet.InsertNTString "Trigger is: " & frmConfig.trigger.Text
            Packet.SendPacket bnetsocket, &HE
             Packet.Clear

[/code]

Theres my trigger command, is that right or is there anything else i need to add?


Edit:

[code]
access = GetAccess(Username)
[/code]

Error: "GetAccess" highlighted with error: "Expected: Array"
:-\  :-\   :-\
Edit: #2 Wait i just had wrong code, now rtesting sec



February 16, 2005, 6:45 PM
Spilled[DW]
paste me the getaccess function plz, thank you.
February 16, 2005, 6:48 PM
^
[code]
Public Function GetAccess(username as string)
Dim Splt() As String
For i = 0 to frmConfig.List1.listcount
Splt = Split(frmConfig.List1.list(i), " ", 2)
If lcase(splt(0)) = lcase(username) then
getaccess = splt(1)
Exit function
end if
next i
end with
end function[/code]

Im using that for TESTS


I get the error: "Expected: Array" for [code] Access = GetAccess(Username) [/code]
February 16, 2005, 6:51 PM
Spilled[DW]
[code]
Public Function GetAccess(username as string)
On error resume next
Dim Splt() As String
For i = 0 to frmConfig.List1.listcount
Splt = Split(frmConfig.List1.list(i), " ", 2)
If lcase(splt(0)) = lcase(username) then
getaccess = splt(1)
Exit function
end if
next i
end with
end function
[/code]

Ok i believe whats its doign is it trying to split the .list(i) when its "" and erroring out so i added On error resume next try this and get back at me, Goodluck

PS: next time use [Code and /Code]
February 16, 2005, 6:53 PM
^
[code]
Public Function GetAccess()
Dim Username As String
On Error Resume Next

Dim splt() As String

    For i = 0 To frmConfig.List1.ListCount - 1
      splt = Split(frmConfig.List1.List(i), " ")
      If splt(0) = LCase(Username) Then
          GetAccess = splt(1)
      MsgBox GetAccess
      MsgBox splt(1)
    Else
        If splt(0) = UCase(Username) Then
          GetAccess = splt(1)
      MsgBox GetAccess
      MsgBox splt(1)
      End If
    End If
  Next i
'End With
End Function
[/code]

Thats my code.

Still getting that "Expected Array" error for [code] Access = GetAccess(Username)[/code] with [code] GetAccess[/code] highlighted.
February 16, 2005, 6:57 PM
Spilled[DW]
[quote author=^OwnaGe~ link=topic=10574.msg99997#msg99997 date=1108580277]
[code]
Public Function GetAccess()
Dim Username As String
On Error Resume Next

Dim splt() As String

    For i = 0 To frmConfig.List1.ListCount - 1
      splt = Split(frmConfig.List1.List(i), " ")
       If splt(0) = LCase(Username) Then
           GetAccess = splt(1)
       MsgBox GetAccess
       MsgBox splt(1)
    Else
         If splt(0) = UCase(Username) Then
           GetAccess = splt(1)
       MsgBox GetAccess
       MsgBox splt(1)
       End If
     End If
   Next i
'End With
End Function
[/code]

Thats my code.

Still getting that "Expected Array" error for [code] Access = GetAccess(Username)[/code] with [code] GetAccess[/code] highlighted.
[/quote]

its public Function getaccess(username as string) is the function heading and you call it by passing the username like this:
[code]
Access = getaccess("usernamehere")
[/code]
February 16, 2005, 6:59 PM
^
Uhm. Can we make this easy? Have you got msn ? If you have, can i have ur email to add you?

It would be easier =[

[code]
Access = GetAccess("usernamehere")
[/code]

That is not what i need. I dont want just one user to be able to do the commands.. or maybe im looking at it wrong? If i am, what would i put in "usernamhere" ..
February 16, 2005, 7:00 PM
Spilled[DW]
No, i use AIM and this is easy programming if you dont get this how did you write a connection? Anyways if you got AIM PM me for my sn cuz this is a waste of a topic =\
February 16, 2005, 7:02 PM
^
No, i am half on success to my access levels. I am just VERY confused. Anyway back on topic.


What should i put in ("usernamehere")
Wouldnt that mean only ONE user can do the commands.


Omfg i am Very confused. Explain more help plz  :'(
February 16, 2005, 7:04 PM
Spilled[DW]
... for username here you would pass the variable string that contains the users name whos access you seek... so on user talks under packet &HF username is sent within that packet data... so you would pass that variable that holds the user talkings name... and when you pass it into that function that function will return that persons access... wether it be "" or 100 or 40... doesnt matter it will search the access listbox and return the value...

Edit: and no that doenst mean only one user will be able to access.. it will search for anyones access in the listbox... just provide the username to search for
February 16, 2005, 7:07 PM
^
[code]
Access = GetAccess(username)
[/code]

I had that, but now
[code]
Access = GetAccess("SpongeMan")
[/code]

A old name i use to have, right?

Ok i start it up

"Expected: Array"

...
February 16, 2005, 7:10 PM
Spilled[DW]
-.- paste me the whole sub that contains the line of coding where you call the function up
February 16, 2005, 7:12 PM
^
Umm, its all in my Parse function, where i have literally everything..


But it was at the top, but now i just moved it under Case &HF

Edit: Can we meet on battle.net so we can do it better?  :-\

February 16, 2005, 7:13 PM
Spilled[DW]
roflmao....wow... paste me case &HF then and ill show you what it should look like =\

Edit: yes uswest or useast and what channel -.-

Edit#2: ipb from east, go west same channel
February 16, 2005, 7:14 PM
^
Um my Case &HF has nothing but commands, whisper, chat and stuff like that. Whats there to see?[quote author=^OwnaGe~ link=topic=10574.msg100005#msg100005 date=1108581221]

Edit: Can we meet on battle.net so we can do it better? :-\


[/quote]


Go to USEAST, Channel: help1234  .... /me waits
February 16, 2005, 7:15 PM
^
Ok, after some work i finally have
[code]
            ElseIf access >= 10 And Mid(strText, 1, 7) = frmConfig.trigger.Text & "whois " Then
              If Right(strCompare, 3) = "" Then getaccess = 0
            Packet.InsertNTString Mid(strText, 8) & " has access of " & getaccess
            Packet.SendPacket bnetsocket, &HE
            Packet.Clear
[/code]

And my getaccess function:

[code]
Sub getaccess(ByRef getaccess As Integer, ByVal Username As String)
            On Error Resume Next
            Dim strCompare As String
            Dim s As String
            s = Dir$(App.Path & "\users.txt")
            If s = "" Then
                GoTo theend
            End If
            Open (App.Path & "\users.txt") For Input As #1
            Do
                Input #1, strCompare
                Call PrepareCheck(strCompare)
                Call PrepareCheck(Username)
                If StrComp(LCase(Username), LCase(Left(strCompare, Len(Username))), vbTextCompare) = 0 Then
                    getaccess = Right(strCompare, 3)
                End If
            Loop Until EOF(1)
        Close #1
theend:
End Sub
[/code]

My right(strCompare,1) = Name
Right(strCompare,2) = A space..
Right(strCompare,3) = their access

But its coming back as "" >_<

Ideas, help?  :P  ::)  ;D  :-\  :'(
February 16, 2005, 7:55 PM
Yegg
Looking at that code I think of Stealthbot source code release 1.1.4. Spilled, I do believe that you just wasted your life helping him.
February 16, 2005, 8:40 PM
^
Yegg read up.


I am 100% sure i said "TESTS"

Do you understand that?

Hey ive read about 10 topics accusing of stealing, Ok i took the code for TESTS, but im only god dam trying to see how it works. Ok once i got it to work, and i revise over his code i will create my own.

Please notice when you download my bot, Stealth is mentioned for help.

Edit:

Read the news. "STAY ON TOPIC".

Back on topic please.

Edit#2: Ok, if it makes you happy, ill write my own code, but its going to do the same, but once i had access working i would of wrote my own. Its callled learning, or, MY way.

Hey Yegg, thanks for no help.
February 16, 2005, 8:47 PM
Gangz
[quote author=Spilled[DW] link=topic=10574.msg100006#msg100006 date=1108581280]
roflmao....wow... paste me case &HF then and ill show you what it should look like =\

Edit: yes uswest or useast and what channel -.-

Edit#2: ipb from east, go west same channel

[/quote]

Nice to see an old student now teaching others!... LOL

Anyways... Ownage how do you have "YOUR" own parsing code if you do not know what a split is? How did you split the incomming packets?

Edit: I know you may not have seen me around the forums, and other may remember me from along time ago. I program very little anymore. ...Anyways... I do not mean to bash. I once did the same thing, Stole others code and called it my own. The easiest way to learn is pick up a book. You have the basics down, but you can tell that chances are you have been trying to learn by reading others people codes.(just my suggestions)
February 17, 2005, 8:47 AM
Spilled[DW]
[quote author=Gangz link=topic=10574.msg100175#msg100175 date=1108630077]

Nice to see an old student now teaching others!... LOL

[/quote]

haha thanks gangz... been awhile

on the other hand, i totally agree with gangz i could tell that wasnt your source because the help that i provided was more then enough information for you to code your own access/commands database, so the best thing for you would be to keep studying sources and code something easier then a bot related program.

Edit: As i said in the PM i jsut replied to you, those function i wrote for you are perfectly capable of what your trying to accomplish... use the functions i wrote and you will be fine, have fun and gl.
February 17, 2005, 3:53 PM
^
Uh yeah thanks for all help. I decided to have just a master be able to do in my first version of a bot, because i think i have spent too long on it, and i needed a break. While im working on v2 i now have time to learn it.

I would like to thank Spilled[DW] for hes major help!

You and along with loads of people from this forum are mentioned in the bot.

Thanks for all help
February 17, 2005, 8:06 PM

Search