• Welcome to Valhalla Legends Archive.
 

CSB Access list

Started by titan0060, August 23, 2004, 04:28 PM

Previous topic - Next topic

titan0060

Does anyone here know how to create an access list on CSB?

MindArchon

Try using an array system. And then to save the list have it loop throughout the array on form unload and save it to a file such as MindArchon|999.

Then on startup of the bot have it import it into the array(s) with the split function

MyndFyre

Quote from: titan0060 on August 23, 2004, 04:28 PM
Does anyone here know how to create an access list on CSB?

Yes.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

titan0060

Quote from: MyndFyre on August 23, 2004, 05:11 PM
Quote from: titan0060 on August 23, 2004, 04:28 PM
Does anyone here know how to create an access list on CSB?

Yes.

next time MyndFyre, lets try going alittle more in depth...

Kp

Quote from: titan0060 on August 23, 2004, 05:33 PMnext time MyndFyre, lets try going alittle more in depth...

OK, how's this?  Yes, lots of people know, and it's considered such a trivial task you shouldn't be bothering us with it.  Figure it out for yourself.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

MindArchon

OK. These are the functions I use. This is a really bad way to do it, but I am still learning VB, so if you really want to you can use my horrible way. Put this in a module


Public Const MaxAccessList = 250
Public AccessListNames(0 To MaxAccessList) As String
Public AccessListAccess(0 To MaxAccessList) As Double

Public Function AddAccess(username As String, access As Integer) As Boolean

   Dim I As Integer
   
   For I = 0 To MaxAccessList
       If AccessListNames(I) = "" Then
           AccessListNames(I) = username
           AccessListAccess(I) = access
           AddAccess = True
           Exit For
       ElseIf AccessListNames(I) = username Then
           AccessListAccess(I) = access
           AddAccess = True
           Exit For
       End If
   Next I

End Function

Public Function RemoveAccess(username As String) As Boolean

   Dim I As Integer
   
   For I = 0 To MaxAccessList
       If AccessListNames(I) = username Then
           AccessListNames(I) = ""
           AccessListAccess(I) = 0
           RemoveAccess = True
       End If
   Next I
   
End Function

Public Function CheckAccess(username As String) As Integer

   Dim I As Integer
   
   CheckAccess = -1
   For I = 0 To MaxAccessList
       If AccessListNames(I) = username Then
           CheckAccess = AccessListAccess(I)
           Exit For
       End If
   Next I
   
End Function

Public Sub SaveAccess(FilePath As String)
   
   Dim I As Integer

   On Error Resume Next
   Kill FilePath
   On Error GoTo 0
   
   Open FilePath For Output As #1
   For I = 0 To MaxAccessList
       If AccessListNames(I) <> "" Then
           Print #1, AccessListNames(I) & "|" & AccessListAccess(I)
           End If
   Next I
   Close #1

End Sub

Public Function LoadAccess(FilePath As String)

   Dim TextLine As String
   Dim Arguments() As String
   Dim I As Integer

   Open FilePath For Input As #1
       Do While Not EOF(1)
       Line Input #1, TextLine

       If TextLine <> "" Then
           Arguments = Split(TextLine, "|")
           AccessListNames(I) = LCase(Arguments(0))
           AccessListAccess(I) = Val(Arguments(1))
       End If
       I = I + 1
       Loop
   Close #1

End Function


Then at your main form you would go

Private Sub Form_Load()

LoadAccess App.Path & "\Access.ini"

End Sub

Private Sub Form_Unload()

SaveAccess App.Path & "\Access.ini"

End Sub


Then when someone talks you would put their access in a vairable like


Dim useraccess as string

useraccess = CheckAccess(Username)


Then you would compare that to the required access for a command.

To list all the usernames in the access list and their access you would go

For I = 0 To MaxAccessList
If AccessListNames(I) <> "" Then


accesslist.ListItems.add , , AccessListNames(I) & " - " & AccessListAccess(I)

End If
Next I


You will get errors if Access.ini does not exist, so make sure you put it beside your bot

hismajesty

Quote from: titan0060 on August 23, 2004, 05:33 PM
Quote from: MyndFyre on August 23, 2004, 05:11 PM
Quote from: titan0060 on August 23, 2004, 04:28 PM
Does anyone here know how to create an access list on CSB?

Yes.

next time MyndFyre, lets try going alittle more in depth...

Yes, somebody does.

Is that better?

titan0060

Thanks for that code, it works pretty good, only one problem though... Im set to -1 access and i cant figure out how to change that.

MindArchon

AddAccess also works to edit that persons access, so just addaccess yourself to 999

titan0060

but then couldn't anyone set themselfs to 999?
also please explain how i set myself to 999 alittle more, cause i dont quite understand what your saying.

Eli_1

Quote from: titan0060 on August 23, 2004, 09:15 PM
but then couldn't anyone set themselfs to 999?
also please explain how i set myself to 999 alittle more, cause i dont quite understand what your saying.

You don't have to remove a person's access before adding them.  If they already have access, adding them again will simply overwrite their previous access.

MindArchon

Quote from: titan0060 on August 23, 2004, 09:15 PM
but then couldn't anyone set themselfs to 999?
also please explain how i set myself to 999 alittle more, cause i dont quite understand what your saying.

Try doing this.

Private Sub Form_Load()

LoadAccess App.Path & "\Access.ini"
AddAccess "titan0060", 999

End Sub


There. Your 999 now. For instance, if you want a .add command, you would do something like this (this is under usertalks sub)


Dim access as string

access = GetAccess(Username)

If Mid$(Message, 1, 4) = trigger & "add" And access > 59 Then

Dim addstats() as string

addstats = Split(Message, " ")

AddAccess addstats(1), Val(addstats(2))

bot1.send "Added " & addstats(1) & " with " & addstats(2) & " access"

End If

Gangz

Good job letting him write his own code. Not only did you give him your code to do it... You gave him an indepth message on how to use it.. Ask him what he learned.. He came back and asked how to use it.

My advice: Since you have already gotten the code. Read and Study it. Follow it all back and forth till you understand what it is actually doing to make the process work. If you succeed then write your own doing things the way you wanted to. If you dont succeed pick up the a damn VB book, It doesn't weigh that much