kasuganosoras / zerodream_parking

🚗 A car parking script for FiveM
https://forum.cfx.re/t/standalone-esx-zerodream-parking-parking-your-car-like-in-real-life/4986567
GNU General Public License v3.0
33 stars 12 forks source link

Fixes bug on multichar #1

Closed NoobSpielt closed 1 year ago

NoobSpielt commented 1 year ago

Following Error is fixed via this Pull Request:

The ESX code is broken when using Multichar. On line 301 till 305

   -- Load player data
    DebugPrint('Loading player data...')
    TriggerServerCallback('zerodream_parking:getPlayerData', function(data)
        _g.identifier = data.identifier
    end)

This Script trys instantly to fetch the Player data on join. But on Multichar Server it won’t work. Becouse on the join the Player don’t have the right identifier. I think if u implement esx:onPlayerSpawn here it should work. I am currently testing it and I can do a pull reqeust if its working on my end if you want

ERROR:

[script:zerodream_par] SCRIPT ERROR: @zerodream_parking/server/main.lua:68: attempt to index a nil value (local 'xPlayer') More Information:

I’m not quite sure if its happend becouse of that error. But when a Player Joins no Cars are Spawned. They are Only Spawned for the client if I restart the Script while the Player is on the Server.(No error if I do that becouse the Script can get the right identifier)

See: https://forum.cfx.re/t/standalone-esx-zerodream-parking-parking-your-car-like-in-real-life/4986567/29?u=noobspielt

kasuganosoras commented 1 year ago

Here is a little issue, if someone not uses multichar, they will not able to load the identifier.

Still need to find a way to solve this.

Edit: Now I think it is solved, I added the code to fall back to use license when xPlayer is nil or xPlayer.identifier is nil

NoobSpielt commented 1 year ago

Edit: Now I think it is solved, I added the code to fall back to use license when xPlayer is nil or xPlayer.identifier is nil

But that would make older Servers or Servers that use steam as a save identfier incompatible.

NoobSpielt commented 1 year ago

But im not quite sure why this breaks server that are not using multichar: Isn't esx:onPlayerSpawn something that standart esx calls when a player is fully loaded into the game?

kasuganosoras commented 1 year ago

But im not quite sure why this breaks server that are not using multichar: Isn't esx:onPlayerSpawn something that standart esx calls when a player is fully loaded into the game?

In ESX 1.1.0, this event isn't existing, that will cause the script stuck on loading.

kasuganosoras commented 1 year ago

But that would make older Servers or Servers that use steam as a save identfier incompatible.

That can be solved in easy, just open the server/api.lua, and search for GetIdentifierById, then change the license: to steam: and you can use steam as identifier now.

NoobSpielt commented 1 year ago

well, thanks for the fast fix then. I will close the pull request as completed :D