diff --git a/README.md b/README.md
index 4be65dd0..911302a6 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,6 @@ git clone https://github.com/ESX-Org/esx_boat [esx]/esx_boat
- Download https://github.com/ESX-Org/esx_boat/archive/master.zip
- Put it in the `[esx]` directory
-
## Installation
- Import `esx_boat.sql` in your database
- Add this to your `server.cfg`:
diff --git a/client/main.lua b/client/main.lua
index 5547f3a8..ac689dba 100644
--- a/client/main.lua
+++ b/client/main.lua
@@ -184,6 +184,39 @@ function OpenBoatGarage(garage)
end)
end
+function OpenLicenceMenu(shop)
+ ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'boat_license',
+ {
+ title = _U('license_menu'),
+ align = 'top-left',
+ elements = {
+ { label = _U('license_buy_no'), value = 'no' },
+ { label = _U('license_buy_yes', Config.LicensePrice), value = 'yes' }
+ }
+ }, function (data, menu)
+ if data.current.value == 'yes' then
+ ESX.TriggerServerCallback('esx_boat:buyBoatLicense', function (boughtLicense)
+ if boughtLicense then
+ ESX.ShowNotification(_U('license_bought', Config.LicensePrice))
+ menu.close()
+
+ OpenBoatShop(shop) -- parse current shop
+ else
+ ESX.ShowNotification(_U('license_nomoney'))
+ end
+ end)
+ else
+ CurrentAction = 'boat_shop'
+ CurrentActionMsg = _U('boat_shop_open')
+ menu.close()
+ end
+ end, function (data, menu)
+ CurrentAction = 'boat_shop'
+ CurrentActionMsg = _U('boat_shop_open')
+ menu.close()
+ end)
+end
+
function StoreBoatInGarage(vehicle)
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
diff --git a/client/marker.lua b/client/marker.lua
index 9e0d3825..c89c7645 100644
--- a/client/marker.lua
+++ b/client/marker.lua
@@ -17,7 +17,21 @@ Citizen.CreateThread(function()
if IsControlJustReleased(0, Keys['E']) then
if CurrentAction == 'boat_shop' then
- OpenBoatShop(Config.Zones.BoatShops[CurrentActionData.zoneNum])
+
+ if not Config.EnableLicense then
+ OpenBoatShop(Config.Zones.BoatShops[CurrentActionData.zoneNum])
+ else -- check for license
+
+ ESX.TriggerServerCallback('esx_license:checkLicense', function (hasBoatLicense)
+ if hasBoatLicense then
+ OpenBoatShop(Config.Zones.BoatShops[CurrentActionData.zoneNum])
+ else
+ OpenLicenceMenu(Config.Zones.BoatShops[CurrentActionData.zoneNum])
+ end
+ end, GetPlayerServerId(PlayerId()), 'boat')
+
+ end
+
elseif CurrentAction == 'garage_out' then
OpenBoatGarage(Config.Zones.Garages[CurrentActionData.zoneNum])
elseif CurrentAction == 'garage_in' then
@@ -28,7 +42,7 @@ Citizen.CreateThread(function()
end
else
- Citizen.Wait(200)
+ Citizen.Wait(500)
end
end
end)
diff --git a/config.lua b/config.lua
index 0352f1a1..7a5c240d 100644
--- a/config.lua
+++ b/config.lua
@@ -1,9 +1,12 @@
-Config = {}
+Config = {}
-Config.Locale = 'en'
+Config.Locale = 'en'
-Config.MarkerType = 1
-Config.DrawDistance = 100.0
+Config.EnableLicense = true -- enable boat license?
+Config.LicensePrice = 50000
+
+Config.MarkerType = 1
+Config.DrawDistance = 100.0
Config.Marker = {
r = 100, g = 204, b = 100, -- blue-ish color, standard size circle
@@ -15,7 +18,6 @@ Config.StoreMarker = {
x = 5.0, y = 5.0, z = 1.0 -- big circle for storing boat
}
-
Config.Zones = {
Garages = {
@@ -54,6 +56,7 @@ Config.Zones = {
StorePos = { x = -1.03, y = -2799.20, z = 0.50 },
Heading = 181.0
},
+
{
GaragePos = { x = -3427.36, y = 956.94, z = 7.35 },
SpawnPoint = { x = -3448.97, y = 953.80, z = 0.00 },
diff --git a/esx_boat.sql b/esx_boat.sql
new file mode 100644
index 00000000..82e7c875
--- /dev/null
+++ b/esx_boat.sql
@@ -0,0 +1,10 @@
+USE `essentialmode`;
+
+INSERT INTO `licenses` (`type`, `label`) VALUES
+ ('boat', 'Boat License')
+;
+
+ALTER TABLE `owned_vehicles`
+ ADD COLUMN `vehicleType` VARCHAR(20) NULL DEFAULT 'car',
+ ADD COLUMN `stored` TINYINT(1) NOT NULL DEFAULT '1'
+;
\ No newline at end of file
diff --git a/locales/en.lua b/locales/en.lua
index 1f7372a3..d0837892 100644
--- a/locales/en.lua
+++ b/locales/en.lua
@@ -2,9 +2,9 @@ Locales['en'] = {
-- shop
['boat_shop'] = 'boat shop',
['boat_shop_open'] = 'press ~INPUT_CONTEXT~ to access the ~y~boat shop~s~.',
- ['boat_shop_confirm'] = 'buy a %s for $%s?',
+ ['boat_shop_confirm'] = 'buy %s for $%s?',
['boat_shop_bought'] = 'you have ~y~bought~s~ a ~b~%s~s~ for ~g~$%s~s~',
- ['boat_shop_nomoney'] = 'you cannot afford this boat!',
+ ['boat_shop_nomoney'] = 'you cannot ~r~afford~s~ this boat!',
['confirm_no'] = 'no',
['confirm_yes'] = 'yes',
@@ -17,6 +17,13 @@ Locales['en'] = {
['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!',
+ -- license
+ ['license_menu'] = 'buy Boat License?',
+ ['license_buy_no'] = 'no',
+ ['license_buy_yes'] = 'buy Boat License $%s',
+ ['license_bought'] = 'you have bought the ~y~Boat License~s~ for ~g~$%s~s~',
+ ['license_nomoney'] = 'you cannot ~r~afford~s~ the ~y~Boat License~s~!',
+
-- blips
['blip_garage'] = 'boat Garage',
['blip_shop'] = 'boat Shop',
diff --git a/server/main.lua b/server/main.lua
index c4c96c3e..6d71cdc2 100644
--- a/server/main.lua
+++ b/server/main.lua
@@ -87,6 +87,20 @@ ESX.RegisterServerCallback('esx_boat:getGarage', function (source, cb)
end)
+ESX.RegisterServerCallback('esx_boat:buyBoatLicense', function (source, cb)
+ local xPlayer = ESX.GetPlayerFromId(source)
+
+ if xPlayer.getMoney() >= Config.LicensePrice then
+ xPlayer.removeMoney(Config.LicensePrice)
+
+ TriggerEvent('esx_license:addLicense', source, 'boat', function()
+ cb(true)
+ end)
+ else
+ cb(false)
+ end
+end)
+
function getPriceFromModel(model)
for i=1, #Config.Vehicles, 1 do
if Config.Vehicles[i].model == model then