-- Local local Keys = { ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 } local CurrentAction = nil local GUI = {} GUI.Time = 0 local HasAlreadyEnteredMarker = false local LastZone = nil local CurrentActionMsg = '' local CurrentActionData = {} local this_Garage = {} -- Fin Local -- Init ESX ESX = nil Citizen.CreateThread(function() while ESX == nil do TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Citizen.Wait(0) end end) -- Fin init ESX --- Gestion Des blips RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(xPlayer) --PlayerData = xPlayer --TriggerServerEvent('esx_jobs:giveBackCautionInCaseOfDrop') refreshBlips() end) function refreshBlips() local zones = {} local blipInfo = {} for zoneKey,zoneValues in pairs(Config.Garages)do local blip = AddBlipForCoord(zoneValues.Pos.x, zoneValues.Pos.y, zoneValues.Pos.z) SetBlipSprite (blip, Config.BlipInfos.Sprite) SetBlipDisplay(blip, 4) SetBlipScale (blip, 1.2) SetBlipColour (blip, Config.BlipInfos.Color) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") AddTextComponentString(zoneKey) EndTextCommandSetBlipName(blip) end end -- Fin Gestion des Blips --Fonction Menu function OpenMenuGarage() ESX.UI.Menu.CloseAll() local elements = { {label = "Lista pojazdow", value = 'list_vehicles'}, {label = "Zwroc pojazd", value = 'stock_vehicle'}, {label = "Zniszczone pojazdy ("..Config.Price.."$)", value = 'return_vehicle'}, } ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'garage_menu', { title = 'Garage', align = 'top-left', elements = elements, }, function(data, menu) menu.close() if(data.current.value == 'list_vehicles') then ListVehiclesMenu() end if(data.current.value == 'stock_vehicle') then StockVehicleMenu() end if(data.current.value == 'return_vehicle') then ReturnVehicleMenu() end local playerPed = GetPlayerPed(-1) SpawnVehicle(data.current.value) --local coords = societyConfig.Zones.VehicleSpawnPoint.Pos end, function(data, menu) menu.close() --CurrentAction = 'open_garage_action' end ) end -- Afficher les listes des vehicules function ListVehiclesMenu() local elements = {} ESX.TriggerServerCallback('eden_garage:getVehicles', function(vehicles) for _,v in pairs(vehicles) do local hashVehicule = v.vehicle.model local vehicleName = GetDisplayNameFromVehicleModel(hashVehicule) local labelvehicle if(v.state)then labelvehicle = vehicleName..': W garazu' else labelvehicle = vehicleName..': Brak w garazu' end table.insert(elements, {label =labelvehicle , value = v}) end ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'spawn_vehicle', { title = 'Garage', align = 'top-left', elements = elements, }, function(data, menu) if(data.current.value.state)then menu.close() SpawnVehicle(data.current.value.vehicle) else TriggerEvent('esx:showNotification', 'Pojazd zostal wyciagniety') end end, function(data, menu) menu.close() --CurrentAction = 'open_garage_action' end ) end) end -- Fin Afficher les listes des vehicules -- Fonction qui permet de rentrer un vehicule function StockVehicleMenu() local playerPed = GetPlayerPed(-1) if IsAnyVehicleNearPoint(this_Garage.DeletePoint.Pos.x, this_Garage.DeletePoint.Pos.y, this_Garage.DeletePoint.Pos.z, 3.5) then local vehicle = GetClosestVehicle(this_Garage.DeletePoint.Pos.x, this_Garage.DeletePoint.Pos.y, this_Garage.DeletePoint.Pos.z, this_Garage.DeletePoint.Size.x, 0, 70) local vehicleProps = ESX.Game.GetVehicleProperties(vehicle) ESX.TriggerServerCallback('eden_garage:stockv',function(valid) if(valid) then TriggerServerEvent('eden_garage:debug', vehicle) DeleteVehicle(vehicle) TriggerServerEvent('eden_garage:modifystate', vehicleProps, true) TriggerEvent('esx:showNotification', 'Pojazd zostal przeniesiony do garazu') else TriggerEvent('esx:showNotification', 'Nie posiadasz tego pojazdu') end end,vehicleProps) else TriggerEvent('esx:showNotification', 'Brak pojazdu w punkcie') end end -- Fin fonction qui permet de rentrer un vehicule --Fin fonction Menu --Fonction pour spawn vehicule function SpawnVehicle(vehicle) ESX.Game.SpawnVehicle(vehicle.model, { x = this_Garage.SpawnPoint.Pos.x , y = this_Garage.SpawnPoint.Pos.y, z = this_Garage.SpawnPoint.Pos.z + 1 },120, function(callback_vehicle) ESX.Game.SetVehicleProperties(callback_vehicle, vehicle) end) TriggerServerEvent('eden_garage:modifystate', vehicle, false) end --Fin fonction pour spawn vehicule --Action das les markers AddEventHandler('eden_garage:hasEnteredMarker', function(zone) if zone == 'garage' then CurrentAction = 'garage_action_menu' CurrentActionMsg = "Wcisnij ~INPUT_PICKUP~ zeby otworzyc garaz" CurrentActionData = {} end end) AddEventHandler('eden_garage:hasExitedMarker', function(zone) ESX.UI.Menu.CloseAll() CurrentAction = nil end) --Fin Action das les markers function ReturnVehicleMenu() ESX.TriggerServerCallback('eden_garage:getOutVehicles', function(vehicles) local elements = {} for _,v in pairs(vehicles) do local hashVehicule = v.model local vehicleName = GetDisplayNameFromVehicleModel(hashVehicule) local labelvehicle labelvehicle = vehicleName..': Brak pojazdu w garazu' table.insert(elements, {label =labelvehicle , value = v}) end ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'return_vehicle', { title = 'Garage', align = 'top-left', elements = elements, }, function(data, menu) ESX.TriggerServerCallback('eden_garage:checkMoney', function(hasEnoughMoney) if hasEnoughMoney then TriggerServerEvent('eden_garage:pay') SpawnVehicle(data.current.value) else ESX.ShowNotification('Nie masz wystarczajaco pieniedzy') end end) end, function(data, menu) menu.close() --CurrentAction = 'open_garage_action' end ) end) end -- Affichage markers Citizen.CreateThread(function() while true do Wait(0) local coords = GetEntityCoords(GetPlayerPed(-1)) for k,v in pairs(Config.Garages) do if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then DrawMarker(v.Marker, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, true, 2, false, false, false, false) DrawMarker(v.SpawnPoint.Marker, v.SpawnPoint.Pos.x, v.SpawnPoint.Pos.y, v.SpawnPoint.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.SpawnPoint.Size.x, v.SpawnPoint.Size.y, v.SpawnPoint.Size.z, v.SpawnPoint.Color.r, v.SpawnPoint.Color.g, v.SpawnPoint.Color.b, 100, false, true, 2, false, false, false, false) DrawMarker(v.DeletePoint.Marker, v.DeletePoint.Pos.x, v.DeletePoint.Pos.y, v.DeletePoint.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.DeletePoint.Size.x, v.DeletePoint.Size.y, v.DeletePoint.Size.z, v.DeletePoint.Color.r, v.DeletePoint.Color.g, v.DeletePoint.Color.b, 100, false, true, 2, false, false, false, false) end end end end) -- Fin affichage markers -- Activer le menu quand player dedans Citizen.CreateThread(function() local currentZone = 'garage' while true do Wait(0) local coords = GetEntityCoords(GetPlayerPed(-1)) local isInMarker = false for _,v in pairs(Config.Garages) do if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x) then isInMarker = true this_Garage = v end end if isInMarker and not hasAlreadyEnteredMarker then hasAlreadyEnteredMarker = true LastZone = currentZone TriggerEvent('eden_garage:hasEnteredMarker', currentZone) end if not isInMarker and hasAlreadyEnteredMarker then hasAlreadyEnteredMarker = false TriggerEvent('eden_garage:hasExitedMarker', LastZone) end end end) -- Fin activer le menu quand player dedans -- Controle touche Citizen.CreateThread(function() while true do Citizen.Wait(0) if CurrentAction ~= nil then SetTextComponentFormat('STRING') AddTextComponentString(CurrentActionMsg) DisplayHelpTextFromStringLabel(0, 0, 1, -1) if IsControlPressed(0, Keys['E']) and (GetGameTimer() - GUI.Time) > 150 then if CurrentAction == 'garage_action_menu' then OpenMenuGarage() end CurrentAction = nil GUI.Time = GetGameTimer() end end end end) -- Fin controle touche