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

[Bug] - es_extended v1.11.2 - Can't get ESX.PlayerData correctly #1454

Open
DyroS3 opened this issue Nov 12, 2024 · 12 comments
Open

[Bug] - es_extended v1.11.2 - Can't get ESX.PlayerData correctly #1454

DyroS3 opened this issue Nov 12, 2024 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@DyroS3
Copy link
Contributor

DyroS3 commented Nov 12, 2024

Describe the bug
When I have the esx:playerLoaded event in the latest ESX version, I find that it doesn't get the ESX.PlayerData correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Client codes:
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
  -- Wait(1) -- When I add wait, the following code works fine, but when I remove wait, the following code does not work.
  print('playerdata', ESX.DumpTable(ESX.PlayerData)) -- when add `Wait` it works, but when remove `Wait` it doesn't work.
end)
  1. When I add Wait(1), print data correctly
  2. When I remover Wait(1) , print {}

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
image.
image

Debug Info (please complete the following information):

  • OS: Windows
  • FiveM Artifact: 10822
  • ESX Version:1.11.2
@DyroS3 DyroS3 added the bug Something isn't working label Nov 12, 2024
@Arctos2win
Copy link
Contributor

Hi @DyroS3,

Where did you put this code ?

@DyroS3
Copy link
Contributor Author

DyroS3 commented Nov 12, 2024

image
client codes

@Arctos2win
Copy link
Contributor

image client codes

this is bcs the ESX.PlayerData gets set with that event as well in the imports file

@DyroS3
Copy link
Contributor Author

DyroS3 commented Nov 12, 2024

image
image
image
This is what I just tested, it works fine in version 1.10.10

@Mycroft-Studios
Copy link
Member

Mycroft-Studios commented Nov 12, 2024

the argument xPlayer is ESX.PlayerData.
ESX.PlayerData itself is not set until after that event

@DyroS3
Copy link
Contributor Author

DyroS3 commented Nov 12, 2024

the argument xPlayer is ESX.PlayerData. ESX.PlayerData itself is not set until after that event

Sorry, I don't quite understand what you mean, maybe my translator is wrong. Do you mean that in the new version you have to set some Wait in order for the event to get the ESX.PlayerData correctly?

@Mycroft-Studios
Copy link
Member

No.

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
ESX.PlayerData = xPlayer
end)

the parameter xPlayer in the Event, is ESX.PlayerData

@DyroS3
Copy link
Contributor Author

DyroS3 commented Nov 12, 2024

No.

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
ESX.PlayerData = xPlayer
end)

the parameter xPlayer in the Event, is ESX.PlayerData

Yes, I know that this parameter represents ESX.PlayerData, but isn't it true that the new ESX kernel has an empty ESX.PlayerData at the first time a player logs in, and it takes some time to load and get it. PlayerData` is empty the first time a player logs in, and it takes some time to load and get it. Because this code doesn't throw an error in version 1.10.10.

@Mycroft-Studios
Copy link
Member

No.
ESX.PlayerData gets set in that event.
you cannot use a variable before it is set

@Mycroft-Studios
Copy link
Member

image
As u can see from the code.

@DyroS3
Copy link
Contributor Author

DyroS3 commented Nov 12, 2024

local function init()
    if ESX.PlayerData.job.name == "xxx" then
        xxxxx()
    end
end

RegisterNetEvent('esx:playerLoaded', function(xPlayer, isNew, skin)
    init()
end)

Because I had code that was roughly structured like this, but in the new version it gives me the error

@Mycroft-Studios
Copy link
Member

I will investigate

@Mycroft-Studios Mycroft-Studios self-assigned this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 🆕 New
Development

No branches or pull requests

5 participants