mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 01:38:52 +00:00
refactor - esx_garage
This commit is contained in:
@@ -1,16 +1,7 @@
|
||||
# esx_garage
|
||||
# ESX Garage
|
||||
|
||||
ESX Garage
|
||||
|
||||
[INSTALLATION]
|
||||
## INSTALLATION
|
||||
|
||||
1) CD in your resources/[esx] folder
|
||||
2) Clone the repository
|
||||
```
|
||||
git clone https://github.com/esx-framework/esx-legacy esx_garage
|
||||
```
|
||||
3) Import esx_garage.sql in your database
|
||||
4) Add this in your server.cfg :
|
||||
|
||||
```
|
||||
start esx_garage
|
||||
```
|
||||
1) Import esx_garage.sql in your database
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
local LastMarker, LastPart, thisGarage, thisPound = nil, nil, nil, nil
|
||||
local next = next
|
||||
local nearMarker, menuIsShowed = false, false
|
||||
local vehiclesList, vehiclesImpoundedList = {}, {}
|
||||
local LastMarker, LastPart, thisGarage, thisPound = nil, nil, nil, nil
|
||||
local next = next
|
||||
local nearMarker, menuIsShowed = false, false
|
||||
local vehiclesList, vehiclesImpoundedList = {}, {}
|
||||
|
||||
RegisterNetEvent('esx_garage:closemenu')
|
||||
AddEventHandler('esx_garage:closemenu', function()
|
||||
menuIsShowed = false
|
||||
menuIsShowed = false
|
||||
vehiclesList, vehiclesImpoundedList = {}, {}
|
||||
|
||||
SetNuiFocus(false)
|
||||
SendNUIMessage({hideAll = true})
|
||||
SendNUIMessage({
|
||||
hideAll = true
|
||||
})
|
||||
|
||||
if not menuIsShowed and thisGarage then ESX.TextUI(_U('access_parking')) end
|
||||
if not menuIsShowed and thisPound then ESX.TextUI(_U('access_pound')) end
|
||||
if not menuIsShowed and thisGarage then
|
||||
ESX.TextUI(_U('access_parking'))
|
||||
end
|
||||
if not menuIsShowed and thisPound then
|
||||
ESX.TextUI(_U('access_Impound'))
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNUICallback('escape', function(data, cb)
|
||||
@@ -27,55 +33,53 @@ RegisterNUICallback('spawnVehicle', function(data, cb)
|
||||
z = data.spawnPoint.z
|
||||
}
|
||||
|
||||
if thisGarage ~= nil then
|
||||
|
||||
if thisGarage then
|
||||
|
||||
if ESX.Game.IsSpawnPointClear(spawnCoords, 2.5) then
|
||||
ESX.Game.SpawnVehicle(data.vehicleProps.model, spawnCoords,
|
||||
data.spawnPoint.heading, function(vehicle)
|
||||
TaskWarpPedIntoVehicle(PlayerPedId(), vehicle, -1)
|
||||
ESX.Game.SpawnVehicle(data.vehicleProps.model, spawnCoords, data.spawnPoint.heading, function(vehicle)
|
||||
TaskWarpPedIntoVehicle(ESX.PlayerData.ped, vehicle, -1)
|
||||
ESX.Game.SetVehicleProperties(vehicle, data.vehicleProps)
|
||||
SetVehicleEngineOn(vehicle, (not GetIsVehicleEngineRunning(vehicle)), true, true)
|
||||
end)
|
||||
|
||||
thisGarage = nil
|
||||
|
||||
thisGarage = nil
|
||||
|
||||
TriggerServerEvent('esx_garage:updateOwnedVehicle', false, nil, nil, data.vehicleProps)
|
||||
TriggerEvent('esx_garage:closemenu')
|
||||
|
||||
ESX.ShowNotification(_U('veh_released'))
|
||||
|
||||
|
||||
else
|
||||
ESX.ShowNotification(_U('veh_block'), 'error')
|
||||
end
|
||||
|
||||
elseif thisPound ~= nil then
|
||||
elseif thisPound then
|
||||
|
||||
ESX.TriggerServerCallback('esx_garage:checkMoney',
|
||||
function(hasMoney)
|
||||
ESX.TriggerServerCallback('esx_garage:checkMoney', function(hasMoney)
|
||||
if hasMoney then
|
||||
if ESX.Game.IsSpawnPointClear(spawnCoords, 2.5) then
|
||||
TriggerServerEvent('esx_garage:payPound', data.exitVehicleCost)
|
||||
|
||||
ESX.Game.SpawnVehicle(data.vehicleProps.model, spawnCoords,
|
||||
data.spawnPoint.heading, function(vehicle)
|
||||
TaskWarpPedIntoVehicle(PlayerPedId(), vehicle, -1)
|
||||
ESX.Game.SetVehicleProperties(vehicle, data.vehicleProps)
|
||||
SetVehicleEngineOn(vehicle, (not GetIsVehicleEngineRunning(vehicle)), true, true)
|
||||
end)
|
||||
ESX.Game.SpawnVehicle(data.vehicleProps.model, spawnCoords, data.spawnPoint.heading,
|
||||
function(vehicle)
|
||||
TaskWarpPedIntoVehicle(ESX.PlayerData.ped, vehicle, -1)
|
||||
ESX.Game.SetVehicleProperties(vehicle, data.vehicleProps)
|
||||
SetVehicleEngineOn(vehicle, (not GetIsVehicleEngineRunning(vehicle)), true, true)
|
||||
end)
|
||||
|
||||
thisPound = nil
|
||||
|
||||
thisPound = nil
|
||||
|
||||
TriggerServerEvent('esx_garage:updateOwnedVehicle', false, nil, nil, data.vehicleProps)
|
||||
TriggerEvent('esx_garage:closemenu')
|
||||
|
||||
|
||||
else
|
||||
ESX.ShowNotification(_U('veh_block'), 'error')
|
||||
end
|
||||
else
|
||||
ESX.ShowNotification(_U('missing_money'))
|
||||
end
|
||||
else
|
||||
ESX.ShowNotification(_U('missing_money'))
|
||||
end
|
||||
end, data.exitVehicleCost)
|
||||
|
||||
|
||||
end
|
||||
|
||||
cb('ok')
|
||||
@@ -84,7 +88,7 @@ end)
|
||||
RegisterNUICallback('impound', function(data, cb)
|
||||
local poundCoords = {
|
||||
x = data.poundSpawnPoint.x,
|
||||
y = data.poundSpawnPoint.y,
|
||||
y = data.poundSpawnPoint.y
|
||||
}
|
||||
|
||||
TriggerServerEvent('esx_garage:setImpound', data.poundName, data.vehicleProps)
|
||||
@@ -100,10 +104,10 @@ CreateThread(function()
|
||||
for k, v in pairs(Config.Garages) do
|
||||
local blip = AddBlipForCoord(v.EntryPoint.x, v.EntryPoint.y, v.EntryPoint.z)
|
||||
|
||||
SetBlipSprite(blip, Config.Blips.Parking.Sprite)
|
||||
SetBlipSprite(blip, v.Sprite)
|
||||
SetBlipDisplay(blip, 4)
|
||||
SetBlipScale(blip, Config.Blips.Parking.Scale)
|
||||
SetBlipColour(blip, Config.Blips.Parking.Colour)
|
||||
SetBlipScale(blip, v.Scale)
|
||||
SetBlipColour(blip, v.Colour)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
@@ -111,28 +115,28 @@ CreateThread(function()
|
||||
EndTextCommandSetBlipName(blip)
|
||||
end
|
||||
|
||||
for k, v in pairs(Config.Pounds) do
|
||||
for k, v in pairs(Config.Impounds) do
|
||||
local blip = AddBlipForCoord(v.GetOutPoint.x, v.GetOutPoint.y, v.GetOutPoint.z)
|
||||
|
||||
SetBlipSprite(blip, Config.Blips.Pound.Sprite)
|
||||
SetBlipSprite(blip, v.Sprite)
|
||||
SetBlipDisplay(blip, 4)
|
||||
SetBlipScale(blip, Config.Blips.Pound.Scale)
|
||||
SetBlipColour(blip, Config.Blips.Pound.Colour)
|
||||
SetBlipScale(blip, v.Scale)
|
||||
SetBlipColour(blip, v.Colour)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
AddTextComponentSubstringPlayerName(_U('pound_blip_name'))
|
||||
AddTextComponentSubstringPlayerName(_U('Impound_blip_name'))
|
||||
EndTextCommandSetBlipName(blip)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_garage:hasEnteredMarker', function(name, part)
|
||||
if part == 'EntryPoint' then
|
||||
local isInVehicle = IsPedInAnyVehicle(PlayerPedId(), false)
|
||||
local isInVehicle = IsPedInAnyVehicle(ESX.PlayerData.ped, false)
|
||||
local garage = Config.Garages[name]
|
||||
thisGarage = garage
|
||||
thisGarage = garage
|
||||
|
||||
if isInVehicle then
|
||||
if isInVehicle then
|
||||
ESX.TextUI(_U('park_veh'))
|
||||
else
|
||||
ESX.TextUI(_U('access_parking'))
|
||||
@@ -140,16 +144,16 @@ AddEventHandler('esx_garage:hasEnteredMarker', function(name, part)
|
||||
end
|
||||
|
||||
if part == 'GetOutPoint' then
|
||||
local pound = Config.Pounds[name]
|
||||
thisPound = pound
|
||||
local pound = Config.Impounds[name]
|
||||
thisPound = pound
|
||||
|
||||
ESX.TextUI(_U('access_pound'))
|
||||
ESX.TextUI(_U('access_Impound'))
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_garage:hasExitedMarker', function()
|
||||
thisGarage = nil
|
||||
thisPound = nil
|
||||
thisGarage = nil
|
||||
thisPound = nil
|
||||
ESX.HideUI()
|
||||
TriggerEvent('esx_garage:closemenu')
|
||||
end)
|
||||
@@ -157,34 +161,42 @@ end)
|
||||
-- Display markers
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local sleep = 500
|
||||
local sleep = 500
|
||||
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
local inVehicle = IsPedInAnyVehicle(playerPed, false)
|
||||
local playerPed = ESX.PlayerData.ped
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
local inVehicle = IsPedInAnyVehicle(playerPed, false)
|
||||
|
||||
-- parking
|
||||
for k, v in pairs(Config.Garages) do
|
||||
if (#(coords - vector3(v.EntryPoint.x, v.EntryPoint.y, v.EntryPoint.z)) < Config.DrawDistance) then
|
||||
DrawMarker(Config.Markers.EntryPoint.Type, v.EntryPoint.x, v.EntryPoint.y, v.EntryPoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Markers.EntryPoint.Size.x, Config.Markers.EntryPoint.Size.y, Config.Markers.EntryPoint.Size.z, Config.Markers.EntryPoint.Color.r, Config.Markers.EntryPoint.Color.g, Config.Markers.EntryPoint.Color.b, 100, false, true, 2, false, false, false, false)
|
||||
sleep = 0
|
||||
DrawMarker(Config.Markers.EntryPoint.Type, v.EntryPoint.x, v.EntryPoint.y, v.EntryPoint.z, 0.0, 0.0,
|
||||
0.0, 0, 0.0, 0.0, Config.Markers.EntryPoint.Size.x, Config.Markers.EntryPoint.Size.y,
|
||||
Config.Markers.EntryPoint.Size.z, Config.Markers.EntryPoint.Color.r,
|
||||
Config.Markers.EntryPoint.Color.g, Config.Markers.EntryPoint.Color.b, 100, false, true, 2, false,
|
||||
false, false, false)
|
||||
sleep = 0
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- pound
|
||||
for k, v in pairs(Config.Pounds) do
|
||||
-- Impound
|
||||
for k, v in pairs(Config.Impounds) do
|
||||
if (#(coords - vector3(v.GetOutPoint.x, v.GetOutPoint.y, v.GetOutPoint.z)) < Config.DrawDistance) then
|
||||
DrawMarker(Config.Markers.GetOutPoint.Type, v.GetOutPoint.x, v.GetOutPoint.y, v.GetOutPoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Markers.GetOutPoint.Size.x, Config.Markers.GetOutPoint.Size.y, Config.Markers.GetOutPoint.Size.z, Config.Markers.GetOutPoint.Color.r, Config.Markers.GetOutPoint.Color.g, Config.Markers.GetOutPoint.Color.b, 100, false, true, 2, false, false, false, false)
|
||||
sleep = 0
|
||||
DrawMarker(Config.Markers.GetOutPoint.Type, v.GetOutPoint.x, v.GetOutPoint.y, v.GetOutPoint.z, 0.0, 0.0,
|
||||
0.0, 0, 0.0, 0.0, Config.Markers.GetOutPoint.Size.x, Config.Markers.GetOutPoint.Size.y,
|
||||
Config.Markers.GetOutPoint.Size.z, Config.Markers.GetOutPoint.Color.r,
|
||||
Config.Markers.GetOutPoint.Color.g, Config.Markers.GetOutPoint.Color.b, 100, false, true, 2, false,
|
||||
false, false, false)
|
||||
sleep = 0
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if sleep == 0 then
|
||||
nearMarker = true
|
||||
nearMarker = true
|
||||
else
|
||||
nearMarker = false
|
||||
nearMarker = false
|
||||
end
|
||||
|
||||
Wait(sleep)
|
||||
@@ -195,180 +207,170 @@ end)
|
||||
CreateThread(function()
|
||||
while true do
|
||||
if nearMarker then
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
local isInMarker = false
|
||||
local currentMarker = nil
|
||||
local currentPart = nil
|
||||
local playerPed = ESX.PlayerData.ped
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
local isInMarker = false
|
||||
local currentMarker = nil
|
||||
local currentPart = nil
|
||||
|
||||
for k, v in pairs(Config.Garages) do
|
||||
if (#(coords - vector3(v.EntryPoint.x, v.EntryPoint.y, v.EntryPoint.z)) < Config.Markers.EntryPoint.Size.x) then
|
||||
isInMarker = true
|
||||
currentMarker = k
|
||||
currentPart = 'EntryPoint'
|
||||
local isInVehicle = IsPedInAnyVehicle(playerPed, false)
|
||||
if (#(coords - vector3(v.EntryPoint.x, v.EntryPoint.y, v.EntryPoint.z)) <
|
||||
Config.Markers.EntryPoint.Size.x) then
|
||||
isInMarker = true
|
||||
currentMarker = k
|
||||
currentPart = 'EntryPoint'
|
||||
local isInVehicle = IsPedInAnyVehicle(playerPed, false)
|
||||
|
||||
if not isInVehicle then
|
||||
if IsControlJustReleased(0, 38) and not menuIsShowed then
|
||||
ESX.TriggerServerCallback('esx_garage:getVehiclesInParking',
|
||||
function(vehicles)
|
||||
if next(vehicles) ~= nil then
|
||||
menuIsShowed = true
|
||||
ESX.TriggerServerCallback('esx_garage:getVehiclesInParking', function(vehicles)
|
||||
if next(vehicles) then
|
||||
menuIsShowed = true
|
||||
|
||||
for i = 1, #vehicles, 1 do
|
||||
table.insert(vehiclesList, {
|
||||
model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model),
|
||||
plate = vehicles[i].plate,
|
||||
props = vehicles[i].vehicle
|
||||
})
|
||||
for i = 1, #vehicles, 1 do
|
||||
table.insert(vehiclesList, {
|
||||
model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model),
|
||||
plate = vehicles[i].plate,
|
||||
props = vehicles[i].vehicle
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
local spawnPoint = {
|
||||
x = v.SpawnPoint.x,
|
||||
y = v.SpawnPoint.y,
|
||||
z = v.SpawnPoint.z,
|
||||
heading = v.SpawnPoint.heading
|
||||
}
|
||||
|
||||
ESX.TriggerServerCallback('esx_garage:getVehiclesImpounded',
|
||||
function(vehicles)
|
||||
if next(vehicles) ~= nil then
|
||||
|
||||
for i = 1, #vehicles, 1 do
|
||||
table.insert(vehiclesImpoundedList, {
|
||||
model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model),
|
||||
plate = vehicles[i].plate,
|
||||
props = vehicles[i].vehicle
|
||||
})
|
||||
end
|
||||
|
||||
local poundSpawnPoint = {
|
||||
x = Config.Pounds[v.ImpoundedName].GetOutPoint.x,
|
||||
y = Config.Pounds[v.ImpoundedName].GetOutPoint.y,
|
||||
}
|
||||
|
||||
SendNUIMessage({
|
||||
showMenu = true,
|
||||
type = 'garage',
|
||||
vehiclesList = {
|
||||
json.encode(vehiclesList)
|
||||
},
|
||||
vehiclesImpoundedList = {
|
||||
json.encode(vehiclesImpoundedList)
|
||||
},
|
||||
poundName = v.ImpoundedName,
|
||||
poundSpawnPoint = poundSpawnPoint,
|
||||
spawnPoint = spawnPoint,
|
||||
locales = {
|
||||
action = _U('veh_exit'),
|
||||
veh_model = _U('veh_model'),
|
||||
veh_plate = _U('veh_plate'),
|
||||
veh_condition = _U('veh_condition'),
|
||||
veh_action = _U('veh_action'),
|
||||
impound_action = _U('impound_action'),
|
||||
}
|
||||
})
|
||||
else
|
||||
SendNUIMessage({
|
||||
showMenu = true,
|
||||
type = 'garage',
|
||||
vehiclesList = {
|
||||
json.encode(vehiclesList)
|
||||
},
|
||||
spawnPoint = spawnPoint,
|
||||
locales = {
|
||||
action = _U('veh_exit'),
|
||||
veh_model = _U('veh_model'),
|
||||
veh_plate = _U('veh_plate'),
|
||||
veh_condition = _U('veh_condition'),
|
||||
veh_action = _U('veh_action'),
|
||||
no_veh_impounded = _U('no_veh_impounded'),
|
||||
}
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
SetNuiFocus(true, true)
|
||||
|
||||
if menuIsShowed then
|
||||
ESX.HideUI()
|
||||
end
|
||||
else
|
||||
menuIsShowed = true
|
||||
|
||||
ESX.TriggerServerCallback('esx_garage:getVehiclesImpounded',
|
||||
function(vehicles)
|
||||
if next(vehicles) ~= nil then
|
||||
|
||||
for i = 1, #vehicles, 1 do
|
||||
table.insert(vehiclesImpoundedList, {
|
||||
model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model),
|
||||
plate = vehicles[i].plate,
|
||||
props = vehicles[i].vehicle
|
||||
})
|
||||
end
|
||||
|
||||
local poundSpawnPoint = {
|
||||
x = Config.Pounds[v.ImpoundedName].GetOutPoint.x,
|
||||
y = Config.Pounds[v.ImpoundedName].GetOutPoint.y,
|
||||
}
|
||||
|
||||
SendNUIMessage({
|
||||
showMenu = true,
|
||||
type = 'garage',
|
||||
vehiclesImpoundedList = {
|
||||
json.encode(vehiclesImpoundedList)
|
||||
},
|
||||
poundName = v.ImpoundedName,
|
||||
poundSpawnPoint = poundSpawnPoint,
|
||||
locales = {
|
||||
action = _U('veh_exit'),
|
||||
veh_model = _U('veh_model'),
|
||||
veh_plate = _U('veh_plate'),
|
||||
veh_condition = _U('veh_condition'),
|
||||
veh_action = _U('veh_action'),
|
||||
no_veh_parking = _U('no_veh_parking'),
|
||||
no_veh_impounded = _U('no_veh_impounded'),
|
||||
impound_action = _U('impound_action'),
|
||||
}
|
||||
})
|
||||
else
|
||||
SendNUIMessage({
|
||||
showMenu = true,
|
||||
type = 'garage',
|
||||
locales = {
|
||||
action = _U('veh_exit'),
|
||||
veh_model = _U('veh_model'),
|
||||
veh_plate = _U('veh_plate'),
|
||||
veh_condition = _U('veh_condition'),
|
||||
veh_action = _U('veh_action'),
|
||||
no_veh_parking = _U('no_veh_parking')
|
||||
}
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
SetNuiFocus(true, true)
|
||||
|
||||
if menuIsShowed then
|
||||
ESX.HideUI()
|
||||
end
|
||||
end
|
||||
end, currentMarker)
|
||||
|
||||
local spawnPoint = {
|
||||
x = v.SpawnPoint.x,
|
||||
y = v.SpawnPoint.y,
|
||||
z = v.SpawnPoint.z,
|
||||
heading = v.SpawnPoint.heading
|
||||
}
|
||||
|
||||
ESX.TriggerServerCallback('esx_garage:getVehiclesImpounded', function(vehicles)
|
||||
if next(vehicles) then
|
||||
|
||||
for i = 1, #vehicles, 1 do
|
||||
table.insert(vehiclesImpoundedList, {
|
||||
model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model),
|
||||
plate = vehicles[i].plate,
|
||||
props = vehicles[i].vehicle
|
||||
})
|
||||
end
|
||||
|
||||
local poundSpawnPoint = {
|
||||
x = Config.Impounds[v.ImpoundedName].GetOutPoint.x,
|
||||
y = Config.Impounds[v.ImpoundedName].GetOutPoint.y
|
||||
}
|
||||
|
||||
SendNUIMessage({
|
||||
showMenu = true,
|
||||
type = 'garage',
|
||||
vehiclesList = {json.encode(vehiclesList)},
|
||||
vehiclesImpoundedList = {json.encode(vehiclesImpoundedList)},
|
||||
poundName = v.ImpoundedName,
|
||||
poundSpawnPoint = poundSpawnPoint,
|
||||
spawnPoint = spawnPoint,
|
||||
locales = {
|
||||
action = _U('veh_exit'),
|
||||
veh_model = _U('veh_model'),
|
||||
veh_plate = _U('veh_plate'),
|
||||
veh_condition = _U('veh_condition'),
|
||||
veh_action = _U('veh_action'),
|
||||
impound_action = _U('impound_action')
|
||||
}
|
||||
})
|
||||
else
|
||||
SendNUIMessage({
|
||||
showMenu = true,
|
||||
type = 'garage',
|
||||
vehiclesList = {json.encode(vehiclesList)},
|
||||
spawnPoint = spawnPoint,
|
||||
locales = {
|
||||
action = _U('veh_exit'),
|
||||
veh_model = _U('veh_model'),
|
||||
veh_plate = _U('veh_plate'),
|
||||
veh_condition = _U('veh_condition'),
|
||||
veh_action = _U('veh_action'),
|
||||
no_veh_impounded = _U('no_veh_impounded')
|
||||
}
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
SetNuiFocus(true, true)
|
||||
|
||||
if menuIsShowed then
|
||||
ESX.HideUI()
|
||||
end
|
||||
else
|
||||
menuIsShowed = true
|
||||
|
||||
ESX.TriggerServerCallback('esx_garage:getVehiclesImpounded', function(vehicles)
|
||||
if next(vehicles) then
|
||||
|
||||
for i = 1, #vehicles, 1 do
|
||||
table.insert(vehiclesImpoundedList, {
|
||||
model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model),
|
||||
plate = vehicles[i].plate,
|
||||
props = vehicles[i].vehicle
|
||||
})
|
||||
end
|
||||
|
||||
local poundSpawnPoint = {
|
||||
x = Config.Impounds[v.ImpoundedName].GetOutPoint.x,
|
||||
y = Config.Impounds[v.ImpoundedName].GetOutPoint.y
|
||||
}
|
||||
|
||||
SendNUIMessage({
|
||||
showMenu = true,
|
||||
type = 'garage',
|
||||
vehiclesImpoundedList = {json.encode(vehiclesImpoundedList)},
|
||||
poundName = v.ImpoundedName,
|
||||
poundSpawnPoint = poundSpawnPoint,
|
||||
locales = {
|
||||
action = _U('veh_exit'),
|
||||
veh_model = _U('veh_model'),
|
||||
veh_plate = _U('veh_plate'),
|
||||
veh_condition = _U('veh_condition'),
|
||||
veh_action = _U('veh_action'),
|
||||
no_veh_parking = _U('no_veh_parking'),
|
||||
no_veh_impounded = _U('no_veh_impounded'),
|
||||
impound_action = _U('impound_action')
|
||||
}
|
||||
})
|
||||
else
|
||||
SendNUIMessage({
|
||||
showMenu = true,
|
||||
type = 'garage',
|
||||
locales = {
|
||||
action = _U('veh_exit'),
|
||||
veh_model = _U('veh_model'),
|
||||
veh_plate = _U('veh_plate'),
|
||||
veh_condition = _U('veh_condition'),
|
||||
veh_action = _U('veh_action'),
|
||||
no_veh_parking = _U('no_veh_parking')
|
||||
}
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
SetNuiFocus(true, true)
|
||||
|
||||
if menuIsShowed then
|
||||
ESX.HideUI()
|
||||
end
|
||||
end
|
||||
end, currentMarker)
|
||||
end
|
||||
end
|
||||
|
||||
if isInVehicle then
|
||||
if IsControlJustReleased(0, 38) then
|
||||
local vehicle = GetVehiclePedIsIn(playerPed, false)
|
||||
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
|
||||
|
||||
local vehicle = GetVehiclePedIsIn(playerPed, false)
|
||||
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
|
||||
|
||||
ESX.TriggerServerCallback('esx_garage:checkVehicleOwner', function(owner)
|
||||
if owner then
|
||||
ESX.Game.DeleteVehicle(vehicle)
|
||||
TriggerServerEvent('esx_garage:updateOwnedVehicle', true, currentMarker, nil, vehicleProps)
|
||||
TriggerServerEvent('esx_garage:updateOwnedVehicle', true, currentMarker, nil,
|
||||
vehicleProps)
|
||||
else
|
||||
ESX.ShowNotification(_U('not_owning_veh'), 'error')
|
||||
end
|
||||
@@ -379,73 +381,75 @@ CreateThread(function()
|
||||
end
|
||||
end
|
||||
|
||||
for k, v in pairs(Config.Pounds) do
|
||||
if (#(coords - vector3(v.GetOutPoint.x, v.GetOutPoint.y, v.GetOutPoint.z)) < Config.Markers.GetOutPoint.Size.x) then
|
||||
isInMarker = true
|
||||
currentMarker = k
|
||||
currentPart = 'GetOutPoint'
|
||||
for k, v in pairs(Config.Impounds) do
|
||||
|
||||
if (#(coords - vector3(v.GetOutPoint.x, v.GetOutPoint.y, v.GetOutPoint.z)) < 2.0) then
|
||||
isInMarker = true
|
||||
currentMarker = k
|
||||
currentPart = 'GetOutPoint'
|
||||
|
||||
if IsControlJustReleased(0, 38) and not menuIsShowed then
|
||||
ESX.TriggerServerCallback('esx_garage:getVehiclesInPound',
|
||||
function(vehicles)
|
||||
if next(vehicles) ~= nil then
|
||||
menuIsShowed = true
|
||||
print("2")
|
||||
ESX.TriggerServerCallback('esx_garage:getVehiclesInPound', function(vehicles)
|
||||
print(1)
|
||||
print(vehicles)
|
||||
if next(vehicles) then
|
||||
menuIsShowed = true
|
||||
|
||||
for i = 1, #vehicles, 1 do
|
||||
table.insert(vehiclesList, {
|
||||
model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model),
|
||||
plate = vehicles[i].plate,
|
||||
props = vehicles[i].vehicle
|
||||
})
|
||||
end
|
||||
|
||||
local spawnPoint = {
|
||||
x = v.SpawnPoint.x,
|
||||
y = v.SpawnPoint.y,
|
||||
z = v.SpawnPoint.z,
|
||||
heading = v.SpawnPoint.heading
|
||||
}
|
||||
|
||||
SendNUIMessage({
|
||||
showMenu = true,
|
||||
type = 'impound',
|
||||
vehiclesList = {
|
||||
json.encode(vehiclesList)
|
||||
},
|
||||
spawnPoint = spawnPoint,
|
||||
poundCost = v.Cost,
|
||||
locales = {
|
||||
action = _U('pay_pound'),
|
||||
veh_model = _U('veh_model'),
|
||||
veh_plate = _U('veh_plate'),
|
||||
veh_condition = _U('veh_condition'),
|
||||
veh_action = _U('veh_action')
|
||||
}
|
||||
for i = 1, #vehicles, 1 do
|
||||
table.insert(vehiclesList, {
|
||||
model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model),
|
||||
plate = vehicles[i].plate,
|
||||
props = vehicles[i].vehicle
|
||||
})
|
||||
|
||||
SetNuiFocus(true, true)
|
||||
|
||||
if menuIsShowed then
|
||||
ESX.HideUI()
|
||||
end
|
||||
else
|
||||
ESX.ShowNotification(_U('no_veh_pound'))
|
||||
end
|
||||
end, currentMarker)
|
||||
|
||||
local spawnPoint = {
|
||||
x = v.SpawnPoint.x,
|
||||
y = v.SpawnPoint.y,
|
||||
z = v.SpawnPoint.z,
|
||||
heading = v.SpawnPoint.heading
|
||||
}
|
||||
|
||||
SendNUIMessage({
|
||||
showMenu = true,
|
||||
type = 'impound',
|
||||
vehiclesList = {json.encode(vehiclesList)},
|
||||
spawnPoint = spawnPoint,
|
||||
poundCost = v.Cost,
|
||||
locales = {
|
||||
action = _U('pay_impound'),
|
||||
veh_model = _U('veh_model'),
|
||||
veh_plate = _U('veh_plate'),
|
||||
veh_condition = _U('veh_condition'),
|
||||
veh_action = _U('veh_action')
|
||||
}
|
||||
})
|
||||
|
||||
SetNuiFocus(true, true)
|
||||
|
||||
if menuIsShowed then
|
||||
ESX.HideUI()
|
||||
end
|
||||
else
|
||||
ESX.ShowNotification(_U('no_veh_Impound'))
|
||||
end
|
||||
end, currentMarker)
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if isInMarker and not HasAlreadyEnteredMarker or (isInMarker and (LastMarker ~= currentMarker or LastPart ~= currentPart)) then
|
||||
|
||||
if isInMarker and not HasAlreadyEnteredMarker or
|
||||
(isInMarker and (LastMarker ~= currentMarker or LastPart ~= currentPart)) then
|
||||
|
||||
if LastMarker ~= currentMarker or LastPart ~= currentPart then
|
||||
TriggerEvent('esx_garage:hasExitedMarker')
|
||||
end
|
||||
|
||||
HasAlreadyEnteredMarker = true
|
||||
LastMarker = currentMarker
|
||||
LastPart = currentPart
|
||||
LastMarker = currentMarker
|
||||
LastPart = currentPart
|
||||
|
||||
TriggerEvent('esx_garage:hasEnteredMarker', currentMarker, currentPart)
|
||||
end
|
||||
|
||||
@@ -1,122 +1,124 @@
|
||||
Config = {}
|
||||
Config.Locale = 'en'
|
||||
Config.Locale = 'en'
|
||||
|
||||
Config.Blips = {
|
||||
Parking = {
|
||||
Sprite = 357,
|
||||
Scale = 1.0,
|
||||
Colour = 3,
|
||||
},
|
||||
Pound = {
|
||||
Sprite = 794,
|
||||
Scale = 1.0,
|
||||
Colour = 1,
|
||||
},
|
||||
}
|
||||
|
||||
Config.DrawDistance = 10.0
|
||||
Config.DrawDistance = 10.0
|
||||
|
||||
Config.Markers = {
|
||||
EntryPoint = {
|
||||
Type = 1,
|
||||
Type = 21,
|
||||
Size = {
|
||||
x = 2.0,
|
||||
y = 2.0,
|
||||
z = 1.0
|
||||
x = 1.0,
|
||||
y = 1.0,
|
||||
z = 0.5
|
||||
},
|
||||
Color = {
|
||||
r = 54,
|
||||
g = 51,
|
||||
b = 255,
|
||||
r = 50,
|
||||
g = 200,
|
||||
b = 50
|
||||
}
|
||||
},
|
||||
GetOutPoint = {
|
||||
Type = 1,
|
||||
Type = 21,
|
||||
Size = {
|
||||
x = 2.0,
|
||||
y = 2.0,
|
||||
z = 1.0
|
||||
x = 1.0,
|
||||
y = 1.0,
|
||||
z = 0.5
|
||||
},
|
||||
Color = {
|
||||
r = 153,
|
||||
g = 51,
|
||||
b = 51,
|
||||
r = 200,
|
||||
g = 51,
|
||||
b = 51
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Config.Garages = {
|
||||
VespucciBoulevard = {
|
||||
EntryPoint = {
|
||||
x = -285.2,
|
||||
y = -886.5,
|
||||
z = 30.0
|
||||
x = -285.2,
|
||||
y = -886.5,
|
||||
z = 31.0
|
||||
},
|
||||
SpawnPoint = {
|
||||
x = -309.3,
|
||||
y = -897.0,
|
||||
z = 31.0,
|
||||
heading = 351.8
|
||||
x = -309.3,
|
||||
y = -897.0,
|
||||
z = 31.0,
|
||||
heading = 351.8
|
||||
},
|
||||
ImpoundedName = 'LosSantos',
|
||||
Sprite = 357,
|
||||
Scale = 0.8,
|
||||
Colour = 3,
|
||||
ImpoundedName = 'LosSantos'
|
||||
},
|
||||
SanAndreasAvenue = {
|
||||
EntryPoint = {
|
||||
x = 216.4,
|
||||
y = -786.6,
|
||||
z = 29.8,
|
||||
x = 216.4,
|
||||
y = -786.6,
|
||||
z = 30.8
|
||||
},
|
||||
SpawnPoint = {
|
||||
x = 218.9,
|
||||
y = -779.7,
|
||||
z = 30.8,
|
||||
heading = 338.8
|
||||
x = 218.9,
|
||||
y = -779.7,
|
||||
z = 30.8,
|
||||
heading = 338.8
|
||||
},
|
||||
ImpoundedName = 'LosSantos',
|
||||
},
|
||||
Sprite = 357,
|
||||
Scale = 0.8,
|
||||
Colour = 3,
|
||||
ImpoundedName = 'LosSantos'
|
||||
}
|
||||
}
|
||||
|
||||
Config.Pounds = {
|
||||
Config.Impounds = {
|
||||
LosSantos = {
|
||||
GetOutPoint = {
|
||||
x = 400.7,
|
||||
y = -1630.5,
|
||||
z = 28.3
|
||||
x = 400.7,
|
||||
y = -1630.5,
|
||||
z = 29.3
|
||||
},
|
||||
SpawnPoint = {
|
||||
x = 401.9,
|
||||
y = -1647.4,
|
||||
z = 29.2,
|
||||
heading = 323.3
|
||||
x = 401.9,
|
||||
y = -1647.4,
|
||||
z = 29.2,
|
||||
heading = 323.3
|
||||
},
|
||||
Sprite = 524,
|
||||
Scale = 0.8,
|
||||
Colour = 1,
|
||||
Cost = 3000
|
||||
},
|
||||
PaletoBay = {
|
||||
GetOutPoint = {
|
||||
x = -211.4,
|
||||
y = 6206.5,
|
||||
z = 30.4
|
||||
x = -211.4,
|
||||
y = 6206.5,
|
||||
z = 31.4
|
||||
},
|
||||
SpawnPoint = {
|
||||
x = -204.6,
|
||||
y = 6221.6,
|
||||
z = 30.5,
|
||||
heading = 227.2
|
||||
x = -204.6,
|
||||
y = 6221.6,
|
||||
z = 30.5,
|
||||
heading = 227.2
|
||||
},
|
||||
Sprite = 524,
|
||||
Scale = 0.8,
|
||||
Colour = 1,
|
||||
Cost = 3000
|
||||
},
|
||||
SandyShores = {
|
||||
GetOutPoint = {
|
||||
x = 1728.2,
|
||||
y = 3709.3,
|
||||
z = 33.2,
|
||||
x = 1728.2,
|
||||
y = 3709.3,
|
||||
z = 33.2
|
||||
},
|
||||
SpawnPoint = {
|
||||
x = 1722.7,
|
||||
y = 3713.6,
|
||||
z = 33.2,
|
||||
heading = 19.9
|
||||
x = 1722.7,
|
||||
y = 3713.6,
|
||||
z = 33.2,
|
||||
heading = 19.9
|
||||
},
|
||||
Sprite = 524,
|
||||
Scale = 0.8,
|
||||
Colour = 1,
|
||||
Cost = 3000
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,27 +8,10 @@ lua54 'yes'
|
||||
|
||||
shared_script '@es_extended/imports.lua'
|
||||
|
||||
server_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
'locales/*.lua',
|
||||
'@oxmysql/lib/MySQL.lua',
|
||||
'config.lua',
|
||||
'server/main.lua'
|
||||
}
|
||||
server_scripts {'@es_extended/locale.lua', 'locales/*.lua', '@oxmysql/lib/MySQL.lua', 'config.lua', 'server/main.lua'}
|
||||
|
||||
client_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
'locales/*.lua',
|
||||
'config.lua',
|
||||
'client/main.lua'
|
||||
}
|
||||
client_scripts {'@es_extended/locale.lua', 'locales/*.lua', 'config.lua', 'client/main.lua'}
|
||||
|
||||
ui_page 'nui/ui.html'
|
||||
|
||||
files {
|
||||
'nui/ui.html',
|
||||
'nui/js/*.js',
|
||||
'nui/css/*.css',
|
||||
'nui/img/*.png',
|
||||
'nui/roboto.ttf',
|
||||
}
|
||||
files {'nui/ui.html', 'nui/js/*.js', 'nui/css/*.css', 'nui/img/*.png', 'nui/roboto.ttf'}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
Locales["en"] = {
|
||||
["parking_blip_name"] = 'Garage',
|
||||
["pound_blip_name"] = 'Pound',
|
||||
["access_parking"] = 'press [E] to access the car park.',
|
||||
["access_pound"] = 'press [E] to access the pound.',
|
||||
["park_veh"] = 'press [E] to park the vehicle.',
|
||||
["not_owning_veh"] = 'this vehicle does not belong to you.',
|
||||
['veh_released'] = 'the vehicle has been released from the parking.',
|
||||
['veh_pound_released'] = 'the vehicle has been released from the pound.',
|
||||
['veh_stored'] = 'the vehicle has been stored.',
|
||||
['veh_impounded'] = 'the vehicle was impounded.',
|
||||
['no_veh_parking'] = 'no vehicles in this garage.',
|
||||
['no_veh_impounded'] = 'no vehicles impounded.',
|
||||
['no_veh_pound'] = 'you have no vehicle in this pound.',
|
||||
['veh_model'] = 'model',
|
||||
['veh_plate'] = 'plate',
|
||||
['veh_condition'] = 'condition',
|
||||
['veh_action'] = 'action',
|
||||
['impound_action'] = 'impound',
|
||||
['veh_exit'] = 'exit the vehicle',
|
||||
['pay_pound'] = 'pay the pound bill',
|
||||
['veh_block'] = 'it looks like a vehicle is blocking the exit.',
|
||||
['pay_pound_bill'] = 'you just paid ~g~$%s~s~ at the pound.',
|
||||
['missing_money'] = 'you do not have enough money.',
|
||||
}
|
||||
["parking_blip_name"] = 'Garage',
|
||||
["Impound_blip_name"] = 'Impound',
|
||||
["access_parking"] = 'press [E] to access the car park.',
|
||||
["access_Impound"] = 'press [E] to access the impound.',
|
||||
["park_veh"] = 'press [E] to park the vehicle.',
|
||||
["not_owning_veh"] = 'You do not own this vehicle!',
|
||||
['veh_released'] = 'Successfully Retrieved Vehicle.',
|
||||
['veh_Impound_released'] = 'Successfully Retrieved Vehicle From Impound.',
|
||||
['veh_stored'] = 'Successfully Stored Vehicle',
|
||||
['veh_impounded'] = 'Impounded Vehicle',
|
||||
['no_veh_parking'] = 'No Vehicles Stored Here.',
|
||||
['no_veh_impounded'] = 'No Impounded Vehicles.',
|
||||
['no_veh_Impound'] = 'you have No Impounded Vehicles.',
|
||||
['veh_model'] = 'Model',
|
||||
['veh_plate'] = 'Plate',
|
||||
['veh_condition'] = 'Condition',
|
||||
['veh_action'] = 'Action',
|
||||
['impound_action'] = 'Impound',
|
||||
['veh_exit'] = 'Retrieve Vehicle',
|
||||
['pay_impound'] = 'Pay Impound',
|
||||
['veh_block'] = 'Unable to retrieve vehicle, Spawn Position is blocked.',
|
||||
['pay_Impound_bill'] = 'Successfully Paid ~g~$%s~s~ to the Impound.',
|
||||
['missing_money'] = 'You don`t have enough money.'
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
Locales["fr"] = {
|
||||
["parking_blip_name"] = 'Garage',
|
||||
["pound_blip_name"] = 'Fourrière',
|
||||
["access_parking"] = "appuyez sur [E] pour accéder au parking.",
|
||||
["access_pound"] = 'appuyez sur [E] pour accéder à la fourrière.',
|
||||
["park_veh"] = "appuyez sur [E] pour ranger le véhicule.",
|
||||
["not_owning_veh"] = "ce véhicule ne t'appartient pas.",
|
||||
['veh_released'] = 'le véhicule a été sorti du parking.',
|
||||
['veh_pound_released'] = 'the vehicle has been released from the pound.',
|
||||
['veh_stored'] = 'le véhicule a bien été rangé.',
|
||||
['veh_impounded'] = 'le véhicule a bien été mis en fourrière.',
|
||||
['no_veh_parking'] = 'aucun véhicule dans ce parking.',
|
||||
['no_veh_impounded'] = 'aucun véhicule à mettre en fourrière.',
|
||||
['no_veh_pound'] = 'vous n\'avez aucun véhicule dans cette fourrière.',
|
||||
['veh_model'] = 'modèle',
|
||||
['veh_plate'] = 'immatriculation',
|
||||
['veh_condition'] = 'etat',
|
||||
['veh_action'] = 'action',
|
||||
['impound_action'] = 'impound',
|
||||
['veh_exit'] = 'sortir le véhicule',
|
||||
['pay_pound'] = 'payer la fourrière',
|
||||
['veh_block'] = 'il semble qu\'un véhicule gêne la sortie.',
|
||||
['pay_pound_bill'] = 'vous venez de payer $%s à la fourrière.',
|
||||
['missing_money'] = 'vous n\'avez pas assez d\'argent.'
|
||||
["parking_blip_name"] = 'Garage',
|
||||
["pound_blip_name"] = 'Fourrière',
|
||||
["access_parking"] = "appuyez sur [E] pour accéder au parking.",
|
||||
["access_pound"] = 'appuyez sur [E] pour accéder à la fourrière.',
|
||||
["park_veh"] = "appuyez sur [E] pour ranger le véhicule.",
|
||||
["not_owning_veh"] = "ce véhicule ne t'appartient pas.",
|
||||
['veh_released'] = 'le véhicule a été sorti du parking.',
|
||||
['veh_pound_released'] = 'the vehicle has been released from the pound.',
|
||||
['veh_stored'] = 'le véhicule a bien été rangé.',
|
||||
['veh_impounded'] = 'le véhicule a bien été mis en fourrière.',
|
||||
['no_veh_parking'] = 'aucun véhicule dans ce parking.',
|
||||
['no_veh_impounded'] = 'aucun véhicule à mettre en fourrière.',
|
||||
['no_veh_pound'] = 'vous n\'avez aucun véhicule dans cette fourrière.',
|
||||
['veh_model'] = 'modèle',
|
||||
['veh_plate'] = 'immatriculation',
|
||||
['veh_condition'] = 'etat',
|
||||
['veh_action'] = 'action',
|
||||
['impound_action'] = 'impound',
|
||||
['veh_exit'] = 'sortir le véhicule',
|
||||
['pay_pound'] = 'payer la fourrière',
|
||||
['veh_block'] = 'il semble qu\'un véhicule gêne la sortie.',
|
||||
['pay_pound_bill'] = 'vous venez de payer $%s à la fourrière.',
|
||||
['missing_money'] = 'vous n\'avez pas assez d\'argent.'
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@font-face {
|
||||
font-family: roboto;
|
||||
src: url("../roboto.ttf");
|
||||
src: url('../roboto.ttf');
|
||||
}
|
||||
|
||||
body {
|
||||
|
||||
@@ -1,45 +1,50 @@
|
||||
$(window).ready(function () {
|
||||
window.addEventListener("message", function (event) {
|
||||
let data = event.data;
|
||||
window.addEventListener('message', function (event) {
|
||||
let data = event.data
|
||||
|
||||
if (data.showMenu) {
|
||||
$("#container").fadeIn();
|
||||
$("#menu").fadeIn();
|
||||
$('#container').fadeIn()
|
||||
$('#menu').fadeIn()
|
||||
|
||||
if (data.type === 'impound') {
|
||||
$('#header ul').hide();
|
||||
$('#header ul').hide()
|
||||
} else {
|
||||
$('#header ul').show();
|
||||
$('#header ul').show()
|
||||
}
|
||||
|
||||
|
||||
if (data.vehiclesList != undefined) {
|
||||
$("#container").data("spawnpoint", data.spawnPoint);
|
||||
if (data.poundCost) $("#container").data("poundcost", data.poundCost);
|
||||
$('#container').data('spawnpoint', data.spawnPoint)
|
||||
if (data.poundCost) $('#container').data('poundcost', data.poundCost)
|
||||
|
||||
if (data.poundCost != undefined) {
|
||||
$(".content .vehicle-list").html(getVehicles(data.locales, data.vehiclesList, data.poundCost));
|
||||
$('.content .vehicle-list').html(
|
||||
getVehicles(data.locales, data.vehiclesList, data.poundCost)
|
||||
)
|
||||
} else {
|
||||
$(".content .vehicle-list").html(getVehicles(data.locales, data.vehiclesList));
|
||||
$('.content .vehicle-list').html(
|
||||
getVehicles(data.locales, data.vehiclesList)
|
||||
)
|
||||
}
|
||||
|
||||
$('.content h2').hide();
|
||||
$('.content h2').hide()
|
||||
} else {
|
||||
$('.content h2').show();
|
||||
$('.content .vehicle-list').empty();
|
||||
$('.content h2').show()
|
||||
$('.content .vehicle-list').empty()
|
||||
}
|
||||
|
||||
if (data.vehiclesImpoundedList != undefined) {
|
||||
$(".impounded_content").data("poundName", data.poundName);
|
||||
$(".impounded_content").data("poundSpawnPoint", data.poundSpawnPoint);
|
||||
$('.impounded_content').data('poundName', data.poundName)
|
||||
$('.impounded_content').data('poundSpawnPoint', data.poundSpawnPoint)
|
||||
|
||||
if (data.poundCost) $("#container").data("poundcost", data.poundCost);
|
||||
if (data.poundCost) $('#container').data('poundcost', data.poundCost)
|
||||
|
||||
$(".impounded_content .vehicle-list").html(getImpoundedVehicles(data.locales, data.vehiclesImpoundedList));
|
||||
$('.impounded_content h2').hide();
|
||||
$('.impounded_content .vehicle-list').html(
|
||||
getImpoundedVehicles(data.locales, data.vehiclesImpoundedList)
|
||||
)
|
||||
$('.impounded_content h2').hide()
|
||||
} else {
|
||||
$('.impounded_content h2').show();
|
||||
$('.impounded_content .vehicle-list').empty();
|
||||
$('.impounded_content h2').show()
|
||||
$('.impounded_content .vehicle-list').empty()
|
||||
}
|
||||
|
||||
// Locales
|
||||
@@ -53,166 +58,171 @@ $(window).ready(function () {
|
||||
// return text.replace("No vehicle impounded.", data.locales.no_veh_impounded);
|
||||
// });
|
||||
|
||||
$(".vehicle-listing").html(function (i, text) {
|
||||
return text.replace("Model", data.locales.veh_model);
|
||||
});
|
||||
$(".vehicle-listing").html(function (i, text) {
|
||||
return text.replace("Plate", data.locales.veh_plate);
|
||||
});
|
||||
$(".vehicle-listing").html(function (i, text) {
|
||||
return text.replace("Condition", data.locales.veh_condition);
|
||||
});
|
||||
$('.vehicle-listing').html(function (i, text) {
|
||||
return text.replace('Model', data.locales.veh_model)
|
||||
})
|
||||
$('.vehicle-listing').html(function (i, text) {
|
||||
return text.replace('Plate', data.locales.veh_plate)
|
||||
})
|
||||
$('.vehicle-listing').html(function (i, text) {
|
||||
return text.replace('Condition', data.locales.veh_condition)
|
||||
})
|
||||
} else if (data.hideAll) {
|
||||
$("#container").fadeOut();
|
||||
$('#container').fadeOut()
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$("#container").hide();
|
||||
$('#container').hide()
|
||||
|
||||
$(".close").click(function (event) {
|
||||
$("#container").hide();
|
||||
$.post("https://esx_garage/escape", "{}");
|
||||
$('.close').click(function (event) {
|
||||
$('#container').hide()
|
||||
$.post('https://esx_garage/escape', '{}')
|
||||
|
||||
$(".impounded_content").hide();
|
||||
$(".content").show();
|
||||
$('li[data-page="garage"]').addClass("selected")
|
||||
$('li[data-page="impounded"]').removeClass("selected")
|
||||
});
|
||||
$('.impounded_content').hide()
|
||||
$('.content').show()
|
||||
$('li[data-page="garage"]').addClass('selected')
|
||||
$('li[data-page="impounded"]').removeClass('selected')
|
||||
})
|
||||
|
||||
document.onkeyup = function (data) {
|
||||
if (data.which == 27) {
|
||||
$.post("https://esx_garage/escape", "{}");
|
||||
$.post('https://esx_garage/escape', '{}')
|
||||
|
||||
$(".impounded_content").hide();
|
||||
$(".content").show();
|
||||
$('li[data-page="garage"]').addClass("selected")
|
||||
$('li[data-page="impounded"]').removeClass("selected")
|
||||
$('.impounded_content').hide()
|
||||
$('.content').show()
|
||||
$('li[data-page="garage"]').addClass('selected')
|
||||
$('li[data-page="impounded"]').removeClass('selected')
|
||||
}
|
||||
};
|
||||
|
||||
function getVehicles(locale, vehicle, amount = null) {
|
||||
let html = "";
|
||||
let vehicleData = JSON.parse(vehicle);
|
||||
let bodyHealth = 1000;
|
||||
let engineHealth = 1000;
|
||||
let tankHealth = 1000;
|
||||
let vehicleDamagePercent = "";
|
||||
|
||||
for (let i = 0; i < vehicleData.length; i++) {
|
||||
bodyHealth = (vehicleData[i].props.bodyHealth / 1000) * 100;
|
||||
engineHealth = (vehicleData[i].props.engineHealth / 1000) * 100;
|
||||
tankHealth = (vehicleData[i].props.tankHealth / 1000) * 100;
|
||||
|
||||
vehicleDamagePercent =
|
||||
Math.round(((bodyHealth + engineHealth + tankHealth) / 300) * 100) +
|
||||
"%";
|
||||
|
||||
html += "<div class='vehicle-listing'>";
|
||||
html += "<div>Model: <strong>" + vehicleData[i].model + "</strong></div>";
|
||||
html += "<div>Plate: <strong>" + vehicleData[i].plate + "</strong></div>";
|
||||
html +=
|
||||
"<div>Condition: <strong>" + vehicleDamagePercent + "</strong></div>";
|
||||
html +=
|
||||
"<button data-button='spawn' class='vehicle-action unstyled-button' data-vehprops='" +
|
||||
JSON.stringify(vehicleData[i].props) +
|
||||
"'>" +
|
||||
locale.action + (amount ? " ($" + amount + ")" : "") +
|
||||
"</button>";
|
||||
html += "</div>";
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
function getVehicles (locale, vehicle, amount = null) {
|
||||
let html = ''
|
||||
let vehicleData = JSON.parse(vehicle)
|
||||
let bodyHealth = 1000
|
||||
let engineHealth = 1000
|
||||
let tankHealth = 1000
|
||||
let vehicleDamagePercent = ''
|
||||
|
||||
function getImpoundedVehicles(locale, vehicle) {
|
||||
let html = "";
|
||||
let vehicleData = JSON.parse(vehicle);
|
||||
let bodyHealth = 1000;
|
||||
let engineHealth = 1000;
|
||||
let tankHealth = 1000;
|
||||
let vehicleDamagePercent = "";
|
||||
for (let i = 0; i < vehicleData.length; i++) {
|
||||
bodyHealth = (vehicleData[i].props.bodyHealth / 1000) * 100
|
||||
engineHealth = (vehicleData[i].props.engineHealth / 1000) * 100
|
||||
tankHealth = (vehicleData[i].props.tankHealth / 1000) * 100
|
||||
|
||||
for (let i = 0; i < vehicleData.length; i++) {
|
||||
bodyHealth = (vehicleData[i].props.bodyHealth / 1000) * 100;
|
||||
engineHealth = (vehicleData[i].props.engineHealth / 1000) * 100;
|
||||
tankHealth = (vehicleData[i].props.tankHealth / 1000) * 100;
|
||||
vehicleDamagePercent =
|
||||
Math.round(((bodyHealth + engineHealth + tankHealth) / 300) * 100) + '%'
|
||||
|
||||
vehicleDamagePercent =
|
||||
Math.round(((bodyHealth + engineHealth + tankHealth) / 300) * 100) +
|
||||
"%";
|
||||
html += "<div class='vehicle-listing'>"
|
||||
html += '<div>Model: <strong>' + vehicleData[i].model + '</strong></div>'
|
||||
html += '<div>Plate: <strong>' + vehicleData[i].plate + '</strong></div>'
|
||||
html +=
|
||||
'<div>Condition: <strong>' + vehicleDamagePercent + '</strong></div>'
|
||||
html +=
|
||||
"<button data-button='spawn' class='vehicle-action unstyled-button' data-vehprops='" +
|
||||
JSON.stringify(vehicleData[i].props) +
|
||||
"'>" +
|
||||
locale.action +
|
||||
(amount ? ' ($' + amount + ')' : '') +
|
||||
'</button>'
|
||||
html += '</div>'
|
||||
}
|
||||
|
||||
html += "<div class='vehicle-listing'>";
|
||||
html += "<div>Model: <strong>" + vehicleData[i].model + "</strong></div>";
|
||||
html += "<div>Plate: <strong>" + vehicleData[i].plate + "</strong></div>";
|
||||
html +=
|
||||
"<div>Condition: <strong>" + vehicleDamagePercent + "</strong></div>";
|
||||
html +=
|
||||
"<button data-button='impounded' class='vehicle-action red unstyled-button' data-vehprops='" +
|
||||
JSON.stringify(vehicleData[i].props) +
|
||||
"'>" +
|
||||
locale.impound_action +
|
||||
"</button>";
|
||||
html += "</div>";
|
||||
return html
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
function getImpoundedVehicles (locale, vehicle) {
|
||||
let html = ''
|
||||
let vehicleData = JSON.parse(vehicle)
|
||||
let bodyHealth = 1000
|
||||
let engineHealth = 1000
|
||||
let tankHealth = 1000
|
||||
let vehicleDamagePercent = ''
|
||||
|
||||
for (let i = 0; i < vehicleData.length; i++) {
|
||||
bodyHealth = (vehicleData[i].props.bodyHealth / 1000) * 100
|
||||
engineHealth = (vehicleData[i].props.engineHealth / 1000) * 100
|
||||
tankHealth = (vehicleData[i].props.tankHealth / 1000) * 100
|
||||
|
||||
$('li[data-page="garage"]').click(function(event) {
|
||||
$(".impounded_content").hide();
|
||||
$(".content").show();
|
||||
$('li[data-page="garage"]').addClass("selected")
|
||||
$('li[data-page="impounded"]').removeClass("selected")
|
||||
});
|
||||
vehicleDamagePercent =
|
||||
Math.round(((bodyHealth + engineHealth + tankHealth) / 300) * 100) + '%'
|
||||
|
||||
$('li[data-page="impounded"]').click(function(event) {
|
||||
$(".content").hide();
|
||||
$(".impounded_content").show();
|
||||
$('li[data-page="impounded"]').addClass("selected")
|
||||
$('li[data-page="garage"]').removeClass("selected")
|
||||
});
|
||||
html += "<div class='vehicle-listing'>"
|
||||
html += '<div>Model: <strong>' + vehicleData[i].model + '</strong></div>'
|
||||
html += '<div>Plate: <strong>' + vehicleData[i].plate + '</strong></div>'
|
||||
html +=
|
||||
'<div>Condition: <strong>' + vehicleDamagePercent + '</strong></div>'
|
||||
html +=
|
||||
"<button data-button='impounded' class='vehicle-action red unstyled-button' data-vehprops='" +
|
||||
JSON.stringify(vehicleData[i].props) +
|
||||
"'>" +
|
||||
locale.impound_action +
|
||||
'</button>'
|
||||
html += '</div>'
|
||||
}
|
||||
|
||||
$(document).on("click", "button[data-button='spawn'].vehicle-action", function (event) {
|
||||
let spawnPoint = $("#container").data("spawnpoint");
|
||||
let poundCost = $("#container").data("poundcost");
|
||||
let vehicleProps = $(this).data("vehprops");
|
||||
return html
|
||||
}
|
||||
|
||||
// prevent empty cost
|
||||
if (poundCost === undefined) poundCost = 0;
|
||||
$('li[data-page="garage"]').click(function (event) {
|
||||
$('.impounded_content').hide()
|
||||
$('.content').show()
|
||||
$('li[data-page="garage"]').addClass('selected')
|
||||
$('li[data-page="impounded"]').removeClass('selected')
|
||||
})
|
||||
|
||||
$.post(
|
||||
"https://esx_garage/spawnVehicle",
|
||||
JSON.stringify({
|
||||
vehicleProps: vehicleProps,
|
||||
spawnPoint: spawnPoint,
|
||||
exitVehicleCost: poundCost
|
||||
})
|
||||
);
|
||||
$('li[data-page="impounded"]').click(function (event) {
|
||||
$('.content').hide()
|
||||
$('.impounded_content').show()
|
||||
$('li[data-page="impounded"]').addClass('selected')
|
||||
$('li[data-page="garage"]').removeClass('selected')
|
||||
})
|
||||
|
||||
$(".impounded_content").hide();
|
||||
$(".content").show();
|
||||
$('li[data-page="garage"]').addClass("selected")
|
||||
$('li[data-page="impounded"]').removeClass("selected")
|
||||
});
|
||||
$(document).on(
|
||||
'click',
|
||||
"button[data-button='spawn'].vehicle-action",
|
||||
function (event) {
|
||||
let spawnPoint = $('#container').data('spawnpoint')
|
||||
let poundCost = $('#container').data('poundcost')
|
||||
let vehicleProps = $(this).data('vehprops')
|
||||
|
||||
$(document).on("click", "button[data-button='impounded'].vehicle-action", function (event) {
|
||||
// prevent empty cost
|
||||
if (poundCost === undefined) poundCost = 0
|
||||
|
||||
let vehicleProps = $(this).data("vehprops");
|
||||
let poundName = $(".impounded_content").data("poundName");
|
||||
let poundSpawnPoint = $(".impounded_content").data("poundSpawnPoint");
|
||||
$.post(
|
||||
"https://esx_garage/impound",
|
||||
JSON.stringify({
|
||||
vehicleProps: vehicleProps,
|
||||
poundName: poundName,
|
||||
poundSpawnPoint: poundSpawnPoint
|
||||
})
|
||||
);
|
||||
$.post(
|
||||
'https://esx_garage/spawnVehicle',
|
||||
JSON.stringify({
|
||||
vehicleProps: vehicleProps,
|
||||
spawnPoint: spawnPoint,
|
||||
exitVehicleCost: poundCost
|
||||
})
|
||||
)
|
||||
|
||||
$(".impounded_content").hide();
|
||||
$(".content").show();
|
||||
$('li[data-page="garage"]').addClass("selected")
|
||||
$('li[data-page="impounded"]').removeClass("selected")
|
||||
});
|
||||
});
|
||||
$('.impounded_content').hide()
|
||||
$('.content').show()
|
||||
$('li[data-page="garage"]').addClass('selected')
|
||||
$('li[data-page="impounded"]').removeClass('selected')
|
||||
}
|
||||
)
|
||||
|
||||
$(document).on(
|
||||
'click',
|
||||
"button[data-button='impounded'].vehicle-action",
|
||||
function (event) {
|
||||
let vehicleProps = $(this).data('vehprops')
|
||||
let poundName = $('.impounded_content').data('poundName')
|
||||
let poundSpawnPoint = $('.impounded_content').data('poundSpawnPoint')
|
||||
$.post(
|
||||
'https://esx_garage/impound',
|
||||
JSON.stringify({
|
||||
vehicleProps: vehicleProps,
|
||||
poundName: poundName,
|
||||
poundSpawnPoint: poundSpawnPoint
|
||||
})
|
||||
)
|
||||
|
||||
$('.impounded_content').hide()
|
||||
$('.content').show()
|
||||
$('li[data-page="garage"]').addClass('selected')
|
||||
$('li[data-page="impounded"]').removeClass('selected')
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="header">
|
||||
<div class="title" style="display: inline">ESX garage</div>
|
||||
<div class="title" style="display: inline">ESX Garage</div>
|
||||
<ul>
|
||||
<li data-page="garage" class="selected">Garage</li>
|
||||
<li data-page="impounded">Impounded</li>
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
<div id="menu">
|
||||
<div class="content">
|
||||
<h2>No vehicle in this garage.</h2>
|
||||
<h2>No Vehicles Stored Here.</h2>
|
||||
<div class="vehicle-list"></div>
|
||||
</div>
|
||||
|
||||
<div class="impounded_content">
|
||||
<h2>No vehicle impounded.</h2>
|
||||
<h2>No Impounded Vehicles.</h2>
|
||||
<div class="vehicle-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
RegisterServerEvent('esx_garage:updateOwnedVehicle')
|
||||
AddEventHandler('esx_garage:updateOwnedVehicle', function(stored, parking, pound, vehicleProps)
|
||||
AddEventHandler('esx_garage:updateOwnedVehicle', function(stored, parking, Impound, vehicleProps)
|
||||
local source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
MySQL.update('UPDATE owned_vehicles SET `stored` = @stored, `parking` = @parking, `pound` = @pound, `vehicle` = @vehicle WHERE `plate` = @plate AND `owner` = @identifier',
|
||||
MySQL.update('UPDATE owned_vehicles SET `stored` = @stored, `parking` = @parking, `pound` = @Impound, `vehicle` = @vehicle WHERE `plate` = @plate AND `owner` = @identifier',
|
||||
{
|
||||
['@identifier'] = xPlayer.identifier,
|
||||
['@vehicle'] = json.encode(vehicleProps),
|
||||
['@plate'] = vehicleProps.plate,
|
||||
['@stored'] = stored,
|
||||
['@parking'] = parking,
|
||||
['@pound'] = pound
|
||||
['@Impound'] = Impound
|
||||
})
|
||||
|
||||
if stored then
|
||||
@@ -19,17 +19,17 @@ AddEventHandler('esx_garage:updateOwnedVehicle', function(stored, parking, pound
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_garage:setImpound')
|
||||
AddEventHandler('esx_garage:setImpound', function(pound, vehicleProps)
|
||||
AddEventHandler('esx_garage:setImpound', function(Impound, vehicleProps)
|
||||
local source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
MySQL.update('UPDATE owned_vehicles SET `stored` = @stored, `pound` = @pound, `vehicle` = @vehicle WHERE `plate` = @plate AND `owner` = @identifier',
|
||||
MySQL.update('UPDATE owned_vehicles SET `stored` = @stored, `pound` = @Impound, `vehicle` = @vehicle WHERE `plate` = @plate AND `owner` = @identifier',
|
||||
{
|
||||
['@identifier'] = xPlayer.identifier,
|
||||
['@vehicle'] = json.encode(vehicleProps),
|
||||
['@plate'] = vehicleProps.plate,
|
||||
['@stored'] = 2,
|
||||
['@pound'] = pound
|
||||
['@Impound'] = Impound
|
||||
})
|
||||
|
||||
xPlayer.showNotification(_U('veh_impounded'))
|
||||
@@ -96,13 +96,13 @@ ESX.RegisterServerCallback('esx_garage:getVehiclesImpounded', function(source, c
|
||||
end)
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_garage:getVehiclesInPound', function(source, cb, pound)
|
||||
ESX.RegisterServerCallback('esx_garage:getVehiclesInPound', function(source, cb, Impound)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
MySQL.query('SELECT * FROM `owned_vehicles` WHERE `owner` = @identifier AND `pound` = @pound AND `stored` = 2',
|
||||
MySQL.query('SELECT * FROM `owned_vehicles` WHERE `owner` = @identifier AND `pound` = @Impound AND `stored` = 2',
|
||||
{
|
||||
['@identifier'] = xPlayer.identifier,
|
||||
['@pound'] = pound
|
||||
['@Impound'] = Impound
|
||||
}, function(result)
|
||||
local vehicles = {}
|
||||
|
||||
@@ -125,12 +125,12 @@ end)
|
||||
|
||||
RegisterServerEvent("esx_garage:payPound")
|
||||
AddEventHandler("esx_garage:payPound", function(amount)
|
||||
local source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
if xPlayer.getMoney() >= amount then
|
||||
xPlayer.removeMoney(amount)
|
||||
|
||||
xPlayer.showNotification(_U('pay_pound_bill', amount))
|
||||
xPlayer.showNotification(_U('pay_Impound_bill', amount))
|
||||
else
|
||||
xPlayer.showNotification(_U('missing_money'))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user