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

vehicleshop stable version #87

Merged
merged 23 commits into from
Aug 30, 2024
Merged

vehicleshop stable version #87

merged 23 commits into from
Aug 30, 2024

Conversation

Frowmza
Copy link
Contributor

@Frowmza Frowmza commented Aug 28, 2024

Description

  • Overall code improvements
  • Use qbx_vehicles API (need 21)
  • Fix test drive
  • Add statebag isInTestDrive to check if player is in test drive

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
Member

@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.

Where are the changes to qbx_vehicles being used in this PR?

server/main.lua Outdated Show resolved Hide resolved
server/main.lua Outdated Show resolved Hide resolved
@Frowmza
Copy link
Contributor Author

Frowmza commented Aug 29, 2024

is this good?, i removed plate from filters in qbx_vehicles here

@Frowmza
Copy link
Contributor Author

Frowmza commented Aug 29, 2024

as for createPlayerVehicle, should make it return generated plate, i think it would be best approach

local function createPlayerVehicle(request)
    assert(request.model ~= nil, 'missing required field: model')

    local props = request.props or {}
    if not props.plate then
        repeat
            props.plate = qbx.generateRandomPlate()
        until doesEntityPlateExist(props.plate) == false
    end
    props.engineHealth = props.engineHealth or 1000
    props.bodyHealth = props.bodyHealth or 1000
    props.fuelLevel = props.fuelLevel or 100
    props.model = joaat(request.model)

    if not triggerEventHooks('createPlayerVehicle', { citizenid = request.citizenid, garage = request.garage, props = props }) then
        return nil, {
            code = 'hook_cancelled',
            message = 'a createPlayerVehicle event hook cancelled this operation'
        }
    end

    local vehicleId = MySQL.insert.await('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, state, garage) VALUES ((SELECT license FROM players WHERE citizenid = @citizenid), @citizenid, @vehicle, @hash, @mods, @plate, @state, @garage)', {
        citizenid = request.citizenid,
        vehicle = request.model,
        hash = props.model,
        mods = json.encode(props),
        plate = props.plate,
        state = request.garage and State.GARAGED or State.OUT,
        garage = request.garage
    })

    return {
        vehicleId = vehicleId,
        plate = props.plate
    }
    
    -- or this so we dont need to make changes where this function is used in any other resource
    -- return vehicleId, props.plate
end

@Frowmza
Copy link
Contributor Author

Frowmza commented Aug 29, 2024

this tested and ready for a review!

client/main.lua Outdated Show resolved Hide resolved
client/main.lua Outdated Show resolved Hide resolved
server/main.lua Outdated Show resolved Hide resolved
server/main.lua Outdated Show resolved Hide resolved
server/main.lua Outdated Show resolved Hide resolved
server/main.lua Outdated Show resolved Hide resolved
server/main.lua Outdated Show resolved Hide resolved
server/main.lua Outdated Show resolved Hide resolved
server/main.lua Outdated Show resolved Hide resolved
@Manason Manason merged commit 6df9047 into Qbox-project:main Aug 30, 2024
2 checks passed
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.

3 participants