mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-01 20:01:47 +00:00
@@ -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`:
|
||||
|
||||
@@ -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)
|
||||
|
||||
+16
-2
@@ -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)
|
||||
|
||||
+8
-5
@@ -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 },
|
||||
|
||||
@@ -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'
|
||||
;
|
||||
+9
-2
@@ -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 <span style="color: orange;">$%s</span>?',
|
||||
['boat_shop_confirm'] = 'buy <span style="color: yellow;">%s</span> for <span style="color: orange;">$%s</span>?',
|
||||
['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 <span style="color: green;">$%s</span>',
|
||||
['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',
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user