diff --git a/[SQL]/legacy.sql b/[SQL]/legacy.sql index 39e24040..2ba76874 100644 --- a/[SQL]/legacy.sql +++ b/[SQL]/legacy.sql @@ -402,7 +402,8 @@ CREATE TABLE `users` ( `disabled` TINYINT(1) NULL DEFAULT '0', `last_property` varchar(255) DEFAULT NULL, `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `last_seen` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP + `last_seen` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + `phone_number` VARCHAR(20) DEFAULT NULL ) ENGINE=InnoDB; -- -------------------------------------------------------- diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index 5403abcd..240111c7 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -7,8 +7,6 @@ Core.ServerCallbacks = {} Core.TimeoutCallbacks = {} Core.Input = {} ESX.UI = {} -ESX.UI.HUD = {} -ESX.UI.HUD.RegisteredElements = {} ESX.UI.Menu = {} ESX.UI.Menu.RegisteredTypes = {} ESX.UI.Menu.Opened = {} @@ -210,70 +208,6 @@ function ESX.TriggerServerCallback(name, cb, ...) Core.CurrentRequestId = Core.CurrentRequestId < 65535 and Core.CurrentRequestId + 1 or 0 end -function ESX.UI.HUD.SetDisplay(opacity) - SendNUIMessage({ - action = 'setHUDDisplay', - opacity = opacity - }) -end - -function ESX.UI.HUD.RegisterElement(name, index, priority, html, data) - local found = false - - for i = 1, #ESX.UI.HUD.RegisteredElements, 1 do - if ESX.UI.HUD.RegisteredElements[i] == name then - found = true - break - end - end - - if found then - return - end - - ESX.UI.HUD.RegisteredElements[#ESX.UI.HUD.RegisteredElements + 1] = name - - SendNUIMessage({ - action = 'insertHUDElement', - name = name, - index = index, - priority = priority, - html = html, - data = data - }) - - ESX.UI.HUD.UpdateElement(name, data) -end - -function ESX.UI.HUD.RemoveElement(name) - for i = 1, #ESX.UI.HUD.RegisteredElements, 1 do - if ESX.UI.HUD.RegisteredElements[i] == name then - table.remove(ESX.UI.HUD.RegisteredElements, i) - break - end - end - - SendNUIMessage({ - action = 'deleteHUDElement', - name = name - }) -end - -function ESX.UI.HUD.Reset() - SendNUIMessage({ - action = 'resetHUDElements' - }) - ESX.UI.HUD.RegisteredElements = {} -end - -function ESX.UI.HUD.UpdateElement(name, data) - SendNUIMessage({ - action = 'updateHUDElement', - name = name, - data = data - }) -end - function ESX.UI.Menu.RegisterType(type, open, close) ESX.UI.Menu.RegisteredTypes[type] = { open = open, diff --git a/[core]/es_extended/client/main.lua b/[core]/es_extended/client/main.lua index a10df217..653960d9 100644 --- a/[core]/es_extended/client/main.lua +++ b/[core]/es_extended/client/main.lua @@ -118,23 +118,6 @@ AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin) end end) - if Config.EnableHud then - for i=1, #(ESX.PlayerData.accounts) do - local accountTpl = '
 {{money}}
' - ESX.UI.HUD.RegisterElement('account_' .. ESX.PlayerData.accounts[i].name, i, 0, accountTpl, {money = ESX.Math.GroupDigits(ESX.PlayerData.accounts[i].money)}) - end - - local jobTpl = '
{{job_label}}{{grade_label}}
' - - local gradeLabel = ESX.PlayerData.job.grade_label ~= ESX.PlayerData.job.label and ESX.PlayerData.job.grade_label or '' - if gradeLabel ~= '' then gradeLabel = ' - '..gradeLabel end - - ESX.UI.HUD.RegisterElement('job', #ESX.PlayerData.accounts, 0, jobTpl, { - job_label = ESX.PlayerData.job.label, - grade_label = gradeLabel - }) - end - SetDefaultVehicleNumberPlateTextPattern(-1, Config.CustomAIPlates) StartServerSyncLoops() end) @@ -142,7 +125,6 @@ end) RegisterNetEvent('esx:onPlayerLogout') AddEventHandler('esx:onPlayerLogout', function() ESX.PlayerLoaded = false - if Config.EnableHud then ESX.UI.HUD.Reset() end end) RegisterNetEvent('esx:setMaxWeight') @@ -227,12 +209,6 @@ AddEventHandler('esx:setAccountMoney', function(account) end ESX.SetPlayerData('accounts', ESX.PlayerData.accounts) - - if Config.EnableHud then - ESX.UI.HUD.UpdateElement('account_' .. account.name, { - money = ESX.Math.GroupDigits(account.money) - }) - end end) if not Config.OxInventory then @@ -307,14 +283,6 @@ end RegisterNetEvent('esx:setJob') AddEventHandler('esx:setJob', function(Job) - if Config.EnableHud then - local gradeLabel = Job.grade_label ~= Job.label and Job.grade_label or '' - if gradeLabel ~= '' then gradeLabel = ' - '..gradeLabel end - ESX.UI.HUD.UpdateElement('job', { - job_label = Job.label, - grade_label = gradeLabel - }) - end ESX.SetPlayerData('job', Job) end) @@ -379,32 +347,6 @@ if not Config.OxInventory then end) end --- Pause menu disables HUD display -if Config.EnableHud then - CreateThread(function() - local isPaused = false - - while true do - local time = 500 - Wait(time) - - if IsPauseMenuActive() and not isPaused then - time = 100 - isPaused = true - ESX.UI.HUD.SetDisplay(0.0) - elseif not IsPauseMenuActive() and isPaused then - time = 100 - isPaused = false - ESX.UI.HUD.SetDisplay(1.0) - end - end - end) - - AddEventHandler('esx:loadingScreenOff', function() - ESX.UI.HUD.SetDisplay(1.0) - end) -end - function StartServerSyncLoops() if not Config.OxInventory then -- keep track of ammo diff --git a/[core]/es_extended/client/modules/actions.lua b/[core]/es_extended/client/modules/actions.lua new file mode 100644 index 00000000..499649b1 --- /dev/null +++ b/[core]/es_extended/client/modules/actions.lua @@ -0,0 +1,114 @@ +local isInVehicle, isEnteringVehicle, isJumping, inPauseMenu = false, false, false, false +local currentVehicle, currentSeat, currentPlate = nil, nil, nil +local playerPed = PlayerPedId() + +local function GetPedVehicleSeat(ped, vehicle) + for i = -1, 16 do + if (GetPedInVehicleSeat(vehicle, i) == ped) then return i end + end + return -1 +end + +local function GetData(vehicle) + local model = GetEntityModel(currentVehicle) + local displayName = GetDisplayNameFromVehicleModel(model) + local netId = VehToNet(vehicle) + return displayName, netId +end + +CreateThread(function() + while true do + + if playerPed ~= PlayerPedId() then + playerPed = PlayerPedId() + TriggerEvent('esx:playerPedChanged', playerPed) + TriggerServerEvent('esx:playerPedChanged', PedToNet(playerPed)) + end + + if IsPedJumping(playerPed) and not isJumping then + isJumping = true + TriggerEvent('esx:playerJumping') + TriggerServerEvent('esx:playerJumping') + elseif not IsPedJumping(playerPed) and isJumping then + isJumping = false + end + + if IsPauseMenuActive() and not inPauseMenu then + inPauseMenu = true + TriggerEvent('esx:pauseMenuActive', inPauseMenu) + elseif not IsPauseMenuActive() and inPauseMenu then + inPauseMenu = false + TriggerEvent('esx:pauseMenuActive', inPauseMenu) + end + + + if not isInVehicle and not IsPlayerDead(PlayerId()) then + if DoesEntityExist(GetVehiclePedIsTryingToEnter(playerPed)) and not isEnteringVehicle then + -- trying to enter a vehicle! + local vehicle = GetVehiclePedIsTryingToEnter(playerPed) + local plate = GetVehicleNumberPlateText(vehicle) + local seat = GetSeatPedIsTryingToEnter(playerPed) + local displayName, netId = GetData(vehicle) + isEnteringVehicle = true + TriggerEvent('esx:enteringVehicle', vehicle, plate, seat, netId) + TriggerServerEvent('esx:enteringVehicle', vehicle, plate, seat, netId) + elseif not DoesEntityExist(GetVehiclePedIsTryingToEnter(playerPed)) and + not IsPedInAnyVehicle(playerPed, true) and isEnteringVehicle then + -- vehicle entering aborted + TriggerEvent('esx:enteringVehicleAborted') + TriggerServerEvent('esx:enteringVehicleAborted') + isEnteringVehicle = false + elseif IsPedInAnyVehicle(playerPed, false) then + -- suddenly appeared in a vehicle, possible teleport + isEnteringVehicle = false + isInVehicle = true + currentVehicle = GetVehiclePedIsUsing(playerPed) + currentSeat = GetPedVehicleSeat(playerPed, currentVehicle) + currentPlate = GetVehicleNumberPlateText(currentVehicle) + local displayName, netId = GetData(currentVehicle) + TriggerEvent('esx:enteredVehicle', currentVehicle, currentPlate, currentSeat, displayName, netId) + TriggerServerEvent('esx:enteredVehicle', currentVehicle, currentPlate, currentSeat, displayName, netId) + end + elseif isInVehicle then + if not IsPedInAnyVehicle(playerPed, false) or IsPlayerDead(PlayerId()) then + -- bye, vehicle + local displayName, netId = GetData(currentVehicle) + TriggerEvent('esx:exitedVehicle', currentVehicle, currentPlate, currentSeat, displayName, netId) + TriggerServerEvent('esx:exitedVehicle', currentVehicle, currentPlate, currentSeat, displayName, netId) + isInVehicle = false + currentVehicle = nil + currentSeat = nil + currentPlate = nil + end + end + Wait(200) + end +end) + +if Config.EnableDebug then + + AddEventHandler('esx:playerPedChanged', function(netId) + print('esx:playerPedChanged', netId) + end) + + AddEventHandler('esx:playerJumping', function() + print('esx:playerJumping') + end) + + AddEventHandler('esx:enteringVehicle', function(vehicle, plate, seat, netId) + print('esx:enteringVehicle', 'vehicle', vehicle, 'plate', plate, 'seat', seat, 'netId', netId) + end) + + AddEventHandler('esx:enteringVehicleAborted', function() + print('esx:enteringVehicleAborted') + end) + + AddEventHandler('esx:enteredVehicle', function(vehicle, plate, seat, displayName, netId) + print('esx:enteredVehicle', 'vehicle', vehicle, 'plate', plate, 'seat', seat, 'displayName', displayName, 'netId', netId) + end) + + AddEventHandler('esx:exitedVehicle', function(vehicle, plate, seat, displayName, netId) + print('esx:exitedVehicle', 'vehicle', vehicle, 'plate', plate, 'seat', seat, 'displayName', displayName, 'netId', netId) + end) + +end \ No newline at end of file diff --git a/[core]/es_extended/client/modules/npwd.lua b/[core]/es_extended/client/modules/npwd.lua new file mode 100644 index 00000000..fb04f356 --- /dev/null +++ b/[core]/es_extended/client/modules/npwd.lua @@ -0,0 +1,55 @@ +local npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil + +local function checkPhone() + if not npwd then + return + end + + npwd:setPhoneDisabled((ESX.SearchInventory('phone').count or 0) <= 0) +end +RegisterNetEvent('esx:playerLoaded', checkPhone) + +AddEventHandler('onClientResourceStart', function(resource) + if resource ~= 'npwd' then + return + end + + npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil + + if ESX.PlayerLoaded then + checkPhone() + end +end) + +AddEventHandler('onClientResourceStop', function(resource) + if resource == 'npwd' then + npwd = nil + end +end) + +RegisterNetEvent('esx:onPlayerLogout', function() + if not npwd then + return + end + + npwd:setPhoneVisible(false) + npwd:setPhoneDisabled(true) +end) + +RegisterNetEvent('esx:removeInventoryItem', function(item, count) + if not npwd then + return + end + + if item == 'phone' and count == 0 then + npwd:setPhoneDisabled(true) + end +end) + +RegisterNetEvent('esx:addInventoryItem', function(item) + if not npwd or item ~= 'phone' then + return + end + + npwd:setPhoneDisabled(false) +end) \ No newline at end of file diff --git a/[core]/es_extended/common/functions.lua b/[core]/es_extended/common/functions.lua index b3074c8a..f8d65bde 100644 --- a/[core]/es_extended/common/functions.lua +++ b/[core]/es_extended/common/functions.lua @@ -39,8 +39,8 @@ function ESX.GetWeaponFromHash(weaponHash) return weaponsByHash[weaponHash] end -function ESX.GetWeaponList() - return Config.Weapons +function ESX.GetWeaponList(byHash) + return byHash and weaponsByHash or Config.Weapons end function ESX.GetWeaponLabel(weaponName) diff --git a/[core]/es_extended/config.lua b/[core]/es_extended/config.lua index 50c57ea3..2f465f82 100644 --- a/[core]/es_extended/config.lua +++ b/[core]/es_extended/config.lua @@ -19,7 +19,6 @@ Config.Accounts = { Config.StartingAccountMoney = {bank = 50000} Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society -Config.EnableHud = false -- enable the default hud? Display current job and accounts (black, bank & cash) Config.MaxWeight = 24 -- the max inventory weight without backpack Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in milliseconds Config.EnableDebug = false -- Use Debug options? @@ -60,7 +59,7 @@ Config.RemoveHudCommonents = { [22] = false, --HUD_WEAPONS } -Config.MaxAdminVehicles = false -- admin vehicles spawn with max vehcle settings +Config.SpawnVehMaxUpgrades = true -- admin vehicles spawn with max vehcle settings Config.CustomAIPlates = 'ESX.A111' -- Custom plates for AI vehicles -- Pattern string format --1 will lead to a random number from 0-9. diff --git a/[core]/es_extended/fxmanifest.lua b/[core]/es_extended/fxmanifest.lua index 1c9c63be..0b004d72 100644 --- a/[core]/es_extended/fxmanifest.lua +++ b/[core]/es_extended/fxmanifest.lua @@ -5,7 +5,7 @@ game 'gta5' description 'ES Extended' lua54 'yes' -version '1.9.0' +version '1.9.1' shared_scripts { 'locale.lua', @@ -27,9 +27,9 @@ server_scripts { 'server/main.lua', 'server/commands.lua', - 'common/modules/math.lua', - 'common/modules/table.lua', - 'common/functions.lua' + 'common/modules/*.lua', + 'common/functions.lua', + 'server/modules/*.lua' } client_scripts { @@ -37,14 +37,11 @@ client_scripts { 'client/functions.lua', 'client/wrapper.lua', 'client/main.lua', + + 'common/modules/*.lua', + 'common/functions.lua', - 'client/modules/death.lua', - 'client/modules/scaleform.lua', - 'client/modules/streaming.lua', - - 'common/modules/math.lua', - 'common/modules/table.lua', - 'common/functions.lua' + 'client/modules/*.lua' } ui_page { @@ -64,10 +61,6 @@ files { 'html/fonts/pdown.ttf', 'html/fonts/bankgothic.ttf', - - 'html/img/accounts/bank.png', - 'html/img/accounts/black_money.png', - 'html/img/accounts/money.png' } dependencies { diff --git a/[core]/es_extended/html/css/app.css b/[core]/es_extended/html/css/app.css index 7c4c63f1..0bdbc908 100644 --- a/[core]/es_extended/html/css/app.css +++ b/[core]/es_extended/html/css/app.css @@ -1,88 +1,75 @@ @font-face { - font-family: 'Pricedown'; - src: url('../fonts/pdown.ttf') + font-family: 'Pricedown'; + src: url('../fonts/pdown.ttf'); } @font-face { - font-family: 'bankgothic'; - src: url('../fonts/bankgothic.ttf') + font-family: 'bankgothic'; + src: url('../fonts/bankgothic.ttf'); } html { - overflow: hidden; -} - -#hud { - opacity: 0.0; - position: absolute; - font-family: 'Pricedown'; - font-size: 35px; - color: white; - padding: 4px; - text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; - text-align: right; - top: 80; - right: 40; + overflow: hidden; } #inventory_notifications { - font-family: bankgothic; - position: absolute; - right: 40; - bottom: 40; - font-size: 2em; - font-weight: bold; - color: #FFF; - text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; + font-family: bankgothic; + position: absolute; + right: 40; + bottom: 40; + font-size: 2em; + font-weight: bold; + color: #fff; + text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; } .menu { - font-family: 'Open Sans', sans-serif; - min-width: 400px; - min-height: 250px; - color: #fff; - position: absolute; - left: 40; - top: 0; + font-family: 'Open Sans', sans-serif; + min-width: 400px; + min-height: 250px; + color: #fff; + position: absolute; + left: 40; + top: 0; } .menu .head { - font-family: 'Open Sans', sans-serif; - font-size: 28px; - padding: 10px; - background: #1A1A1A; - border-bottom: 3px solid #BC1635; - border-radius: 10px 10px 0 0; - -webkit-border-radius: 10px 10px 0 0; - -moz-border-radius: 10px 10px 0 0; - -o-border-radius: 10px 10px 0 0; - box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); - -webkit-box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); - -moz-box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); - -o-box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); - box-shadow: 1px 1px 10px 4px rgba(0, 0, 0, 0.4); + font-family: 'Open Sans', sans-serif; + font-size: 28px; + padding: 10px; + background: #1a1a1a; + border-bottom: 3px solid #bc1635; + border-radius: 10px 10px 0 0; + -webkit-border-radius: 10px 10px 0 0; + -moz-border-radius: 10px 10px 0 0; + -o-border-radius: 10px 10px 0 0; + box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); + -webkit-box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); + -moz-box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); + -o-box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); + box-shadow: 1px 1px 10px 4px rgba(0, 0, 0, 0.4); } .menu .head span { - font-family: 'Pricedown'; - font-size: 28px; - padding-left: 15px; - padding-top: 6px; + font-family: 'Pricedown'; + font-size: 28px; + padding-left: 15px; + padding-top: 6px; } .menu .menu-items .menu-item { - font-family: 'Open Sans', sans-serif; - font-size: 14px; - height: 40px; - display: block; - background-color: #f1f1f1; - box-shadow: inset 1px 0px 0px 1px #b8b8b8; - height: 32px; - line-height: 32px; - color: #3A3A3A; - text-align: center; + font-family: 'Open Sans', sans-serif; + font-size: 14px; + height: 40px; + display: block; + background-color: #f1f1f1; + box-shadow: inset 1px 0px 0px 1px #b8b8b8; + height: 32px; + line-height: 32px; + color: #3a3a3a; + text-align: center; } .menu .menu-items .menu-item.selected { - background-color: #ccc; + background-color: #ccc; } diff --git a/[core]/es_extended/html/img/accounts/bank.png b/[core]/es_extended/html/img/accounts/bank.png deleted file mode 100644 index eb36dc8e..00000000 Binary files a/[core]/es_extended/html/img/accounts/bank.png and /dev/null differ diff --git a/[core]/es_extended/html/img/accounts/black_money.png b/[core]/es_extended/html/img/accounts/black_money.png deleted file mode 100644 index a42f6aa5..00000000 Binary files a/[core]/es_extended/html/img/accounts/black_money.png and /dev/null differ diff --git a/[core]/es_extended/html/img/accounts/money.png b/[core]/es_extended/html/img/accounts/money.png deleted file mode 100644 index e05c91b0..00000000 Binary files a/[core]/es_extended/html/img/accounts/money.png and /dev/null differ diff --git a/[core]/es_extended/html/js/app.js b/[core]/es_extended/html/js/app.js index dce07feb..26fb67e4 100644 --- a/[core]/es_extended/html/js/app.js +++ b/[core]/es_extended/html/js/app.js @@ -1,59 +1,5 @@ (() => { - ESX = {}; - ESX.HUDElements = []; - - ESX.setHUDDisplay = function (opacity) { - $('#hud').css('opacity', opacity); - }; - - ESX.insertHUDElement = function (name, index, priority, html, data) { - ESX.HUDElements.push({ - name: name, - index: index, - priority: priority, - html: html, - data: data - }); - - ESX.HUDElements.sort((a, b) => { - return a.index - b.index || b.priority - a.priority; - }); - }; - - ESX.updateHUDElement = function (name, data) { - for (let i = 0; i < ESX.HUDElements.length; i++) { - if (ESX.HUDElements[i].name == name) { - ESX.HUDElements[i].data = data; - } - } - - ESX.refreshHUD(); - }; - - ESX.deleteHUDElement = function (name) { - for (let i = 0; i < ESX.HUDElements.length; i++) { - if (ESX.HUDElements[i].name == name) { - ESX.HUDElements.splice(i, 1); - } - } - - ESX.refreshHUD(); - }; - - ESX.resetHUDElements = function () { - ESX.HUDElements = []; - ESX.refreshHUD(); - }; - - ESX.refreshHUD = function () { - $('#hud').html(''); - - for (let i = 0; i < ESX.HUDElements.length; i++) { - let html = Mustache.render(ESX.HUDElements[i].html, ESX.HUDElements[i].data); - $('#hud').append(html); - } - }; ESX.inventoryNotification = function (add, label, count) { let notif = ''; @@ -79,35 +25,8 @@ }; window.onData = (data) => { - switch (data.action) { - case 'setHUDDisplay': { - ESX.setHUDDisplay(data.opacity); - break; - } - - case 'insertHUDElement': { - ESX.insertHUDElement(data.name, data.index, data.priority, data.html, data.data); - break; - } - - case 'updateHUDElement': { - ESX.updateHUDElement(data.name, data.data); - break; - } - - case 'deleteHUDElement': { - ESX.deleteHUDElement(data.name); - break; - } - - case 'resetHUDElements': { - ESX.resetHUDElements(); - break; - } - - case 'inventoryNotification': { - ESX.inventoryNotification(data.add, data.item, data.count); - } + if (data.action === 'inventoryNotification') { + ESX.inventoryNotification(data.add, data.item, data.count); } }; @@ -116,5 +35,4 @@ onData(event.data); }); }; - })(); diff --git a/[core]/es_extended/html/ui.html b/[core]/es_extended/html/ui.html index 653f41d8..86ad62be 100644 --- a/[core]/es_extended/html/ui.html +++ b/[core]/es_extended/html/ui.html @@ -1,14 +1,12 @@ - - - - - -
-
+ + + + +
- - - - - \ No newline at end of file + + + + + diff --git a/[core]/es_extended/server/commands.lua b/[core]/es_extended/server/commands.lua index 1ebe1754..b89ae36a 100644 --- a/[core]/es_extended/server/commands.lua +++ b/[core]/es_extended/server/commands.lua @@ -23,29 +23,56 @@ end, true, {help = TranslateCap('command_setjob'), validate = true, arguments = {name = 'grade', help = TranslateCap('command_setjob_grade'), type = 'number'} }}) +local upgrades = Config.SpawnVehMaxUpgrades and + { + plate = "ADMINCAR", + modEngine = 3, + modBrakes = 2, + modTransmission = 2, + modSuspension = 3, + modArmor = true, + windowTint = 1 + } or {} + ESX.RegisterCommand('car', 'admin', function(xPlayer, args, showError) - local GameBuild = tonumber(GetConvar("sv_enforceGameBuild", 1604)) - if not args.car then args.car = GameBuild >= 2699 and "draugur" or "prototipo" end + if not xPlayer then + return print('[^1ERROR^7] The xPlayer value is nil') + end + + local playerPed = GetPlayerPed(xPlayer.source) + local playerCoords = GetEntityCoords(playerPed) + local playerHeading = GetEntityHeading(playerPed) + local playerVehicle = GetVehiclePedIsIn(playerPed) + + if not args.car or type(args.car) ~= 'string' then + args.car = 'adder' + end + + if playerVehicle then + DeleteEntity(playerVehicle) + end + ESX.DiscordLogFields("UserActions", "/car Triggered", "pink", { {name = "Player", value = xPlayer.name, inline = true}, {name = "ID", value = xPlayer.source, inline = true}, - {name = "Vehicle", value = args.car, inline = true} + {name = "Vehicle", value = args.car, inline = true} }) - local upgrades = Config.MaxAdminVehicles and { - plate = "ADMINCAR", - modEngine = 3, - modBrakes = 2, - modTransmission = 2, - modSuspension = 3, - modArmor = true, - windowTint = 1, - } or {} - local coords = xPlayer.getCoords(true) - local PlayerPed = GetPlayerPed(xPlayer.source) - ESX.OneSync.SpawnVehicle(args.car, coords - vector3(0,0, 0.9), GetEntityHeading(PlayerPed), upgrades, function(networkId) - local vehicle = NetworkGetEntityFromNetworkId(networkId) - Wait(250) - TaskWarpPedIntoVehicle(PlayerPed, vehicle, -1) + + ESX.OneSync.SpawnVehicle(args.car, playerCoords, playerHeading, upgrades, function(networkId) + if networkId then + local vehicle = NetworkGetEntityFromNetworkId(networkId) + for i = 1, 20 do + Wait(0) + SetPedIntoVehicle(playerPed, vehicle, -1) + + if GetVehiclePedIsIn(playerPed, false) == vehicle then + break + end + end + if GetVehiclePedIsIn(playerPed, false) ~= vehicle then + print('[^1ERROR^7] The player could not be seated in the vehicle') + end + end end) end, false, {help = TranslateCap('command_car'), validate = false, arguments = { {name = 'car',validate = false, help = TranslateCap('command_car_car'), type = 'string'} diff --git a/[core]/es_extended/server/modules/actions.lua b/[core]/es_extended/server/modules/actions.lua new file mode 100644 index 00000000..7bd6c29d --- /dev/null +++ b/[core]/es_extended/server/modules/actions.lua @@ -0,0 +1,34 @@ +RegisterServerEvent('esx:playerPedChanged') +RegisterServerEvent('esx:playerJumping') +RegisterServerEvent('esx:enteringVehicle') +RegisterServerEvent('esx:enteringVehicleAborted') +RegisterServerEvent('esx:enteredVehicle') +RegisterServerEvent('esx:exitedVehicle') + +if Config.EnableDebug then + + AddEventHandler('esx:playerPedChanged', function(netId) + print('esx:playerPedChanged', source, netId) + end) + + AddEventHandler('esx:playerJumping', function() + print('esx:playerJumping', source) + end) + + AddEventHandler('esx:enteringVehicle', function(vehicle, plate, seat, netId) + print('esx:enteringVehicle', 'source', source, 'vehicle', vehicle, 'plate', plate, 'seat', seat, 'netId', netId) + end) + + AddEventHandler('esx:enteringVehicleAborted', function() + print('esx:enteringVehicleAborted', source) + end) + + AddEventHandler('esx:enteredVehicle', function(vehicle, plate, seat, displayName, netId) + print('esx:enteredVehicle', 'source', source, 'vehicle', vehicle, 'plate', plate, 'seat', seat, 'displayName', displayName, 'netId', netId) + end) + + AddEventHandler('esx:exitedVehicle', function(vehicle, plate, seat, displayName, netId) + print('esx:exitedVehicle', 'source', source, 'vehicle', vehicle, 'plate', plate, 'seat', seat, 'displayName', displayName, 'netId', netId) + end) + +end \ No newline at end of file diff --git a/[core]/es_extended/server/modules/npwd.lua b/[core]/es_extended/server/modules/npwd.lua new file mode 100644 index 00000000..3e0c1ffc --- /dev/null +++ b/[core]/es_extended/server/modules/npwd.lua @@ -0,0 +1,49 @@ +local npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil + +AddEventHandler('onServerResourceStart', function(resource) + if resource ~= 'npwd' then + return + end + + npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil + + for _, xPlayer in pairs(ESX.Players) do + npwd:newPlayer({ + source = xPlayer.source, + identifier = xPlayer.identifier, + firstname = xPlayer.get('firstName'), + lastname = xPlayer.get('lastName') + }) + end +end) + +AddEventHandler('onServerResourceStop', function(resource) + if resource == 'npwd' then + npwd = nil + end +end) + +AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) + if not npwd then + return + end + + if not xPlayer then + xPlayer = ESX.GetPlayerFromId(playerId) + end + + npwd:newPlayer({ + source = playerId, + identifier = xPlayer.identifier, + firstname = xPlayer.get('firstName'), + lastname = xPlayer.get('lastName') + }) +end) + +AddEventHandler('esx:playerLogout', function(playerId) + if not npwd then + return + end + + npwd:unloadPlayer(playerId) +end) \ No newline at end of file diff --git a/[core]/es_extended/server/onesync.lua b/[core]/es_extended/server/onesync.lua index 2ede0ff2..21e979c9 100644 --- a/[core]/es_extended/server/onesync.lua +++ b/[core]/es_extended/server/onesync.lua @@ -61,29 +61,29 @@ end ---@param heading number ---@param Properties table ---@param cb function - function ESX.OneSync.SpawnVehicle(model, coords, heading, Properties, cb) - local veh_model = type(model) == 'string' and joaat(model) or model - Properties = Properties or {} - local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z) - TriggerClientEvent("esx:requestModel", -1, model) - CreateThread(function() - local xPlayer = ESX.OneSync.GetClosestPlayer(vector, 300) - ESX.GetVehicleType(veh_model, xPlayer.id, function(Type) - if Type then - local SpawnedEntity = CreateVehicleServerSetter(veh_model, Type, vector, heading) - local NetworkId = NetworkGetNetworkIdFromEntity(SpawnedEntity) - while not DoesEntityExist(SpawnedEntity) do - Wait(100) - end - Properties.NetId = NetworkId - Entity(SpawnedEntity).state:set('VehicleProperties', Properties, true) - cb(NetworkId) - else - print(('[^1ERROR^7] Tried to spawn invalid vehicle - ^5%s^7!'):format(model)) +function ESX.OneSync.SpawnVehicle(model, coords, heading, properties, cb) + local vehicleModel = joaat(model) + local vehicleProperties = properties + + CreateThread(function() + local xPlayer = ESX.OneSync.GetClosestPlayer(coords, 300) + ESX.GetVehicleType(vehicleModel, xPlayer.id, function(vehicleType) + if vehicleType then + local createdVehicle = CreateVehicleServerSetter(vehicleModel, vehicleType, coords, heading) + if DoesEntityExist(createdVehicle) then + local networkId = NetworkGetNetworkIdFromEntity(createdVehicle) + vehicleProperties.NetId = networkId + Entity(createdVehicle).state:set('VehicleProperties', vehicleProperties, true) + cb(networkId) + else + print('[^1ERROR^7] Unfortunately, this vehicle has not spawned') end - end) + else + print(('[^1ERROR^7] Tried to spawn invalid vehicle - ^5%s^7!'):format(model)) + end end) - end + end) +end ---@param model number|string diff --git a/[core]/esx_multicharacter/client/main.lua b/[core]/esx_multicharacter/client/main.lua index de34e7c3..b0ee83de 100644 --- a/[core]/esx_multicharacter/client/main.lua +++ b/[core]/esx_multicharacter/client/main.lua @@ -35,7 +35,6 @@ if ESX.GetConfig().Multichar then RenderScriptCams(true, false, 1, true, true) SetCamCoord(cam, offset.x, offset.y, offset.z) PointCamAtCoord(cam, Config.Spawn.x, Config.Spawn.y, Config.Spawn.z + 1.3) - ESX.UI.HUD.SetDisplay(0.0) StartLoop() ShutdownLoadingScreen() ShutdownLoadingScreenNui()