Fix new player error on first spawn

This commit is contained in:
ElPumpo
2018-12-31 14:11:05 +01:00
parent dc44b7c667
commit 22a4d67971
3 changed files with 9 additions and 9 deletions
+2 -4
View File
@@ -568,18 +568,16 @@ end)
-- Last position
Citizen.CreateThread(function()
while true do
Citizen.Wait(1000)
if ESX ~= nil and ESX.PlayerLoaded and PlayerSpawned then
if ESX.PlayerLoaded and PlayerSpawned then
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
if not IsEntityDead(playerPed) then
ESX.PlayerData.lastPosition = {x = ESX.Math.Round(coords.x, 2), y = ESX.Math.Round(coords.y, 2), z = ESX.Math.Round(coords.z, 2)}
ESX.PlayerData.lastPosition = {x = coords.x, y = coords.y, z = coords.z}
end
end
end
end)
+2 -2
View File
@@ -1,12 +1,12 @@
USE `essentialmode`;
ALTER TABLE `users`
ADD COLUMN `name` VARCHAR(255) NULL DEFAULT '' AFTER `money`,
ADD COLUMN `name` VARCHAR(50) NULL DEFAULT '' AFTER `money`,
ADD COLUMN `skin` LONGTEXT NULL AFTER `name`,
ADD COLUMN `job` varchar(50) NULL DEFAULT 'unemployed' AFTER `skin`,
ADD COLUMN `job_grade` INT NULL DEFAULT 0 AFTER `job`,
ADD COLUMN `loadout` LONGTEXT NULL AFTER `job_grade`,
ADD COLUMN `position` VARCHAR(50) NULL AFTER `loadout`
ADD COLUMN `position` VARCHAR(36) NULL AFTER `loadout`
;
CREATE TABLE `items` (
+5 -3
View File
@@ -199,9 +199,11 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
end
self.getLastPosition = function()
self.lastPosition.x = ESX.Math.Round(self.lastPosition.x, 2)
self.lastPosition.y = ESX.Math.Round(self.lastPosition.y, 2)
self.lastPosition.z = ESX.Math.Round(self.lastPosition.z, 2)
if self.lastPosition then
self.lastPosition.x = ESX.Math.Round(self.lastPosition.x, 1)
self.lastPosition.y = ESX.Math.Round(self.lastPosition.y, 1)
self.lastPosition.z = ESX.Math.Round(self.lastPosition.z, 1)
end
return self.lastPosition
end