mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
Merge pull request #1155 from thelindat/legacy
fix(legacy): Resolve version conflict (#1148); tweak event handler in imports; general tweaks
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)
|
||||
|
||||
+82
-82
@@ -13,13 +13,14 @@ RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(playerData, isNew)
|
||||
ESX.PlayerLoaded = true
|
||||
ESX.PlayerData = playerData
|
||||
ESX.PlayerData.ped = ESX.PlayerData.ped
|
||||
|
||||
|
||||
FreezeEntityPosition(PlayerPedId(), true)
|
||||
FreezeEntityPosition(ESX.PlayerData.ped, true)
|
||||
|
||||
-- enable PVP
|
||||
if Config.EnablePVP then
|
||||
SetCanAttackFriendly(PlayerPedId(), true, false)
|
||||
SetCanAttackFriendly(ESX.PlayerData.ped, true, false)
|
||||
NetworkSetFriendlyFireOption(true)
|
||||
end
|
||||
|
||||
@@ -56,28 +57,28 @@ AddEventHandler('esx:playerLoaded', function(playerData, isNew)
|
||||
Citizen.Wait(4000)
|
||||
ShutdownLoadingScreen()
|
||||
ShutdownLoadingScreenNui()
|
||||
FreezeEntityPosition(PlayerPedId(), false)
|
||||
FreezeEntityPosition(ESX.PlayerData.ped, false)
|
||||
StartServerSyncLoops()
|
||||
end)
|
||||
if isNew then
|
||||
TriggerEvent('esx_identity:showRegisterIdentity')
|
||||
else
|
||||
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
|
||||
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)
|
||||
|
||||
RegisterNetEvent('esx:setMaxWeight')
|
||||
AddEventHandler('esx:setMaxWeight', function(newMaxWeight) ESX.PlayerData.maxWeight = newMaxWeight end)
|
||||
|
||||
AddEventHandler('esx:onPlayerSpawn', function() isDead = false end)
|
||||
AddEventHandler('esx:onPlayerDeath', function() isDead = true end)
|
||||
AddEventHandler('esx:onPlayerSpawn', function()
|
||||
local playerPed = PlayerPedId()
|
||||
if ESX.PlayerData.ped ~= playerPed then ESX.SetPlayerData('ped', playerPed) end
|
||||
ESX.SetPlayerData('dead', false)
|
||||
isDead = false
|
||||
end)
|
||||
|
||||
AddEventHandler('esx:onPlayerDeath', function()
|
||||
local playerPed = PlayerPedId()
|
||||
if ESX.PlayerData.ped ~= playerPed then ESX.SetPlayerData('ped', playerPed) end
|
||||
ESX.SetPlayerData('dead', true)
|
||||
isDead = true
|
||||
end)
|
||||
|
||||
AddEventHandler('skinchanger:modelLoaded', function()
|
||||
while not ESX.PlayerLoaded do
|
||||
@@ -89,25 +90,26 @@ end)
|
||||
|
||||
AddEventHandler('esx:restoreLoadout', function()
|
||||
local playerPed = PlayerPedId()
|
||||
if ESX.PlayerData.ped ~= playerPed then ESX.SetPlayerData('ped', playerPed) end
|
||||
local ammoTypes = {}
|
||||
RemoveAllPedWeapons(playerPed, true)
|
||||
RemoveAllPedWeapons(ESX.PlayerData.ped, true)
|
||||
|
||||
for k,v in ipairs(ESX.PlayerData.loadout) do
|
||||
local weaponName = v.name
|
||||
local weaponHash = GetHashKey(weaponName)
|
||||
|
||||
GiveWeaponToPed(playerPed, weaponHash, 0, false, false)
|
||||
SetPedWeaponTintIndex(playerPed, weaponHash, v.tintIndex)
|
||||
GiveWeaponToPed(ESX.PlayerData.ped, weaponHash, 0, false, false)
|
||||
SetPedWeaponTintIndex(ESX.PlayerData.ped, weaponHash, v.tintIndex)
|
||||
|
||||
local ammoType = GetPedAmmoTypeFromWeapon(playerPed, weaponHash)
|
||||
local ammoType = GetPedAmmoTypeFromWeapon(ESX.PlayerData.ped, weaponHash)
|
||||
|
||||
for k2,v2 in ipairs(v.components) do
|
||||
local componentHash = ESX.GetWeaponComponent(weaponName, v2).hash
|
||||
GiveWeaponComponentToPed(playerPed, weaponHash, componentHash)
|
||||
GiveWeaponComponentToPed(ESX.PlayerData.ped, weaponHash, componentHash)
|
||||
end
|
||||
|
||||
if not ammoTypes[ammoType] then
|
||||
AddAmmoToPed(playerPed, weaponHash, v.ammo)
|
||||
AddAmmoToPed(ESX.PlayerData.ped, weaponHash, v.ammo)
|
||||
ammoTypes[ammoType] = true
|
||||
end
|
||||
end
|
||||
@@ -169,47 +171,45 @@ AddEventHandler('esx:removeInventoryItem', function(item, count, showNotificatio
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:addWeapon')
|
||||
AddEventHandler('esx:addWeapon', function(weaponName, ammo)
|
||||
-- Removed PlayerPedId() from being stored in a variable, not needed
|
||||
AddEventHandler('esx:addWeapon', function(weapon, ammo)
|
||||
-- Removed ESX.PlayerData.ped 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(ESX.PlayerData.ped, 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(ESX.PlayerData.ped, GetHashKey(weapon), componentHash)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:setWeaponAmmo')
|
||||
AddEventHandler('esx:setWeaponAmmo', function(weaponName, weaponAmmo)
|
||||
SetPedAmmo(PlayerPedId(), weaponName, weaponAmmo)
|
||||
AddEventHandler('esx:setWeaponAmmo', function(weapon, weaponAmmo)
|
||||
SetPedAmmo(ESX.PlayerData.ped, GetHashKey(weapon), weaponAmmo)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:setWeaponTint')
|
||||
AddEventHandler('esx:setWeaponTint', function(weaponName, weaponTintIndex)
|
||||
SetPedWeaponTintIndex(PlayerPedId(), weaponName, weaponTintIndex)
|
||||
AddEventHandler('esx:setWeaponTint', function(weapon, weaponTintIndex)
|
||||
SetPedWeaponTintIndex(ESX.PlayerData.ped, GetHashKey(weapon), weaponTintIndex)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:removeWeapon')
|
||||
AddEventHandler('esx:removeWeapon', function(weaponName)
|
||||
local playerPed = PlayerPedId()
|
||||
RemoveWeaponFromPed(playerPed, weaponName)
|
||||
SetPedAmmo(playerPed, weaponName, 0)
|
||||
AddEventHandler('esx:removeWeapon', function(weapon)
|
||||
local playerPed = ESX.PlayerData.ped
|
||||
RemoveWeaponFromPed(ESX.PlayerData.ped, GetHashKey(weapon))
|
||||
SetPedAmmo(ESX.PlayerData.ped, 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(ESX.PlayerData.ped, GetHashKey(weapon), componentHash)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:teleport')
|
||||
AddEventHandler('esx:teleport', function(coords)
|
||||
-- The coords x, y and z were having 0.0 added to them here to make them floats
|
||||
-- Since we are forcing vectors in the teleport function now we don't need to do it
|
||||
ESX.Game.Teleport(PlayerPedId(), coords)
|
||||
ESX.Game.Teleport(ESX.PlayerData.ped, coords)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:setJob')
|
||||
@@ -220,17 +220,18 @@ AddEventHandler('esx:setJob', function(Job)
|
||||
grade_label = Job.grade_label
|
||||
})
|
||||
end
|
||||
ESX.SetPlayerData("job", Job)
|
||||
ESX.SetPlayerData('job', Job)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:spawnVehicle')
|
||||
AddEventHandler('esx:spawnVehicle', function(vehicle)
|
||||
if IsModelInCdimage(vehicle) then
|
||||
local playerPed = PlayerPedId()
|
||||
local playerCoords, playerHeading = GetEntityCoords(playerPed), GetEntityHeading(playerPed)
|
||||
local model = (type(vehicle) == 'number' and vehicle or GetHashKey(vehicle))
|
||||
|
||||
ESX.Game.SpawnVehicle(vehicle, playerCoords, playerHeading, function(vehicle)
|
||||
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
|
||||
if IsModelInCdimage(model) then
|
||||
local playerCoords, playerHeading = GetEntityCoords(ESX.PlayerData.ped), GetEntityHeading(ESX.PlayerData.ped)
|
||||
|
||||
ESX.Game.SpawnVehicle(model, playerCoords, playerHeading, function(vehicle)
|
||||
TaskWarpPedIntoVehicle(ESX.PlayerData.ped, vehicle, -1)
|
||||
end)
|
||||
else
|
||||
TriggerEvent('chat:addMessage', { args = { '^1SYSTEM', 'Invalid vehicle model.' } })
|
||||
@@ -295,11 +296,9 @@ end)
|
||||
|
||||
RegisterNetEvent('esx:deleteVehicle')
|
||||
AddEventHandler('esx:deleteVehicle', function(radius)
|
||||
local playerPed = PlayerPedId()
|
||||
|
||||
if radius and tonumber(radius) then
|
||||
radius = tonumber(radius) + 0.01
|
||||
local vehicles = ESX.Game.GetVehiclesInArea(GetEntityCoords(playerPed), radius)
|
||||
local vehicles = ESX.Game.GetVehiclesInArea(GetEntityCoords(ESX.PlayerData.ped), radius)
|
||||
|
||||
for k,entity in ipairs(vehicles) do
|
||||
local attempt = 0
|
||||
@@ -317,8 +316,8 @@ AddEventHandler('esx:deleteVehicle', function(radius)
|
||||
else
|
||||
local vehicle, attempt = ESX.Game.GetVehicleInDirection(), 0
|
||||
|
||||
if IsPedInAnyVehicle(playerPed, true) then
|
||||
vehicle = GetVehiclePedIsIn(playerPed, false)
|
||||
if IsPedInAnyVehicle(ESX.PlayerData.ped, true) then
|
||||
vehicle = GetVehiclePedIsIn(ESX.PlayerData.ped, false)
|
||||
end
|
||||
|
||||
while not NetworkHasControlOfEntity(vehicle) and attempt < 100 and DoesEntityExist(vehicle) do
|
||||
@@ -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()
|
||||
@@ -357,15 +360,14 @@ function StartServerSyncLoops()
|
||||
Citizen.Wait(1000)
|
||||
|
||||
local letSleep = true
|
||||
local playerPed = PlayerPedId()
|
||||
|
||||
if IsPedArmed(playerPed, 4) then
|
||||
if IsPedShooting(playerPed) then
|
||||
local _,weaponHash = GetCurrentPedWeapon(playerPed, true)
|
||||
if IsPedArmed(ESX.PlayerData.ped, 4) then
|
||||
if IsPedShooting(ESX.PlayerData.ped) then
|
||||
local _,weaponHash = GetCurrentPedWeapon(ESX.PlayerData.ped, true)
|
||||
local weapon = ESX.GetWeaponFromHash(weaponHash)
|
||||
|
||||
if weapon then
|
||||
local ammoCount = GetAmmoInPedWeapon(playerPed, weaponHash)
|
||||
local ammoCount = GetAmmoInPedWeapon(ESX.PlayerData.ped, weaponHash)
|
||||
TriggerServerEvent('esx:updateWeaponAmmo', weapon.name, ammoCount)
|
||||
end
|
||||
end
|
||||
@@ -383,14 +385,15 @@ function StartServerSyncLoops()
|
||||
while ESX.PlayerLoaded do
|
||||
Citizen.Wait(1500)
|
||||
local playerPed = PlayerPedId()
|
||||
if ESX.PlayerData.ped ~= playerPed then ESX.SetPlayerData('ped', playerPed) end
|
||||
|
||||
if DoesEntityExist(playerPed) then
|
||||
local playerCoords = GetEntityCoords(playerPed)
|
||||
if DoesEntityExist(ESX.PlayerData.ped) then
|
||||
local playerCoords = GetEntityCoords(ESX.PlayerData.ped)
|
||||
local distance = #(playerCoords - previousCoords)
|
||||
|
||||
if distance > 1 then
|
||||
previousCoords = playerCoords
|
||||
local playerHeading = ESX.Math.Round(GetEntityHeading(playerPed), 1)
|
||||
local playerHeading = ESX.Math.Round(GetEntityHeading(ESX.PlayerData.ped), 1)
|
||||
local formattedCoords = {x = ESX.Math.Round(playerCoords.x, 1), y = ESX.Math.Round(playerCoords.y, 1), z = ESX.Math.Round(playerCoords.z, 1), heading = playerHeading}
|
||||
TriggerServerEvent('esx:updateCoords', formattedCoords)
|
||||
end
|
||||
@@ -418,8 +421,7 @@ end
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
local playerPed = PlayerPedId()
|
||||
local playerCoords, letSleep = GetEntityCoords(playerPed), true
|
||||
local playerCoords, letSleep = GetEntityCoords(ESX.PlayerData.ped), true
|
||||
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer(playerCoords)
|
||||
|
||||
for pickupId,pickup in pairs(pickups) do
|
||||
@@ -431,12 +433,12 @@ Citizen.CreateThread(function()
|
||||
|
||||
if distance < 1 then
|
||||
if IsControlJustReleased(0, 38) then
|
||||
if IsPedOnFoot(playerPed) and (closestDistance == -1 or closestDistance > 3) and not pickup.inRange then
|
||||
if IsPedOnFoot(ESX.PlayerData.ped) and (closestDistance == -1 or closestDistance > 3) and not pickup.inRange then
|
||||
pickup.inRange = true
|
||||
|
||||
local dict, anim = 'weapons@first_person@aim_rng@generic@projectile@sticky_bomb@', 'plant_floor'
|
||||
ESX.Streaming.RequestAnimDict(dict)
|
||||
TaskPlayAnim(playerPed, dict, anim, 8.0, 1.0, 1000, 16, 0.0, false, false, false)
|
||||
TaskPlayAnim(ESX.PlayerData.ped, dict, anim, 8.0, 1.0, 1000, 16, 0.0, false, false, false)
|
||||
Citizen.Wait(1000)
|
||||
|
||||
TriggerServerEvent('esx:onPickup', pickupId)
|
||||
@@ -472,12 +474,12 @@ AddEventHandler("esx:tpm", function()
|
||||
local waypointCoords = GetBlipInfoIdCoord(WaypointHandle)
|
||||
|
||||
for height = 1, 1000 do
|
||||
SetPedCoordsKeepVehicle(PlayerPedId(), waypointCoords["x"], waypointCoords["y"], height + 0.0)
|
||||
SetPedCoordsKeepVehicle(ESX.PlayerData.ped, waypointCoords["x"], waypointCoords["y"], height + 0.0)
|
||||
|
||||
local foundGround, zPos = GetGroundZFor_3dCoord(waypointCoords["x"], waypointCoords["y"], height + 0.0)
|
||||
|
||||
if foundGround then
|
||||
SetPedCoordsKeepVehicle(PlayerPedId(), waypointCoords["x"], waypointCoords["y"], height + 0.0)
|
||||
SetPedCoordsKeepVehicle(ESX.PlayerData.ped, waypointCoords["x"], waypointCoords["y"], height + 0.0)
|
||||
|
||||
break
|
||||
end
|
||||
@@ -494,11 +496,10 @@ local noclip = false
|
||||
RegisterNetEvent("esx:noclip")
|
||||
AddEventHandler("esx:noclip", function(input)
|
||||
local player = PlayerId()
|
||||
local ped = PlayerPedId
|
||||
|
||||
local msg = "disabled"
|
||||
if(noclip == false)then
|
||||
noclip_pos = GetEntityCoords(PlayerPedId(), false)
|
||||
noclip_pos = GetEntityCoords(ESX.PlayerData.ped, false)
|
||||
end
|
||||
|
||||
noclip = not noclip
|
||||
@@ -516,7 +517,7 @@ AddEventHandler("esx:noclip", function(input)
|
||||
Citizen.Wait(0)
|
||||
|
||||
if(noclip)then
|
||||
SetEntityCoordsNoOffset(PlayerPedId(), noclip_pos.x, noclip_pos.y, noclip_pos.z, 0, 0, 0)
|
||||
SetEntityCoordsNoOffset(ESX.PlayerData.ped, noclip_pos.x, noclip_pos.y, noclip_pos.z, 0, 0, 0)
|
||||
|
||||
if(IsControlPressed(1, 34))then
|
||||
heading = heading + 1.5
|
||||
@@ -524,7 +525,7 @@ AddEventHandler("esx:noclip", function(input)
|
||||
heading = 0
|
||||
end
|
||||
|
||||
SetEntityHeading(PlayerPedId(), heading)
|
||||
SetEntityHeading(ESX.PlayerData.ped, heading)
|
||||
end
|
||||
|
||||
if(IsControlPressed(1, 9))then
|
||||
@@ -533,23 +534,23 @@ AddEventHandler("esx:noclip", function(input)
|
||||
heading = 360
|
||||
end
|
||||
|
||||
SetEntityHeading(PlayerPedId(), heading)
|
||||
SetEntityHeading(ESX.PlayerData.ped, heading)
|
||||
end
|
||||
|
||||
if(IsControlPressed(1, 8))then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 1.0, 0.0)
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 1.0, 0.0)
|
||||
end
|
||||
|
||||
if(IsControlPressed(1, 32))then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, -1.0, 0.0)
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, -1.0, 0.0)
|
||||
end
|
||||
|
||||
if(IsControlPressed(1, 27))then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 0.0, 1.0)
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 0.0, 1.0)
|
||||
end
|
||||
|
||||
if(IsControlPressed(1, 173))then
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 0.0, -1.0)
|
||||
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 0.0, -1.0)
|
||||
end
|
||||
else
|
||||
Citizen.Wait(200)
|
||||
@@ -559,20 +560,19 @@ end)
|
||||
|
||||
RegisterNetEvent("esx:killPlayer")
|
||||
AddEventHandler("esx:killPlayer", function()
|
||||
SetEntityHealth(PlayerPedId(), 0)
|
||||
SetEntityHealth(ESX.PlayerData.ped, 0)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:freezePlayer")
|
||||
AddEventHandler("esx:freezePlayer", function(input)
|
||||
local player = PlayerId()
|
||||
local ped = PlayerPedId()
|
||||
if input == 'freeze' then
|
||||
SetEntityCollision(ped, false)
|
||||
FreezeEntityPosition(ped, true)
|
||||
SetEntityCollision(ESX.PlayerData.ped, false)
|
||||
FreezeEntityPosition(ESX.PlayerData.ped, true)
|
||||
SetPlayerInvincible(player, true)
|
||||
elseif input == 'unfreeze' then
|
||||
SetEntityCollision(ped, true)
|
||||
FreezeEntityPosition(ped, false)
|
||||
SetEntityCollision(ESX.PlayerData.ped, true)
|
||||
FreezeEntityPosition(ESX.PlayerData.ped, false)
|
||||
SetPlayerInvincible(player, false)
|
||||
end
|
||||
end)
|
||||
|
||||
+8
-6
@@ -1,8 +1,10 @@
|
||||
ESX = exports['es_extended']:getSharedObject()
|
||||
|
||||
AddEventHandler('esx:setPlayerData', function(key, val)
|
||||
if GetInvokingResource() == 'es_extended' then
|
||||
ESX.PlayerData[key] = val
|
||||
if OnPlayerData ~= nil then OnPlayerData(key, val) end
|
||||
end
|
||||
end)
|
||||
if not IsDuplicityVersion() then -- Only register this event for the client
|
||||
AddEventHandler('esx:setPlayerData', function(key, val)
|
||||
if GetInvokingResource() == 'es_extended' then
|
||||
ESX.PlayerData[key] = val
|
||||
if OnPlayerData ~= nil then OnPlayerData(key, val) end
|
||||
end
|
||||
end)
|
||||
end
|
||||
+1
-1
@@ -168,7 +168,7 @@ ESX.RegisterCommand('sv_restart', "admin", function(xPlayer, args, showError)
|
||||
for _, playerId in ipairs(GetPlayers()) do
|
||||
DropPlayer(playerId, "Server Restart")
|
||||
end
|
||||
print('[^5es_extended^0] ^2[INFO] ^1 Server Restarting, Please Wait :)')
|
||||
print('^2[INFO] ^1 Server Restarting, Please Wait :)')
|
||||
crash = true
|
||||
while crash do
|
||||
end
|
||||
|
||||
+6
-4
@@ -41,26 +41,28 @@ MySQL.ready(function()
|
||||
if ESX.Jobs[v.job_name] then
|
||||
ESX.Jobs[v.job_name].grades[tostring(v.grade)] = v
|
||||
else
|
||||
print(('[^5es_extended^0] [^3WARNING^7] Ignoring job grades for ^5"%s"^0 due to missing job'):format(v.job_name))
|
||||
print(('[^3WARNING^7] Ignoring job grades for ^5"%s"^0 due to missing job'):format(v.job_name))
|
||||
end
|
||||
end
|
||||
|
||||
for k2,v2 in pairs(ESX.Jobs) do
|
||||
if ESX.Table.SizeOf(v2.grades) == 0 then
|
||||
ESX.Jobs[v2.name] = nil
|
||||
print(('[^5es_extended^0] [^3WARNING^7] Ignoring job ^5"%s"^0due to no job grades found'):format(v2.name))
|
||||
print(('[^3WARNING^7] Ignoring job ^5"%s"^0due to no job grades found'):format(v2.name))
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
print('[^5es_extended^0] [^2INFO^7] ESX ^5Legacy^0 initialized')
|
||||
print('[^2INFO^7] ESX ^5Legacy^0 initialized')
|
||||
ESX.StartDBSync()
|
||||
ESX.StartPayCheck()
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx:clientLog')
|
||||
AddEventHandler('esx:clientLog', function(msg)
|
||||
if Config.EnableDebug then
|
||||
print(('[^5es_extended^0] [^2TRACE^7] %s^7'):format(msg))
|
||||
print(('[^2TRACE^7] %s^7'):format(msg))
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
ESX.Trace = function(msg)
|
||||
if Config.EnableDebug then
|
||||
print(('[^5es_extended^0] [^2TRACE^7] %s^7'):format(msg))
|
||||
print(('[^2TRACE^7] %s^7'):format(msg))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ ESX.RegisterCommand = function(name, group, cb, allowConsole, suggestion)
|
||||
end
|
||||
|
||||
if ESX.RegisteredCommands[name] then
|
||||
print(('[^5es_extended^0] [^3WARNING^7] Command ^5"%s" already registered, overriding command'):format(name))
|
||||
print(('[^3WARNING^7] Command ^5"%s" already registered, overriding command'):format(name))
|
||||
|
||||
if ESX.RegisteredCommands[name].suggestion then
|
||||
TriggerClientEvent('chat:removeSuggestion', -1, ('/%s'):format(name))
|
||||
@@ -50,7 +50,7 @@ ESX.RegisterCommand = function(name, group, cb, allowConsole, suggestion)
|
||||
local command = ESX.RegisteredCommands[name]
|
||||
|
||||
if not command.allowConsole and playerId == 0 then
|
||||
print(('[^5es_extended^0] [^3WARNING^7] ^5%s'):format(_U('commanderror_console')))
|
||||
print(('[^3WARNING^7] ^5%s'):format(_U('commanderror_console')))
|
||||
else
|
||||
local xPlayer, error = ESX.GetPlayerFromId(playerId), nil
|
||||
|
||||
@@ -122,14 +122,14 @@ ESX.RegisterCommand = function(name, group, cb, allowConsole, suggestion)
|
||||
|
||||
if error then
|
||||
if playerId == 0 then
|
||||
print(('[^5es_extended^0] [^3WARNING^7] %s^7'):format(error))
|
||||
print(('[^3WARNING^7] %s^7'):format(error))
|
||||
else
|
||||
xPlayer.triggerEvent('chat:addMessage', {args = {'^1SYSTEM', error}})
|
||||
end
|
||||
else
|
||||
cb(xPlayer or false, args, function(msg)
|
||||
if playerId == 0 then
|
||||
print(('[^5es_extended^0] [^3WARNING^7] %s^7'):format(msg))
|
||||
print(('[^3WARNING^7] %s^7'):format(msg))
|
||||
else
|
||||
xPlayer.triggerEvent('chat:addMessage', {args = {'^1SYSTEM', msg}})
|
||||
end
|
||||
@@ -159,7 +159,7 @@ ESX.TriggerServerCallback = function(name, requestId, source, cb, ...)
|
||||
if ESX.ServerCallbacks[name] then
|
||||
ESX.ServerCallbacks[name](source, cb, ...)
|
||||
else
|
||||
print(('[^5es_extended^0] [^3WARNING^7] Server callback ^5"%s"^0 does not exist. ^1Please Check The Server File for Errors!'):format(name))
|
||||
print(('[^3WARNING^7] Server callback ^5"%s"^0 does not exist. ^1Please Check The Server File for Errors!'):format(name))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -182,7 +182,7 @@ ESX.SavePlayer = function(xPlayer, cb)
|
||||
end)
|
||||
|
||||
Async.parallel(asyncTasks, function(results)
|
||||
print(('[^5es_extended^0] [^2INFO^7] Saved player ^5"%s^7"'):format(xPlayer.getName()))
|
||||
print(('[^2INFO^7] Saved player ^5"%s^7"'):format(xPlayer.getName()))
|
||||
|
||||
if cb then
|
||||
cb()
|
||||
@@ -201,7 +201,7 @@ ESX.SavePlayers = function(cb)
|
||||
end
|
||||
|
||||
Async.parallelLimit(asyncTasks, 8, function(results)
|
||||
print(('[^5es_extended^0] [^2INFO^7] Saved ^5%s^0 player(s)'):format(#xPlayers))
|
||||
print(('[^2INFO^7] Saved ^5%s^0 player(s)'):format(#xPlayers))
|
||||
if cb then
|
||||
cb()
|
||||
end
|
||||
|
||||
+6
-10
@@ -30,7 +30,7 @@ function onPlayerJoined(playerId)
|
||||
end
|
||||
|
||||
if IsPlayerAceAllowed(playerId, "command") then
|
||||
print(('[^5es_extended^0] ^2[INFO] ^0 Player ^5%s ^0Has been granted admin permissions via ^5Ace Perms.^7'):format(playerId))
|
||||
print(('^2[INFO] ^0 Player ^5%s ^0Has been granted admin permissions via ^5Ace Perms.^7'):format(playerId))
|
||||
defaultGroup = "admin"
|
||||
else
|
||||
defaultGroup = "user"
|
||||
@@ -108,7 +108,7 @@ function loadESXPlayer(identifier, playerId, isNew)
|
||||
if ESX.DoesJobExist(job, grade) then
|
||||
jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade]
|
||||
else
|
||||
print(('[^5es_extended^0] [^3WARNING^7] Ignoring invalid job for %s [job: %s, grade: %s]'):format(identifier, job, grade))
|
||||
print(('[^3WARNING^7] Ignoring invalid job for %s [job: %s, grade: %s]'):format(identifier, job, grade))
|
||||
job, grade = 'unemployed', '0'
|
||||
jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade]
|
||||
end
|
||||
@@ -138,7 +138,7 @@ function loadESXPlayer(identifier, playerId, isNew)
|
||||
if item then
|
||||
foundItems[name] = count
|
||||
else
|
||||
print(('[^5es_extended^0] [^3WARNING^7] Ignoring invalid item "%s" for "%s"'):format(name, identifier))
|
||||
print(('[^3WARNING^7] Ignoring invalid item "%s" for "%s"'):format(name, identifier))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -199,7 +199,7 @@ function loadESXPlayer(identifier, playerId, isNew)
|
||||
if result[1].position and result[1].position ~= '' then
|
||||
userData.coords = json.decode(result[1].position)
|
||||
else
|
||||
print('[^5es_extended^0] [^3WARNING^7] Column ^5"position"^0 in ^5"users"^0 table is missing required default value. Using backup coords, fix your database.')
|
||||
print('[^3WARNING^7] Column ^5"position"^0 in ^5"users"^0 table is missing required default value. Using backup coords, fix your database.')
|
||||
userData.coords = {x = -269.4, y = -955.3, z = 31.2, heading = 205.8}
|
||||
end
|
||||
|
||||
@@ -225,7 +225,7 @@ function loadESXPlayer(identifier, playerId, isNew)
|
||||
|
||||
xPlayer.triggerEvent('esx:createMissingPickups', ESX.Pickups)
|
||||
xPlayer.triggerEvent('esx:registerSuggestions', ESX.RegisteredCommands)
|
||||
print(('[^5es_extended^0] [^2INFO^0] Player ^5"%s" ^0has connected to the server. ID: ^5%s^7'):format(xPlayer.getName(), playerId))
|
||||
print(('[^2INFO^0] Player ^5"%s" ^0has connected to the server. ID: ^5%s^7'):format(xPlayer.getName(), playerId))
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -568,7 +568,7 @@ Citizen.CreateThread(
|
||||
)
|
||||
end
|
||||
else
|
||||
print('[^5es_extended^0] [^1ERROR^0] Es-Extended unable to check version!')
|
||||
print('[^1ERROR^0] Es-Extended unable to check version!')
|
||||
end
|
||||
end,
|
||||
'GET'
|
||||
@@ -576,7 +576,3 @@ Citizen.CreateThread(
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
ESX.StartDBSync()
|
||||
ESX.StartPayCheck()
|
||||
|
||||
+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