From 7e00e1212c5132cf93fafadea75698e9c05833c4 Mon Sep 17 00:00:00 2001 From: MiddleSkillz Date: Wed, 12 May 2021 09:51:10 -0600 Subject: [PATCH 1/2] tweak(client/functions): Updates to Events & Functions Updated some events and functions to preserve some backwards compatibility with 4head scripts. --- client/functions.lua | 14 ++++++++------ client/main.lua | 43 +++++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/client/functions.lua b/client/functions.lua index 8d7df142..3b86c1b3 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -325,7 +325,8 @@ ESX.Game.Teleport = function(entity, coords, cb) end end -ESX.Game.SpawnObject = function(model, coords, cb, networked, dynamic) +ESX.Game.SpawnObject = function(object, coords, cb, networked, dynamic) + local model = (type(object) == 'number' and model or GetHashKey(object)) local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z) networked = networked == nil and true or false dynamic = dynamic ~= nil and true or false @@ -343,9 +344,9 @@ ESX.Game.SpawnObject = function(model, coords, cb, networked, dynamic) end) end -ESX.Game.SpawnLocalObject = function(model, coords, cb) +ESX.Game.SpawnLocalObject = function(object, coords, cb) -- Why have 2 separate functions for this? Just call the other one with an extra param - ESX.Game.SpawnObject(model, coords, cb, false) + ESX.Game.SpawnObject(object, coords, cb, false) end ESX.Game.DeleteVehicle = function(vehicle) @@ -358,7 +359,8 @@ ESX.Game.DeleteObject = function(object) DeleteObject(object) end -ESX.Game.SpawnVehicle = function(model, coords, heading, cb, networked) +ESX.Game.SpawnVehicle = function(vehicle, coords, heading, cb, networked) + local model = (type(vehicle) == 'number' and vehicle or GetHashKey(vehicle)) local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z) networked = networked == nil and true or false CreateThread(function() @@ -385,9 +387,9 @@ ESX.Game.SpawnVehicle = function(model, coords, heading, cb, networked) end) end -ESX.Game.SpawnLocalVehicle = function(model, coords, heading, cb) +ESX.Game.SpawnLocalVehicle = function(vehicle, coords, heading, cb) -- Why have 2 separate functions for this? Just call the other one with an extra param - ESX.Game.SpawnVehicle(model, coords, heading, cb, false) + ESX.Game.SpawnVehicle(vehicle, coords, heading, cb, false) end ESX.Game.IsVehicleEmpty = function(vehicle) diff --git a/client/main.lua b/client/main.lua index 751b5c33..0084b2f4 100644 --- a/client/main.lua +++ b/client/main.lua @@ -66,9 +66,6 @@ AddEventHandler('esx:playerLoaded', function(playerData, isNew) TriggerEvent('skinchanger:loadSkin', skin) end) end - if Config.EnableHud then - ESX.UI.HUD.SetDisplay(1.0) - end TriggerEvent('esx:loadingScreenOff') -- compatibility with old scripts, will be removed soon. end) @@ -168,40 +165,40 @@ AddEventHandler('esx:removeInventoryItem', function(item, count, showNotificatio end) RegisterNetEvent('esx:addWeapon') -AddEventHandler('esx:addWeapon', function(weaponName, ammo) +AddEventHandler('esx:addWeapon', function(weapon, ammo) -- Removed PlayerPedId() from being stored in a variable, not needed -- when it's only being used once, also doing it in a few -- functions below this one - GiveWeaponToPed(PlayerPedId(), weaponName, ammo, false, false) + GiveWeaponToPed(PlayerPedId(), GetHashKey(weapon), ammo, false, false) end) RegisterNetEvent('esx:addWeaponComponent') -AddEventHandler('esx:addWeaponComponent', function(weaponName, weaponComponent) - local componentHash = ESX.GetWeaponComponent(weaponName, weaponComponent).hash - GiveWeaponComponentToPed(PlayerPedId(), weaponName, componentHash) +AddEventHandler('esx:addWeaponComponent', function(weapon, weaponComponent) + local componentHash = ESX.GetWeaponComponent(weapon, weaponComponent).hash + GiveWeaponComponentToPed(PlayerPedId(), GetHashKey(weapon), componentHash) end) RegisterNetEvent('esx:setWeaponAmmo') -AddEventHandler('esx:setWeaponAmmo', function(weaponName, weaponAmmo) - SetPedAmmo(PlayerPedId(), weaponName, weaponAmmo) +AddEventHandler('esx:setWeaponAmmo', function(weapon, weaponAmmo) + SetPedAmmo(PlayerPedId(), GetHashKey(weapon), weaponAmmo) end) RegisterNetEvent('esx:setWeaponTint') -AddEventHandler('esx:setWeaponTint', function(weaponName, weaponTintIndex) - SetPedWeaponTintIndex(PlayerPedId(), weaponName, weaponTintIndex) +AddEventHandler('esx:setWeaponTint', function(weapon, weaponTintIndex) + SetPedWeaponTintIndex(PlayerPedId(), GetHashKey(weapon), weaponTintIndex) end) RegisterNetEvent('esx:removeWeapon') -AddEventHandler('esx:removeWeapon', function(weaponName) +AddEventHandler('esx:removeWeapon', function(weapon) local playerPed = PlayerPedId() - RemoveWeaponFromPed(playerPed, weaponName) - SetPedAmmo(playerPed, weaponName, 0) + RemoveWeaponFromPed(playerPed, GetHashKey(weapon)) + SetPedAmmo(playerPed, GetHashKey(weapon), 0) end) RegisterNetEvent('esx:removeWeaponComponent') -AddEventHandler('esx:removeWeaponComponent', function(weaponName, weaponComponent) - local componentHash = ESX.GetWeaponComponent(weaponName, weaponComponent).hash - RemoveWeaponComponentFromPed(PlayerPedId(), weaponName, componentHash) +AddEventHandler('esx:removeWeaponComponent', function(weapon, weaponComponent) + local componentHash = ESX.GetWeaponComponent(weapon, weaponComponent).hash + RemoveWeaponComponentFromPed(PlayerPedId(), GetHashKey(weapon), componentHash) end) RegisterNetEvent('esx:teleport') @@ -224,11 +221,13 @@ end) RegisterNetEvent('esx:spawnVehicle') AddEventHandler('esx:spawnVehicle', function(vehicle) - if IsModelInCdimage(vehicle) then + local model = (type(vehicle) == 'number' and vehicle or GetHashKey(vehicle)) + + if IsModelInCdimage(model) then local playerPed = PlayerPedId() local playerCoords, playerHeading = GetEntityCoords(playerPed), GetEntityHeading(playerPed) - ESX.Game.SpawnVehicle(vehicle, playerCoords, playerHeading, function(vehicle) + ESX.Game.SpawnVehicle(model, playerCoords, playerHeading, function(vehicle) TaskWarpPedIntoVehicle(playerPed, vehicle, -1) end) else @@ -347,6 +346,10 @@ if Config.EnableHud then end end end) + + AddEventHandler('esx:loadingScreenOff', function() + ESX.UI.HUD.SetDisplay(1.0) + end) end function StartServerSyncLoops() From 0a706097415ab886e775bf1eb8b437e5ea51b2ce Mon Sep 17 00:00:00 2001 From: MiddleSkillz Date: Wed, 12 May 2021 11:32:31 -0600 Subject: [PATCH 2/2] fix(version): Forgot to Update Version --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index 3ff5d1a3..afbe9ba9 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { "version": "legacy", - "commit" : "1.1.9", + "commit" : "1.2.0", "changelog": "Fix esx_identity" }