Zyke ResourcesDocumentation

Transfer Ownership

Shorthand to transfer vehicle ownerships easier.

Transfer vehicle ownership between players using a single export. Note that this is server-sided only.


For advanced use cases where you need to pass custom vehicle data, target a specific garage, or initialize an unowned vehicle, use the SetNewOwner export directly. See the Exports page for details.

#Quick Start

local success, reason = exports.zyke_garages:TransferOwnership(
    "ABC 1234",      -- plate
    "char1:abc123"   -- new owner's identifier (citizenid for QB, identifier for ESX)
)

The script resolves the plate to a VIN internally, validates that the vehicle isn't impounded, transfers ownership, rotates keys, and assigns a valid garage — all in one call.


#Parameters

ParameterTypeDescription
platestringThe vehicle's license plate
newOwnerstringTarget character identifier (citizenid for QB, identifier for ESX)

Returns: boolean, string? - success, failure reason


#Failure Reasons

ReasonMeaning
"missingArguments"plate or newOwner was not provided
"noVehicleFound"No vehicle found with that plate
"vehicleIsImpounded2"Vehicle is currently impounded
"noPlayer"Target identifier is invalid

#Example: Vehicle Dealership

RegisterNetEvent("myDealership:purchaseVehicle", function(plate)
    local source = source
    local identifier = Z.getIdentifier(source)

    local success, reason = exports.zyke_garages:TransferOwnership(plate, identifier)

    if success then
        TriggerClientEvent("myDealership:purchaseComplete", source)
    else
        print("Transfer failed: " .. (reason or "unknown"))
    end
end)

#Example: Admin Command

RegisterCommand("transferveh", function(source, args)
    local plate = args[1]
    local targetId = tonumber(args[2])
    if (not plate or not targetId) then return end

    local targetIdentifier = Z.getIdentifier(targetId)
    local success, reason = exports.zyke_garages:TransferOwnership(plate, targetIdentifier)

    print(success and "Transfer complete" or ("Failed: " .. (reason or "unknown")))
end, true)