Guest User

Untitled

a guest
May 28th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. vehicle = getPedOccupiedVehicle ( getLocalPlayer() )
  2. centre = createObject ( 1097, 0, 0, 0 )
  3. setElementAlpha ( centre, 0 )
  4. point = createObject ( 1097, 0, 0, 0 )
  5. setElementAlpha ( point, 0 )
  6. speed = 0.8/15
  7. cx = 0 cy = -5 cz = 1 ox = 0 oy = 0 oz = 1
  8.  
  9.  
  10. isAKeyPressed = false
  11. isDKeyPressed = false
  12. areAllStock = true
  13.  
  14. function getA()
  15. aTimer = setTimer ( function () isAKeyPressed = true isATimerRunning = false end, 150, 1 )
  16. isATimerRunning = true
  17. end
  18.  
  19. function getD()
  20. dTimer = setTimer ( function () isDKeyPressed = true isDTimerRunning = false end, 150, 1 )
  21. isDTimerRunning = true
  22. end
  23.  
  24. function getS()
  25. isSKeyPressed = true
  26. isSTimerRunning = true
  27. end
  28.  
  29. function getAStock()
  30. if isATimerRunning == true then
  31. killTimer ( aTimer )
  32. isATimerRunning = false
  33. end
  34. isAKeyPressed = false
  35. end
  36.  
  37. function getDStock()
  38. if isDTimerRunning == true then
  39. killTimer ( dTimer )
  40. isDTimerRunning = false
  41. end
  42. isDKeyPressed = false
  43. end
  44.  
  45. function getSStock()
  46. isSKeyPressed = false
  47. end
  48.  
  49.  
  50.  
  51. bindKey ( "a", "down", getA )
  52. bindKey ( "a", "up", getAStock )
  53.  
  54. bindKey ( "d", "down", getD )
  55. bindKey ( "d", "up", getDStock )
  56.  
  57. bindKey ( "s", "down", getS )
  58. bindKey ( "s", "up", getSStock )
  59.  
  60.  
  61. function moving()
  62. vehicle = getPedOccupiedVehicle ( getLocalPlayer() )
  63. if vehicle then
  64. attachElements ( centre, vehicle, ox, oy, oz )
  65. attachElements ( point, vehicle, cx, cy, cz )
  66. x, y, z = getElementPosition ( centre )
  67. px, py, pz = getElementPosition ( point )
  68. setCameraMatrix ( px, py, pz, x, y, z )
  69. if isDKeyPressed == true then
  70. if cx < 1.5 then
  71. cx = cx + speed
  72. elseif cx > 1.5 then
  73. cx = 1.5
  74. end
  75. elseif isAKeyPressed == true then
  76. if cx > -1.5 then
  77. cx = cx - speed
  78. elseif cx < -1.5 then
  79. cx = -1.5
  80. end
  81. elseif cx > 0.1 then
  82. cx = cx - speed
  83. elseif cx < -0.1 then
  84. cx = cx + speed
  85. end
  86.  
  87.  
  88. if isDKeyPressed == true then
  89. if ox < 1 then
  90. ox = ox + speed
  91. elseif cx > 1 then
  92. ox = 1
  93. end
  94. elseif isAKeyPressed == true then
  95. if ox > -1 then
  96. ox = ox - speed
  97. elseif ox < -1 then
  98. ox = -1
  99. end
  100. elseif ox > 0.1 then
  101. ox = ox - speed
  102. elseif ox < -0.1 then
  103. ox = ox + speed
  104. end
  105.  
  106.  
  107.  
  108.  
  109. if isSKeyPressed == true then
  110. if oz > -1 then
  111. oz = oz - speed*2
  112. end
  113. elseif oz < 1 then
  114. oz = oz + speed*2
  115. end
  116. end
  117. end
  118. addEventHandler ( "onClientPreRender", root, moving )
Add Comment
Please, Sign In to add comment