Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/08/24 in all areas

  1. Actually the km data is saved in the memory local function initializePlayerData(player, km_driven) playerData[player] = { lastPosition = Vector3(getElementPosition(player)), distanceTraveled = km_driven * 1000, newDistance = 0, } end Only the final data that has been driven between login and quit will be saved in the db.
    1 point
  2. It depends on the amount of players and the server. 10 players should be fine. More players? It is fine to save the the current km's inside of the memory. But writing it immediately to the database will definitely be a waste of performance, that can be spend else were.
    1 point
  3. For example trigger every 10 seconds a latent event. Those last <10 seconds do not really matter. You want to balance performance and accuracy. To reduce server load and less db crash exploit able: Save it inside of the memory and write every 10/X minutes updates to the database. + onResourceStop
    1 point
  4. Multiple reasons onClientPlayerQuit is for remote players only. (Other players than yourself) Currently when another player leaves, the stats of all other players are being saved, except yours. When you quit the game, the client code on your system will stop. Not sure if there is enough time to send data on onClientResourceStop + resourceRoot. But I wouldn't rely on it. Using a timer to delay sending data, makes things really impossible. Other issues: onClientPlayerWasted should be attached to the localPlayer, not the root element. Else it also triggers for remote players. addEventHandler("onClientPlayerWasted", localPlayer, onPlayerWasted) The source from remote events can't be trusted, use the predefined variable client instead: if not exports.login:isPlayerLoggedIn(client) then return end exports.login:updatePlayerStat(client, "stat", "stat", data)
    1 point
×
×
  • Create New...