Closed dictateurfou closed 3 years ago
not exactly the same function but its ok everytick have the same problem of setInterval :/
The problem is not in timers themselves as a lot of servers are running stable for a long time so need more info
the only other info i have it's the code because i dosent have error in console :/
the following code is for prevent user spam (he need 2 local dependency but you remove if you need to try)
import { sendDiscordEmbed } from '../discord/index.js'
import { onClient, emitClient, everyTick } from 'alt-server'
import { callEvent } from '../webview/index.js'
let moduleAntiSpam = {
}
function checkModuleSpam (player, module) {
if (moduleAntiSpam[player.id] == undefined) { moduleAntiSpam[player.id] = {} }
if (moduleAntiSpam[player.id][module] == undefined) { moduleAntiSpam[player.id][module] = 0 }
moduleAntiSpam[player.id][module]++
if (moduleAntiSpam[player.id][module] < 15) {
// ajouter une notif merci de ne pas spammer
return true
} else if (moduleAntiSpam[player.id][module] < 25) {
// let identity = exports.rFramework:getIdentity(source)
callEvent(player, 'notifications:CreateNotification', { msg: "Votre action n'a pas été éxecuter merci de ne pas spammer" })
sendDiscordEmbed('spam', "antiSpam", player.firstName, " ", player.lastName, " spam le module ", module, "\n", "Sid = ", player.id, "\n", "uniqueId = ", player.uniqueId)
return false
} else {
player.kick("Sécuritée anti spam")
return false
}
}
function secureEvent (eventName, cb) {
onClient(eventName, (player, ...args) => {
const splitedEvent = eventName.split(':')
const check = checkModuleSpam(player, splitedEvent[0])
if (check == true) {
cb(player, ...args)
}
})
}
let lastTime = Date.now()
everyTick(() => {
const newTime = Date.now()
if (newTime - lastTime >= 3500) {
moduleAntiSpam = {}
lastTime = Date.now()
}
})
and the exemple of use case
secureEvent("entreprise:configSetBoss", async (player, entrepriseId) => {
//you event code
})
//use alt.emitServer on client for call this event
I was never able to reproduce this with my own reproduction steps nor with the provided reproduction steps, so I will close this issue. If you are sure this is still an issue, provide more information and ask for this issue to be reopened.
Describe the bug when you set a setInterval this destroy after long time run server (4 - 5 hour) (only tested on server)
To Reproduce make setInterval and wait a long time without interaction with you game or server
My interval
Environment: