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

fix: Garage vehicles spawn feat: statebag of keys #47

Merged
merged 6 commits into from
May 10, 2024

Conversation

artur-michalak
Copy link
Contributor

Major changes
Change the data structure of vehicleKeys[plate][citizenid] to keysList[citizenid][plate]. This simplifies the logic of most functions.
Instead of synchronizing the variable on the client side, the player's statebag is modified.
Vehicle spawning works in shops, fixed GetKeys function

Other changes
fixed lint tests by rewriting imports
lockpicking for all vehicle doors
restored oryginal qbx fxmanifest.lua style

Need to think about how you can optimize the storage of keys in a variable on the server

Checklist

  • I have personally loaded this code into an updated Qbox project and checked all of its functionality.
  • My pull request fits the contribution guidelines & code conventions.

…oors chore: restore qbx fxmanifest.lua style
@artur-michalak artur-michalak changed the title fix: Garage vehicles spawn feat: fix: Garage vehicles spawn feat: statebag of keys May 7, 2024
Copy link
Contributor

@Manason Manason left a comment

Choose a reason for hiding this comment

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

Thanks for taking on this resource. Mostly minor comments. Great job!

keysList[citizenid] = {}
end

keysList[citizenid][plate] = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we even need this table now that the keys are stored on the player's state bag? This question boils down to do we need to access keys by citizenid, or would serverId suffice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's quite problematic. if the player disconnects and reconnects, the statebag disappears. Maybe new item "vehicle keys" in inventory?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah. Maybe we should limit its use to saving/loading on player disconnect/reconnect then? Or maybe there is a broader solution that could be put in core of saving/loading statebags? No action required.

Copy link
Contributor

Choose a reason for hiding this comment

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

Another point to consider is whether this data should be persisted between server restarts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What if in hotwiring replace TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys') with a statebag change?
Then only the keys assigned by the scripts would be in the server's memory.

artur-michalak and others added 5 commits May 8, 2024 21:55
Co-authored-by: Manason <clanerp@gmail.com>
Co-authored-by: Manason <clanerp@gmail.com>
…to separate variables on client, lockpicking semaphore to lock flag as a guard of a critical section, removed redundant isHotwiring setting and getHash function, moving onResourceStart over Backwards Compatibility section
@Manason Manason merged commit aae0c26 into Qbox-project:main May 10, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants