Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: CrAz3D on February 10, 2005, 09:23 PM

Title: Custom Access Commands
Post by: CrAz3D on February 10, 2005, 09:23 PM
[vb6]

I'm trying to make different user groups that will contain w/e command the user specifies.  What I've done SO FAR is allowed the user to create a custom group & add whichever commands to the group.  Now I'm trying to make it so whoever is part of that access group has access to those commands...not so sure how to go about this totally.
I am using a couple of array to accomplish this.

array A() = the user's db info (username, flags, created date, created by, modified date, modified by, grouplist

array B() = the grouplist info (groupname, commands(ex: CMD1, CMD2))

array C() = a Split(B).  C(0) = the group name & C(1) = the commands


No where I'm stuck @ is how would I compare A(6)[the user's group] & C(0)[the groupname] & C(1) so that I can have the user able to access the commands.  I will be splitting C(1) into another array, most likely D() that each item will be the command name.

I KNOW this is confusing, I'm not so sure I understand what I wrote, if you need more clarification say so & I'll try.


EDIT: I think this is something similar to what ZeroBot does?... I can't remember totally.



EDIT, again:

if a(6) = c(0) then
   if left(message,len) = d(INDEX)  then
     do stuff for this cmd
   end if
end if

Maybe something like that?
Title: Re: Custom Access Commands
Post by: CrAz3D on February 11, 2005, 10:15 AM
Well, it seems what I have works, but I have a feeling that it is hugely inefficent.  Any suggestions on what I might want to do differently?


Public Sub CommandIT(ByVal Username As String, Message As String)
Dim a() As String
Dim b() As String
Dim c() As String
Dim d() As String
Dim pA() As String
ReDim c(0)
Dim i As Integer, X As Integer

If Not Left(Message, 1) = "!" Then Exit Sub
Message = Right(Message, Len(Message) - 1)
    pA = Split(Message, Space(1), 2)
   
a() = GetAccess(Username)
b() = ADO.getinfo("grouplist")

For i = 0 To UBound(b) - 1
    c() = Split(b(i), "|", 2)
    d = Split(c(1), ",")
    If LCase(a(6)) = LCase(c(0)) Then
        For X = 0 To UBound(d)
            If LCase(d(X)) = LCase(pA(0)) Then
            Select Case pA(0)
                Case "say"
                    QU.AddQueue pA(1)
                Case "ver"
                    QU.AddQueue "I am a FREAKIN' PIMP Xenogenic by CrAz3D[xL]"
            End Select
            End If
        Next X
    End If
Next i

End Sub
Title: Re: Custom Access Commands
Post by: Yegg on February 11, 2005, 01:53 PM
Why does that code look so much like the source from Flawed Bot? If I remember correctly, Flawed Bot contains pA(), not saying that you copied it, but it looks like it.
Title: Re: Custom Access Commands
Post by: Warrior on February 11, 2005, 05:10 PM
Or did you ever think it was maybe Fleet- that uses Stolen code? IMHO people pick up other people's code habbits one way or another.
For example I use "Splt" often because I asked for help with a User DB from someone a while back and he used code with that in it and i've used it ever since.

Yegg, dont be an idiot.
Title: Re: Custom Access Commands
Post by: CrAz3D on February 11, 2005, 06:05 PM
Yegg, all of that looks like Flawed bot?  k, I've never used Flawed nor have I seen the source so....


That is just a bunch of random stuff I came up with that I'm not going to use anymore (LoRd[nK] explained a few flaws in my idea, so it ALL went bye bye).  But not I'm contemplating a new method which will be cool too, so, w/e
Title: Re: Custom Access Commands
Post by: R.a.B.B.i.T on February 12, 2005, 09:28 PM
What I did (for FoFoBot) was to create a type that had RequiredAccess and RequiredFlags as its two parts.  I then had a public array (one for each command) which was filled at run-time by reading out of access.ini.  Then I just checked the user's access against the RequiredAccess (or Flags) instead of a hardcoded value.
Title: Re: Custom Access Commands
Post by: Grok on February 15, 2005, 06:45 AM
Oh please let's not degrade this into stolen code discussion.  If you posted code here you have to expect people to use it.

I was the first person on these forums to use pA() so don't even go there and get off your high horse.

"pA()" is an obvious choice for a procedural-level array.  If we start looking at such details and saying "stolen code", we will look as bad as SCO.
Title: Re: Custom Access Commands
Post by: CrAz3D on February 15, 2005, 10:12 AM
k, to the topic ... & away!

::)
:-*
Thanks for the help folks, decided it would be eaier just to have set flags & the user can add themself w/e flag.  Maybe I'll let them change what commands are associated with what flags, but not til later.
Title: Re: Custom Access Commands
Post by: Warrior on February 15, 2005, 12:47 PM
Exactly my point Grok, everyone adapts a coding style either by example or by leeching.