IdoX10

police light system

Oct 28th, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. local r = 255
  2. local b = 0
  3. light = false
  4. local ply = LocalPlayer()
  5. hook.Add("Think", "HookKeyManagement", function()
  6. for i=1, 159 do
  7. if(!vgui.CursorVisible) then break; end;
  8.  
  9. if(input.WasKeyPressed(i)) then
  10. hook.Call("KeyPressed", nil, i);
  11. end;
  12.  
  13. if(input.WasKeyReleased(i)) then
  14. hook.Call("KeyReleased", nil, i);
  15. end;
  16. end;
  17.  
  18.  
  19. if light == true then
  20.  
  21. LightOn()
  22.  
  23. end
  24. end);
  25.  
  26.  
  27. hook.Add("KeyReleased", "TestShiftBlablabla", function(Key)
  28. if(Key == KEY_LSHIFT) then
  29.  
  30. if light == false and ply:InVehicle() == true then
  31.  
  32. LightOn()
  33.  
  34. end
  35.  
  36. if light == true and ply:InVehicle() == true then
  37.  
  38. LightOff()
  39.  
  40. end
  41.  
  42. end
  43. end)
  44.  
  45. function LightOn()
  46.  
  47. light = true
  48. print("light on")
  49. local dlight = DynamicLight( LocalPlayer():GetVehicle():EntIndex() )
  50. dlight.pos = LocalPlayer():GetVehicle():GetPos() + Vector(0, 10, 0)
  51. dlight.r = r
  52. dlight.g = 0
  53. dlight.b = b
  54. dlight.brightness = 2
  55. dlight.Decay = 1000
  56. dlight.Size = 200
  57. dlight.DieTime = CurTime() + 1
  58.  
  59. end
  60.  
  61. function LightOff()
  62.  
  63. light = false
  64. print("light off")
  65. r = 0
  66. b = 0
  67.  
  68. end
Add Comment
Please, Sign In to add comment