Advertisement
Guest User

Herse

a guest
Sep 3rd, 2017
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.28 KB | None | 0 0
  1. function POLICE_removeOrPlaceHerse()
  2.     local coords = GetEntityCoords(GetPlayerPed(-1), true)
  3.     local heading = GetEntityHeading(GetPlayerPed(-1))
  4.  
  5.     local hashHerse = GetHashKey("P_ld_stinger_s")
  6.  
  7.     local herse = GetClosestObjectOfType( coords.x, coords.y, coords.z, 0.9, hashHerse, false, false, false)
  8.     print(herse)
  9.     if herse ~= 0 then
  10.         print('HERSE')
  11.         -- On supprime les herses
  12.         RemoveHerse(herse)
  13.     else
  14.         print('NO HERSE')
  15.         -- On ajoute la herse
  16.         RequestModel(hashHerse)
  17.         while not HasModelLoaded(hashHerse) do
  18.             Citizen.Wait(1)
  19.         end
  20.  
  21.         local herse = CreateObject('P_ld_stinger_s', coords.x, coords.y, coords.z - 2, true, true, true)
  22.         PlaceObjectOnGroundProperly(herse)
  23.         SetEntityHeading(herse, heading)
  24.         SetNetworkIdCanMigrate(id, true)
  25.     end
  26. end
  27.  
  28. function RemoveHerse(herse)
  29.     NetworkRequestControlOfEntity(herse)
  30.     Citizen.InvokeNative(0xB736A491E64A32CF, Citizen.PointerValueIntInitialized(herse))
  31.     Citizen.InvokeNative(0x539E0AE3E6634B9F, Citizen.PointerValueIntInitialized(herse))
  32.     DeleteObject(herse)
  33.     SetEntityCoords(herse, -2000.0, -2000.0, -2000.0)
  34. end
  35.  
  36. Citizen.CreateThread(function()
  37.     while true do
  38.         Citizen.Wait(0)
  39.         local ped = GetPlayerPed(-1)
  40.         local veh = GetVehiclePedIsIn(ped, false)
  41.         local vehCoord = GetEntityCoords(veh)
  42.         local hashHerse = GetHashKey("P_ld_stinger_s")
  43.         if IsPedInAnyVehicle(ped, false) then
  44.             local herse = GetClosestObjectOfType( vehCoord.x, vehCoord.y, vehCoord.z, 1.3, hashHerse, false, false, false)
  45.             if herse ~= 0 then
  46.                 print(herse)
  47.                 RemoveHerse(herse)
  48.                 SetVehicleTyreBurst(veh, 0, true, 1000.0)
  49.                 SetVehicleTyreBurst(veh, 1, true, 1000.0)
  50.                 Citizen.Wait(200)
  51.                 SetVehicleTyreBurst(veh, 2, true, 1000.0)
  52.                 SetVehicleTyreBurst(veh, 3, true, 1000.0)
  53.                 Citizen.Wait(200)
  54.                 SetVehicleTyreBurst(veh, 4, true, 1000.0)
  55.                 SetVehicleTyreBurst(veh, 5, true, 1000.0)
  56.                 SetVehicleTyreBurst(veh, 6, true, 1000.0)
  57.                 SetVehicleTyreBurst(veh, 7, true, 1000.0)
  58.             end
  59.         end
  60.     end
  61. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement