Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: ^ on February 15, 2005, 11:47 AM

Title: Access / Command trouble
Post by: ^ on February 15, 2005, 11:47 AM
Hello everyone.


Ok, my problem starts with:


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


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



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?
Title: Re: Access / Command trouble
Post by: Spilled on February 15, 2005, 12:39 PM
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


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


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
Title: Re: Access / Command trouble
Post by: ^ on February 15, 2005, 12:45 PM
I wrote code like that but i put


  For i = 0 to frmConfig.List1.ListCount + 1



Is + 1 wrong?
Title: Re: Access / Command trouble
Post by: Warrior on February 15, 2005, 12:46 PM
For i = 0 to frmConfig.List1.ListCount Step 1 ??
Title: Re: Access / Command trouble
Post by: ^ on February 15, 2005, 12:47 PM
Huh? Sorry, but why did you put "Step" instead of "1" ?
Title: Re: Access / Command trouble
Post by: tA-Kane on February 15, 2005, 12:51 PM
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.
Title: Re: Access / Command trouble
Post by: ^ on February 15, 2005, 12:55 PM
Yeah, k.

Umm back to my problem:

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


    Dim strCompare as string

getaccess = Right(strCompare , 3)



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

And i have

If getaccess >= 50 and username = Right(strCompare , 1) and Mid(strText, 1, 8) = "+trigger" then

But it doesnt work? Ahh help :(
Title: Re: Access / Command trouble
Post by: Spilled on February 15, 2005, 01:11 PM
... just use a split of " " to get the access of the username so it would be something like this...


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

somethign like that would be very simple...
Title: Re: Access / Command trouble
Post by: ^ on February 15, 2005, 01:25 PM
Omfg i see how simple it is, but whats the " " mean / for :(
Title: Re: Access / Command trouble
Post by: UserLoser. on February 15, 2005, 01:33 PM
Quote from: ^OwnaGe~ on February 15, 2005, 01:25 PM
Omfg i see how simple it is, but whats the " " mean / for :(

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.
Title: Re: Access / Command trouble
Post by: ^ on February 15, 2005, 01:47 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?  :-\
Title: Re: Access / Command trouble
Post by: Spilled on February 15, 2005, 02:14 PM
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.
Title: Re: Access / Command trouble
Post by: ^ on February 15, 2005, 02:26 PM
Umm, what would i put to store it in a listbox ?



List1.Additem <What here>


:'(
Title: Re: Access / Command trouble
Post by: Spilled on February 15, 2005, 02:32 PM
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 " "
Title: Re: Access / Command trouble
Post by: ^ on February 15, 2005, 02:35 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 ?
Title: Re: Access / Command trouble
Post by: Spilled on February 15, 2005, 02:43 PM
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:

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


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
Title: Re: Access / Command trouble
Post by: ^ on February 15, 2005, 02:44 PM
Yeah, but what do i put for Ping


Ping = ??


Hmm, im struggling :'(
Title: Re: Access / Command trouble
Post by: Warrior on February 15, 2005, 02:46 PM
Haha, I was at school and didn't read your post I was just trying to see if that is what you meant :P
Title: Re: Access / Command trouble
Post by: ^ on February 15, 2005, 04:14 PM
Oh no, im stuck!

I have an error in my code

If splt(0) = LCase(username) Then

With an error message: "Subscript out of range"
How can i fix this?

Edit:

Was writing something else:

Would this work?

Public Sub recacc()
Dim strCompare As String
Open (App.Path & "\users.txt") For Input As #1
recacc = Right(strCompare, 3)
msgbox recacc

End Sub
?

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


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



And one example of something


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


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? :(
Title: Re: Access / Command trouble
Post by: BaDDBLooD on February 15, 2005, 08:41 PM
just have your Function return there access as a byte, assuming your access will be 1-100
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 05:24 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

Dim username as Byte

Something like that?
Title: Re: Access / Command trouble
Post by: Warrior on February 16, 2005, 06:09 AM
...Dude. Why would you return a Username as a byte
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 06:17 AM
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.


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



And one example of a command



            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))


Im thinking my Mid(strtext, 1, 8) is wrong


Omg, Helpp ahh  :o  :o  :o
Title: Re: Access / Command trouble
Post by: Spilled on February 16, 2005, 09:31 AM
Why make everything so complicated? simply just load the Database.txt into a listbox and use a simple getaccess function like this:


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


Don't  make everything so complicated, you would simply use this function like this:

Access = getaccess("Spilled[DW]")

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
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 12:21 PM
Quote from: ^OwnaGe~ on February 15, 2005, 04:14 PM
Oh no, im stuck!

I have an error in my code

If splt(0) = LCase(username) Then

With an error message: "Subscript out of range"

I get that! argh.
Title: Re: Access / Command trouble
Post by: Spilled on February 16, 2005, 12:39 PM
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.
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 12:40 PM
I have


Access = Getaccess


Should it be

Access = GetAccess(Username)

?
Title: Re: Access / Command trouble
Post by: Spilled on February 16, 2005, 12:43 PM
-.- 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.
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 12:45 PM

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



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


Edit:


access = GetAccess(Username)


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



Title: Re: Access / Command trouble
Post by: Spilled on February 16, 2005, 12:48 PM
paste me the getaccess function plz, thank you.
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 12:51 PM

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


Im using that for TESTS


I get the error: "Expected: Array" for Access = GetAccess(Username)
Title: Re: Access / Command trouble
Post by: Spilled on February 16, 2005, 12:53 PM

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


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]
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 12:57 PM

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


Thats my code.

Still getting that "Expected Array" error for Access = GetAccess(Username) with GetAccess highlighted.
Title: Re: Access / Command trouble
Post by: Spilled on February 16, 2005, 12:59 PM
Quote from: ^OwnaGe~ on February 16, 2005, 12:57 PM

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


Thats my code.

Still getting that "Expected Array" error for Access = GetAccess(Username) with GetAccess highlighted.

its public Function getaccess(username as string) is the function heading and you call it by passing the username like this:

Access = getaccess("usernamehere")
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 01:00 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 =[


Access = GetAccess("usernamehere")


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" ..
Title: Re: Access / Command trouble
Post by: Spilled on February 16, 2005, 01:02 PM
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 =\
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 01:04 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  :'(
Title: Re: Access / Command trouble
Post by: Spilled on February 16, 2005, 01:07 PM
... 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
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 01:10 PM

Access = GetAccess(username)


I had that, but now

Access = GetAccess("SpongeMan")


A old name i use to have, right?

Ok i start it up

"Expected: Array"

...
Title: Re: Access / Command trouble
Post by: Spilled on February 16, 2005, 01:12 PM
-.- paste me the whole sub that contains the line of coding where you call the function up
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 01:13 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?  :-\

Title: Re: Access / Command trouble
Post by: Spilled on February 16, 2005, 01:14 PM
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
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 01:15 PM
Um my Case &HF has nothing but commands, whisper, chat and stuff like that. Whats there to see?
Quote from: ^OwnaGe~ on February 16, 2005, 01:13 PM

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




Go to USEAST, Channel: help1234  .... /me waits
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 01:55 PM
Ok, after some work i finally have

            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


And my getaccess function:


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


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

But its coming back as "" >_<

Ideas, help?  :P  ::)  ;D  :-\  :'(
Title: Re: Access / Command trouble
Post by: Yegg on February 16, 2005, 02:40 PM
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.
Title: Re: Access / Command trouble
Post by: ^ on February 16, 2005, 02:47 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.
Title: Re: Access / Command trouble
Post by: Gangz on February 17, 2005, 02:47 AM
Quote from: Spilled[DW] on February 16, 2005, 01:14 PM
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


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)
Title: Re: Access / Command trouble
Post by: Spilled on February 17, 2005, 09:53 AM
Quote from: Gangz on February 17, 2005, 02:47 AM

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


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.
Title: Re: Access / Command trouble
Post by: ^ on February 17, 2005, 02:06 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