Guest User

Untitled

a guest
Jun 24th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.91 KB | None | 0 0
  1. local function pojazdPusty(veh)
  2. --    local occupants = getVehicleOccupants(veh)
  3. --    local seats = getVehicleMaxPassengers(veh)
  4. --  if (not seats) then return true end
  5. --    for i=0,seats do
  6. --  local occupant = occupants[i]
  7. --  if occupant and (getElementType(occupant)=="player" or getElementType(occupant)=="ped") then
  8. --      return false
  9. --  end
  10. --    end
  11. --    return true
  12.     local occupant=getVehicleOccupant(veh, 0)
  13.     if occupant and isElement(occupant) then
  14.         if (getElementType(occupant)=="player") then
  15.             return false
  16.         end
  17.     end
  18.     return true
  19. end
  20.  
  21. setTimer(function()
  22.     for i,v in ipairs(getElementsByType("vehicle")) do
  23.         --if getElementData(v, "dbid") then -- jeżeli ma działać tylko na pojazdy prywatne to
  24.             if (pojazdPusty(v)) then
  25.                 setVehicleDamageProof(v,true)
  26.             else
  27.                 if not getElementData(v,"pojazdy:zniszczonyWrak") then setVehicleDamageProof(v,false) end
  28.             end
  29.         --end
  30.     end
  31. end, 1000, 1)
  32.  
  33. addEventHandler ( "onVehicleEnter", root, function(plr,seat)
  34.     if seat~=0 then
  35.         return
  36.     end
  37.     if not getElementData(source,"pojazdy:zniszczonyWrak") then setVehicleDamageProof(source, false) end
  38. end)
  39.  
  40. addEventHandler ( "onVehicleExit", root, function(plr,seat)
  41.     if seat~=0 then
  42.         return
  43.     end
  44. --    if (pojazdPusty(source)) then
  45.         if source and isElement(source) then
  46.             if (not getVehicleController(source)) then
  47.                     setVehicleDamageProof(source, true)
  48.                     setVehicleOverrideLights(source, 1)
  49.             else
  50.                     if getElementData(source,"pojazdy:zniszczonyWrak") then return end
  51.                     setVehicleDamageProof(source, false)
  52.             end
  53.         end
  54. end)
  55.  
  56. addEventHandler("onPlayerQuit", root,
  57.     function()
  58.         local veh=getPedOccupiedVehicle(source)
  59.         if not veh then
  60.             return
  61.         end
  62.         if getElementData(veh,"dbid") then
  63.             if (getPedOccupiedVehicleSeat(source)==0) then
  64.                 setVehicleDamageProof(veh, true)
  65.                 setVehicleEngineState(veh, false)
  66.                 setElementFrozen(veh, true)
  67.             end
  68.         end
  69.     end
  70. )
Add Comment
Please, Sign In to add comment