Guest User

Untitled

a guest
May 8th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.63 KB | None | 0 0
  1. --[[
  2. @author Lukasz Biegaj <[email protected]>
  3. @author WUBE <[email protected]>
  4. @copyright 2011-2013 Lukasz Biegaj <[email protected]>
  5. @license Dual GPLv2/MIT
  6. @package MTA-XyzzyRP
  7. @link https://github.com/lpiob/MTA-XyzzyRP GitHub
  8. ]]--
  9.  
  10.  
  11.  
  12. local wybraneOgraniczenie=1
  13. local ograniczenia={nil, 90, 50, 30, 10}
  14.  
  15. local ograniczeniaModeli={
  16.     -- rowery
  17.     [509]=15,
  18.     [510]=18,
  19.     [481]=16,
  20.  
  21.     [431]=40,
  22.     [508]=40,
  23.     [525]=50,
  24.     [530]=10,
  25.     [531]=15,
  26.     [572]=5,
  27.     [574]=10,
  28.     [578]=50,
  29.     [586]=50,
  30.     [462]=30,
  31.     [440]=70,
  32.     [455]=70,
  33.     [514]=70,
  34.     [403]=70,
  35.     [514]=70,
  36.     [515]=70,
  37.     [407]=70,
  38.     [544]=70,
  39. --  [571]=10,
  40.     -- elka
  41. --  [589]=30,
  42. }
  43.  
  44. local ograniczeniaWsteczneModeli={
  45.     [531]=5,    -- tractor
  46.     [530]=5,    -- wozek widlowy
  47.     [572]=5,    -- kosiarka
  48.     [571]=5,    -- kart
  49.  
  50. }
  51.  
  52. local function tempomat()
  53.     local ograniczenie=ograniczenia[wybraneOgraniczenie]
  54.  
  55.     local v=getPedOccupiedVehicle(localPlayer)
  56.     if not v then return end
  57.     local vm=getElementModel(v)
  58.  
  59.     if getVehicleController(v)~=localPlayer then return end
  60.  
  61.     if not isVehicleOnGround(v) then return end
  62.  
  63.  
  64.  
  65.  
  66.     local vx,vy,vz=getElementVelocity(v)
  67.  
  68.     if not getVehicleEngineState(v) then
  69. --      outputDebugString(getDistanceBetweenPoints2D(0,0,vx,vy))
  70.         if getDistanceBetweenPoints2D(0,0,vx,vy)<0.1 then
  71.             vx,vy=0,0
  72.             setElementVelocity(v,vx,vy,vz)
  73.             return
  74.         end
  75.     end
  76.  
  77.     if ograniczeniaWsteczneModeli[vm] and getControlState("brake_reverse") and math.abs(vz)<0.03 then
  78.         -- todo sprawdzic czy pojazd jedzie do tylu!
  79.         local actualspeed = (vx^2 + vy^2 + vz^2)^(0.5) *0.6*180
  80.         if actualspeed>ograniczeniaWsteczneModeli[vm] then
  81.             setElementVelocity(v,vx*0.6,vy*0.6,vz*0.9)
  82.         end
  83.         return
  84.     end
  85.  
  86.  
  87.     if getVehicleType(v)~="Automobile" and not ograniczeniaModeli[vm] then return end
  88.     if ograniczeniaModeli[vm] then
  89.         ograniczenie=ograniczeniaModeli[vm]
  90.     end
  91.  
  92.     if not ograniczenie then return end
  93.  
  94.     local actualspeed = (vx^2 + vy^2 + vz^2)^(0.5) *0.6*180
  95.     if actualspeed>ograniczenie then
  96.         setElementVelocity(v,vx*0.9,vy*0.9,vz*0.9)
  97.     end
  98. end
  99.  
  100. setTimer(tempomat, 50, 0)
  101. addCommandHandler("Zmniejsz ograniczenie predkosci", function()
  102.     if isCursorShowing() or isPedDoingGangDriveby(localPlayer) then return end
  103.     local v=getPedOccupiedVehicle(localPlayer)
  104.     if not v then return end
  105.     if getVehicleController(v)~=localPlayer then return end
  106.     if not isVehicleOnGround(v) then return end
  107.  
  108.  
  109.  
  110.     if getVehicleType(v)~="Automobile" then return end
  111.  
  112.     wybraneOgraniczenie=wybraneOgraniczenie-1
  113.     if wybraneOgraniczenie<1 then wybraneOgraniczenie=#ograniczenia end
  114.     if ograniczenia[wybraneOgraniczenie] then
  115.         outputChatBox("(( Ograniczenie prędkości ustawione na " .. ograniczenia[wybraneOgraniczenie] .. "km/h ))", 150,150,150)
  116.     else
  117.         outputChatBox("(( Ograniczenie prędkości wyłączone. ))", 150,150,150)
  118.     end
  119. end)
  120. bindKey("mouse1","down", "Zmniejsz ograniczenie predkosci")
  121.  
  122.  
  123. addCommandHandler("Zwieksz ograniczenie predkosci", function()
  124.     if isCursorShowing() or isPedDoingGangDriveby(localPlayer) then return end
  125.     local v=getPedOccupiedVehicle(localPlayer)
  126.     if not v then return end
  127.     if getVehicleType(v)~="Automobile" then return end
  128.     if getVehicleController(v)~=localPlayer then return end
  129.     if not isVehicleOnGround(v) then return end
  130.  
  131.     wybraneOgraniczenie=wybraneOgraniczenie+1
  132.     if wybraneOgraniczenie>#ograniczenia then wybraneOgraniczenie=1 end
  133.     if ograniczenia[wybraneOgraniczenie] then
  134.         outputChatBox("(( Ograniczenie prędkości ustawione na " .. ograniczenia[wybraneOgraniczenie] .. "km/h ))", 150,150,150)
  135.     else
  136.         outputChatBox("(( Ograniczenie prędkości wyłączone. ))", 150,150,150)
  137.     end
  138. end)
  139.  
  140. bindKey("mouse2","down", "Zwieksz ograniczenie predkosci")
Add Comment
Please, Sign In to add comment