qbcore-framework / qb-garages

Garage System Used With QB-Core :car:
GNU General Public License v3.0
48 stars 260 forks source link

[BUG] Housing garages not respecting /addgarage headding coordinates for vehicle spawns #261

Closed nzkfc closed 2 years ago

nzkfc commented 2 years ago

Describe the bug Cars that spawn out of housing garages have a fixed heading of north, ignoring the heading when using /addgarage

To Reproduce Steps to reproduce the behavior:

  1. Create house and buy it, add a garage facing the way you want the car to come out
  2. Put a car in and then pull it out
  3. Faces 360 instead of the heading /addgarage was facing (looks like DB still saves correct heading, as I can see here: https://i.imgur.com/DVp8ycO.png)

Expected behavior Car should spawn as per the heading on the houselocations table in the garage column in the DB.

Screenshots Here is a video where I recreate the issue on the latest versions of all qb scripts as at 27/10/22 https://youtu.be/uoXYCx9-LGY

Questions (please complete the following information):

Additional context Issue occured in a recent update I believe, in the last 4-5 weeks

When I compare code from when it was working and the fresh pull, it looks like RegisterNetEvent('qb-garages:client:takeOutGarage', function(data) used to use local heading and also set heading SetEntityHeading(veh, heading) after getting vehicles properties.

tom-osborne commented 2 years ago

Thanks for the report. I suspect this is due to how the heading is added when creating the garage.

I believe a fix you could try is adjusting this section: https://github.com/qbcore-framework/qb-houses/blob/main/client/main.lua#L1068

From this:

h = heading,

To this:

w = heading,

That would be my first guess, but I would have to test it out.

nzkfc commented 2 years ago

Gave it a go, no change.

Before: https://i.imgur.com/in2YaNZ.jpeg

After: https://i.imgur.com/Pfzdclo.jpeg

https://i.imgur.com/OylCgp0.png

DP for new garage with the change saves to the houseloacations table as {"z":4.22972536087036,"x":4513.35302734375,"h":21.25695037841797,"y":-4522.89453125}

tom-osborne commented 2 years ago

Yeah, so I still think the "h" key for heading is the issue. Suprised that made no difference. How are you testing this? I will do some testing, following your steps.

nzkfc commented 2 years ago
  1. Made new house and garage on real estate job character.
  2. Logged out and went into another character
  3. Purchased house
  4. Ran away from area to get out of poly, spawned a car and /admincar
  5. Drive to garage and park it up
  6. Pull out and facing wrong way.
  7. Adjusted the fix as per your notes and saved
  8. Restarted qb-houses and qb-garages just in case
  9. Pull car out, facing wrong way.

Only thing I can think of, is that the DB table is h: and not w: but i'm not 100% sure if that matters, if it does I assume you gotta change the DB to w:

On Sat, 29 Oct 2022, 10:46 pm Stan, @.***> wrote:

Yeah, so I still think the "h" key for heading is the issue. Suprised that made no difference. How are you testing this? I will do some testing, following your steps.

— Reply to this email directly, view it on GitHub https://github.com/qbcore-framework/qb-garages/issues/261#issuecomment-1295787152, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGHUHJCNKDM6PUQ7M567ATWFTXAPANCNFSM6AAAAAARPZCLQE . You are receiving this because you authored the thread.Message ID: @.***>

tom-osborne commented 2 years ago

@nzkfc Thanks, I have done some testing and the fix is as follows:

Head over to qb-garages / client / main.lua Find this section, which starts at line 96

    elseif type == 'hmarker' then
        size = 20
        coords = vector3(garage.takeVehicle.x, garage.takeVehicle.y, garage.takeVehicle.z)
        heading = 0
        minz = coords.z - 4.0
        maxz = coords.z + 2.0
    elseif type == 'house' then
        size = 2
        coords = vector3(garage.takeVehicle.x, garage.takeVehicle.y, garage.takeVehicle.z)
        heading = 0
        minz = coords.z - 1.0
        maxz = coords.z + 2.0
    end

Add in the heading = garage.takeVehicle.h position as follows:

    elseif type == 'hmarker' then
        size = 20
        coords = vector3(garage.takeVehicle.x, garage.takeVehicle.y, garage.takeVehicle.z)
        heading = garage.takeVehicle.h
        minz = coords.z - 4.0
        maxz = coords.z + 2.0
    elseif type == 'house' then
        size = 2
        coords = vector3(garage.takeVehicle.x, garage.takeVehicle.y, garage.takeVehicle.z)
        heading = garage.takeVehicle.h
        minz = coords.z - 1.0
        maxz = coords.z + 2.0
    end

Restart server and existing garages should be facing the right way.

If you had changed h = heading to w = heading from my previous suggestion. You can revert that back in the code. Also, check your database for any garages that were created with 'w' for the heading, and edit those back to 'h'

Test it out and let me know. Thanks

nzkfc commented 2 years ago

Hmm doesn't seem to work still: https://i.imgur.com/e8PlyTh.png

also a second one I tested, so I made the house/garage, restarted the server, joined as another character and purchased the house, did the car into garage and it's facing 0.0 lol

https://i.imgur.com/MxXZ7Qb.jpeg

tom-osborne commented 2 years ago

Not sure why, it defintely fixed it for m. Might be worth jumping in a discord call together at sopme point to discuss it.

amantu-qbit commented 2 years ago

@tom-osborne Making a Pull Req?

tom-osborne commented 2 years ago

@tom-osborne Making a Pull Req?

Hi @amantu-qbit yes. I will make the PR's - We also need one in qb-housing to handle backward compatibility, which I will work on later

nzkfc commented 2 years ago

@tom-osborne Making a Pull Req?

Hi @amantu-qbit yes. I will make the PR's - We also need one in qb-housing to handle backward compatibility, which I will work on later

Thanks, can confirm this is working 100%! Tested in dev and prod.