Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.71 KB | None | 0 0
  1. local LockerPolice = {
  2.   {name="Pole Emploi", colour=15, id=351, x=454.371, y=-993.277, z=30.689},
  3. }
  4.  
  5. local Armory = {
  6.   {name="Pole Emploi", colour=15, id=351, x=452.371, y=-980.028, z=30.689},
  7. }
  8.  
  9. local Garage_police = {
  10.   {name="Pole Emploi", colour=15, id=351, x=453.746, y=-1017.653, z=28.450},
  11. }
  12.  
  13. local police = {
  14.   {name="M4", id="WEAPON_CARBINERIFLE"},
  15.   {name="Fusil à pompe", id="WEAPON_PUMPSHOTGUN"},
  16.   {name="Pistolet", id="WEAPON_PISTOL"},
  17.   {name="Matraque", id="WEAPON_NIGHTSTICK"},
  18. }
  19.  
  20. local jobs = {
  21.   {name="En Service", id=1},
  22.   {name="Hors Service", id=0},
  23. }
  24.  
  25. local garage = {
  26.   {name="Voiture Banaliser", id="police4"},
  27. }
  28.  
  29.  
  30.  
  31.  
  32. ---------------------------------- FUNCTIONS ----------------------------------
  33.  
  34. RegisterNetEvent("jobspolice:giveArmory")
  35. AddEventHandler("jobspolice:giveArmory", function(name, delayTime)
  36.   if delayTime == nil then
  37.     delayTime = 0
  38.   end
  39.  
  40.   Citizen.CreateThread(function()
  41.     Wait(delayTime)
  42.     local hash = GetHashKey(name)
  43.     GiveWeaponToPed(GetPlayerPed(-1), hash, 1000, 0, false)
  44.   end)
  45. end)
  46.  
  47. RegisterNetEvent("jobspolice:giveWeapon")
  48. AddEventHandler("jobspolice:giveWeapon", function(name, delayTime)
  49.   if delayTime == nil then
  50.     delayTime = 0
  51.   end
  52.  
  53.   Citizen.CreateThread(function()
  54.     Wait(delayTime)
  55.     local hash = GetHashKey(name)
  56.     GiveWeaponToPed(GetPlayerPed(-1), hash, 1000, 0, false)
  57.     SetPlayerMaxArmour(PlayerId(),100)
  58.   end)
  59. end)
  60.  
  61. RegisterNetEvent("jobspolice:changeSkin")
  62. AddEventHandler("jobspolice:changeSkin", function(skinName, id)--skinName)
  63.   Citizen.CreateThread(function()
  64.     SetPedPropIndex(GetPlayerPed(-1),  0,  12,  0,  0)
  65.     SetPedPropIndex(GetPlayerPed(-1),  1,  18,  2,  0)
  66.     SetPedComponentVariation(GetPlayerPed(-1), 3, 0, 0, 2)
  67.     SetPedComponentVariation(GetPlayerPed(-1), 4, 35, 0, 2)
  68.     SetPedComponentVariation(GetPlayerPed(-1), 5, 0, 0, 2)
  69.     SetPedComponentVariation(GetPlayerPed(-1), 6, 25, 0, 2)
  70.     SetPedComponentVariation(GetPlayerPed(-1), 7, 15, 0, 2)
  71.     SetPedComponentVariation(GetPlayerPed(-1), 8, 58, 0, 2)
  72.     SetPedComponentVariation(GetPlayerPed(-1), 9, 0, 0, 2) --Dessus Armure / etc
  73.     SetPedComponentVariation(GetPlayerPed(-1), 10, 7, 0, 2)
  74.     SetPedComponentVariation(GetPlayerPed(-1), 11, 55, 0, 2)
  75.  
  76.     --SetPedComponentVariation(GetPlayerPed(-1), 2, id, 0, 2)
  77.     --SetPedComponentVariation(GetPlayerPed(-1), id, 50, 0, 2)
  78.     --SetPedComponentVariation(GetPlayerPed(-1), 2, 2, 0, 2)
  79.   end)
  80. end)
  81.  
  82. ---------------------------------- CITIZEN ----------------------------------
  83. local ServerParking = {0, false}
  84. local ParkingPolice = {
  85.   [1] = false,
  86.   [2] = false,
  87.   [3] = false,
  88.   [4] = false
  89. }
  90.  
  91. Citizen.CreateThread(function()
  92.   while true do
  93.     Citizen.Wait(0)
  94.     Wait(1000)
  95.     if ServerParking[2] then
  96.       Wait(20000)
  97.       TriggerServerEvent("jobspolice:SetParking", tonumber(ServerParking[1]), false)
  98.       Wait(1000)
  99.       if ServerParking[1] then
  100.         ParkingPolice[1] = false
  101.       elseif ServerParking[2] then
  102.         ParkingPolice[2] = false
  103.       elseif ServerParking[3] then
  104.         ParkingPolice[3] = false
  105.       elseif ServerParking[4] then
  106.         ParkingPolice[4] = false
  107.       end
  108.       ServerParking = {0, false}
  109.       Wait(10)
  110.       TriggerServerEvent("jobspolice:CheckParking")
  111.     end
  112.   end
  113. end)
  114.  
  115. local car = nil
  116. local plate = 0
  117.  
  118. Citizen.CreateThread(function()
  119.   while true do
  120.     Citizen.Wait(0)
  121.     if spawningcar == true then
  122.       RequestModel(car)
  123.       while not HasModelLoaded(car) do
  124.         Citizen.Wait(0)
  125.       end
  126.       local spawncar = true
  127.       TriggerServerEvent("jobspolice:CheckParking")
  128.       Wait(100)
  129.       if ServerParking[2] == false then
  130.         if ParkingPolice[1] == false then
  131.           veh = CreateVehicle(car, 452.443, -998.466, 25.742, 0.0, true, false)
  132.           TriggerServerEvent("jobspolice:SetParking", 1, true)
  133.           TriggerServerEvent("jobspolice:CheckParking")
  134.           ServerParking = {1, true}
  135.         elseif ParkingPolice[2] == false then
  136.           veh = CreateVehicle(car, 447.09, -996.98, 25.76, 0.0, true, false)
  137.           TriggerServerEvent("jobspolice:SetParking", 2, true)
  138.           TriggerServerEvent("jobspolice:CheckParking")
  139.           ServerParking = {2, true}
  140.         elseif ParkingPolice[3] == false then
  141.           veh = CreateVehicle(car, 436.455, -996.787, 25.767, 0.0, true, false)
  142.           TriggerServerEvent("jobspolice:SetParking", 3, true)
  143.           TriggerServerEvent("jobspolice:CheckParking")
  144.           ServerParking = {3, true}
  145.         elseif ParkingPolice[4] == false then
  146.           veh = CreateVehicle(car, 431.480, -996.450, 25.772, 0.0, true, false)
  147.           TriggerServerEvent("jobspolice:SetParking", 4, true)
  148.           TriggerServerEvent("jobspolice:CheckParking")
  149.           ServerParking = {4, true}
  150.         else
  151.           spawncar = false
  152.         end
  153.         if spawncar == true then
  154.           SetVehicleNumberPlateText(veh, plate)
  155.           SetVehicleOnGroundProperly(veh)
  156.           SetVehicleHasBeenOwnedByPlayer(veh,true)
  157.           local id = NetworkGetNetworkIdFromEntity(veh)
  158.           SetNetworkIdCanMigrate(id, true)
  159.           SetVehRadioStation(veh, "OFF")
  160.           SetEntityInvincible(veh, false)
  161.           SetVehicleEngineTorqueMultiplier( veh, 2.50 )
  162.           SetVehicleEnginePowerMultiplier( veh, 2.50 )
  163.           SetPedIntoVehicle(GetPlayerPed(-1),  veh,  -1)
  164.           SetEntityAsMissionEntity(veh, true, true)
  165.           TriggerEvent("wrapper:vehPersist", veh)
  166.           drawNotification("Véhicule sorti, bonne route")
  167.         else
  168.           drawNotification("Tous les zones sont encombrées")
  169.         end
  170.       else
  171.         drawNotification("Attendez avant de redemander un véhicule")
  172.       end
  173.       spawningcar = false
  174.     end
  175.     if spawningheli then
  176.       RequestModel(car)
  177.       while not HasModelLoaded(car) do
  178.         Citizen.Wait(0)
  179.       end
  180.       veh = CreateVehicle(car, 449.87265014648, -981.50982666016, 43.69164276123, 0.0, true, false)
  181.       SetVehicleNumberPlateText(veh, plate)
  182.       SetVehicleOnGroundProperly(veh)
  183.       SetVehicleHasBeenOwnedByPlayer(veh,true)
  184.       local id = NetworkGetNetworkIdFromEntity(veh)
  185.       SetNetworkIdCanMigrate(id, true)
  186.       SetVehRadioStation(veh, "OFF")
  187.       SetEntityInvincible(veh, false)
  188.       SetVehicleLivery(veh, 2)
  189.       SetPedIntoVehicle(GetPlayerPed(-1),  veh,  -1)
  190.       SetEntityAsMissionEntity(veh, true, true)
  191.       drawNotification("Véhicule sorti, bonne route")
  192.       spawningheli = false
  193.     end
  194.   end
  195. end)
  196.  
  197. RegisterNetEvent("jobspolice:f_CheckParking")
  198. AddEventHandler('jobspolice:f_CheckParking', function(param)
  199.   ParkingPolice = param
  200. end)
  201.  
  202. RegisterNetEvent("jobspolice:SpawnVehicle")
  203. AddEventHandler('jobspolice:SpawnVehicle', function(vehicle, cplate, param)
  204.   if param then
  205.     car = GetHashKey(vehicle)
  206.     -- VOITURE PAR DÉFAUT
  207.     plate = cplate
  208.     spawningcar = true
  209.   else
  210.     car = GetHashKey(vehicle)
  211.     -- VOITURE PAR DÉFAUT
  212.     plate = cplate
  213.     spawningheli = true
  214.   end
  215. end)
  216.  
  217. function GetVehicleInDirection( coordFrom, coordTo )
  218.   local rayHandle = CastRayPointToPoint( coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10, GetPlayerPed( -1 ), 0 )
  219.   local _, _, _, _, vehicle = GetRaycastResult( rayHandle )
  220.   return vehicle
  221. end
  222.  
  223. function getUnloadCoord(param)
  224.   if param >= 305 then
  225.     return {-1.3,1.3}
  226.   elseif param >= 260 then
  227.     return {0,1.3}
  228.   elseif param >= 225 then
  229.     return {1.3,1.3}
  230.   elseif param >= 180 then
  231.     return {1.3,0}
  232.   elseif param >= 135 then
  233.     return {1.3,-1.3}
  234.   elseif param >= 90 then
  235.     return {0,-1.3}
  236.   elseif param >= 45 then
  237.     return {-1.3,-1.3}
  238.   else
  239.     return {-1.3,0}
  240.   end
  241. end
  242.  
  243. RegisterNetEvent("jobspolice:DespawnVehicle")
  244. AddEventHandler('jobspolice:DespawnVehicle', function(plateveh)
  245.   local plateveh = plateveh
  246.   local plate = GetVehicleNumberPlateText(v)
  247.   Citizen.CreateThread(function()
  248.     Citizen.Wait(1500)
  249.     local playerPos = GetEntityCoords( GetPlayerPed(-1), 1 )
  250.     local inFrontOfPlayer = GetOffsetFromEntityInWorldCoords( GetPlayerPed(-1), 0.0, 10.000, 0.0 )
  251.     local vehicle = GetVehicleInDirection( playerPos, inFrontOfPlayer )
  252.     if ( DoesEntityExist( vehicle ) ) then
  253.       local plate = GetVehicleNumberPlateText(vehicle)
  254.       if plate ~= plateveh then
  255.         drawNotification("Ce véhicule ne vous appartient pas")
  256.       else
  257.         -- local heading = GetEntityHeading(GetPlayerPed(-1))
  258.         -- local unloadCoord = getUnloadCoord(heading)
  259.         -- local ply = GetPlayerPed(-1)
  260.         -- local plyCoords = GetEntityCoords(ply, 0)
  261.         -- SetEntityCoords(GetPlayerPed(-1), plyCoords["x"] + unloadCoord[1], plyCoords["y"] + unloadCoord[2], plyCoords["z"] + 0.3)
  262.         Wait(100)
  263.         SetEntityAsMissionEntity( vehicle, true, true )
  264.         Citizen.InvokeNative( 0xEA386986E786A54F, Citizen.PointerValueIntInitialized( vehicle ) )
  265.         Citizen.InvokeNative( 0xB736A491E64A32CF, Citizen.PointerValueIntInitialized( vehicle ))
  266.         drawNotification("Véhicule rentré")
  267.       end
  268.     else
  269.       drawNotification("Aucun véhicule devant vous")
  270.     end
  271.   end)
  272. end)
  273.  
  274. local Despawnpoint = {
  275.   { ['x'] = 462.76406860352, ['y'] = -1019.4964599609, ['z'] = 28.104484558105 }
  276. }
  277.  
  278. Citizen.CreateThread(function()
  279.   while true do
  280.   Citizen.Wait(50)
  281.     local playerPed = GetPlayerPed(-1)
  282.     local lastSpawnedVeh = GetVehiclePedIsUsing(playerPed)
  283.  
  284.     if IsNearPoints(Despawnpoint, 5.01) then
  285.       DrawMarker(1, Despawnpoint.x, Despawnpoint.y, Despawnpoint.z, 0, 0, 0, 0, 0, 0, 3.001, 3.0001, 0.5001, 0, 155, 255, 200, 0, 0, 0, 0)
  286.     end
  287.  
  288.     if IsNearPoints(Despawnpoint, 2.01) then
  289.  
  290.       if (lastSpawnedVeh ~= nil) then
  291.         deleteCar(lastSpawnedVeh)
  292.       end
  293.     end
  294.   end
  295. end)
  296.  
  297. function deleteCar(car)
  298.   SetEntityAsMissionEntity(car, true, true)
  299.   Citizen.InvokeNative( 0xEA386986E786A54F, Citizen.PointerValueIntInitialized( car ))
  300.   Citizen.InvokeNative( 0xB736A491E64A32CF, Citizen.PointerValueIntInitialized( car ))
  301.   Citizen.InvokeNative( 0xAE3CBE5BF394C9C9, Citizen.PointerValueIntInitialized( car ))
  302. end
  303.  
  304. function IsNearPoints(area, dist)
  305.   local ply = GetPlayerPed(-1)
  306.   local plyCoords = GetEntityCoords(ply, 0)
  307.   for _, item in pairs(area) do
  308.     local distance = GetDistanceBetweenCoords(item.x, item.y, item.z,  plyCoords["x"], plyCoords["y"], plyCoords["z"], true)
  309.     if(distance <= dist) then
  310.       return true
  311.     end
  312.   end
  313. end
  314.  
  315. function drawNotification(text)
  316.   SetNotificationTextEntry("STRING")
  317.   AddTextComponentString(text)
  318.   DrawNotification(false, false)
  319. end
  320.  
  321. RegisterNetEvent("jobspolice:notif")
  322. AddEventHandler('jobspolice:notif', function(lestring)
  323.   drawNotification("" .. lestring .. "")
  324. end)
  325.  
  326. RegisterNetEvent("jobspolice:cadet")
  327. AddEventHandler('jobspolice:cadet', function()
  328.   SetPedComponentVariation(GetPlayerPed(-1), 3, 30, 0, 0)--Gants
  329.   SetPedComponentVariation(GetPlayerPed(-1), 4, 35, 0, 0)--Jean
  330.   SetPedComponentVariation(GetPlayerPed(-1), 6, 24, 0, 0)--Chaussure
  331.   SetPedComponentVariation(GetPlayerPed(-1), 8, 58, 0, 0)--mattraque
  332.   SetPedComponentVariation(GetPlayerPed(-1), 11, 55, 0, 0)--Veste
  333.   SetPedPropIndex(GetPlayerPed(-1), 2, 2, 0, 1)--Oreillete
  334.   SetPedPropIndex(GetPlayerPed(-1), 6, 3, 0, 1)--Montre
  335.   SetPedPropIndex(GetPlayerPed(-1), 1, 7, 0, 1)--Lunette
  336.   SetPedComponentVariation(GetPlayerPed(-1), 8, 59,  0, 0) --Gilet Jaune
  337.   SetPedComponentVariation(GetPlayerPed(-1), 10, 8, 4, 0)--Grade
  338. end)
  339.  
  340. RegisterNetEvent("jobspolice:officier")
  341. AddEventHandler('jobspolice:officier', function()
  342.   SetPedComponentVariation(GetPlayerPed(-1), 3, 30, 0, 0)--Gants
  343.   SetPedComponentVariation(GetPlayerPed(-1), 4, 35, 0, 0)--Jean
  344.   SetPedComponentVariation(GetPlayerPed(-1), 6, 24, 0, 0)--Chaussure
  345.   SetPedComponentVariation(GetPlayerPed(-1), 8, 58, 0, 0)--mattraque
  346.   SetPedComponentVariation(GetPlayerPed(-1), 11, 55, 0, 0)--Veste
  347.   SetPedPropIndex(GetPlayerPed(-1), 2, 2, 0, 1)--Oreillete
  348.   SetPedPropIndex(GetPlayerPed(-1), 6, 3, 0, 1)--Montre
  349.   SetPedPropIndex(GetPlayerPed(-1), 1, 7, 0, 1)--Lunette
  350. end)
  351. RegisterNetEvent("jobspolice:sergent")
  352. AddEventHandler('jobspolice:sergent', function()
  353.   SetPedComponentVariation(GetPlayerPed(-1), 3, 30, 0, 0)--Gants
  354.   SetPedComponentVariation(GetPlayerPed(-1), 4, 35, 0, 0)--Jean
  355.   SetPedComponentVariation(GetPlayerPed(-1), 6, 24, 0, 0)--Chaussure
  356.   SetPedComponentVariation(GetPlayerPed(-1), 8, 58, 0, 0)--mattraque
  357.   SetPedComponentVariation(GetPlayerPed(-1), 11, 55, 0, 0)--Veste
  358.   SetPedPropIndex(GetPlayerPed(-1), 2, 2, 0, 1)--Oreillete
  359.   SetPedPropIndex(GetPlayerPed(-1), 6, 3, 0, 1)--Montre
  360.   SetPedPropIndex(GetPlayerPed(-1), 1, 7, 0, 1)--Lunette
  361.   SetPedComponentVariation(GetPlayerPed(-1), 10, 8, 1, 0)--Grade
  362. end)
  363. RegisterNetEvent("jobspolice:lieutenant")
  364. AddEventHandler('jobspolice:lieutenant', function()
  365.   SetPedComponentVariation(GetPlayerPed(-1), 3, 30, 0, 0)--Gants
  366.   SetPedComponentVariation(GetPlayerPed(-1), 4, 35, 0, 0)--Jean
  367.   SetPedComponentVariation(GetPlayerPed(-1), 6, 24, 0, 0)--Chaussure
  368.   SetPedComponentVariation(GetPlayerPed(-1), 8, 58, 0, 0)--mattraque
  369.   SetPedComponentVariation(GetPlayerPed(-1), 11, 55, 0, 0)--Veste
  370.   SetPedPropIndex(GetPlayerPed(-1), 2, 2, 0, 1)--Oreillete
  371.   SetPedPropIndex(GetPlayerPed(-1), 6, 3, 0, 1)--Montre
  372.   SetPedPropIndex(GetPlayerPed(-1), 1, 7, 0, 1)--Lunette
  373.   SetPedComponentVariation(GetPlayerPed(-1), 10, 8, 3, 0)--Grade
  374. end)
  375. RegisterNetEvent("jobspolice:capitaine")
  376. AddEventHandler('jobspolice:capitaine', function()
  377.   SetPedComponentVariation(GetPlayerPed(-1), 3, 30, 0, 0)--Gants
  378.   SetPedComponentVariation(GetPlayerPed(-1), 4, 35, 0, 0)--Jean
  379.   SetPedComponentVariation(GetPlayerPed(-1), 6, 24, 0, 0)--Chaussure
  380.   SetPedComponentVariation(GetPlayerPed(-1), 8, 58, 0, 0)--mattraque
  381.   SetPedComponentVariation(GetPlayerPed(-1), 11, 55, 0, 0)--Veste
  382.   SetPedPropIndex(GetPlayerPed(-1), 2, 2, 0, 1)--Oreillete
  383.   SetPedPropIndex(GetPlayerPed(-1), 6, 3, 0, 1)--Montre
  384.   SetPedPropIndex(GetPlayerPed(-1), 1, 7, 0, 1)--Lunette
  385.   SetPedComponentVariation(GetPlayerPed(-1), 10, 8, 2, 0)--Grade
  386. end)
  387. RegisterNetEvent("jobspolice:commandant")
  388. AddEventHandler('jobspolice:commandant', function()
  389.   SetPedComponentVariation(GetPlayerPed(-1), 3, 30, 0, 0)--Gants
  390.   SetPedComponentVariation(GetPlayerPed(-1), 4, 35, 0, 0)--Jean
  391.   SetPedComponentVariation(GetPlayerPed(-1), 6, 24, 0, 0)--Chaussure
  392.   SetPedComponentVariation(GetPlayerPed(-1), 8, 58, 0, 0)--mattraque
  393.   SetPedComponentVariation(GetPlayerPed(-1), 11, 55, 0, 0)--Veste
  394.   SetPedPropIndex(GetPlayerPed(-1), 2, 2, 0, 1)--Oreillete
  395.   SetPedPropIndex(GetPlayerPed(-1), 6, 3, 0, 1)--Montre
  396.   SetPedPropIndex(GetPlayerPed(-1), 1, 7, 0, 1)--Lunette
  397.   SetPedComponentVariation(GetPlayerPed(-1), 10, 8, 2, 0)--Grade
  398.   SetPedComponentVariation(GetPlayerPed(-1), 9, 10, 1, 2)--Gilet
  399. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement