#Permanent Ban List

21 messages · Page 1 of 1 (latest)

viscid ravine
#

How do I return every single key within a datastore and it's value? I can't seem to do it myself.

    {
        Command = "pbans",
        Arguments = {},
        PermissionLevel = 5,
        Code = function(Executor: Player)
            print("pbans executed")

            local Bans: DataStore = DataStoreService:GetDataStore(PermanentBansDataStore)
            local ActiveBans: DataStoreKeyPages = Bans:ListKeysAsync("", 999999999999, "")

            for key, value in pairs(ActiveBans:GetCurrentPage()) do
                print("Key:", key, "Value:", value.value)
            end
        end
    },

For now I'm just trying to get the list, this is to display in a GUI later on. "key" returns as an Instance and value (even without .value) returns as nil. Perhaps I'm completely doing it wrong, but I can't seem to do it even with help from the documentation.

viscid ravine
#

@austere mesa ^ (if you have time later)

coarse lanternBOT
#

studio** You are now Level 10! **studio

austere mesa
#

The documentation gives you sufficient information

viscid ravine
austere mesa
#

💪

viscid ravine
# austere mesa 💪
    {
        Command = "pbans",
        Arguments = {},
        PermissionLevel = 5,
        Code = function(Executor: Player)
            print("pbans executed")

            local Bans: DataStore = DataStoreService:GetDataStore(PermanentBansDataStore)
            local ActiveBans: DataStoreKeyPages = Bans:ListKeysAsync("", 999999999999, "")
    
            local Pages: Pages = ActiveBans:GetCurrentPage()

            for Key, Value in pairs(Pages) do
                print(Key, "-", Value)
            end
        end
    },

Current code, but I didn't loop and instead just printed (Pages) for now.
So I figured I need to get the current page. It returns the value as an instance. I really am unsure on how to proceed. I'm trying to iterate through the entire table to return a list of user IDs and why they were pbanned. The key is the user's user ID and the value of the key is their ban reason.

viscid ravine
# austere mesa <https://create.roblox.com/docs/reference/engine/classes/DataStoreKey#KeyName>

I think I got it, but it doesn't seem to access the datastore by any chance?

        Code = function(Executor: Player)
            print("pbans executed")

            local Bans: DataStore = DataStoreService:GetDataStore(PermanentBansDataStore)
            local ActiveBans: DataStoreKeyPages = Bans:ListKeysAsync("", 999999999999, "")
    
            local Page: Pages = ActiveBans:GetCurrentPage()
            print(Page)
            
            for _, Key: DataStoreKey in ipairs(Page) do
                print(Bans:GetAsync(Key.KeyName)) <--- line 78
            end
        end
#

Output for line 78 is completely blank.

austere mesa
#

🤷

viscid ravine
#

@austere mesa If it helps, it seems to skip some entries. I've banned user ids 1 2 and 3 but only the reason for the third player shows up.

    {
        Command = "pbans",
        Arguments = {},
        PermissionLevel = 5,
        Code = function(Executor: Player)
            print("pbans executed")

            local Bans: DataStore = DataStoreService:GetDataStore(PermanentBansDataStore)
            local ActiveBans: DataStoreKeyPages = Bans:ListKeysAsync()
            local Page: Pages = ActiveBans:GetCurrentPage()
            
            for _, Key: DataStoreKey in ipairs(Page) do
                print(Bans:GetAsync(Key.KeyName))
                ActiveBans:AdvanceToNextPageAsync()
            end
        end
    },

It also stops after that, never getting to the test ban that I placed on newer users with larger user IDs.

austere mesa
#

How exactly are you banning players?

#

You should be setting a boolean in the database

#

I don't see that in your output

ornate sluice
viscid ravine
viscid ravine
ornate sluice