[Abandoned] [FREE] ESX Real Parking v1.4 | Real Life Parking | Parking Anywhere | Optimized

i found it out already thank you tho : )
edit: im still having an issue tho, when i retrieve the vehicle it says the price but it doesn’t actually take that amount it just takes 0

1 Like

Nice job man! Thank you :smiley:

if you using my script it does not use the parameter fee…
in my world parking is free, because my players can park anyware they want this because they have prived houses and can park on there on propperty.

de amount of fee you can find it in de config file

if the card count in your inventory = 0 then you get 0, because it works afther a day in real time :wink: then the amount gets up and you most pay, if you get the car the same day its free so 0 :wink:
this is the code that remove the money.

local fee = math.floor(((os.time() - rs[1].time) / 86400) * Config.ParkingLocations[rs[1].parking].fee)
local playerMoney = xPlayer.getMoney()
local parkingCard = xPlayer.getInventoryItem('parkingcard').count
if parkingCard > 0 then
	fee = 0
end
if playerMoney >= fee then
	xPlayer.removeMoney(fee)

EDIT:
i have look to the script again but i cant find the call to add a parkingcart to your inventory so the count is always 0…
and this check make also no sence because why checking a parkingcard that does not exsist…

so you have to add this in your code were the car safe is

ESX.RegisterServerCallback("esx_realparking:saveCar", function(source, cb, vehicleData)
	local xPlayer = ESX.GetPlayerFromId(source)
    local plate   = vehicleData.props.plate
	local isFound = false
	FindPlayerVehicles(xPlayer.identifier, function(vehicles)
		for k, v in pairs(vehicles) do
			if type(v.plate) ~= 'nil' and string.trim(plate) == string.trim(v.plate) then
				isFound = true
			end		
		end
		if GetVehicleNumOfParking(vehicleData.parking) > Config.ParkingLocations[vehicleData.parking].maxcar then
			cb({
				status  = false,
				message = _U("parking_full"),
			})
		elseif isFound then
			MySQL.Async.fetchAll("SELECT * FROM car_parking WHERE owner = @identifier AND plate = @plate", {
				['@identifier'] = xPlayer.identifier,
				['@plate']      = plate
			}, function(rs)
				if type(rs) == 'table' and #rs > 0 then
					cb({
						status  = false,
						message = _U("already_parking"),
					})
				else
xPlayer.addInventoryItem('parkingcard', 1) -- just add this line here(dont forget to add this in your inventory database)
					MySQL.Async.execute("INSERT INTO car_parking (owner, plate, data, time, parking) VALUES (@owner, @plate, @data, @time, @parking)", {
							["@owner"]   = xPlayer.identifier,
							["@plate"]   = plate,
							["@data"]    = json.encode(vehicleData),
							["@time"]    = os.time(),
							["@parking"] = vehicleData.parking
						}
					)
					MySQL.Async.execute('UPDATE owned_vehicles SET stored = 2 WHERE plate = @plate AND owner = @identifier', {
						["@plate"]      = plate,
						["@identifier"] = xPlayer.identifier
					})
					MySQL.Async.execute('UPDATE owned_vehicles SET vehicle = @vehicle WHERE owner = @owner AND plate = @plate', {
									['@owner'] = xPlayer.identifier,
									['@vehicle'] = json.encode(vehicleData.props),
									['@plate'] =  plate
								})
					cb({
						status  = true,
						message = _U("car_saved"),
					})
					Wait(100)
					TriggerClientEvent("esx_realparking:addVehicle", -1, {vehicle = vehicleData, plate = plate, fee = 0.0, owner = xPlayer.identifier, name = xPlayer.getName()})
				end
			end)
		else
			cb({
				status  = false,
				message = _U("not_your_car"),
			})
		end
	end)
end)

I just edited the script shown above, I’m not a programmer either, so I don’t really understand the lines of code very much :sweat_smile:.

okay, i think i understand now… if you pickup your car earlier than 24 hours real time its free and as for the parking card, i was able to get it added to the item database and be able to sell them in shops. also do you think it would be possible to make it so when players disconnect from the server if their car is unparked or just sitting out, to make it park at the last location or is that just too much?

1 Like

that is possible yes, and not to hard to make,

what you do is, make a database table with the info of the vehicle:

vehicle(plate, player identfier, last parked position, vehicledata)

then when players disconnect, do a check if the player vehicles is outsite, if this is the case place them back on the last parking position.

this means you must create a new db table for this, because the parking car when you unpark it, it removes from the car_parking table, so you have to safe it in a other table, and if the plaer disconnect you can add it back in car_parking table.

1 Like

okay i understand that but i dont know how to run a check if the vehicle isnt parked. im not very good at coding so idk how i would code that but maybe i can learn from youtube or from other posts on this site… thank you again for all your help : )

It seems like there’s an issue for me. If i park the car it shows me the right owner and plate. But if i rejoin the server, the name turns to “nil” instead of my name. And i can’t take the car out anymore

in the config.lua change Config.UsingOldESX = true to Config.UsingOldESX = false should fix your issue

woh can unpound vehicles =?

I Don’t Understand Where To Paste This Code

I read the entire Topic and still haven’t found a solution for this error.
Can someone help me out here?

I forget how I fixed this but I now use a script called “Advanced Parking” which allows vehicles to be parked where ever they are left. It is a paid script though but works great!

1 Like

I have the garage script in my sql how do I stop the cars from reverting back to the garage parking automatically?

same, let me know if you find out how.

I made a modified version of this script that would add that functionality, shoot me a PM

I sent one🏌🏿‍♂️

Has anyone figured out how to solve this issue??

I have read through the comments and the suggested config edit does not resolve it. It does not matter if I choose true or false on ESX version.

Also I have a firstname and lastname listed in my DB so I am not sure what the issue is. Any help would greatly be appreciated.

you dont have a plate on that vehicle, this value cant be emtpy, this value will be giving to you if you buy a car from a vehicle shop resourch. if you have a costom shop make sure that the data is placed correctly.

This is the code where you have the error,

if you look, you see that it ask you if you want to use the old or a new version of ESX (See config file)

So, if you have version 1.0 then you have to use old esx.
thats the reason why you get this error.

Edit:
File:Config.lua
Line 7: Config.UsingOldESX = true – If you are using ESX 1.2.0 or higher please leave this to false.

also the requested values cant be emty, or nil… so check your database if this row has a value in it. if this is not the case then you get the same error aswell…