mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
Refactor: ESX Multicharacter - Useless Configs, better readme, performance
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
ESX = exports['es_extended']:getSharedObject()
|
||||
local mp_m_freemode_01 = `mp_m_freemode_01`
|
||||
local mp_f_freemode_01 = `mp_f_freemode_01`
|
||||
if ESX.GetConfig().Multichar then
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
@@ -102,7 +104,7 @@ if ESX.GetConfig().Multichar then
|
||||
y = Config.Spawn.y,
|
||||
z = Config.Spawn.z,
|
||||
heading = Config.Spawn.w,
|
||||
model = Characters[index].model or GetHashKey("mp_m_freemode_01"),
|
||||
model = Characters[index].model or mp_m_freemode_01,
|
||||
skipFade = true
|
||||
}, function()
|
||||
canRelog = false
|
||||
@@ -158,7 +160,7 @@ if ESX.GetConfig().Multichar then
|
||||
y = Config.Spawn.y,
|
||||
z = Config.Spawn.z,
|
||||
heading = Config.Spawn.w,
|
||||
model = GetHashKey("mp_m_freemode_01"),
|
||||
model = mp_m_freemode_01,
|
||||
skipFade = true
|
||||
}, function()
|
||||
canRelog = false
|
||||
@@ -173,7 +175,7 @@ if ESX.GetConfig().Multichar then
|
||||
else
|
||||
for k,v in pairs(Characters) do
|
||||
if not v.model and v.skin then
|
||||
if v.skin.model then v.model = v.skin.model elseif v.skin.sex == 1 then v.model = GetHashKey("mp_f_freemode_01") else v.model = GetHashKey("mp_m_freemode_01") end
|
||||
if v.skin.model then v.model = v.skin.model elseif v.skin.sex == 1 then v.model = mp_f_freemode_01 else v.model = mp_m_freemode_01 end
|
||||
end
|
||||
if spawned == false then SetupCharacter(Character) end
|
||||
local label = v.firstname..' '..v.lastname
|
||||
@@ -272,7 +274,7 @@ if ESX.GetConfig().Multichar then
|
||||
if isNew or not skin or #skin == 1 then
|
||||
local finished = false
|
||||
local sex = skin.sex or 0
|
||||
if sex == 0 then model = GetHashKey("mp_m_freemode_01") else model = GetHashKey("mp_f_freemode_01") end
|
||||
if sex == 0 then model = mp_m_freemode_01 else model = mp_f_freemode_01 end
|
||||
RequestModel(model)
|
||||
while not HasModelLoaded(model) do
|
||||
RequestModel(model)
|
||||
|
||||
@@ -12,11 +12,7 @@ if IsDuplicityVersion() then
|
||||
|
||||
-- Text to prepend to each character (char#:identifier) - keep it short
|
||||
Config.Prefix = 'char'
|
||||
--------------------
|
||||
|
||||
-- Default identifier to store for characters - this should always match es_extended (recommended: license)
|
||||
Config.Identifier = 'license'
|
||||
|
||||
|
||||
else
|
||||
-- Sets the location for the character selection scene
|
||||
-- To set the spawn location for new characters, modify the default value in the users SQL table
|
||||
|
||||
@@ -1,39 +1,18 @@
|
||||
fx_version 'cerulean'
|
||||
game 'gta5'
|
||||
author 'ESX-Framework - Linden - KASH'
|
||||
description 'Official Multicharacter System For ESX Legacy'
|
||||
version '1.7.5'
|
||||
lua54 'yes'
|
||||
|
||||
dependencies {
|
||||
'es_extended',
|
||||
'esx_menu_default',
|
||||
'esx_identity',
|
||||
'esx_skin'
|
||||
}
|
||||
dependencies {'es_extended', 'esx_menu_default', 'esx_identity', 'esx_skin'}
|
||||
|
||||
shared_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
'locales/*.lua',
|
||||
'config.lua'
|
||||
}
|
||||
shared_scripts {'@es_extended/locale.lua', 'locales/*.lua', 'config.lua'}
|
||||
|
||||
server_scripts {
|
||||
'@es_extended/imports.lua',
|
||||
'@oxmysql/lib/MySQL.lua',
|
||||
'server/*.lua',
|
||||
}
|
||||
server_scripts {'@es_extended/imports.lua', '@oxmysql/lib/MySQL.lua', 'server/*.lua'}
|
||||
|
||||
client_scripts {
|
||||
'client/*.lua'
|
||||
}
|
||||
client_scripts {'client/*.lua'}
|
||||
|
||||
ui_page {
|
||||
'html/ui.html',
|
||||
}
|
||||
ui_page {'html/ui.html'}
|
||||
|
||||
files {
|
||||
'html/ui.html',
|
||||
'html/css/main.css',
|
||||
'html/js/app.js',
|
||||
'html/locales/*.js',
|
||||
}
|
||||
files {'html/ui.html', 'html/css/main.css', 'html/js/app.js', 'html/locales/*.js'}
|
||||
|
||||
@@ -1,40 +1,20 @@
|
||||
<h1 align='center'>[ESX] Multi-Character</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
|
||||
|
||||
# Preview
|
||||
A Simple, Easy to Use resource, that allows Players to have multiple Characters, which can be configured to All players with the `Config.Slots` or To each Player personally using the `setslots`, `remslots`, `enablechar` and `disablechar` Commands :)
|
||||
|
||||

|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
- Modify your ESX config with `Config.Multichar = true`
|
||||
- All owner and identifier columns should be set to `VARCHAR(60)` to ensure correct data entry
|
||||
- The resource will attempt to set columns automatically
|
||||
|
||||
### Relogging
|
||||
## Relogging
|
||||
|
||||
- Do not enable this setting if you do not intend to properly set up relog support
|
||||
- Requires the latest update for ESX Status (prevents multiple status ticks from running)
|
||||
- Add the following events to resources that require support for relogging, or
|
||||
- Add them to [@es_extended/imports.lua](https://github.com/esx-framework/esx-legacy/blob/main/[esx]/es_extended/imports.lua) (and use the imports in your resources)
|
||||
|
||||
```lua
|
||||
RegisterNetEvent('esx:playerLoaded', function(xPlayer)
|
||||
ESX.PlayerData = xPlayer
|
||||
ESX.PlayerLoaded = true
|
||||
end)
|
||||
## Notes
|
||||
|
||||
RegisterNetEvent('esx:onPlayerLogout', function()
|
||||
ESX.PlayerLoaded = false
|
||||
ESX.PlayerData = {}
|
||||
end)
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
- Characters are stored in the users table as `char#:license` - if you need to use a different identifier then you need to modify ESX itself
|
||||
- Characters are stored in the users table as `char#:license`
|
||||
- Character deletion does not require manual entries for the tables to remove
|
||||
- As characters are stored with unique identifiers, there is no excessive queries being executed
|
||||
|
||||
### Kashacters
|
||||
## Kashacters
|
||||
|
||||
- This project is forked from the [kashacters multicharacter resource](https://github.com/FiveEYZ/esx_kashacter)
|
||||
- Most of the code has been entirely rewritten
|
||||
|
||||
@@ -23,7 +23,7 @@ elseif ESX.GetConfig().Multichar == true then
|
||||
local FETCH = nil
|
||||
local SLOTS = Config.Slots or 4
|
||||
local PREFIX = Config.Prefix or 'char'
|
||||
local PRIMARY_IDENTIFIER = ESX.GetConfig().Identifier or GetConvar('sv_lan', '') == 'true' and 'ip' or Config.Identifier
|
||||
local PRIMARY_IDENTIFIER = ESX.GetConfig().Identifier or GetConvar('sv_lan', '') == 'true' and 'ip' or "license"
|
||||
|
||||
local function GetIdentifier(source)
|
||||
local identifier = PRIMARY_IDENTIFIER..':'
|
||||
|
||||
Reference in New Issue
Block a user