mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 01:38:52 +00:00
Proper raycast arguments, trim last position
This commit is contained in:
@@ -582,8 +582,13 @@ ESX.Game.GetVehicleInDirection = function()
|
||||
local playerCoords = GetEntityCoords(playerPed)
|
||||
local inDirection = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 5.0, 0.0)
|
||||
local rayHandle = StartShapeTestRay(playerCoords, inDirection, 10, playerPed, 0)
|
||||
local a, b, c, d, vehicle = GetShapeTestResult(rayHandle)
|
||||
return vehicle
|
||||
local numRayHandle, hit, endCoords, surfaceNormal, entityHit = GetShapeTestResult(rayHandle)
|
||||
|
||||
if hit == 1 and GetEntityType(entityHit) == 2 then
|
||||
return entityHit
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
ESX.Game.IsSpawnPointClear = function(coords, radius)
|
||||
|
||||
+1
-1
@@ -538,7 +538,7 @@ Citizen.CreateThread(function()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
if not IsEntityDead(playerPed) then
|
||||
ESX.PlayerData.lastPosition = {x = coords.x, y = coords.y, z = coords.z}
|
||||
ESX.PlayerData.lastPosition = {x = ESX.Math.Round(coords.x, 2), y = ESX.Math.Round(coords.y, 2), z = ESX.Math.Round(coords.z, 2)}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+11
-11
@@ -3,15 +3,15 @@ USE `essentialmode`;
|
||||
ALTER TABLE `users`
|
||||
ADD COLUMN `name` VARCHAR(255) NULL DEFAULT '' AFTER `money`,
|
||||
ADD COLUMN `skin` LONGTEXT NULL AFTER `name`,
|
||||
ADD COLUMN `job` varchar(255) NULL DEFAULT 'unemployed' AFTER `skin`,
|
||||
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(255) NULL AFTER `loadout`
|
||||
ADD COLUMN `position` VARCHAR(50) NULL AFTER `loadout`
|
||||
;
|
||||
|
||||
CREATE TABLE `items` (
|
||||
`name` varchar(50) NOT NULL,
|
||||
`label` varchar(255) NOT NULL,
|
||||
`label` varchar(50) NOT NULL,
|
||||
`limit` int(11) NOT NULL DEFAULT '-1',
|
||||
`rare` int(11) NOT NULL DEFAULT '0',
|
||||
`can_remove` int(11) NOT NULL DEFAULT '1',
|
||||
@@ -21,10 +21,10 @@ CREATE TABLE `items` (
|
||||
|
||||
CREATE TABLE `job_grades` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`job_name` varchar(255) DEFAULT NULL,
|
||||
`job_name` varchar(50) DEFAULT NULL,
|
||||
`grade` int(11) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`label` varchar(255) NOT NULL,
|
||||
`name` varchar(50) NOT NULL,
|
||||
`label` varchar(50) NOT NULL,
|
||||
`salary` int(11) NOT NULL,
|
||||
`skin_male` longtext NOT NULL,
|
||||
`skin_female` longtext NOT NULL,
|
||||
@@ -36,7 +36,7 @@ INSERT INTO `job_grades` VALUES (1,'unemployed',0,'unemployed','Unemployed',200,
|
||||
|
||||
CREATE TABLE `jobs` (
|
||||
`name` varchar(50) NOT NULL,
|
||||
`label` varchar(255) DEFAULT NULL,
|
||||
`label` varchar(50) DEFAULT NULL,
|
||||
|
||||
PRIMARY KEY (`name`)
|
||||
);
|
||||
@@ -45,8 +45,8 @@ INSERT INTO `jobs` VALUES ('unemployed','Unemployed');
|
||||
|
||||
CREATE TABLE `user_accounts` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`identifier` varchar(255) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`identifier` varchar(22) NOT NULL,
|
||||
`name` varchar(50) NOT NULL,
|
||||
`money` double NOT NULL DEFAULT '0',
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
@@ -54,8 +54,8 @@ CREATE TABLE `user_accounts` (
|
||||
|
||||
CREATE TABLE `user_inventory` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`identifier` varchar(255) NOT NULL,
|
||||
`item` varchar(255) NOT NULL,
|
||||
`identifier` varchar(22) NOT NULL,
|
||||
`item` varchar(50) NOT NULL,
|
||||
`count` int(11) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
|
||||
@@ -13,7 +13,7 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
|
||||
self.identifier = self.player.get('identifier')
|
||||
|
||||
self.setMoney = function(money)
|
||||
money = ESX.Round(money)
|
||||
money = ESX.Math.Round(money)
|
||||
|
||||
if money >= 0 then
|
||||
self.player.setMoney(money)
|
||||
@@ -27,7 +27,7 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
|
||||
end
|
||||
|
||||
self.setBankBalance = function(money)
|
||||
money = ESX.Round(money)
|
||||
money = ESX.Math.Round(money)
|
||||
|
||||
if money >= 0 then
|
||||
self.player.setBankBalance(money)
|
||||
@@ -53,7 +53,7 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
|
||||
end
|
||||
|
||||
self.addMoney = function(money)
|
||||
money = ESX.Round(money)
|
||||
money = ESX.Math.Round(money)
|
||||
|
||||
if money >= 0 then
|
||||
self.player.addMoney(money)
|
||||
@@ -63,7 +63,7 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
|
||||
end
|
||||
|
||||
self.removeMoney = function(money)
|
||||
money = ESX.Round(money)
|
||||
money = ESX.Math.Round(money)
|
||||
|
||||
if money >= 0 then
|
||||
self.player.removeMoney(money)
|
||||
@@ -73,7 +73,7 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
|
||||
end
|
||||
|
||||
self.addBank = function(money)
|
||||
money = ESX.Round(money)
|
||||
money = ESX.Math.Round(money)
|
||||
|
||||
if money >= 0 then
|
||||
self.player.addBank(money)
|
||||
@@ -83,7 +83,7 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
|
||||
end
|
||||
|
||||
self.removeBank = function(money)
|
||||
money = ESX.Round(money)
|
||||
money = ESX.Math.Round(money)
|
||||
|
||||
if money >= 0 then
|
||||
self.player.removeBank(money)
|
||||
@@ -199,6 +199,10 @@ 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)
|
||||
|
||||
return self.lastPosition
|
||||
end
|
||||
|
||||
@@ -251,7 +255,7 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
|
||||
|
||||
local account = self.getAccount(acc)
|
||||
local prevMoney = account.money
|
||||
local newMoney = ESX.Round(money)
|
||||
local newMoney = ESX.Math.Round(money)
|
||||
|
||||
account.money = newMoney
|
||||
|
||||
@@ -269,7 +273,7 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
|
||||
end
|
||||
|
||||
local account = self.getAccount(acc)
|
||||
local newMoney = account.money + ESX.Round(money)
|
||||
local newMoney = account.money + ESX.Math.Round(money)
|
||||
|
||||
account.money = newMoney
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@ ESX.SavePlayer = function(xPlayer, cb)
|
||||
{
|
||||
['@job'] = xPlayer.job.name,
|
||||
['@job_grade'] = xPlayer.job.grade,
|
||||
['@loadout'] = json.encode(xPlayer.loadout),
|
||||
['@position'] = json.encode(xPlayer.lastPosition),
|
||||
['@loadout'] = json.encode(xPlayer.getLoadout()),
|
||||
['@position'] = json.encode(xPlayer.getLastPosition()),
|
||||
['@identifier'] = xPlayer.identifier
|
||||
}, function(rowsChanged)
|
||||
cb()
|
||||
|
||||
Reference in New Issue
Block a user