diff --git a/client/main.lua b/client/main.lua index 27ad5e95..9c8c8c91 100644 --- a/client/main.lua +++ b/client/main.lua @@ -10,38 +10,24 @@ end) RegisterNetEvent('esx:playerLoaded') -AddEventHandler('esx:playerLoaded', function(playerData) +AddEventHandler('esx:playerLoaded', function(playerData, isNew) ESX.PlayerLoaded = true ESX.PlayerData = playerData - if GetEntityModel(PlayerPedId()) == GetHashKey('PLAYER_ZERO') then - local defaultModel = GetHashKey('a_m_y_stbla_02') - RequestModel(defaultModel) - - while not HasModelLoaded(defaultModel) do - Citizen.Wait(10) - end - - SetPlayerModel(PlayerId(), defaultModel) - SetPedDefaultComponentVariation(PlayerPedId()) - SetPedRandomComponentVariation(PlayerPedId(), true) - SetModelAsNoLongerNeeded(defaultModel) - end - - FreezeEntityPosition(PlayerPedId(), true) - + -- enable PVP if Config.EnablePVP then SetCanAttackFriendly(PlayerPedId(), true, false) NetworkSetFriendlyFireOption(true) - end + end + -- disable wanted level -if not Config.EnableWantedLevel then - ClearPlayerWantedLevel(PlayerId()) - SetMaxWantedLevel(0) -end + if not Config.EnableWantedLevel then + ClearPlayerWantedLevel(PlayerId()) + SetMaxWantedLevel(0) + end if Config.EnableHud then for k,v in ipairs(playerData.accounts) do @@ -61,11 +47,13 @@ end }) end - ESX.Game.Teleport(PlayerPedId(), { + exports.spawnmanager:spawnPlayer({ x = playerData.coords.x, y = playerData.coords.y, z = playerData.coords.z + 0.25, - heading = playerData.coords.heading + heading = playerData.coords.heading, + model = Config.DefaultPlayerModel, + skipFade = false }, function() TriggerServerEvent('esx:onPlayerSpawn') TriggerEvent('esx:onPlayerSpawn') @@ -78,6 +66,11 @@ end FreezeEntityPosition(PlayerPedId(), false) DoScreenFadeIn(10000) StartServerSyncLoops() + if isNew then + -- Put your code for if you want to do something with new players. + else + -- If they aren't new put that code here. + end end) TriggerEvent('esx:loadingScreenOff') diff --git a/config.lua b/config.lua index 264e60cb..3e18a491 100644 --- a/config.lua +++ b/config.lua @@ -12,9 +12,10 @@ Config.StartingAccountMoney = {bank = 50000} Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society Config.EnableHud = true -- enable the default hud? Display current job and accounts (black, bank & cash) Config.MaxWeight = 24 -- the max inventory weight without backpack -Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in milliseconds -Config.EnableDebug = false -- Use Debug options? -Config.EnableDefaultInventory = true -- Display the default Inventory ( F2 ) +Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in milliseconds +Config.EnableDebug = false -- Use Debug options? +Config.EnableDefaultInventory = true -- Display the default Inventory ( F2 ) Config.EnableWantedLevel = false -- Use Normal GTA wanted Level? -Config.EnablePVP = true -- Allow Player to player combat +Config.EnablePVP = true -- Allow Player to player combat +Config.DefaultPlayerModel = `mp_m_freemode_01` -- Don't Change this there is absolutely no need diff --git a/server/main.lua b/server/main.lua index 3102f0e8..12e74141 100644 --- a/server/main.lua +++ b/server/main.lua @@ -29,7 +29,7 @@ function onPlayerJoined(playerId) ['@identifier'] = identifier }, function(result) if result then - loadESXPlayer(identifier, playerId) + loadESXPlayer(identifier, playerId, false) else local accounts = {} @@ -49,7 +49,7 @@ function onPlayerJoined(playerId) ['@identifier'] = identifier, ['@group'] = defaultGroup }, function(rowsChanged) - loadESXPlayer(identifier, playerId) + loadESXPlayer(identifier, playerId, true) end) end end) @@ -83,7 +83,7 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals) end end) -function loadESXPlayer(identifier, playerId) +function loadESXPlayer(identifier, playerId, isNew) local tasks = {} local userData = { @@ -235,7 +235,7 @@ function loadESXPlayer(identifier, playerId) loadout = xPlayer.getLoadout(), maxWeight = xPlayer.getMaxWeight(), money = xPlayer.getMoney() - }) + }, isNew) xPlayer.triggerEvent('esx:createMissingPickups', ESX.Pickups) xPlayer.triggerEvent('esx:registerSuggestions', ESX.RegisteredCommands)