Qbox-project / qbx_vehiclekeys

GNU General Public License v3.0
5 stars 40 forks source link

Unable to Grant Key to Locally Spawned Vehicle #153

Open Jerrys-C opened 6 days ago

Jerrys-C commented 6 days ago

Summary

Unable to Grant Key to Locally Spawned Vehicle

Reproduction

In a test drive scenario, attempting to use TriggerEvent('vehiclekeys:client:SetOwner', GetVehicleNumberPlateText(vehicle_entity)) to provide keys results in the client receiving a notification that the key was obtained; however, the vehicle remains locked and cannot be unlocked. This issue only occurs during the test drive stage (non-global vehicle). When purchasing a vehicle, using the same event allows the key to function normally.

Expected behavior

Can drive vehicle

Actual behavior

Can not driver vehicle

Additional context

No response

Current Version

1.0.1

Custom Resources

ZSX_Dealership

Manason commented 6 days ago

Does the vehicle spawn in a different bucket?

Jerrys-C commented 6 days ago

Does the vehicle spawn in a different bucket?

I think that's the case

Manason commented 6 days ago

My guess without testing it is that it searches for a vehicle to give you keys in the same bucket as the player. This is a slight behavior change from qb-vehiclekeys which actually associates keys to a plate. In Qbox vehicle keys we look up the vehicles using plate on the server. I'll have to double check if this is the case. If you don't want to wait for a fix, you could switch the call to use the GiveKeys exports.

Jerrys-C commented 6 days ago

My guess without testing it is that it searches for a vehicle to give you keys in the same bucket as the player. This is a slight behavior change from qb-vehiclekeys which actually associates keys to a plate. In Qbox vehicle keys we look up the vehicles using plate on the server. I'll have to double check if this is the case. If you don't want to wait for a fix, you could switch the call to use the GiveKeys exports.

While attempting to call the export function GiveKeys from the resource qbx_vehiclekeys, the following error occurred:

14:20:20 [script:ZSX_Dealership] SCRIPT ERROR: @ZSX_Dealership/server/functions/sv_editable.lua:226: 
14:20:20 [script:ZSX_Dealership] An error occurred while calling export `GiveKeys` in resource `qbx_vehiclekeys`:
14:20:20 [script:ZSX_Dealership]   nil
14:20:20 [script:ZSX_Dealership] --- 
14:20:20 [script:ZSX_Dealership] Gave player 1 the keys to vehicle 1231106.
14:20:20 [    c-scripting-core] InvokeNative: execution failed: Tried to access invalid entity: 1231106