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

Sharedkeys config is not working with addon cars #266

Open
FenixDK opened this issue Nov 18, 2024 · 1 comment
Open

Sharedkeys config is not working with addon cars #266

FenixDK opened this issue Nov 18, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@FenixDK
Copy link

FenixDK commented Nov 18, 2024

The addon cars in Config.SharedKeys are locked. Only the vanilla cars are working fine.

To Reproduce
Steps to reproduce the behavior:

  1. Add addon cars to Config.SharedKeys

Expected behavior
To be able to unlock the car models that are in Config.SharedKeys.

Questions (please complete the following information):

  • When you last updated: now,
  • Are you using custom resource? which ones? In general quite a few, but none that should impact this feature. Especially considering that vanilla cars can be unlocked.
  • Have you renamed qb- to something custom? No
@FenixDK FenixDK added the bug Something isn't working label Nov 18, 2024
@FenixDK
Copy link
Author

FenixDK commented Nov 18, 2024

Alrighty, so the issue is in client->main.lua. You need to convert the name to the hash:

function AreKeysJobShared(veh)
    local vehModelHash = GetEntityModel(veh) -- Get the model hash
    local vehPlate = QBCore.Functions.GetPlate(veh)
    local jobName = QBCore.Functions.GetPlayerData().job.name
    local onDuty = QBCore.Functions.GetPlayerData().job.onduty

    for job, v in pairs(Config.SharedKeys) do
        if job == jobName then
            if Config.SharedKeys[job].requireOnduty and not onDuty then
                return false -- Require on-duty but player isn't
            end

            for _, vehicle in pairs(v.vehicles) do
                local vehicleHash = GetHashKey(vehicle) -- Convert config vehicle name to hash
                if vehicleHash == vehModelHash then
                    if not HasKeys(vehPlate) then
                        TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', vehPlate)
                    end
                    return true
                end
            end
        end
    end
    return false
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant