Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local garage = {
- {x=216.329,y=-792.278,z=30.492}
- }
- local VehiclePlayer = {}
- RegisterNetEvent("ft_libs:OnClientReady")
- AddEventHandler('ft_libs:OnClientReady', function()
- creationGarage()
- end)
- function addVehicleToPlayer(data)
- VehiclePlayer[data["plateText" ]] = {model = data[ "model" ], data = data, inGarage = data["inGarage"]}
- TriggerServerEvent("car:RegisterImatriculation",data["plateText" ])
- end
- RegisterNetEvent("car:GetAllPlayerVehicle")
- AddEventHandler("car:GetAllPlayerVehicle", function(result)
- for i = 1, i =< #result) do
- addVehicleToPlayer(result[i])
- end
- end)
- function creationGarage()
- for i =1, #garage do
- exports.ft_libs:AddArea("Garage"..i, {
- marker = {text = "Garage", type = 1, weight = 1, height = 2, red = 51, green = 153, blue = 255,showDistance = 20},
- trigger = { weight = 1, active = { callback = openGarage } },
- blip = { text = "Garage", colorId = 38, imageId = 50 },
- locations = {
- { x = garage[i].x , y = garage[i].y, z = garage[i].z},
- }
- })
- end
- exports.ft_libs:AddMenu("car:garage",{
- menuTitle = "Bienvenue au garage",
- closable = true,
- position = 1,
- buttons = {
- {text = "Quitter", close = true, exec = {callback = function()SetEntityInvincible(GetPlayerPed(-1), false)end)}}
- {text = "Rentrer vehicule",buttons = {{text = "Retour", back = true}} exec = {callback = rentrerVehicule}},
- {text = "Sortir vehicule", exec = {callback = sortirVehiculeInit}},
- }
- })
- exports.ft_libs:AddMenu("car:outVehicle",{position = 1,menuTitle ="Sortir Vehicule"})
- end
- function openGarage(data)
- if not exports.ft_libs:MenuIsOpen() then
- exports.ft_libs:HelpPromt("Appuyez sur ~INPUT_CONTEXT~ pour ouvrir le ~g~garage")
- if IsControlJustPressed(1,51) then
- exports.ft_libs:OpenMenu("car:garage")
- SetEntityInvincible(GetPlayerPed(-1), true)
- end
- end
- end
- function SpawnVehicleGarage(data)
- local pos = GetEntityCoords(PlayerPedId())
- local veh = SpawnVehicle(data.vehicleData.data["Model"],data.vehicleData.data,{x=pos.x,y=pos.y,z=pos.z},240,true)
- SetEntityAsMissionEntity(veh,true,false)
- TaskWarpPedIntoVehicle(GetPlayerPed(-1), veh, -1)
- SetVehicleHasBeenOwnedByPlayer(veh, true)
- VehiclePlayer[data.vehicleData.data["plateText"]].inGarage = 0
- exports.ft_libs:CloseMenu()
- SetEntityInvincible(GetPlayerPed(-1), false)
- end
- function sortirVehiculeInit()
- exports.ft_libs:CleanMenuButtons("car:outVehicle")
- exports.ft_libs:AddMenuButton("car:outVehicle", {{text = "Retour", back = true}})
- for k,v in pairs(VehiclePlayer) do
- if VehiclePlayer[k].inGarage == 1 then
- exports.ft_libs:AddMenuButton("car:outVehicle", {{text = VehiclePlayer[k].model.. " ("..k..")", exec = {callback = SpawnVehicleGarage}, data = {vehicleData = VehiclePlayer[k]}}})
- end
- end
- exports.ft_libs:NextMenu("car:outVehicle")
- end
- function rentrerVehicule()
- local playerPed = GetPlayerPed(-1)
- local notfound = true
- local vehicle
- if IsPedSittingInAnyVehicle(playerPed) then
- vehicle = GetVehiclePedIsIn(playerPed, true)
- else
- Citizen.Wait(0)
- local pos = GetEntityCoords(PlayerPedId())
- local entityWorld = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 20.0, 0.0)
- local rayHandle = CastRayPointToPoint(pos.x, pos.y, pos.z, entityWorld.x, entityWorld.y, entityWorld.z, 10, playerPed, 0)
- local a, b, c, d, vehicleHandle = GetRaycastResult(rayHandle)
- if vehicleHandle ~= nil then
- if IsEntityAVehicle(vehicleHandle) then
- vehicle = vehicleHandle
- end
- end
- end
- if vehicle ~= nil then
- plate = GetVehicleNumberPlateText(vehicle)
- if VehiclePlayer[plate] ~= nil then
- if VehiclePlayer[plate].inGarage == 0 then
- TriggerServerEvent("car:SetVehicleGarage",plate,1)
- VehiclePlayer[plate].inGarage = 1
- exports.ft_libs:TextNotification({ text = "Ton vehicule a été mit au garage", time = 5000 })
- SetEntityAsMissionEntity(vehicle)
- DeleteVehicle(vehicle)
- exports.ft_libs:CloseMenu()
- SetEntityInvincible(GetPlayerPed(-1), true)
- else
- exports.ft_libs:TextNotification({ text = "Ce vehicule est sortie (contacte un admin si tu voie ce message)", time = 5000 })
- end
- else
- exports.ft_libs:TextNotification({ text = "Ce vehicule ne t'appartiens pas", time = 5000 })
- end
- else
- exports.ft_libs:TextNotification({ text = "Pas de vehicule à rentrer", time = 5000 })
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment