Hi, I'm working on a script to count and display the number of laps made by different players in a race. I rapidly found out that the one programing board was infact multiple as it was run localy by all the players (when I start it I'm the only one who sees it as started) and therefore I tried using a database to sync them all up.
I have an array full of ints and I'm trying to write functions that would help me get those in and ou the database (The problem only accurs when I try to get my arrays back) my script allways gets shutdown by the game for some reason (it's not a script error but a cpu overload or smth).
so there's the code if annyone got some time to lose trying to help me:
function insertIntArrayToDB(startKey,array)
i = 1
while i <= #array do
db.setIntValue(i+startKey-1, array[i])
i = i + 1
end
end
function getIntArrayFromDB(startKey) --we supose there's an unused key after the array
i = startKey
arrayToFill = {}
while db.hasKey(i) do
table.insert(arrayToFill,db.getIntValue(i))
i=i+1
end
return arrayToFill
end
array={2,4,8,16,32,128}
insertIntArrayToDB(0,array)
backArray = getIntArrayFromDB(0)
system.print(backArray) --btw printing arrays in chat doesn't work