Question - for the delating of the vehicle from the database, is it looking specifically for the rented plate?
Concern here would be, a player selling the car to another player (illegally obviously since its a rental) - and if its not looking for the vehicle plate - basically a player could rent a car, and sell it and now that injects a cheap or free car into the enconomy.
If its searching by the plate then that issue should be fine, because after the time period still, it would delete from the DB. The player who bought the car from the player who rented it, would lose their car - but that can atleast be RP’ed as repo’ed because it was technically a rental.
That is a good point !!!
All the rental vehicle plates Starts with RENT****, so they can disable it from the selling command inbetween players, or add the rentingStart/End time to the sold vehicle.
But i really like what you said !
So just to clarify, when the vehicles time is over - the sql fetch to delete from the owned vehicles table is based on plate correct? not plate & owner?
If its plate & owners citizen id, passing through the sql check for deleting, then thats gunna be a problem for abuse. BUT if its only passing for the plate - then it should be fine and can be handled in server via Repo RP.
Just wanna make sure we arnt accidently introducing a way to keep rental cars via exploit. (common problem it seems with a lot of rental car scripts… bought 3 and all of them were checking for plate & owner match… which means if a player sold to another player, it wouldnt delete the vehicle after the time expires… very frustrating lol)
Just make sure that the vehicle sell script (between players) doesn’t delete the vehicle data from DB and creates another line with same data, because in that case the rental periode will be lost.
The vehicle sell Script shall update the data (citizenid etc…) which is logic and used in default qb and esx vehicleshop scripts.
oh good call, ill go check that! Hopefully it doesnt delete when selling but rather just changes the citizen ID. I know milage transfers with selling so i think its just a db owner swap not a line delete.
If its the ladder, then ill for sure be picking this script up tonight… rental cars for new players at LSIA (our intro point) has been a serious missing gap in server haha.
RegisterNetEvent("zat-carrental:server:CheckRentalPeriode", function(plate)
local src = source
local currentdate = os.time()
if Config.Framework == "qbcore" then
MySQL.query('SELECT * FROM player_vehicles WHERE plate = ?', {plate}, function(result)
if result[1] ~= nil then
if (os.difftime(currentdate, result[1].loandate)) >= (result[1].loanperiode * 86400) then
MySQL.query('DELETE FROM player_vehicles WHERE plate = ?',{plate})
TriggerClientEvent("zat-carrental:client:RemoveVehicle", src, plate)
TriggerClientEvent("QBCore:Notify", src, "Renting Periode is Over...", 'primary', 5000)
end
end
end)
elseif Config.Framework == "esx" then
MySQL.query('SELECT * FROM owned_vehicles WHERE plate = ?', {plate}, function(result)
if result[1] ~= nil then
if (os.difftime(currentdate, result[1].loandate)) >= (result[1].loanperiode * 86400) then
MySQL.query('DELETE FROM owned_vehicles WHERE plate = ?',{plate})
TriggerClientEvent("zat-carrental:client:RemoveVehicle", src, plate)
TriggerClientEvent("esx:showNotification", src, "Renting Periode is Over...")
end
end
end)
end
end)