Game script

Melon Man and Cat
Joined 25/07/2020
Posts 567
06:00 PM 01/06/2022
const savingInterval = 30000 // Time in MS
const dataSaver = getModule("dataSaver")

Game.on("initialSpawn", (player) => {
let data = dataSaver.read(player.userId, false) //tries to read the file where the score is saved
if (data == undefined) { //if there is no file it will return undefined
dataSaver.write("0", player.userId)//creates a new file with the id of the player and the value of 0
} else {
player.setScore(parseInt(data))
player.lastSavedScore = data
}

player.setInterval(() => {
if (player.lastSavedScore === player.score) return
player.lastSavedScore = player.score
dataSaver.write(player.score.toString(), player.userId)
}, savingInterval)
})

Game.on("playerLeave", (player) => {
dataSaver.write(player.score.toString(), player.userId)
})


XxEmeraldxX
Joined 22/02/2021
Posts 676
10:40 PM 03/06/2022
What does it do?


[RG] Rainbow Games
Joined 02/03/2019
Posts 159
01:23 AM 04/06/2022
Quote from XxEmeraldxX , 10:40 PM 03/06/2022
What does it do?
I’m assuming it saves points


Floppys
Joined 18/05/2022
Posts 23
02:41 AM 12/06/2022
Thing is, it's not getModule(dataSaver), it's supposed to be fs.
Also, this script is outdated and a newer version is a lot better than this one.


[ㅤㅤ] [Deleted941447]
Joined 16/06/2022
Posts 204
07:03 PM 19/06/2022
[ Content Removed ]

1