local pickups = {}
Citizen.CreateThread(function()
while not Config.Multichar do
Citizen.Wait(0)
if NetworkIsPlayerActive(PlayerId()) then
exports.spawnmanager:setAutoSpawn(false)
DoScreenFadeOut(0)
TriggerServerEvent('esx:onPlayerJoined')
break
end
end
end)
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin)
ESX.PlayerLoaded = true
ESX.PlayerData = xPlayer
FreezeEntityPosition(PlayerPedId(), true)
if Config.Multichar then
Citizen.Wait(3000)
else
exports.spawnmanager:spawnPlayer({
x = ESX.PlayerData.coords.x,
y = ESX.PlayerData.coords.y,
z = ESX.PlayerData.coords.z + 0.25,
heading = ESX.PlayerData.coords.heading,
model = `mp_m_freemode_01`,
skipFade = false
}, function()
TriggerServerEvent('esx:onPlayerSpawn')
TriggerEvent('esx:onPlayerSpawn')
TriggerEvent('playerSpawned') -- compatibility with old scripts
TriggerEvent('esx:restoreLoadout')
if isNew then
if skin.sex == 0 then
TriggerEvent('skinchanger:loadDefaultModel', true)
else
TriggerEvent('skinchanger:loadDefaultModel', false)
end
elseif skin then TriggerEvent('skinchanger:loadSkin', skin) end
TriggerEvent('esx:loadingScreenOff')
ShutdownLoadingScreen()
ShutdownLoadingScreenNui()
FreezeEntityPosition(ESX.PlayerData.ped, false)
end)
end
while ESX.PlayerData.ped == nil do Citizen.Wait(20) end
-- enable PVP
if Config.EnablePVP then
SetCanAttackFriendly(ESX.PlayerData.ped, true, false)
NetworkSetFriendlyFireOption(true)
end
if Config.EnableHud then
for k,v in ipairs(ESX.PlayerData.accounts) do
local accountTpl = '<div> 360)then
heading = 0
end
SetEntityHeading(ESX.PlayerData.ped, heading)
end
if(IsControlPressed(1, 9))then
heading = heading - 1.5
if(heading < 0)then
heading = 360
end
SetEntityHeading(ESX.PlayerData.ped, heading)
end
if(IsControlPressed(1, 8))then
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 1.0, 0.0)
end
if(IsControlPressed(1, 32))then
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, -1.0, 0.0)
end
if(IsControlPressed(1, 27))then
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 0.0, 1.0)
end
if(IsControlPressed(1, 173))then
noclip_pos = GetOffsetFromEntityInWorldCoords(ESX.PlayerData.ped, 0.0, 0.0, -1.0)
end
else
Citizen.Wait(200)
end
end
end)
RegisterNetEvent("esx:killPlayer")
AddEventHandler("esx:killPlayer", function()
SetEntityHealth(ESX.PlayerData.ped, 0)
end)
RegisterNetEvent("esx:freezePlayer")
AddEventHandler("esx:freezePlayer", function(input)
local player = PlayerId()
if input == 'freeze' then
SetEntityCollision(ESX.PlayerData.ped, false)
FreezeEntityPosition(ESX.PlayerData.ped, true)
SetPlayerInvincible(player, true)
elseif input == 'unfreeze' then
SetEntityCollision(ESX.PlayerData.ped, true)
FreezeEntityPosition(ESX.PlayerData.ped, false)
SetPlayerInvincible(player, false)
end
end)
|