From bee21651057425cc6953cd27a78a96a45a273ae6 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Thu, 29 Apr 2021 18:39:31 +0100 Subject: [PATCH] Kashacter --- client/main.lua | 77 ++++++++++++++++++++++++++++++++--------------- config.lua | 1 + es_extended.sql | 2 +- server/common.lua | 2 +- server/main.lua | 25 ++++++++++----- 5 files changed, 73 insertions(+), 34 deletions(-) diff --git a/client/main.lua b/client/main.lua index 18904766..c8342360 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,7 +1,7 @@ local isPaused, isDead, pickups = false, false, {} Citizen.CreateThread(function() - while true do + while not Config.UseKashacters do Citizen.Wait(0) if NetworkIsPlayerActive(PlayerId()) then @@ -12,11 +12,19 @@ Citizen.CreateThread(function() end end) +if Config.UseKashacters then + RegisterNetEvent('esx:kashloaded') + AddEventHandler('esx:kashloaded', function() + TriggerServerEvent('esx:onPlayerJoined') + end) +end + RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(playerData) ESX.PlayerLoaded = true ESX.PlayerData = playerData + if Config.UseKashacters then -- check if player is coming from loading screen if GetEntityModel(PlayerPedId()) == GetHashKey('PLAYER_ZERO') then local defaultModel = GetHashKey('a_m_y_stbla_02') @@ -30,6 +38,7 @@ AddEventHandler('esx:playerLoaded', function(playerData) SetPedDefaultComponentVariation(PlayerPedId()) SetPedRandomComponentVariation(PlayerPedId(), true) SetModelAsNoLongerNeeded(defaultModel) + end end -- freeze the player @@ -63,24 +72,46 @@ end }) end - 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') + if Config.UseKashacters then + --[[ + ESX.Game.Teleport(PlayerPedId(), { + x = playerData.coords.x, + y = playerData.coords.y, + z = playerData.coords.z + 0.25, + heading = playerData.coords.heading + }, function() + end) + ]]-- + 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(0) + ShutdownLoadingScreen() + FreezeEntityPosition(PlayerPedId(), false) + DoScreenFadeIn(0) + StartServerSyncLoops() + 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') + + Citizen.Wait(4000) + ShutdownLoadingScreen() + ShutdownLoadingScreenNui() + FreezeEntityPosition(PlayerPedId(), false) + DoScreenFadeIn(10000) + StartServerSyncLoops() end) +end TriggerEvent('esx:loadingScreenOff') end) @@ -179,11 +210,6 @@ AddEventHandler('esx:removeInventoryItem', function(item, count, showNotificatio end end) -RegisterNetEvent('esx:setJob') -AddEventHandler('esx:setJob', function(job) - ESX.PlayerData.job = job -end) - RegisterNetEvent('esx:addWeapon') AddEventHandler('esx:addWeapon', function(weaponName, ammo) local playerPed = PlayerPedId() @@ -248,13 +274,14 @@ AddEventHandler('esx:teleport', function(coords) end) RegisterNetEvent('esx:setJob') -AddEventHandler('esx:setJob', function(job) +AddEventHandler('esx:setJob', function(Job) if Config.EnableHud then ESX.UI.HUD.UpdateElement('job', { - job_label = job.label, - grade_label = job.grade_label + job_label = Job.label, + grade_label = Job.grade_label }) end + ESX.SetPlayerData(job, Job) end) RegisterNetEvent('esx:spawnVehicle') diff --git a/config.lua b/config.lua index f778c00e..57824c77 100644 --- a/config.lua +++ b/config.lua @@ -18,4 +18,5 @@ Config.EnableDefaultInventory = true -- Display the default Inventory ( F2 ) Config.EnableWantedLevel = false -- Use Normal GTA wanted Level? Config.DisableSuperadmin = true -- Disable the use of superadmin Config.UseMulticharacter = false -- WIP, ADDS multicharacter features +Config.UseKashacters = true diff --git a/es_extended.sql b/es_extended.sql index 3ddacbe5..6bfa339e 100644 --- a/es_extended.sql +++ b/es_extended.sql @@ -2,7 +2,7 @@ CREATE DATABASE IF NOT EXISTS `es_extended`; USE `es_extended`; CREATE TABLE `users` ( - `identifier` VARCHAR(40) NOT NULL, + `identifier` VARCHAR(64) NOT NULL, `accounts` LONGTEXT NULL DEFAULT NULL, `group` VARCHAR(50) NULL DEFAULT 'user', `inventory` LONGTEXT NULL DEFAULT NULL, diff --git a/server/common.lua b/server/common.lua index 4921c75c..406e87f4 100644 --- a/server/common.lua +++ b/server/common.lua @@ -54,7 +54,7 @@ MySQL.ready(function() end) end) - print('[es_extended] [^2INFO^7] ESX developed by ESX-Org has been initialized') + print('[es_extended] [^2INFO^7] ESX Legacy developed by The ESX-Framework Team has been initialized') end) RegisterServerEvent('esx:clientLog') diff --git a/server/main.lua b/server/main.lua index e0c728ed..069eddc0 100644 --- a/server/main.lua +++ b/server/main.lua @@ -24,8 +24,13 @@ function onPlayerJoined(playerId) else for k,v in ipairs(GetPlayerIdentifiers(playerId)) do if string.match(v, 'license:') then + if Config.UseKashacters then + identifier = v + break + else identifier = string.sub(v, 9) break + end end end end @@ -79,11 +84,17 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals) else for k,v in ipairs(GetPlayerIdentifiers(playerId)) do if string.match(v, 'license:') then + if Config.UseKashacters then + identifier = v + break + else identifier = string.sub(v, 9) break + end end end end + if identifier then if ESX.GetPlayerFromIdentifier(identifier) then deferrals.done(('There was an error loading your character!\nError code: identifier-active\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same Rockstar account.\n\nYour Rockstar identifier: %s'):format(identifier)) @@ -538,7 +549,7 @@ Citizen.CreateThread( print( ([[ -------------------------------------------------------- +^1------------------------------------------------------- URGENT: YOUR ES-EXTENDED IS OUTDATATED!!! COMMIT UPDATE: %s AVAILABLE CHANGELOG: %s @@ -552,12 +563,12 @@ CHANGELOG: %s print( ([[ -------------------------------------------------------- -Your Es-extended is the latest version! -Version: %s -COMMIT: %s -CHANGELOG: %s -------------------------------------------------------- +^8------------------------------------------------------- +^2Your Es-extended is the latest version! +^5Version:^0 %s +^5COMMIT:^0 %s +^5CHANGELOG:^0 %s +^8------------------------------------------------------- ]]):format( rv.version rv.commit,