BREAKING COMMIT - Player loading improvements (read description!)

This commit implements a new way of saving and getting player coords.

Player coords are synced with its assigned xPlayer, the syncing interval is defined in the configuration file.
Also coords wont sync if the player is too close to their previous location.

Existing servers must change their database to account for the new length of the position varchar, at 53 chars max. There's also a column default value specified in the sql file.

New xPlayer functions:
- .getCoords()
- .setCoords() (x,y,z,heading (optional) table
- .updateCoords()

The last one is used for syncing coords from client (interval). The second one will teleport the player. First one is a renamed .getLastPosition()
This commit is contained in:
ElPumpo
2020-01-12 22:13:30 +01:00
parent 5566abca4f
commit f89e051756
6 changed files with 277 additions and 311 deletions
+3 -4
View File
@@ -38,7 +38,6 @@ end
ESX.SavePlayer = function(xPlayer, cb)
local asyncTasks = {}
xPlayer.setLastPosition(xPlayer.getCoords())
-- User accounts
for k,v in ipairs(xPlayer.accounts) do
@@ -80,7 +79,7 @@ ESX.SavePlayer = function(xPlayer, cb)
['@job'] = xPlayer.job.name,
['@job_grade'] = xPlayer.job.grade,
['@loadout'] = json.encode(xPlayer.getLoadout()),
['@position'] = json.encode(xPlayer.getLastPosition()),
['@position'] = json.encode(xPlayer.getCoords()),
['@identifier'] = xPlayer.identifier
}, function(rowsChanged)
cb()
@@ -88,7 +87,7 @@ ESX.SavePlayer = function(xPlayer, cb)
end)
Async.parallel(asyncTasks, function(results)
print(('[es_extended] [^2INFO^7] Saved %s'):format(xPlayer.getName()))
print(('[es_extended] [^2INFO^7] Saved player "%s^7"'):format(xPlayer.getName()))
if cb ~= nil then
cb()
@@ -190,4 +189,4 @@ ESX.DoesJobExist = function(job, grade)
end
return false
end
end