diff --git a/client/main.lua b/client/main.lua index 41e38d0f..2ca7281e 100644 --- a/client/main.lua +++ b/client/main.lua @@ -186,6 +186,13 @@ end function StoreBoatInGarage(vehicle) + local vehicleProps = ESX.Game.GetVehicleProperties(vehicle) + + ESX.TriggerServerCallback('esx_boat:storeVehicle', function (rowsChanged) + ESX.Game.DeleteVehicle(vehicle) + ESX.ShowNotification(_U('garage_stored')) + end, vehicleProps.plate) + end @@ -219,4 +226,4 @@ function getVehicleModelFromHash(hash) end return 'Unknown hash [' .. hash .. ']' -end \ No newline at end of file +end diff --git a/client/marker.lua b/client/marker.lua index 96c7bc6e..37038238 100644 --- a/client/marker.lua +++ b/client/marker.lua @@ -22,6 +22,9 @@ Citizen.CreateThread(function() OpenBoatGarage(Config.Zones.Garages[CurrentActionData.zoneNum]) elseif CrurentAction == 'garage_in' then StoreBoatInGarage(CurrentActionData.vehicle) + + else + print('unknown') -- what's going on?!?! end CurrentAction = nil @@ -34,9 +37,6 @@ Citizen.CreateThread(function() end) AddEventHandler('esx_boat:hasEnteredMarker', function(zone, zoneNum) - print(zone) - print(zoneNum) - if zone == 'boat_shop' then CurrentAction = 'boat_shop' CurrentActionMsg = _U('boat_shop_open') diff --git a/config.lua b/config.lua index a5a1f16d..370e9b13 100644 --- a/config.lua +++ b/config.lua @@ -22,7 +22,7 @@ Config.Zones = { { GaragePos = { x = -772.42, y = -1430.90, z = 0.55 }, SpawnPoint = { x = -785.39, y = -1426.30, z = -0.47 }, - StorePos = { x = -798.45, y = -1456.03, z = -0.47 }, + StorePos = { x = -798.45, y = -1456.03, z = 0.00 }, Heading = 150.0 } diff --git a/server/main.lua b/server/main.lua index a32a4f9d..c4c96c3e 100644 --- a/server/main.lua +++ b/server/main.lua @@ -43,16 +43,28 @@ ESX.RegisterServerCallback('esx_boat:buyBoat', function (source, cb, vehicleProp end) RegisterServerEvent('esx_boat:takeOutVehicle') -AddEventHandler('esx_boat:takeOutVehicle', function(plate) - MySQL.Async.execute('UPDATE owned_vehicles SET stored = @stored WHERE owner = @owner AND plate = @plate', - { - ['@stored'] = false, - ['@owner'] = GetPlayerIdentifiers(source)[1], - ['@plate'] = plate - }, function (rowsChanged) - print(rowsChanged) - end) +AddEventHandler('esx_boat:takeOutVehicle', function (plate) + MySQL.Async.execute('UPDATE owned_vehicles SET stored = @stored WHERE owner = @owner AND plate = @plate', + { + ['@stored'] = false, + ['@owner'] = GetPlayerIdentifiers(source)[1], + ['@plate'] = plate + }, function (rowsChanged) + if rowsChanged == 0 then + print(('esx_boat: %s exploited the garage!'):format(GetPlayerIdentifiers(source)[1])) + end + end) +end) +ESX.RegisterServerCallback('esx_boat:storeVehicle', function (source, cb, plate) + MySQL.Async.execute('UPDATE owned_vehicles SET stored = @stored WHERE owner = @owner AND plate = @plate', + { + ['@stored'] = true, + ['@owner'] = GetPlayerIdentifiers(source)[1], + ['@plate'] = plate + }, function (rowsChanged) + cb(rowsChanged) + end) end) ESX.RegisterServerCallback('esx_boat:getGarage', function (source, cb)