Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Rewrite LoadESXPlayer #1288

wants to merge 2 commits into from

Conversation

Arctos2win
Copy link
Contributor

  • Removing unnecessary loops
  • More performant and faster
  • Compatibility with all synced accounts ( ox inventory )

Copy link
Contributor

@Gellipapa Gellipapa left a 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?

Comment on lines 138 to 139
skin = { sex = 'm' },
sex = 'm',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this? Duplicate?

Copy link
Contributor Author

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

playerName = GetPlayerName(playerId),
weight = 0,
metadata = {},

Copy link
Contributor

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.


-- Loadout
if not Config.OxInventory then
if result.loadout and result.loadout ~= '' then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent


-- Position
userData.coords = json.decode(result.position) or Config.DefaultSpawns[math.random(#Config.DefaultSpawns)]
xPlayer.set('firstName', result.firstname)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

userData.skin = { sex = 0 }
end
end
userData.playerName = userData.firstName .. ' ' .. userData.lastName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

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))
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

local shared = json.decode(GetConvar('inventory:accounts', '["money"]'))

for i=1, #shared do
local account = Config.StartingAccountMoney[shared[i]]
Copy link
Contributor

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

@Gellipapa
Copy link
Contributor

Gellipapa commented Jan 22, 2024

@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.

Copy link
Contributor

@Gellipapa Gellipapa left a 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.

@Arctos2win Arctos2win deleted the branch esx-framework:dev January 22, 2024 22:42
@Arctos2win Arctos2win closed this Jan 22, 2024
@Arctos2win Arctos2win deleted the dev branch January 22, 2024 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants