From 8560a9438b6fad6922964c7dc2c3b39a5f76249e Mon Sep 17 00:00:00 2001 From: Linden Date: Wed, 28 Jul 2021 21:44:05 +1000 Subject: [PATCH] improvement(multicharacter): Version bump --- [esx_addons]/esx_multicharacter/LICENSE.md | 6 +-- .../esx_multicharacter/client/main.lua | 48 +++++++++---------- [esx_addons]/esx_multicharacter/config.lua | 3 +- .../esx_multicharacter/fxmanifest.lua | 2 +- [esx_addons]/esx_multicharacter/readme.md | 14 ++---- .../esx_multicharacter/server/main.lua | 17 +++++-- 6 files changed, 47 insertions(+), 43 deletions(-) diff --git a/[esx_addons]/esx_multicharacter/LICENSE.md b/[esx_addons]/esx_multicharacter/LICENSE.md index e0fc2f09..f288702d 100644 --- a/[esx_addons]/esx_multicharacter/LICENSE.md +++ b/[esx_addons]/esx_multicharacter/LICENSE.md @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - esx_multicharacter - Copyright (C) 2021 Linden and KASH + + Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - esx_multicharacter Copyright (C) 2021 Linden and KASH + Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/[esx_addons]/esx_multicharacter/client/main.lua b/[esx_addons]/esx_multicharacter/client/main.lua index 3d7aab44..242d159d 100644 --- a/[esx_addons]/esx_multicharacter/client/main.lua +++ b/[esx_addons]/esx_multicharacter/client/main.lua @@ -25,12 +25,17 @@ if ESX.GetConfig().Multichar then ESX.PlayerLoaded = false ESX.PlayerData = {} Spawned = false - cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", Config.Spawn.x, Config.Spawn.y+1.6, Config.Spawn.z+1.3, 0.0, 0.0, 180.0, 100.00, false, 0) - SetEntityCoords(PlayerPedId(), Config.Spawn.x, Config.Spawn.y, Config.Spawn.z, true, false, false, false) - SetEntityHeading(PlayerPedId(), Config.Spawn.w) + cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true) + local playerPed = PlayerPedId() + SetEntityCoords(playerPed, Config.Spawn.x, Config.Spawn.y, Config.Spawn.z, true, false, false, false) + SetEntityHeading(playerPed, Config.Spawn.w) + local offset = GetOffsetFromEntityInWorldCoords(playerPed, 0, 1.7, 0.4) DoScreenFadeOut(0) SetCamActive(cam, true) RenderScriptCams(true, false, 1, true, true) + SetCamCoord(cam, offset.x, offset.y, offset.z) + PointCamAtCoord(cam, Config.Spawn.x, Config.Spawn.y, Config.Spawn.z + 1.3) + ESX.UI.HUD.SetDisplay(0.0) StartLoop() ShutdownLoadingScreen() @@ -110,8 +115,8 @@ if ESX.GetConfig().Multichar then TriggerEvent('skinchanger:loadSkin', skin) end DoScreenFadeIn(400) - while IsScreenFadedOut() do Citizen.Wait(100) end end) + repeat Citizen.Wait(200) until not IsScreenFadedOut() elseif Characters[index] and Characters[index].skin then if Characters[Spawned] and Characters[Spawned].model then @@ -254,20 +259,9 @@ if ESX.GetConfig().Multichar then RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(playerData, isNew, skin) - DoScreenFadeOut(100) local spawn = playerData.coords - local playerPed = PlayerPedId() - FreezeEntityPosition(playerPed, true) - SetEntityCoords(playerPed, spawn.x, spawn.y, spawn.z-1.3, true, false, false, false) - SetEntityHeading(playerPed, spawn.heading) - Citizen.Wait(300) - SetCamActive(cam, false) - RenderScriptCams(0, 0) - DestroyAllCams(true) - DoScreenFadeIn(400) - Citizen.Wait(400) - if isNew or not skin or #skin == 1 then + local finished = false local sex = skin.sex or 0 if sex == 0 then model = `mp_m_freemode_01` else model = `mp_f_freemode_01` end RequestModel(model) @@ -286,16 +280,22 @@ if ESX.GetConfig().Multichar then TriggerEvent('esx_skin:openSaveableMenu', function() finished = true end, function() finished = true end) - SetEntityHeading(playerPed, spawn.heading) end) - while not finished do Citizen.Wait(200) end - else - local playerPed = PlayerPedId() - SetEntityHeading(playerPed, spawn.heading) - TriggerEvent('skinchanger:loadSkin', skin or Characters[Spawned].skin) - playerPed = PlayerPedId() - SetEntityVisible(playerPed, true, 0) + repeat Citizen.Wait(200) until finished end + DoScreenFadeOut(100) + repeat Citizen.Wait(200) until IsScreenFadedOut() + SetCamActive(cam, false) + RenderScriptCams(false, false, 0, true, true) + cam = nil + local playerPed = PlayerPedId() + FreezeEntityPosition(playerPed, true) + SetEntityCoords(playerPed, spawn.x, spawn.y, spawn.z-1.3, true, false, false, false) + SetEntityHeading(playerPed, spawn.heading) + if not isNew then TriggerEvent('skinchanger:loadSkin', skin or Characters[Spawned].skin) end + Citizen.Wait(400) + DoScreenFadeIn(400) + repeat Citizen.Wait(200) until not IsScreenFadedOut() TriggerServerEvent('esx:onPlayerSpawn') TriggerEvent('esx:onPlayerSpawn') TriggerEvent('playerSpawned') diff --git a/[esx_addons]/esx_multicharacter/config.lua b/[esx_addons]/esx_multicharacter/config.lua index a444f660..0dff5211 100644 --- a/[esx_addons]/esx_multicharacter/config.lua +++ b/[esx_addons]/esx_multicharacter/config.lua @@ -2,7 +2,8 @@ Config = {} Config.Locale = 'en' Config.Slots = 4 -Config.Spawn = vector4(-113.7, 565.3, 195.2, 0) +Config.Spawn = vector4(-113.7, 565.3, 195.2, 0) -- Sets the location for character selection +-- To set the spawn location for new characters, modify the default value in the `users` SQL table -------------------- -- Do not use unless you are prepared to adjust your resources to correctly reset data diff --git a/[esx_addons]/esx_multicharacter/fxmanifest.lua b/[esx_addons]/esx_multicharacter/fxmanifest.lua index 57787aaa..617f933c 100644 --- a/[esx_addons]/esx_multicharacter/fxmanifest.lua +++ b/[esx_addons]/esx_multicharacter/fxmanifest.lua @@ -1,7 +1,7 @@ fx_version 'adamant' game 'gta5' description 'https://github.com/thelindat/esx_multicharacter' -version '1.2.1' +version '1.2.2' dependencies { 'es_extended', diff --git a/[esx_addons]/esx_multicharacter/readme.md b/[esx_addons]/esx_multicharacter/readme.md index c4d591d3..7fb62877 100644 --- a/[esx_addons]/esx_multicharacter/readme.md +++ b/[esx_addons]/esx_multicharacter/readme.md @@ -1,8 +1,5 @@ -

Although this resource is included, a more updated version may be available.

- - ### Requirements (ensure you are using the latest) -- [ESX Legacy](https://github.com/esx-framework/es_extended/tree/legacy) +- [ESX Legacy](https://github.com/esx-framework/esx-legacy) - [MySQL Async 3.3.2](https://github.com/brouznouf/fivem-mysql-async/releases/tag/3.3.2) - [ESX Identity](https://github.com/esx-framework/esx_identity) - [ESX Skin](https://github.com/esx-framework/esx_skin) @@ -12,27 +9,26 @@ - Modify your ESX config with `Config.Multichar = true` - Set your database name for `Config.Database` in server/main.lua - All owner and identifier columns should be set to `VARCHAR(60)` to ensure correct data entry -- Use the `varchar` command from the console to update your SQL tables -- Once you have used the command you should just remove it for sanity's sake + - The resource will attempt to set columns automatically ### Conflicts * The following resources should not be used with ESX Legacy and can result in errors - - **essentialsmode** + - essentialmode - basic-gamemode - fivem-map-skater - fivem-map-hipster - default_spawnpoint - - cui_character (or other resources that modify spawn behaviour) ### Common issues #### Black screen / loading scripts - Download and run all requirements + - Use a fresh spawnmanager as many people alter the code - Ensure none of the conflicting resources are enabled #### mysql-async duplicate entry - You have not increased the VARCHAR size of the table holding identifiers - usually `owner` or `identifier` #### The menu interface is esx_menu_default - you can use any version if you want a different appearance -![image](https://user-images.githubusercontent.com/65407488/119010385-592a8c80-b9d7-11eb-9aa1-eb7051004843.png) +![image](https://user-images.githubusercontent.com/65407488/126976325-17cc3241-bb9e-451f-a6ed-610a8ef52fa5.png) ### Relogging - Do not enable this setting if you do not intend to properly set up relog support diff --git a/[esx_addons]/esx_multicharacter/server/main.lua b/[esx_addons]/esx_multicharacter/server/main.lua index 4a52cac9..ea74dafa 100644 --- a/[esx_addons]/esx_multicharacter/server/main.lua +++ b/[esx_addons]/esx_multicharacter/server/main.lua @@ -1,5 +1,5 @@ if not ESX then - SetTimeout(3000, print('[^3WARNING^7] Unable to start Multicharacter - your version of ESX is not compatible ')) + SetTimeout(3000, function() print('[^3WARNING^7] Unable to start Multicharacter - your version of ESX is not compatible ') end) elseif ESX.GetConfig().Multichar == true then local IdentifierTables, Fetch = {}, -1 @@ -44,12 +44,20 @@ elseif ESX.GetConfig().Multichar == true then local DeleteCharacter = function(playerId, charid) local identifier = Config.Prefix..charid..':'..ESX.GetIdentifier(playerId) + local counter = 0 for k, v in pairs(IdentifierTables) do MySQL.Async.execute("DELETE FROM "..v.table.." WHERE "..v.column.." = ?", { identifier - }) + }, function() + counter = counter + 1 + if counter == #IdentifierTables then + print(('[^2INFO^7] Player [%s] %s has deleted a character (%s)'):format(GetPlayerName(playerId), playerId, identifier)) + Citizen.Wait(100) + SetupCharacters(playerId) + end + end) + Citizen.Wait(5) end - print(('[^2INFO^7] Player [%s] %s has deleted a character (%s)'):format(GetPlayerName(playerId), playerId, identifier)) end MySQL.ready(function() @@ -106,7 +114,6 @@ elseif ESX.GetConfig().Multichar == true then local src = source if type(charid) == "number" and string.len(charid) <= 2 then DeleteCharacter(src, charid) - SetupCharacters(src) end end) @@ -121,5 +128,5 @@ elseif ESX.GetConfig().Multichar == true then end, true) else - SetTimeout(3000, print('[^3WARNING^7] Multicharacter is disabled - please check your ESX configuration')) + SetTimeout(3000, function() print('[^3WARNING^7] Multicharacter is disabled - please check your ESX configuration') end) end