From a12046120c2c3101bfa67a4e5df74e00f920e435 Mon Sep 17 00:00:00 2001 From: Stephen York Date: Thu, 7 Jan 2021 10:29:05 +1100 Subject: [PATCH] Update main.lua Added player count to avoid running script when no players are on --- server/main.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/main.lua b/server/main.lua index c1252f0f..469fd5dd 100644 --- a/server/main.lua +++ b/server/main.lua @@ -97,6 +97,7 @@ function SaveData() local whenList = '' local whereList = '' local firstItem = true + local playerCount = 0 for i=1, #xPlayers, 1 do local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) @@ -110,11 +111,14 @@ function SaveData() whereList = whereList .. string.format('\'%s\'', xPlayer.identifier) firstItem = false + playerCount = playerCount + 1 + end + + if playerCount > 0 then + local sql = string.format(updateStatement, whenList, whereList) + + MySQL.Async.execute(sql) end - local sql = string.format(updateStatement, whenList, whereList) - - MySQL.Async.execute(sql) - end