kasuganosoras / esx_realparking

🅿️ A real car parking script for FiveM
GNU General Public License v3.0
51 stars 31 forks source link

HELP timmer #27

Open ismaelviac opened 4 years ago

ismaelviac commented 4 years ago

Hi, I'm working on a timmer that delete the vehicle if the fee is higer the 20k, but dont work u can help me this is my code

function Limit(source) 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 and rs[1] ~= nil then local fee = math.floor(((os.time() - rs[1].time) / 86400) Config.ParkingLocations[rs[1].parking].fee) if fee >= 20000 then MySQL.Async.execute('DELETE FROM car_parking WHERE plate = @plate AND owner = @identifier', { ["@plate"] = plate, ["@identifier"] = xPlayer.identifier}) MySQL.Async.execute('DELETE FROM owned_vehicles WHERE plate = @plate AND owner = @identifier', { ["@plate"] = plate, ["@identifier"] = xPlayer.identifier}) print(result) end end end) end

kasuganosoras commented 4 years ago

You should trigger the event esx_realparking:refreshVehicles after the timer delete the vehicle. Edit: Trigger the event for every client

ismaelviac commented 4 years ago

still dont work

ismaelviac commented 4 years ago

try this but dont work function Limit(source) MySQL.Async.fetchAll("SELECT FROM car_parking WHERE time < @time", { ["@time"]= math.floor((os.time()-(3086400)))}) print(result) MySQL.Async.execute('DELETE FROM car_parking WHERE plate = @plate', {["@plate"]= matricula}) MySQL.Async.execute('DELETE FROM owned_vehicles WHERE plate = @plate', {["@plate"]= matricula}) end