From c31f1c62b1f9c84e1770109efd4bfa8f50476b94 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Tue, 6 Apr 2021 22:57:03 +0100 Subject: [PATCH] Revert "d" This reverts commit 10360436297e08e4a6d269ed523a45ee9188c259. --- client/main.lua | 53 +++++++++++++++++++++++-------------------------- server/main.lua | 38 ++++++++++------------------------- 2 files changed, 35 insertions(+), 56 deletions(-) diff --git a/client/main.lua b/client/main.lua index ab53309f..737384c4 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,12 +1,7 @@ local isPaused, isDead, pickups = false, false, {} -if Config.UseKashacters then - RegisterNetEvent('esx:kashloaded') - AddEventHandler('esx:kashloaded', function() - TriggerServerEvent('esx:onPlayerJoined') - end) -else - Citizen.CreateThread(function() +if not Config.UseKashacters then + Citizen.CreateThread(function() while true do Citizen.Wait(0) @@ -17,6 +12,11 @@ else end end end) +else + RegisterNetEvent('esx:kashloaded') + AddEventHandler('esx:kashloaded', function() + TriggerServerEvent('esx:onPlayerJoined') + end) end RegisterNetEvent('esx:playerLoaded') @@ -25,7 +25,6 @@ AddEventHandler('esx:playerLoaded', function(playerData) ESX.PlayerData = playerData -- check if player is coming from loading screen -if not Config.UseKashacters then if GetEntityModel(PlayerPedId()) == GetHashKey('PLAYER_ZERO') then local defaultModel = GetHashKey('a_m_y_stbla_02') RequestModel(defaultModel) @@ -39,7 +38,6 @@ if not Config.UseKashacters then SetPedRandomComponentVariation(PlayerPedId(), true) SetModelAsNoLongerNeeded(defaultModel) end - end -- freeze the player FreezeEntityPosition(PlayerPedId(), true) @@ -70,6 +68,7 @@ if not Config.UseKashacters then }) end + local wait = 4000 if Config.UseKashacters then --[[ ESX.Game.Teleport(PlayerPedId(), { @@ -90,30 +89,28 @@ ShutdownLoadingScreen() FreezeEntityPosition(PlayerPedId(), false) DoScreenFadeIn(0) StartServerSyncLoops() +TriggerEvent('esx:loadingScreenOff') -else - ESX.Game.Teleport(PlayerPedId(), { - x = playerData.coords.x, - y = playerData.coords.y, - z = playerData.coords.z + 0.25, - heading = playerData.coords.heading + else + ESX.Game.Teleport(PlayerPedId(), { + x = playerData.coords.x, + y = playerData.coords.y, + z = playerData.coords.z + 0.25, + heading = playerData.coords.heading }, function() - TriggerServerEvent('esx:onPlayerSpawn') - TriggerEvent('esx:onPlayerSpawn') - TriggerEvent('playerSpawned') -- compatibility with old scripts, will be removed soon - TriggerEvent('esx:restoreLoadout') + TriggerServerEvent('esx:onPlayerSpawn') + TriggerEvent('esx:onPlayerSpawn') + TriggerEvent('playerSpawned') -- compatibility with old scripts, will be removed soon + TriggerEvent('esx:restoreLoadout') - Citizen.Wait(4000) - ShutdownLoadingScreen() - ShutdownLoadingScreenNui() - FreezeEntityPosition(PlayerPedId(), false) - DoScreenFadeIn(10000) - StartServerSyncLoops() + Citizen.Wait(3000) + ShutdownLoadingScreen() + FreezeEntityPosition(PlayerPedId(), false) + DoScreenFadeIn(10000) + StartServerSyncLoops() + TriggerEvent('esx:loadingScreenOff') end) - TriggerEvent('esx:loadingScreenOff') end) -end - RegisterNetEvent('esx:setMaxWeight') AddEventHandler('esx:setMaxWeight', function(newMaxWeight) ESX.PlayerData.maxWeight = newMaxWeight end) diff --git a/server/main.lua b/server/main.lua index ed629189..5a1f7ac3 100644 --- a/server/main.lua +++ b/server/main.lua @@ -13,21 +13,12 @@ end) function onPlayerJoined(playerId) local identifier - if not Config.UseKashacters then - for k,v in ipairs(GetPlayerIdentifiers(playerId)) do - if string.match(v, 'license:') then - identifier = string.sub(v, 9) - break - end - end - else - for k,v in ipairs(GetPlayerIdentifiers(playerId)) do - if string.match(v, 'license:') then - identifier = v - break - end + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do + if string.match(v, 'license:') then + identifier = string.sub(v, 9) + break + end end -end if identifier then if ESX.GetPlayerFromIdentifier(identifier) then @@ -64,20 +55,11 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals) local playerId, identifier = source Citizen.Wait(100) - if not Config.UseKashacters then - for k,v in ipairs(GetPlayerIdentifiers(playerId)) do - if string.match(v, 'license:') then - identifier = string.sub(v, 9) - break - end - end - else - for k,v in ipairs(GetPlayerIdentifiers(playerId)) do - if string.match(v, 'license:') then - identifier = v - break - end - end + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do + if string.match(v, 'license:') then + identifier = string.sub(v, 9) + break + end end if identifier then