Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Job Garage #83

Open
SantyR0 opened this issue May 3, 2022 · 9 comments
Open

Job Garage #83

SantyR0 opened this issue May 3, 2022 · 9 comments
Labels
question Further information is requested

Comments

@SantyR0
Copy link

SantyR0 commented May 3, 2022

Is it really a feature that you can't store your citizen car in a job garage? I mean should your car be a job vehicle? I have a business job which doesn't have a job vehicles and I'm trying to make a garage for their cars.

@LukeWasTakenn
Copy link
Owner

Yes you currently cannot store your personal vehicle in a job garage. If enough people say it shouldn't be like this then I'll change it.

@SantyR0
Copy link
Author

SantyR0 commented May 3, 2022

How hard could that be? Is it possible for someone who is not a experienced dev like me to change it to that?

@LukeWasTakenn
Copy link
Owner

Probably not too difficult at all, this and the server side callback trigger is what controls that, so play around with it.

ESX.TriggerServerCallback('luke_garages:CheckOwnership', function(doesOwn)
if doesOwn then
if type(doesOwn) == 'table' then return ESX.ShowNotification(Locale('garage_cant_store')) end
TriggerServerEvent('luke_garages:ChangeStored', vehPlate, true, currentGarage.zone.name)
TriggerServerEvent('luke_garages:SaveVehicle', vehProps, health, vehPlate, VehToNet(vehicle))
else
ESX.ShowNotification(Locale('no_ownership'))
end
end, vehPlate, vehProps.model, currentGarage.job)

@SantyR0
Copy link
Author

SantyR0 commented May 3, 2022

Sorry, I don't understand much. I only have a little knowledge changing the codes of some scripts but this seems something I can't figure out for now. I'm currently on a phase of learning. How would I do that?

ESX.RegisterServerCallback('luke_garages:CheckOwnership', function(source, callback, plate, model, job)
    local xPlayer = ESX.GetPlayerFromId(source)
    local identifier = xPlayer.getIdentifier()

    plate = ESX.Math.Trim(plate)

    MySQL.Async.fetchAll('SELECT `vehicle`, `job` FROM owned_vehicles WHERE (`owner` = @owner OR `job` = @job) AND `plate` = @plate', {
        ['@owner'] = identifier,
        ['@plate'] = plate,
        ['@job'] = xPlayer.job.name
    }, function(result)
        if result[1] then
            local vehicle = json.decode(result[1].vehicle)
            local vehicleJob = result[1].job
            if ESX.Math.Trim(vehicle.plate) == plate and vehicle.model == model then
                if not job and not vehicleJob or vehicleJob == 'civ' then return callback(true) end
                if job and job == vehicleJob then return callback(true)
                else return callback({true, false}) end
            else
                -- Player tried to cheat
                callback(false)
            end
        else
            callback(false)
        end
    end)
end)

@SantyR0
Copy link
Author

SantyR0 commented May 4, 2022

Hello. I was able to store a civ vehicle into my police garage but I can't get it out since I don't see it. But in my database I can see that it's on the police garage.

EDIT: I can now see every vehicles that I owned but the problem is that I can't store civ again. If I change else return callback({true, false}) end to else return callback(true) end I would be able to store them but anyone can too even they are not have the same job as mine.

@LukeWasTakenn
Copy link
Owner

hmm not sure, this might be a bit more complicated than I originally thought 🤔

@TheZahamar
Copy link

I am also in favor of simply making the garage available for the job and not the car for the job

@LukeWasTakenn LukeWasTakenn added the question Further information is requested label May 15, 2022
@Esterze
Copy link

Esterze commented Oct 1, 2022

Sure, I too think that you should be able to store your personal vehicle in a job garage.
Hell, you can even make it optional by adding a configuration for it! Please, add it.

@Esterze
Copy link

Esterze commented Oct 1, 2022

Man, this would be totally awesome!
Workers wouldn't have to park their car far from their job place,
instead they could park near the place, that would result in players not walking for hours.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants