Skip to content

Commit

Permalink
Merge branch 'esx-framework:main' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
thefourcraft authored Apr 12, 2023
2 parents 95681f4 + fca0756 commit c9f0bb0
Show file tree
Hide file tree
Showing 71 changed files with 3,069 additions and 2,865 deletions.
1 change: 1 addition & 0 deletions [SQL]/legacy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ CREATE TABLE `users` (
`job` varchar(20) DEFAULT 'unemployed',
`job_grade` int(11) DEFAULT 0,
`loadout` longtext DEFAULT NULL,
`metadata` LONGTEXT NULL DEFAULT NULL,
`position` longtext NULL DEFAULT NULL,
`firstname` varchar(16) DEFAULT NULL,
`lastname` varchar(16) DEFAULT NULL,
Expand Down
674 changes: 0 additions & 674 deletions [core]/async/LICENSE

This file was deleted.

15 changes: 0 additions & 15 deletions [core]/async/README.md

This file was deleted.

71 changes: 0 additions & 71 deletions [core]/async/async.lua

This file was deleted.

7 changes: 0 additions & 7 deletions [core]/async/fxmanifest.lua

This file was deleted.

2 changes: 1 addition & 1 deletion [core]/cron/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ game 'gta5'
author 'ESX-Framework'
description 'cron'
lua54 'yes'
version '1.9.3'
version '1.9.4'

server_script 'server/main.lua'
4 changes: 2 additions & 2 deletions [core]/cron/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ local Jobs = {}
local LastTime = nil

function RunAt(h, m, cb)
table.insert(Jobs, {
Jobs[#Jobs + 1] = {
h = h,
m = m,
cb = cb
})
}
end

function GetTime()
Expand Down
55 changes: 35 additions & 20 deletions [core]/es_extended/client/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ ESX = {}
Core = {}
ESX.PlayerData = {}
ESX.PlayerLoaded = false
Core.CurrentRequestId = 0
Core.ServerCallbacks = {}
Core.Input = {}
ESX.UI = {}
ESX.UI.Menu = {}
Expand Down Expand Up @@ -187,14 +185,6 @@ ESX.RegisterInput = function(command_name, label, input_group, key, on_press, on
RegisterKeyMapping(on_release ~= nil and "+" .. command_name or command_name, label, input_group, key)
end

function ESX.TriggerServerCallback(name, cb, ...)
local Invoke = GetInvokingResource() or "unknown"
Core.ServerCallbacks[Core.CurrentRequestId] = cb

TriggerServerEvent('esx:triggerServerCallback', name, Core.CurrentRequestId,Invoke, ...)
Core.CurrentRequestId = Core.CurrentRequestId < 65535 and Core.CurrentRequestId + 1 or 0
end

function ESX.UI.Menu.RegisterType(type, open, close)
ESX.UI.Menu.RegisteredTypes[type] = {
open = open,
Expand Down Expand Up @@ -416,6 +406,17 @@ 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 == nil and true or networked

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 executingResource = 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))
end

CreateThread(function()
ESX.Streaming.RequestModel(model)

Expand Down Expand Up @@ -1304,15 +1305,6 @@ function ESX.ShowInventory()
end)
end

RegisterNetEvent('esx:serverCallback', function(requestId,invoker, ...)
if Core.ServerCallbacks[requestId] then
Core.ServerCallbacks[requestId](...)
Core.ServerCallbacks[requestId] = nil
else
print('[^1ERROR^7] Server Callback with requestId ^5'.. requestId ..'^7 Was Called by ^5'.. invoker .. '^7 but does not exist.')
end
end)

RegisterNetEvent('esx:showNotification')
AddEventHandler('esx:showNotification', function(msg, type, length)
ESX.ShowNotification(msg, type, length)
Expand All @@ -1327,4 +1319,27 @@ AddEventHandler('esx:showAdvancedNotification',
RegisterNetEvent('esx:showHelpNotification')
AddEventHandler('esx:showHelpNotification', function(msg, thisFrame, beep, duration)
ESX.ShowHelpNotification(msg, thisFrame, beep, duration)
end)
end)

---@param model number|string
---@return string
function ESX.GetVehicleType(model)
model = type(model) == 'string' and joaat(model) or model

if model == `submersible` or model == `submersible2` then
return 'submarine'
end

local vehicleType = GetVehicleClassFromName(model)
local types = {
[8] = "bike",
[11] = "trailer",
[13] = "bike",
[14] = "boat",
[15] = "heli",
[16] = "plane",
[21] = "train",
}

return types[vehicleType] or "automobile"
end
107 changes: 85 additions & 22 deletions [core]/es_extended/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ local pickups = {}

CreateThread(function()
while not Config.Multichar do
Wait(0)
Wait(100)

if NetworkIsPlayerActive(PlayerId()) then
exports.spawnmanager:setAutoSpawn(false)
DoScreenFadeOut(0)
Expand Down Expand Up @@ -74,6 +75,15 @@ AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin)
end
end

if Config.DisableVehicleSeatShuff then
AddEventHandler('esx:enteredVehicle', function(vehicle, plate, seat)
if seat == 0 then
SetPedIntoVehicle(ESX.PlayerData.ped, vehicle, 0)
SetPedConfigFlag(ESX.PlayerData.ped, 184, true)
end
end)
end

if Config.DisableHealthRegeneration or Config.DisableWeaponWheel or Config.DisableAimAssist or Config.DisableVehicleRewards then
CreateThread(function()
while true do
Expand Down Expand Up @@ -101,6 +111,74 @@ AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin)
end)
end

-- Disable Dispatch services
if Config.DisableDispatchServices then
for i = 1, 15 do
EnableDispatchService(i, false)
end
end

-- Disable Scenarios
if Config.DisableScenarios then
local scenarios = {
'WORLD_VEHICLE_ATTRACTOR',
'WORLD_VEHICLE_AMBULANCE',
'WORLD_VEHICLE_BICYCLE_BMX',
'WORLD_VEHICLE_BICYCLE_BMX_BALLAS',
'WORLD_VEHICLE_BICYCLE_BMX_FAMILY',
'WORLD_VEHICLE_BICYCLE_BMX_HARMONY',
'WORLD_VEHICLE_BICYCLE_BMX_VAGOS',
'WORLD_VEHICLE_BICYCLE_MOUNTAIN',
'WORLD_VEHICLE_BICYCLE_ROAD',
'WORLD_VEHICLE_BIKE_OFF_ROAD_RACE',
'WORLD_VEHICLE_BIKER',
'WORLD_VEHICLE_BOAT_IDLE',
'WORLD_VEHICLE_BOAT_IDLE_ALAMO',
'WORLD_VEHICLE_BOAT_IDLE_MARQUIS',
'WORLD_VEHICLE_BOAT_IDLE_MARQUIS',
'WORLD_VEHICLE_BROKEN_DOWN',
'WORLD_VEHICLE_BUSINESSMEN',
'WORLD_VEHICLE_HELI_LIFEGUARD',
'WORLD_VEHICLE_CLUCKIN_BELL_TRAILER',
'WORLD_VEHICLE_CONSTRUCTION_SOLO',
'WORLD_VEHICLE_CONSTRUCTION_PASSENGERS',
'WORLD_VEHICLE_DRIVE_PASSENGERS',
'WORLD_VEHICLE_DRIVE_PASSENGERS_LIMITED',
'WORLD_VEHICLE_DRIVE_SOLO',
'WORLD_VEHICLE_FIRE_TRUCK',
'WORLD_VEHICLE_EMPTY',
'WORLD_VEHICLE_MARIACHI',
'WORLD_VEHICLE_MECHANIC',
'WORLD_VEHICLE_MILITARY_PLANES_BIG',
'WORLD_VEHICLE_MILITARY_PLANES_SMALL',
'WORLD_VEHICLE_PARK_PARALLEL',
'WORLD_VEHICLE_PARK_PERPENDICULAR_NOSE_IN',
'WORLD_VEHICLE_PASSENGER_EXIT',
'WORLD_VEHICLE_POLICE_BIKE',
'WORLD_VEHICLE_POLICE_CAR',
'WORLD_VEHICLE_POLICE',
'WORLD_VEHICLE_POLICE_NEXT_TO_CAR',
'WORLD_VEHICLE_QUARRY',
'WORLD_VEHICLE_SALTON',
'WORLD_VEHICLE_SALTON_DIRT_BIKE',
'WORLD_VEHICLE_SECURITY_CAR',
'WORLD_VEHICLE_STREETRACE',
'WORLD_VEHICLE_TOURBUS',
'WORLD_VEHICLE_TOURIST',
'WORLD_VEHICLE_TANDL',
'WORLD_VEHICLE_TRACTOR',
'WORLD_VEHICLE_TRACTOR_BEACH',
'WORLD_VEHICLE_TRUCK_LOGS',
'WORLD_VEHICLE_TRUCKS_TRAILERS',
'WORLD_VEHICLE_DISTANT_EMPTY_GROUND',
'WORLD_HUMAN_PAPARAZZI'
}

for i, v in pairs(scenarios) do
SetScenarioTypeEnabled(v, false)
end
end

SetDefaultVehicleNumberPlateTextPattern(-1, Config.CustomAIPlates)
StartServerSyncLoops()
end)
Expand Down Expand Up @@ -607,27 +685,8 @@ AddEventHandler("esx:freezePlayer", function(input)
end
end)

RegisterNetEvent("esx:GetVehicleType", function(Model, Request)
if not IsModelInCdimage(Model) then
return TriggerServerEvent("esx:ReturnVehicleType", false, Request)
end

if Model == `submersible` or Model == `submersible2` then
return TriggerServerEvent("esx:ReturnVehicleType", "submarine", Request)
end

local VehicleType = GetVehicleClassFromName(Model)
local types = {
[8] = "bike",
[11] = "trailer",
[13] = "bike",
[14] = "boat",
[15] = "heli",
[16] = "plane",
[21] = "train",
}

TriggerServerEvent("esx:ReturnVehicleType", types[VehicleType] or "automobile", Request)
ESX.RegisterClientCallback("esx:GetVehicleType", function(cb, model)
cb(ESX.GetVehicleType(model))
end)

local DoNotUse = {
Expand All @@ -646,3 +705,7 @@ for i = 1, #DoNotUse do
print("[^1ERROR^7] YOU ARE USING A RESOURCE THAT WILL BREAK ^1ESX^7, PLEASE REMOVE ^5" .. DoNotUse[i] .. "^7")
end
end

RegisterNetEvent('esx:updatePlayerData', function(key, val)
ESX.SetPlayerData(key, val)
end)
2 changes: 1 addition & 1 deletion [core]/es_extended/client/modules/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ if Config.EnableDebug then
print('esx:exitedVehicle', 'vehicle', vehicle, 'plate', plate, 'seat', seat, 'displayName', displayName, 'netId', netId)
end)

end
end
Loading

0 comments on commit c9f0bb0

Please sign in to comment.