Guest User

Untitled

a guest
Apr 26th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.73 KB | None | 0 0
  1. --[[ Warnlicht-Script der Emergencyautos. Beinhaltet (Models):
  2.     [523, 598, 596, 597, 599] & [416, 407, 544]
  3.     © 2011 by JK Exposure]]
  4.  
  5. local policecars = { 523, 598, 596, 597, 599 }
  6. local emergencycars = { 416, 407, 544 }
  7. local usedcars = {}
  8. local timers = {}
  9. local checked, internmodel = true, false
  10.  
  11. function check( typ, car )
  12.     local typ = "nothing"
  13.     for y,z in ipairs( usedcars ) do
  14.         if z == source then
  15.             typ = "existing"
  16.         end
  17.     end
  18.     if typ == "nothing" then
  19.         for a,b in ipairs( policecars ) do
  20.             if typ == "nothing" then
  21.                 if getElementModel( source ) == b then
  22.                     typ = "police"
  23.                 else
  24.                     typ = "nothing"
  25.                 end
  26.             end
  27.         end
  28.         if typ == "nothing" then
  29.             for c,d in ipairs( emergencycars ) do
  30.                 if typ == "nothing" then
  31.                     if getElementModel( source ) == d then
  32.                         typ = "ambulance"
  33.                     else
  34.                         typ = "nothing"
  35.                     end
  36.                 end
  37.             end
  38.         end
  39.         if typ == "ambulance" or typ == "police" then
  40.             local car = source
  41.             table.insert( usedcars, source )
  42.             colorisation( typ, car )
  43.             timers[car] = setTimer( colorisation, 600, 0, typ, car )
  44.             typ = "nothing"
  45.         end
  46.     end
  47. end
  48.  
  49. function colorisation( typ, car )
  50.     if typ == "police" then
  51.         internmodel = true
  52.     elseif typ == "ambulance" then
  53.         internmodel = false
  54.     end
  55.     if isElement( car ) and not isVehicleBlown( car ) then
  56.         if getVehicleSirensOn( car ) then
  57.             local red, green, blue = getVehicleHeadLightColor( car )
  58.             local lightstate = getVehicleOverrideLights( car )
  59.             if internmodel then
  60.                 if red == 255 then
  61.                     setVehicleHeadLightColor( car, 0, 0, 255 )
  62.                     setVehicleLightState( car, 2, 0 )
  63.                     setVehicleLightState( car, 3, 1 )
  64.                 else
  65.                     setVehicleHeadLightColor( car, 255, 0, 0 )
  66.                     setVehicleLightState( car, 2, 1 )
  67.                     setVehicleLightState( car, 3, 0 )
  68.                 end
  69.             else
  70.                 if green == 255 then
  71.                     setVehicleHeadLightColor( car, 255, 0, 0 )
  72.                     setVehicleLightState( car, 2, 0 )
  73.                     setVehicleLightState( car, 3, 1 )
  74.                 else
  75.                     setVehicleHeadLightColor( car, 255, 255, 255 )
  76.                     setVehicleLightState( car, 2, 1 )
  77.                     setVehicleLightState( car, 3, 0 )
  78.                 end
  79.             end
  80.             checked = false
  81.             if lightstate ~= 2 then
  82.                 setVehicleOverrideLights( car, 2 )
  83.             end
  84.         else
  85.             setVehicleHeadLightColor( car, 255, 255, 255 )
  86.             setVehicleLightState( car, 2, 0 )
  87.             setVehicleLightState( car, 3, 0 )
  88.             if not checked then
  89.                 local hour, mins = getTime()
  90.                 if hour > 18 or hour < 8 then
  91.                     setVehicleOverrideLights( car, 2 )
  92.                 else
  93.                     setVehicleOverrideLights( car, 1 )
  94.                 end
  95.             end
  96.             checked = true
  97.         end
  98.     else
  99.         table.remove( usedcars, y )
  100.         killTimer( timers[car] )
  101.     end
  102. end
  103.  
  104. addEventHandler( "onVehicleEnter", getRootElement(), check )
  105.  
  106. -- FINISHED SCRIPT [17:37, 06.12.11]
Add Comment
Please, Sign In to add comment