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(lib/spawn): retrieve vehicle type #651

Closed
wants to merge 2 commits into from
Closed

Conversation

Frowmza
Copy link
Contributor

@Frowmza Frowmza commented Dec 29, 2024

Description

  • use callback on random client instead of server spawn.
    CreateVehicle on the server side still depends on the client to spawn. If no client is nearby, it will get stuck in a while loop and vehicle will never exist. Instead, we retrieve the type from a random client, which will definitely exist.

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.

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.

  1. Why does it matter if creating a vehicle is stuck waiting for a client? It will be anyway as CreateVehicleServerSetter blocks waiting for a nearby client.

  2. In my experience the current way of getting vehicle types is very reliable. What happens if there is no client connected?

@Frowmza
Copy link
Contributor Author

Frowmza commented Dec 29, 2024

  1. Why does it matter if creating a vehicle is stuck waiting for a client? It will be anyway as CreateVehicleServerSetter blocks waiting for a nearby client.

I don't get what you mean here

2. What happens if there is no client connected?

i can add check if GetPlayers is empty.

I tested this an hour ago. The vehicle I was trying to spawn does not exist in GetVehiclesByHash. Instead, to get the type, it attempts to create the vehicle, but it gets stuck at while not DoesEntityExist() do.

@Manason
Copy link
Contributor

Manason commented Dec 29, 2024

  1. Why does it matter if creating a vehicle is stuck waiting for a client? It will be anyway as CreateVehicleServerSetter blocks waiting for a nearby client.

I don't get what you mean here

  1. What happens if there is no client connected?

i can add check if GetPlayers is empty.

I tested this an hour ago. The vehicle I was trying to spawn does not exist in GetVehiclesByHash. Instead, to get the type, it attempts to create the vehicle, but it gets stuck at while not DoesEntityExist() do.

Does it get permanently stuck, or does it resolve when you get close?

@Frowmza
Copy link
Contributor Author

Frowmza commented Dec 29, 2024

Just retested this now, it seems the issue was on my end. I was spawning vehicles directly on resource start, which doesn’t work. After adding a wait(100) before spawning, it seems to be working as intended. Sorry for the trouble!

@Frowmza Frowmza closed this Dec 29, 2024
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