AddEventHandler('playerSpawned', function()
while not ESX.PlayerLoaded do
Citizen.Wait(1)
end
local playerPed = PlayerPedId()
-- Restore position
if ESX.PlayerData.lastPosition then
SetEntityCoords(playerPed, ESX.PlayerData.lastPosition.x, ESX.PlayerData.lastPosition.y, ESX.PlayerData.lastPosition.z+5)
Citizen.Wait(5000)
SetEntityCoords(playerPed, ESX.PlayerData.lastPosition.x, ESX.PlayerData.lastPosition.y, ESX.PlayerData.lastPosition.z+1)
end
TriggerEvent('esx:restoreLoadout') -- restore loadout
isLoadoutLoaded, isPlayerSpawned, isDead = true, true, false
if Config.EnablePvP then
SetCanAttackFriendly(playerPed, true, false)
NetworkSetFriendlyFireOption(true)
end
end)