mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 08:01:28 +00:00
Update main.lua
Added player count to avoid running script when no players are on
This commit is contained in:
+8
-4
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user