#memorystore service issue

1 messages · Page 1 of 1 (latest)

olive wing
#

i am receiving different values each time i readasync for memory store queue...
help

#

i should be receiving no values

ebon parcel
#

bro

#

it might be not showing errors bc ur pcalls are catching them hold on

#

is this a server script

olive wing
#

no it is in startergui

ebon parcel
#

ok

olive wing
#

i can remove pcall

ebon parcel
#

use a remote event

#

or better yet

#

change it all from server

#

fixed it

olive wing
#

now output is 1

ebon parcel
#

do this as a server script

while task.wait(1) do
    local memstore = game:GetService("MemoryStoreService")
    local queuename = game.JobId.."GenQueue"
    local queue = memstore:GetQueue(queuename)
    print("check 1")
    local data = queue:ReadAsync(10, false, 2)

    local temparr = {}
    local truecount = 0

    if data then
        for i = 1, #data do
            if table.find(temparr, tostring(data[i])) == nil then
                print("ind: "..tostring(i).." val: "..tostring(data[i]))
                table.insert(temparr, tostring(data[i]))
                truecount += 1
            end

            queue:RemoveAsync(data[i])

        end
    end

    for i, v in pairs (game:GetService("Players"):GetChildren()) do
        local label = v:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel") -- Make this the path to your own text label
        label.Text = 'Generators Active: '..tostring(truecount)
    end
end
#

and i recommend

fast harborBOT
#

studio** You are now Level 17! **studio

olive wing
#

thats not broken part

ebon parcel
#

setting the third parameter of data;ReadAsync

#

to a low value

#

it works for me

olive wing
#

if it is in a pcall it doesnt need waitforchild

ebon parcel
#

i replaced the local script with this server script in serverscript service and it works

olive wing
#

third parameter is timeout

ebon parcel
#

ik

#

no it isnt

olive wing
#

it means if too low it wont receive data

#

readsync third param is timeout in seconds

ebon parcel
#

its how long it waits if it doesnt have enough

#

but like

olive wing
#

its how long it takes until it gives up waiting

ebon parcel
#

yeah but 20 seconds is pretty long for a text gui that is updating every second and needs 10 values

olive wing
#

if you timeout early then it wont get the data if latency is high

ebon parcel
#

even if it's server-sided?

#

nvm

olive wing
#

updating every second prevents mass calls

#

instead of less than a second

#

its supposed to only have a maximum of three values. my removeasync is not working properly to cull the duplicate values from the queue

ebon parcel
#

ok

olive wing
#

it is receiving values but it is behaving even more strangely than before

ebon parcel
#

i just tested this and it worked for me

local memstore = game:GetService("MemoryStoreService")
local queuename = game.JobId.."GenQueue"
local queue = memstore:GetQueue(queuename)



for i=1, 10, 1 do
    queue:AddAsync("hi", 10, i)
end

while task.wait(1) do
    local data = queue:ReadAsync(10, false, .1)

    local temparr = {}
    local truecount = 0

    if data then
        for i = 1, #data do
            if not(table.find(temparr, tostring(data[i]))) then
                print("ind: "..tostring(i).." val: "..tostring(data[i]))
                table.insert(temparr, tostring(data[i]))
                truecount += 1
            end

            queue:RemoveAsync(data[i])

        end
    end

    for i, v in pairs (game:GetService("Players"):GetChildren()) do
        local label = v:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel") -- Make this the path to your own text label
        label.Text = 'Generators Active: '..tostring(truecount)
    end
end
#

it only printed hi once

#

nvm

#

weird

olive wing
#

now you see

#

freaky behaviour

#

the cull nest must be wrong

ebon parcel
#

no i think it just caught it before the last hi deleted bc hi was third in queue idk

#

bc after that it didnt print anything else

#

meaning all of them expired

#

bc queue is first in first out right?

#
local memstore = game:GetService("MemoryStoreService")
local queuename = game.JobId.."GenQueue"
local queue = memstore:GetQueue(queuename)



for i=1, 10, 1 do
    queue:AddAsync("hi", 10, i)
end

queue:AddAsync("hello", 10, 11)
queue:AddAsync("yo", 10, 12)

while task.wait(1) do
    local data = queue:ReadAsync(10, false, .1)

    local temparr = {}
    local truecount = 0

    if data then
        for i = 1, #data do
            if not(table.find(temparr, tostring(data[i]))) then
                print("ind: "..tostring(i).." val: "..tostring(data[i]))
                table.insert(temparr, tostring(data[i]))
                truecount += 1
            end

            queue:RemoveAsync(data[i])

        end
    end

    for i, v in pairs (game:GetService("Players"):GetChildren()) do
        local label = v:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel") -- Make this the path to your own text label
        label.Text = 'Generators Active: '..tostring(truecount)
    end
end

this is what i tested

#

I think its just bc queue is first in first out and it caught it at that specific moment i will add "x added/removed" print statements to see

olive wing
#

yes maybe it is something odd with the queue. currently i am treating it like a list

#

yes do that

#

WAIT

#

i done it

#

nvm

#

WHAT IS WRONG WITH THIS MEMORYSTORE

#

bro this is seriously messing with my head

ebon parcel
#

need an else probably that removes clones

olive wing
#

it is

ebon parcel
#

it is bc the repeats stayed in the queue and were added after one was removed

olive wing
#

how

#

i want nothing to be returned by the readasync

#

it is still reading items in the queue after iterating through all and removing them

ebon parcel
#

oh its last in first out

olive wing
#

bro

#

it is saying there is nothing in the queue and then the next iteration is has everything existing in the queue

#

clearly nothing is being removed

ebon parcel
#

it resets

#

bc data is defined inside the loop

olive wing
#

data is defined by the loop

#

it iterates through each item

ebon parcel
#

made it work i think

olive wing
#

showw

ebon parcel
#

only thing is when data has nothing in the table it prints as nil i think thats just how it shows up

#
local memstore = game:GetService("MemoryStoreService")
local queuename = game.JobId.."GenQueue"
local queue = memstore:GetQueue(queuename)
local pastarr = {}


for i=1, 10, 1 do
    queue:AddAsync("hi", 10, i)
end

queue:AddAsync("hello", 10, 11)
queue:AddAsync("yo", 10, 12)

while task.wait(1) do
    local data = queue:ReadAsync(10, false, .1)
    print(data)

    --local preserved = {}

    --for i, v in pairs(data) do
    --    table.insert(preserved, i, v)
    --end

    local temparr = {}
    local truecount = 0

    if data then
        for i = 1, #data do
            if data[i] then
                if not(table.find(temparr, tostring(data[i]))) then
                    print("ind: "..tostring(i).." val: "..tostring(data[i]))
                    table.insert(temparr, tostring(data[i]))
                    truecount += 1
                    print("Removing "..data[i])
                    queue:RemoveAsync(data[i])
                else
                    print("Duplicate found! "..tostring(data[i]))
                    queue:RemoveAsync(data[i])
                    table.remove(data, i)


                end
            end


        end

        for index=1, #pastarr, 1 do
            if not(table.find(data, pastarr[index])) then
                print(pastarr[index].." was removed")
            end
        end
        pastarr = {}
        for i, v in pairs(temparr) do
            table.insert(pastarr, v)
        end
    end
    
    for i, v in pairs (game:GetService("Players"):GetChildren()) do
        local label = v:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel") -- Make this the path to your own text label
        label.Text = 'Generators Active: '..tostring(truecount)
    end

end
olive wing
#

does it repeat the value?

#

after?

#

mine seems to result in "nil" "items... removed" "nil" "items... removed"

#

it oscillates

ebon parcel
#

mine just repeats nil bc of this

    local data = queue:ReadAsync(10, false, .1)
    print(data)
olive wing
#

once all duplicates are remove will it remove them again later?

ebon parcel
#

i just fixed this thing where the duplicates that came after all data was deleted just now by moving temp array outside

olive wing
#

this is the code now

#

why am i getting nil, values, nil, values

ebon parcel
#

idk

olive wing
#

im gonna have a seizure

#

wat

#

the

#

istg

#

how is it oscillating

ebon parcel
#
local memstore = game:GetService("MemoryStoreService")
local queuename = game.JobId.."GenQueue"
local queue = memstore:GetQueue(queuename)
local pastarr = {}


for i=1, 10, 1 do
    queue:AddAsync("hi", 10, i)
end

queue:AddAsync("hello", 10, 11)
queue:AddAsync("yo", 10, 12)

local add_value = coroutine.wrap(function()
    task.wait(15)
    queue:AddAsync("howdy", 10, 13)
    queue:AddAsync("e", 10, 14)
    queue:AddAsync("well", 10, 15)
end)
add_value()

local temparr = {}

while task.wait(1) do
    local data = queue:ReadAsync(10, false, .1)
    --print(data)

    --local preserved = {}

    --for i, v in pairs(data) do
    --    table.insert(preserved, i, v)
    --end


    local truecount = 0
    --print(temparr)
    
    if data then
        for i = 1, #data do
            if data[i] then
                if not(table.find(temparr, tostring(data[i]))) then
                    print("ind: "..tostring(i).." val: "..tostring(data[i]))
                    table.insert(temparr, tostring(data[i]))
                    truecount += 1
                    print("Removing "..data[i])
                    queue:RemoveAsync(data[i])
                else
                    print("Duplicate found! "..tostring(data[i]))
                    queue:RemoveAsync(data[i])
                    table.remove(data, i)


                end
            end


        end

        --for index=1, #pastarr, 1 do
        --    if not(table.find(data, pastarr[index])) then
        --        --print(pastarr[index].." was removed")
        --    end
        --end
        pastarr = {}
        for i, v in pairs(temparr) do
            table.insert(pastarr, v)
        end
    end
    
    for i, v in pairs (game:GetService("Players"):GetChildren()) do
        local label = v:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel") -- Make this the path to your own text label
        label.Text = 'Generators Active: '..tostring(truecount)
    end

end
#

i commented out the prints

#

there is a coroutine that i used for testing'

olive wing
#

if i am getting oscillating values then i dont know if anything can save me

fast harborBOT
#

studio** You are now Level 6! **studio

olive wing
#

what folder did you place your script in

ebon parcel
#

i just put it in serverscriptservice

olive wing
#

okay same

#

so if you do what i did. do your values oscillate too?

ebon parcel
#

but one flaw i noticed is that my script will not let a value repeat at all if it sees it once so u cant ever use the same value twice

#

lemme see

olive wing
#

if your values dont oscillate with this code then im gonna cry

ebon parcel
#

i dont have any values in tho

olive wing
#

i dont either

ebon parcel
#

oh ok

#

im just getting nil

olive wing
#

i just spawn and suddenly i have data in the queue

ebon parcel
olive wing
#

yeah i get nil at first and the next one is data

#

then nil then data

#

like wtf have i done

#

there is literally no code to add data

ebon parcel
#

lol try changing the name of the store

olive wing
#

alright

#

now its nil

#

if i add and remove data now i wonder if the same thing occurs

ebon parcel
#

ik memory store or whatever persists across servers at the same time and thats why its used so thats probably why u had alternating results

olive wing
#

i am on roblox studio there should only be one instance

#

unless collaberator mode messes with the instances

#

it works now

#

with my code

ebon parcel
#

hooray

#

🤞 pray it keeps working

olive wing
#

lowered timeout like you recommended

#

i wonder if it works in startergui

#

or maybe

#

maybe i leave it in server and use firstchild

#

im steal some of ur codes

#

hehe

ebon parcel
#

lol ok

#

imagine ur whole thing just stops working 😅

olive wing
#

bro

ebon parcel
#

...

olive wing
#

just needed an extra waitforchild

#

since i used a screengui parent for textlabel

#

SIUUUU

#

it works

ebon parcel
#

party time

olive wing
#

not YET

ebon parcel
#

aaaaa

olive wing
#

that is only the storing of values

#

i still need to implement the mechanism of what the player sees. that was only the back end

#

atleast now

#

it is most likely exploit proof

#

and it is actually pretty fast :3

ebon parcel
#

well party time for me bc i can finally go do my chores so my parents dont get mad at me

#

cya 👍

olive wing
#

yes yes

#

thank you

#

how to close thread

ebon parcel
#

no idea

olive wing
#

same