tweak(es_extended/client/functions.lua): add more validation

This commit is contained in:
Mycroft
2023-03-02 08:39:19 -08:00
parent 30bee9343f
commit 9be905588f
+5 -2
View File
@@ -406,8 +406,11 @@ function ESX.Game.SpawnVehicle(vehicle, coords, heading, cb, networked)
local model = type(vehicle) == 'number' and vehicle or joaat(vehicle)
local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z)
networked = networked or true
local player_coords = GetEntityCoords(ESX.PlayerData.ped)
local dist = #(player_coords - vector)
local playerCoords = GetEntityCoords(ESX.PlayerData.ped)
if not vector or not playerCoords then
return
end
local dist = #(playerCoords - vector)
if dist > 424 then -- Onesync infinity Range (https://docs.fivem.net/docs/scripting-reference/onesync/)
local executing_resource = GetInvokingResource() or "Unknown"
return print(("[^1ERROR^7] Resource ^5%s^7 Tried to spawn vehicle on the client but the position is too far away (Out of onesync range)."):format(executing_resource))