-
-
Notifications
You must be signed in to change notification settings - Fork 749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite LoadESXPlayer #1288
Rewrite LoadESXPlayer #1288
Conversation
Arctos2win
commented
Jan 18, 2024
- Removing unnecessary loops
- More performant and faster
- Compatibility with all synced accounts ( ox inventory )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to format the code in all sorts of ways, but otherwise well written. Have you tested it works?
[core]/es_extended/server/main.lua
Outdated
skin = { sex = 'm' }, | ||
sex = 'm', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this? Duplicate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the skin is for skinchanger and / or esx skin
and sex is for identity its to maintain backwards compatibility
what we could do is always fallback to the skin sex
[core]/es_extended/server/main.lua
Outdated
playerName = GetPlayerName(playerId), | ||
weight = 0, | ||
metadata = {}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this empty line? I think you need run some formatter.
[core]/es_extended/server/main.lua
Outdated
|
||
-- Loadout | ||
if not Config.OxInventory then | ||
if result.loadout and result.loadout ~= '' then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
[core]/es_extended/server/main.lua
Outdated
|
||
-- Position | ||
userData.coords = json.decode(result.position) or Config.DefaultSpawns[math.random(#Config.DefaultSpawns)] | ||
xPlayer.set('firstName', result.firstname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
[core]/es_extended/server/main.lua
Outdated
userData.skin = { sex = 0 } | ||
end | ||
end | ||
userData.playerName = userData.firstName .. ' ' .. userData.lastName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ("%s %s"):format(firstName,lastName)
end | ||
if result.sex then | ||
userData.sex = result.sex | ||
xPlayer.set('sex', result.sex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
end | ||
if result.height then | ||
userData.height = result.height | ||
xPlayer.set('height', result.height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
[core]/es_extended/server/main.lua
Outdated
if ped then | ||
-- Save player health and armor in metadata | ||
local ped = GetPlayerPed(xPlayer.source) | ||
if ped then | ||
xPlayer.setMeta('health', xPlayer.getMeta('health') or GetEntityHealth(ped)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it should be handled to get from xPlayer if the player is dead and not look at the native because they can use disconnect to resurrect.
end | ||
end | ||
|
||
TriggerEvent('esx:playerLoaded', playerId, xPlayer, isNew) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
[core]/es_extended/server/main.lua
Outdated
local shared = json.decode(GetConvar('inventory:accounts', '["money"]')) | ||
|
||
for i=1, #shared do | ||
local account = Config.StartingAccountMoney[shared[i]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should store shared[i] in local variable and use
@Arctos2win Once this has been merged in, then there will be a 1.10.3 release. This is the last PR that will be accepted in esx_core. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Arctos2win Hi! Thank you for formatted code.