ESX = exports["es_extended"]:getSharedObject()
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
[Link] = xPlayer
end)
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
[Link] = job
end)
local currentVehicles = 0
local maxVehicles = 15
local vehicleCounts = {
["bcpd10"] = 0,
["command"] = 0,
["polfugitivep"] = 0,
["polalamop2"] = 0,
["polbuffalop"] = 0,
["polbuffalop2"] = 0,
["polcarap"] = 0,
["polscoutp"] = 0,
["polspeedop"] = 0,
["polstanierp"] = 0,
["coach2"] = 0, --bus
["swatinsur"] = 0,
["swatstoc"] = 0,
["polbikeb2"] = 0,
}
local function updateDescription(model)
local available = maxVehicles - (vehicleCounts[model] or 0)
return 'Véhicules disponibles : '.. available
end
local function updateVehicleCount(model, delta)
vehicleCounts[model] = (vehicleCounts[model] or 0) + delta
end
local function createVehicle(model)
RequestModel(model)
while not HasModelLoaded(model) do
[Link](10)
end
local playerPed = PlayerPedId()
local playerId = PlayerId()
local coords = GetEntityCoords(playerPed)
local heading = 156.8088
local vehicle = CreateVehicle(model, -313.8059, -1038.4734, 23.0270, heading,
true, false)
while not DoesEntityExist(vehicle) do
[Link](10)
end
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
local plate = GetVehicleNumberPlateText(vehicle)
local hasKey = exports['KaitoCK']:HasKey(plate)
if not hasKey then
exports['KaitoCK']:AddCarkey(playerId, plate, model)
end
SetVehicleDoorsLocked(vehicle, 1)
SetVehicleDoorsLockedForAllPlayers(vehicle, false)
updateVehicleCount(model, 1)
[Link]("~g~Votre véhicule de service a été sorti" .. (hasKey and
" (clé déjà en votre possession)." or " et la clé a été ajoutée."))
end
local function OpenMenuGarage()
local options = {
{
title = 'Ranger votre véhicule',
description = 'Ranger',
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
local playerPed = PlayerPedId()
local playerId = PlayerId()
local vehicle = nil
if IsPedSittingInAnyVehicle(playerPed) then
vehicle = GetVehiclePedIsIn(playerPed, false)
if GetPedInVehicleSeat(vehicle, -1) ~= playerPed then
return [Link]('Vous devez être au siège conducteur,
ou sortir de la voiture.')
end
else
vehicle = [Link]()
if not DoesEntityExist(vehicle) then
return [Link]('Aucune voiture autour.')
end
end
local model = GetEntityModel(vehicle)
local name = GetDisplayNameFromVehicleModel(model)
local plate = GetVehicleNumberPlateText(vehicle)
local hasKey = exports['KaitoCK']:HasKey(plate)
if hasKey then
exports['KaitoCK']:RemoveCarkey(playerId, plate, model)
end
[Link](vehicle)
updateVehicleCount(name, -1)
[Link]('~g~La voiture a été mise dans le garage.')
end
},
{
title = 'Lampaladi',
description = updateDescription("bcpd10"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["bcpd10"] or 0) < maxVehicles then
createVehicle("bcpd10")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'MCC',
description = updateDescription("command"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["command"] or 0) < maxVehicles then
createVehicle("command")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'Cheval',
description = updateDescription("polfugitivep"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["polfugitivep"] or 0) < maxVehicles then
createVehicle("polfugitivep")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'Alamo',
description = updateDescription("polalamop2"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["polalamop2"] or 0) < maxVehicles then
createVehicle("polalamop2")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'Bravado',
description = updateDescription("polbuffalop"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["polbuffalop"] or 0) < maxVehicles then
createVehicle("polbuffalop")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'Buffalo',
description = updateDescription("polbuffalop2"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["polbuffalop2"] or 0) < maxVehicles then
createVehicle("polbuffalop2")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'Vapid',
description = updateDescription("polcarap"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["polcarap"] or 0) < maxVehicles then
createVehicle("polcarap")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'Cruiser',
description = updateDescription("polscoutp"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["polscoutp"] or 0) < maxVehicles then
createVehicle("polscoutp")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'Speedo',
description = updateDescription("polspeedop"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["polspeedop"] or 0) < maxVehicles then
createVehicle("polspeedop")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'Stanier',
description = updateDescription("polstanierp"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["polstanierp"] or 0) < maxVehicles then
createVehicle("polstanierp")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'BUS',
description = updateDescription("coach2"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["coach2"] or 0) < maxVehicles then
createVehicle("coach2")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'Swat',
description = updateDescription("swatinsur"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["swatinsur"] or 0) < maxVehicles then
createVehicle("swatinsur")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'Swat Stoc',
description = updateDescription("swatstoc"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["swatstoc"] or 0) < maxVehicles then
createVehicle("swatstoc")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
{
title = 'Bike B',
description = updateDescription("polbikeb2"),
icon = 'fas fa-home',
iconColor = '#ffffff',
onSelect = function()
if (vehicleCounts["polbikeb2"] or 0) < maxVehicles then
createVehicle("polbikeb2")
else
[Link]("Limite de véhicules atteinte", "#5fa05d")
end
end
},
}
[Link]({
id = 'garage_menu',
title = 'Garage',
options = options
})
[Link]('garage_menu')
end
-- Configuration de la zone d'interaction pour le garage
local garageCoords = vector3(-326.7041, -1031.5956, 23.0271)
[Link](function()
while true do
[Link](0)
local playerCoords = GetEntityCoords(PlayerPedId())
local distance = #(playerCoords - garageCoords)
if distance < 5.0 then
[Link]('esx:getPlayerData', function(playerData)
if [Link] == "police" then
[Link]("Appuyez sur ~INPUT_CONTEXT~ pour
ouvrir le garage.")
if IsControlJustReleased(1, 51) then -- Touche E
OpenMenuGarage()
end
end
end)
end
end
end)
Notification = function(type, title, text)
if [Link] == "esx" then
[Link](text)
elseif [Link] == "ox" then
if type == "info" then
[Link]({
title = title,
description = text,
type = "inform"
})
elseif type == "error" then
[Link]({
title = title,
description = text,
type = "error"
})
elseif type == "success" then
[Link]({
title = title,
description = text,
type = "success"
})
end
elseif [Link] == "okok" then
if type == "info" then
exports['okokNotify']:Alert(
title,
text,
5000,
type
)
elseif type == "error" then
exports['okokNotify']:Alert(
title,
text,
5000,
type
)
elseif type == "success" then
exports['okokNotify']:Alert(
title,
text,
5000,
type
)
end
end
end
ProgressBar = function(duration, label)
if [Link] == "bar" then
[Link]({
duration = duration,
label = label,
useWhileDead = false,
canCancel = false
})
elseif [Link] == "circle" then
[Link]({
duration = duration,
label = label,
useWhileDead = false,
canCancel = false
})
end
end
RegisterNetEvent('cartearmepolice')
AddEventHandler('cartearmepolice', function()
dict = "missheist_agency3aig_23"
clip = "urinal_sink_loop"
RequestAnimDict(dict)
while (not HasAnimDictLoaded(dict)) do Wait(0) end
TaskPlayAnim([Link], dict, clip, 3.0, 1.0, -1, 49, 0, false, false, false)
FreezeEntityPosition([Link], true)
ProgressBar([Link],
[Link])
StopAnimTask([Link], dict, clip, 1.0)
FreezeEntityPosition([Link], false)
ClearPedTasks([Link])
Notification("success", "", "Carte permis arme fait avec success")
TriggerServerEvent('visionpolice:add', 'item', 1, 'ppa')
TriggerServerEvent('esx_dmvschool:addLicense', 'weapon')
end)
CreateThread(function()
for i = 1, #[Link] do
[Link]:AddBoxZone(i .. "_policecarte_menu",
[Link][i].coords, 1.0, 1.0, {
name = i .. "_policecarte_menu",
heading = [Link][i].heading,
debugPoly = false,
minZ = [Link][i].coords.z - 1.5,
maxZ = [Link][i].coords.z + 1.5
}, {
options = {
{
event = 'cartearmepolice',
icon = [Link][i].icon,
label = [Link][i].labeltarget,
job = "police"
}
},
distance = 1.5
})
end
end)