![[RELEASE] Vehicle Selling & Auction System main image](https://forum-cfx-re.akamaized.net/original/5X/9/0/a/e/90aedff46586eed643811c3c2904a9c0987b3e71.jpeg)
![[RELEASE] Vehicle Selling & Auction System thumbnail 1](https://forum-cfx-re.akamaized.net/original/5X/9/0/a/e/90aedff46586eed643811c3c2904a9c0987b3e71.jpeg)
![[RELEASE] Vehicle Selling & Auction System thumbnail 2](https://img.youtube.com/vi/6_hTnw0ddr4/hqdefault.jpg)
Price
UnknownA script by Gamzky
Price
UnknownIntroducing a powerful vehicle selling system with a variety of interactive features for both direct selling and auctions. This system is perfect for any FiveM server looking to enhance vehicle trade dynamics.
Support: Discord
exports.gs_sellvehicles:IsVehicleListed(plate)
If you have any questions or issues, feel free to reach out to me.
Config = {
debug = false, -- Disables some checks (Place bids on own vehicle, overwrite own bid, etc.) to make it easier for testing.
requestZone = vector3(-207.9, -1964.03, 28.63), -- Coordinates of the zone in which the vehicles will be loaded.
requestZoneRadius = 150, -- Radius of the zone in which the vehicles will be loaded.
preventParkedVehicles = true, -- Prevent parked vehicles from being spawned in the spots.
blip = {
coords = vector3(-207.02, -2000.33, 27.74),
sprite = 225,
color = 3,
scale = 1.1,
label = 'Used Cars',
description = 'The place to sell your car or buy a used vehicle.'
},
extendAuction = true, -- Extend auction with 5 minutes if there is less than 5 minutes left and someone places a bid
maxPerPlayer = 3, -- Max number of vehicles a player can have listed
minBidIncrease = 5000, -- Minimum increase in bid price
minListingPrice = 5000, -- Minimum listing price
maxListingPrice = 100000000, -- Maximum listing price
sellMarker = {
coords = vector3(-207.02, -2000.33, 27.74),
type = 1,
size = 1.5,
color = 2,
},
sellOptions = { -- Remove an option from this list to disable it
'direct',
'auction',
},
durationOptions = {
{ hours = 12, label = '12 hours' },
{ hours = 24, label = '1 day' },
{ hours = 48, label = '2 days' },
{ hours = 72, label = '3 days', default = true },
{ hours = 168, label = '1 week' },
}
}
Config.Locales = {
['currency_separator'] = ',',
['loading'] = 'Loading...',
['sell_vehicle'] = 'Sell vehicle',
['buy_vehicle_for'] = 'Buy vehicle for $%s',
-- Left out for display purposes...
}
tuneLabels = {
modEngine = {
[-1] = 'Stock Engine',
[0] = 'EMS Upgrade, Level 1',
[1] = 'EMS Upgrade, Level 2',
[2] = 'EMS Upgrade, Level 3',
[3] = 'EMS Upgrade, Level 4',
},
-- Left out for display purposes...
}
Spots = {
vector4(-210.56, -1958.84, 27.22, 288.22),
vector4(-209.69, -1961.79, 27.22, 287.11),
vector4(-208.73, -1964.64, 27.22, 284.9),
-- Left out for display purposes...
}
ESX = exports.es_extended:getSharedObject()
Functions = {}
Functions.SetVehicleProperties = function(vehicle, props)
lib.setVehicleProperties(vehicle, props)
end
Functions.SpawnLocalVehicle = function(modelHash, coords, heading)
lib.requestModel(modelHash)
local vehicle = CreateVehicle(modelHash, coords.x, coords.y, coords.z, heading, false, true)
SetModelAsNoLongerNeeded(modelHash)
return vehicle
end
Functions.CanInteract = function(data)
local playerPed = PlayerPedId()
if IsPedInAnyVehicle(playerPed, false) then
return false
end
return true
end
Functions.Notify = function(message)
ESX.ShowNotification(message)
end
Functions.ApplyVehicleEffects = function(entity)
-- Optimizations
SetVehicleLodMultiplier(entity, 0.75)
SetEntityLodDist(entity, 75)
-- Freeze
SetVehicleOnGroundProperly(entity)
FreezeEntityPosition(entity, true)
-- Lock doors
SetVehicleDoorsLocked(entity, 2)
-- Clean vehicle
SetVehicleDirtLevel(entity, 0.0)
-- Make vehicle invincible
SetEntityInvincible(entity, true)
SetEntityCanBeDamaged(entity, false)
SetEntityProofs(entity, true, true, true, true, true, true, true, true)
end
ESX = exports.es_extended:getSharedObject()
Functions = {}
Functions.GetIdentifier = function(playerId)
local xPlayer = ESX.GetPlayerFromId(playerId)
return xPlayer.getIdentifier()
end
Functions.GetPlayerName = function(playerId)
local xPlayer = ESX.GetPlayerFromId(playerId)
return xPlayer.getName()
end
Functions.HasMoney = function(playerId, amount)
local xPlayer = ESX.GetPlayerFromId(playerId)
return xPlayer.getAccount('bank').money >= amount
end
Functions.RemoveMoney = function(playerId, amount)
local xPlayer = ESX.GetPlayerFromId(playerId)
xPlayer.removeAccountMoney('bank', amount)
end
Functions.AddMoney = function(playerId, amount)
local xPlayer = ESX.GetPlayerFromId(playerId)
xPlayer.addAccountMoney('bank', amount)
end
Functions.AddMoneyByIdentifier = function(identifier, amount)
local xPlayer = ESX.GetPlayerFromIdentifier(identifier)
if xPlayer then
xPlayer.addAccountMoney('bank', amount)
else
-- Player is not online, add money directly in the database
local curAccounts = MySQL.scalar.await('SELECT `accounts` FROM `users` WHERE `identifier` = ?', { identifier })
if curAccounts then
local accounts = json.decode(curAccounts)
accounts.bank = accounts.bank + amount
MySQL.update.await('UPDATE `users` SET `accounts` = ? WHERE `identifier` = ?', { json.encode(accounts), identifier })
end
end
end
Functions.TransferVehicleOwnership = function(identifier, plate)
-- Set new owner and set vehicle as stored
MySQL.update.await('UPDATE `owned_vehicles` SET `owner` = ?, `stored` = 1 WHERE `plate` = ?', { identifier, plate })
end
-- Add custom logic to check if a player can list a vehicle
Functions.CanListVehicle = function(playerId, data)
local netId = data.netId
local modelHash = data.modelHash -- Vehicle model hash
local plate = data.plate
-- Example when a player can not list a vehicle
if (playerId == -1) then
return {
canList = false,
message = '~r~You cannot sell this vehicle right now.'
}
end
return {
canList = true,
}
end
AddEventHandler('gs_sellvehicles:OnVehicleSold', function(data)
local buyerId = data.buyerId -- Buyer server ID
local buyerIdentifier = data.buyerIdentifier
local sellerIdentifier = data.sellerIdentifier
local plate = data.plate
local price = data.price
local vehicleLabel = data.label
-- Example: Add logging, or notify the seller
end)
AddEventHandler('gs_sellvehicles:OnAuctionEnd', function(data)
local wasSold = data.wasSold
local plate = data.plate
local highestBid = data.highestBid
local highestBidder = data.highestBidder -- Identifier of the player who bid the highest
local seller = data.seller -- Identifier of the player who listed the vehicle
-- Example: Add logging, or notify the seller
end)
-- Exports
exports('IsVehicleListed', IsVehicleListed)
-- Commands for managing vehicle listings
lib.addCommand('removevehlisting', {
help = 'Removes a vehicle listing.',
restricted = { 'group.superadmin' },
params = {
{ name = 'plate', help = 'The plate of the vehicle.', type = 'string', optional = true }
}
}, function(source, args, raw)
local plate = args.plate
if not plate then
return TriggerClientEvent('chat:addMessage', source, { args = { '^1ERROR', 'No plate specified.' } })
end
local vehicle = GetListingByPlate(plate)
if not vehicle then
return TriggerClientEvent('chat:addMessage', source, { args = { '^1ERROR', 'No listing found for the specified plate.' } })
end
if (vehicle.sell_type ~= 'direct') then
return TriggerClientEvent('chat:addMessage', source, { args = { '^1ERROR', 'Use /endvehauction to end a direct sale.' } })
end
vehicle:delete()
TriggerClientEvent('chat:addMessage', source, { args = { '^2SUCCESS', string.format('Vehicle listing with plate %s has been removed.', plate) } })
end)
-- Command to end a vehicle auction
lib.addCommand('endvehauction', {
help = 'Ends a vehicle auction.',
restricted = { 'group.superadmin' },
params = {
{ name = 'plate', help = 'The plate of the vehicle.', type = 'string', optional = true }
}
}, function(source, args, raw)
local plate = args.plate
if not plate then
return TriggerClientEvent('chat:addMessage', source, { args = { '^1ERROR', 'No plate specified.' } })
end
local vehicle = GetListingByPlate(plate)
if not vehicle then
return TriggerClientEvent('chat:addMessage', source, { args = { '^1ERROR', string.format("No listing found with plate: '%s'", plate) } })
end
if (vehicle.sell_type ~= 'auction') then
return TriggerClientEvent('chat:addMessage', source, { args = { '^1ERROR', 'Vehicle is not an auction.' } })
end
-- End the auction
vehicle:endAuction()
TriggerClientEvent('chat:addMessage', source, { args = { '^2SUCCESS', 'Vehicle auction ended.' } })
end)
Code is accessible | No, but core functions are accessible |
Subscription-based | No |
Lines (approximately) | 2080 |
Requirements | ox_lib, ox_target, oxmysql |
Support | Yes |
No approved reviews found for this script yet.