Help - Search - Members - Calendar
Full Version: Convert Access
StealthBot.net > StealthBot > Scripting and Plugins > Plugin Projects
AwaKening
Simple but useful. Just thought I'd share this for others to help make your 2.6 to 2.7 conversion more pleasant.

Simply type /convertaccess internally and it will check your access.ini file and set your commands in the new Command Manager (xml) accordingly. Disregard the following ignorant post by Call.

CODE
'caccess
'1.00
'&Convert Access v1.00:AwaKening
'&convertaccess (Internal Use Only)
'&
'&Use to apply access.ini settings from Stealthbot 2.6 to the new system in 2.7

'// Anything set to this number or higher will result in the command being disabled
Const caccess_Disable = 1001


Sub caccess_Event_PressedEnter(Text)
    If LCase(Text) <> "/convertaccess" Then Exit Sub

    Dim File, objFSO, line, lines, cmd, rank

    VetoThisMessage
    AddChat vbYellow, "CONVERTING ACCESS, please be patient.."
    AddChat vbYellow, "    -Be Sure to click (Continue) if prompted."

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set File = objFSO.OpenTextFile(BotPath & "access.ini", 1, True)
    lines = Split(File.ReadAll, vbCrlf)
    File.Close

    For Each line in Lines
        If InStr(line, "=")>0 Then
            cmd = Split(line, "=")(0)
            rank = Split(line, "=")(1)
            Call AccessUpdate(cmd, rank)
        End If
    Next

    Addchat vbYellow, "Successfully updated Command Access Levels!"

    Set File = Nothing
    Set objFSO = Nothing
End Sub

Private Sub AccessUpdate(command, rank)
    Dim cmd
    Set cmd = OpenCommand(command)
    If IsNumeric(rank) Then
        rank = cInt(rank)
        If rank>=caccess_Disable AND cmd.IsEnabled Then
            cmd.IsEnabled = False
            AddChat vbOrange, command& " Disabled"
        ElseIf cmd.RequiredRank<>rank AND rank<caccess_Disable Then
            cmd.IsEnabled = True
            cmd.RequiredRank = rank
            Addchat vbCyan, "Changed Access: " & command & " = " & rank
        Else
            AddChat vbGreen, "No Change:  " &command
        End If
    Else
        rank = UCase(rank)
        If UCase(cmd.RequiredFlag) <> rank Then
            cmd.RequiredFlag = rank
            Addchat vbBlue, "Changed Flag: " & command & " = " & rank
        Else
            AddChat vbGreen, "No Change:  " &command
        End If
    End If
    cmd.Save
    Set cmd = Nothing
End Sub



Script Format:

CODE
'// Anything set to this number or higher will result in the command being disabled
Const cmd_Disable = 1001

Private Const ForReading = 1

Script("Name") = "ConvertAccess"
Script("Author") = "AwaKening"
Script("Major") = 1
Script("Minor") = 0
Script("Revision") = 0


Sub Event_PressedEnter(Text)
    If LCase(Text) <> "/convertaccess" Then Exit Sub

    Dim File, objFSO, line, lines, cmd, rank

    VetoThisMessage
    AddChat vbYellow, "CONVERTING ACCESS, please be patient.."
    AddChat vbYellow, "    -Be Sure to click (Continue) if prompted."

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set File = objFSO.OpenTextFile(BotPath & "access.ini", 1, True)
    lines = Split(File.ReadAll, vbCrlf)
    File.Close

    For Each line in Lines
        If InStr(line, "=")>0 Then
            cmd = Split(line, "=")(0)
            rank = Split(line, "=")(1)
            Call AccessUpdate(cmd, rank)
        End If
    Next

    Addchat vbYellow, "Successfully updated Command Access Levels!"

    Set File = Nothing
    Set objFSO = Nothing
End Sub

Private Sub AccessUpdate(command, rank)
    Dim cmd
    Set cmd = OpenCommand(command)
    If IsNumeric(rank) Then
        rank = cInt(rank)
        If rank>=cmd_Disable AND cmd.IsEnabled Then
            cmd.IsEnabled = False
            AddChat vbOrange, command& " Disabled"
        ElseIf cmd.RequiredRank<>rank AND rank<cmd_Disable Then
            cmd.IsEnabled = True
            cmd.RequiredRank = rank
            Addchat vbCyan, "Changed Access: " & command & " = " & rank
        Else
            AddChat vbGreen, "No Change:  " &command
        End If
    Else
        rank = UCase(rank)
        If UCase(cmd.RequiredFlag) <> rank Then
            cmd.RequiredFlag = rank
            Addchat vbBlue, "Changed Flag: " & command & " = " & rank
        Else
            AddChat vbGreen, "No Change:  " &command
        End If
    End If
    cmd.Save
    Set cmd = Nothing
End Sub
Call
1. 2.7 don't have access.ini
2. The-Black-Ninja already did this easy script
3. I Believe The-Black-Ninja got a better outcome..
4. Suggestion you to make something new instead of old..
5. GetConfigEntry + WriteConfigEntry can do this simply..
Snap
@Call
1. This is converting 2.6's access.ini's set access overrides and maintaining them to 2.7 CommandsXML.
2. O rly?
3. O rly?
4. See 1, 2 and 3.
5. I was thinking about this, and realized I've forgotten the method used to list all elements within a [section] in a config file -- i know there's a way.. (As this would be required for what he's doin)

I presumed this would be done with the installer - - but it might be forgotten, and still good for those switching to the Beta now.
AwaKening
Saves you a bit of time if you have a lot of command access changes like I do. Eric had mentioned in Release 36 I think it was, that he would implement WriteConfigEntry back into beta for command access, but he apparently took it back out or did something wrong because it hasn't been working. This would eliminate the need for it anyway.

@Call
Read the 2.7 changelogs or test some things, because every one of your arguments were ignorant. Try to know what you're talking about before you taint my thread.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2019 Invision Power Services, Inc.