From fa8103355774d5b0d0db76b052474f6ef4be6456 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 5 Aug 2018 13:17:12 +0200 Subject: [PATCH] Fixed #3, fixed exploit storing boat when not in driver seat, fixed storing boat not owned - Async task for buying boats aswell --- client/main.lua | 15 +++++++++------ client/marker.lua | 4 ++-- locales/en.lua | 1 + server/main.lua | 7 +++---- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/client/main.lua b/client/main.lua index ac689dba..9c05b436 100644 --- a/client/main.lua +++ b/client/main.lua @@ -154,11 +154,10 @@ function OpenBoatGarage(garage) }, function (data, menu) -- make sure the spawn point isn't blocked - local closestVehicle = GetClosestVehicle(garage.SpawnPoint.x, garage.SpawnPoint.y, garage.SpawnPoint.z, 3.0, 0, 71) - local playerPed = PlayerPedId() - local vehicleProps = data.current.vehicleProps + local playerPed = PlayerPedId() + local vehicleProps = data.current.vehicleProps - if not DoesEntityExist(closestVehicle) then + if ESX.Game.IsSpawnPointClear(garage.SpawnPoint, 4.0) then TriggerServerEvent('esx_boat:takeOutVehicle', vehicleProps.plate) ESX.ShowNotification(_U('garage_taken')) @@ -222,8 +221,12 @@ 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')) + if rowsChanged > 0 then + ESX.Game.DeleteVehicle(vehicle) + ESX.ShowNotification(_U('garage_stored')) + else + ESX.ShowNotification(_U('garage_notowner')) + end end, vehicleProps.plate) end diff --git a/client/marker.lua b/client/marker.lua index c89c7645..892d735f 100644 --- a/client/marker.lua +++ b/client/marker.lua @@ -63,10 +63,10 @@ AddEventHandler('esx_boat:hasEnteredMarker', function(zone, zoneNum) if IsPedInAnyVehicle(playerPed, false) then local vehicle = GetVehiclePedIsIn(playerPed, false) - if DoesEntityExist(vehicle) then + if DoesEntityExist(vehicle) and GetPedInVehicleSeat(vehicle, -1) == playerPed then CurrentAction = 'garage_in' CurrentActionMsg = _U('garage_store') - CurrentActionData = {vehicle = vehicle} + CurrentActionData = { vehicle = vehicle } end end diff --git a/locales/en.lua b/locales/en.lua index d0837892..6b14703c 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -16,6 +16,7 @@ Locales['en'] = { ['garage_stored'] = 'the boat has been safely stored in your garage!', ['garage_noboats'] = 'you don\'t have any stored boats! Visit the ~y~boat shop~s~ to buy one.', ['garage_blocked'] = 'the boat cannot be taken out because another vehicle is blocking the spawn point!', + ['garage_notowner'] = 'you don\'t own this boat!', -- license ['license_menu'] = 'buy Boat License?', diff --git a/server/main.lua b/server/main.lua index 4d432c35..36d32b64 100644 --- a/server/main.lua +++ b/server/main.lua @@ -39,9 +39,9 @@ ESX.RegisterServerCallback('esx_boat:buyBoat', function (source, cb, vehicleProp ['@plate'] = vehicleProps.plate, ['@vehicle'] = json.encode(vehicleProps), ['@vehicleType'] = 'boat' - }) - - cb(true) + }, function (rowsChanged) + cb(true) + end) else cb(false) end @@ -73,7 +73,6 @@ ESX.RegisterServerCallback('esx_boat:storeVehicle', function (source, cb, plate) end) ESX.RegisterServerCallback('esx_boat:getGarage', function (source, cb) - MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND vehicleType = @vehicleType AND stored = @stored', { ['@owner'] = GetPlayerIdentifiers(source)[1],