Update main.lua

Added player count to avoid running script when no players are on
This commit is contained in:
Stephen York
2021-01-07 10:29:05 +11:00
committed by GitHub
parent 925bd4559e
commit a12046120c
+8 -4
View File
@@ -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