mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 09:18:53 +00:00
Merge branch 'pr/1148' into legacy
This commit is contained in:
@@ -326,7 +326,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
|
||||
@@ -344,9 +345,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)
|
||||
@@ -359,7 +360,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()
|
||||
@@ -388,9 +390,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)
|
||||
|
||||
+23
-20
@@ -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)
|
||||
@@ -169,40 +166,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')
|
||||
@@ -225,11 +222,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
|
||||
@@ -348,6 +347,10 @@ if Config.EnableHud then
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('esx:loadingScreenOff', function()
|
||||
ESX.UI.HUD.SetDisplay(1.0)
|
||||
end)
|
||||
end
|
||||
|
||||
function StartServerSyncLoops()
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "legacy",
|
||||
"commit" : "1.1.10",
|
||||
"changelog": "function improvements; new import file and functions"
|
||||
"commit" : "1.2.0",
|
||||
"changelog": "Preserve compatibility for getting hashes; store player ped and death in PlayerData; resolve typos and outdated prints"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user