[Release] esx-qalle-sellvehicles (sell used cars)

,

I love this script and am working on a way to minimize the impact of cheats and remove some of the mystery that can surround sales gone wrong. I figure one way to do that is to make it so when a vehicle sells, it makes an entry into a db table, listing the following information. Name of buyer, vehicle, plate, seller and date/time of sale. Mostly it’s working great, except I am stumbling on pulling the seller id from the vehicles_for_sale table. Can any wizard coders take a look at my work please?

I’ve added various lines after line 74 in the server/main.lua and obviously a db table to match. :slight_smile:

ESX.RegisterServerCallback("esx-qalle-sellvehicles:buyVehicle", function(source, cb, vehProps, price)
	local src = source
	local xPlayer = ESX.GetPlayerFromId(src)
	local plate = vehProps["plate"]
	local seller = MySQL.Sync.fetchAll('SELECT seller FROM vehicles_for_sale WHERE vehicleProps LIKE "%' .. plate .. '%"')    
	local price = price
	local dateNow = os.date('%Y-%m-%d %H:%M')
	
	if xPlayer.getAccount("bank")["money"] >= price or price == 0 then
		xPlayer.removeAccountMoney("bank", price)

		MySQL.Async.execute("INSERT INTO owned_vehicles (plate, owner, vehicle) VALUES (@plate, @identifier, @vehProps)",
			{
				["@plate"] = plate,
				["@identifier"] = xPlayer["identifier"],
				["@vehProps"] = json.encode(vehProps)
			}
		)

		MySQL.Async.execute("INSERT INTO vehicle_sold_used (buyer, vehicle, plate, seller, date) VALUES (@buyer, @vehProps, @plate, @seller, @date)",
			{
				["@buyer"] = xPlayer.getName(),
				["@vehProps"] = json.encode(vehProps),
				["@plate"] = plate,
				["@seller"] = seller,
				["@date"] = dateNow
			}
		)
1 Like

im having the issue where when i click to sell it just does nothing, i can set the price but not sell. and yes it was installed the right way. any help?

I have do some work on this ressource and put all in pull-request.
I give you the link to the code to fix or improve your ressource if you need.

hello how could you make the name of the car you are going to buy appear?

1 Like

where do the cars go after buying? they disappear

2 Likes

where do the cars go after buying? they disappear

2 Likes

Same thing, can you fix it?

1 Like

I’m going to work on it more Tomorrow. Idk what’s going on

1 Like

When you add a police vehicle it dosent and buy it off the lot it dosent go back to the Police garage, i looked in the SQL and its under Null how do i fix this if i wanted to add police cars? for the garage??

es_extended: TriggerServerCallback => [esx-qalle-sellvehicles:isVehicleValid] does not exist help please…

1 Like

my problem is: BUY THE CAR:::BUT BUT THE CAR DISAPPEARS IN NOTHING!!! WHYYYY :frowning:

vehicle is impound ?

No vehicle impount i serch…

Can someone pls tell me how to set the permission to sell cars that are not owned.
For example a specific gang can only put the cars on sale.

I get the 11 vehicle error and when I sell a car it disappears if I own the car If I don’t own the car I can’t sell it also when I sell the car there is no way to buy it

1 Like

Is this script still working?

i doubt it m8 this ones very buggy i made a better one myself with few tweak’s to them

Where is your script? Can I download

es_extended: TriggerServerCallback => [esx-qalle-sellvehicles:getmoneyofplayer] does not ex

When sell the car you dont get money from it. Please fix it. My server wants it