Advertisement
Guest User

Modded GTA V Fuel Script

a guest
May 5th, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.64 KB | None | 0 0
  1. -- Fuel Script V 0.2 by Sakis25
  2. -- http://sakis25games.blogspot.com
  3.  
  4.  
  5. local GUI = {}
  6. GUI.GUI = {}
  7. GUI.loaded = false
  8. GUI.time = 0
  9.  
  10. local carGas = 0.14 -- 0.14 is max
  11. local gasStations = {{-725,-935,19},{-71,-1761,29},{265,-1260,29},{-2093,-322,12},{-2555,2334,33},{1038,2669,39},{2679,3264,55},{180,6602,32},{1702,6417,32},{2580,362,108},{-1436,-276,46},{-1800,803,138},{1181,-330,69},{-95,6415,31},{264,2609,44},{49,2776,57},{2537,2593,37},{-525,-1203,18},{1204,-1397,35},{2004,3770,31},{1686,4930,41},{622,264,102},{1786,3330,41}}
  12.  
  13. local currentCar = 1
  14. local enteredCar = false
  15. local refillCar = false
  16. local carspeed = 0.0
  17.  
  18. local toggledLeft = false
  19. local toggledRight = false
  20. local keypressed = {false,false}
  21.  
  22. local blip = {}
  23.  
  24. -- gas rect position
  25. local gasx = 0.01
  26. local gasy = 0.8
  27. local gasw = 0.3
  28. local gash = 0.01
  29.  
  30. function GUI.unload()
  31.     for i, _ in pairs(blip) do
  32.         UI.REMOVE_BLIP(blip[i])
  33.     end
  34. end
  35. function GUI.init()
  36.     GUI.loaded = true
  37.    
  38.     for i, coords in ipairs(gasStations) do
  39.         blip[i] = UI.ADD_BLIP_FOR_COORD(coords[1],coords[2],coords[3])
  40.         UI.SET_BLIP_SPRITE(blip[i], 229)
  41.         UI.SET_BLIP_PRIORITY(blip[i], 1)
  42.         UI.SET_BLIP_AS_SHORT_RANGE(blip[i], true)
  43.     end
  44. end
  45. function GUI.tick()
  46.     local playerPed = PLAYER.PLAYER_PED_ID()
  47.     local player = PLAYER.GET_PLAYER_PED(playerPed)
  48.     local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)
  49.     local playerPosition = ENTITY.GET_ENTITY_COORDS(PLAYER.PLAYER_PED_ID(), false)
  50.  
  51.     if(playerExists) then
  52.         if( get_key_pressed(Keys.F5) ) then
  53.            local position = ENTITY.GET_ENTITY_COORDS(playerPed, nil);
  54.            print ("("..position.x..", "..position.y..", "..position.z..")")
  55.         end
  56.        
  57.         --ENTERED CAR
  58.         if(PED.IS_PED_IN_ANY_VEHICLE(playerPed, false)) then
  59.             local veh = PED.GET_VEHICLE_PED_IS_IN(playerPed,true)
  60.             local coords = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(veh, 0.0, 5.0, 0.0);
  61.             carspeed = ENTITY.GET_ENTITY_SPEED(veh)
  62.  
  63.             if (VEHICLE.IS_THIS_MODEL_A_CAR(ENTITY.GET_ENTITY_MODEL(veh)) or VEHICLE.IS_THIS_MODEL_A_BIKE(ENTITY.GET_ENTITY_MODEL(veh)) or VEHICLE.IS_THIS_MODEL_A_QUADBIKE(ENTITY.GET_ENTITY_MODEL(veh))) then
  64.                 if (refillCar==true) then
  65.                     if (carGas<0.14) then
  66.                         carGas = carGas+0.001
  67.                         VEHICLE.SET_VEHICLE_ENGINE_ON(veh, false,true)
  68.                     else
  69.                         refillCar=false
  70.                         carGas=0.14
  71.                         VEHICLE.SET_VEHICLE_ENGINE_ON(veh, true,true)
  72.                     end
  73.                 end
  74.                
  75.                 if( get_key_pressed(Keys.J) ) then
  76.                     if (not keypressed[0] ) then
  77.                         toggleLeft = not toggleLeft
  78.                         keypressed[0] = true
  79.                     end
  80.                 else
  81.                     keypressed[0] = false
  82.                 end
  83.                
  84.                 if( get_key_pressed(Keys.K) ) then
  85.                     if (not keypressed[1] ) then
  86.                         toggleRight = not toggleRight
  87.                         keypressed[1] = true
  88.                     end
  89.                 else
  90.                     keypressed[1] = false
  91.                 end
  92.                
  93.                 VEHICLE.SET_VEHICLE_INDICATOR_LIGHTS(veh, true, toggleLeft)
  94.                 VEHICLE.SET_VEHICLE_INDICATOR_LIGHTS(veh, false, toggleRight)
  95.                
  96.                 if (enteredCar==false) then
  97.                     enteredCar=true
  98.        
  99.                     if not (currentCar==veh) then
  100.                         carGas = math.random(6,12)/100
  101.                         currentCar=veh
  102.                     end
  103.                 end
  104.                
  105.                 -- OUT OF GAS
  106.                 if (carGas == 0) then
  107.                   VEHICLE.SET_VEHICLE_ENGINE_ON(veh, false,true)
  108.                 end
  109.    
  110.                 if( GUI.time == 0) then
  111.                     GUI.time = GAMEPLAY.GET_GAME_TIMER()
  112.                 end
  113.                 if((GAMEPLAY.GET_GAME_TIMER() - GUI.time)> 100) then        
  114.                     GUI.updateGas()
  115.                 end
  116.                 GUI.renderGUI()
  117.                 if(not GUI.loaded ) then
  118.                     GUI.init()   
  119.                 end
  120.    
  121.                 if(carspeed<1) then
  122.                     local coords = ENTITY.GET_ENTITY_COORDS(playerPed, nil);
  123.                     for i, current in ipairs(gasStations) do
  124.                         if(GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS(coords.x,coords.y,coords.z,current[1],current[2],current[3],false) < 13) then
  125.                             refillCar=true
  126.                             break
  127.                         end
  128.                     end
  129.                    
  130.                     if (carGas < 0.14 and refillCar) then
  131.                         drawHint = true
  132.                         refillCar = get_key_pressed(Keys.L)
  133.                     end
  134.                 else
  135.                     drawHint = false
  136.                 end
  137.             end
  138.         else
  139.             --EXIT CAR
  140.             enteredCar=false
  141.             refillCar=false
  142.         end
  143.        
  144.         if( get_key_pressed(Keys.L) and GAMEPLAY.GET_HASH_KEY(WEAPON.GET_SELECTED_PED_WEAPON(playerPed)) == 2821749192 and carGas < 0.14 ) then
  145.             if( ENTITY.DOES_ENTITY_EXIST(currentCar) ) then
  146.                 local coords = ENTITY.GET_ENTITY_COORDS(currentCar, nil);
  147.                 local coords2 = ENTITY.GET_ENTITY_COORDS(playerPed, nil);
  148.                 if(GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS(coords.x,coords.y,coords.z,coords2.x,coords2.y,coords2.z,false) < 4) then
  149.                     local ammo = WEAPON.GET_AMMO_IN_PED_WEAPON(playerPed, WEAPON.GET_SELECTED_PED_WEAPON(playerPed))
  150.                     if(ammo > 0) then
  151.                         carGas = carGas+0.0002
  152.                         local ammo = WEAPON.SET_PED_AMMO(playerPed, WEAPON.GET_SELECTED_PED_WEAPON(playerPed), ammo-5)
  153.                     end
  154.                 end
  155.             end
  156.            
  157.             if((GAMEPLAY.GET_GAME_TIMER() - GUI.time)> 100) then        
  158.                 GUI.updateGas()
  159.             end
  160.             GUI.renderGUI()
  161.         end
  162.         if (carGas < 0.14 and GAMEPLAY.GET_HASH_KEY(WEAPON.GET_SELECTED_PED_WEAPON(playerPed)) == 2821749192 and ENTITY.DOES_ENTITY_EXIST(currentCar)) then
  163.             local coords = ENTITY.GET_ENTITY_COORDS(currentCar, nil);
  164.             local coords2 = ENTITY.GET_ENTITY_COORDS(playerPed, nil);
  165.             if(GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS(coords.x,coords.y,coords.z,coords2.x,coords2.y,coords2.z,false) < 6) then
  166.                 drawHint = true
  167.                 if((GAMEPLAY.GET_GAME_TIMER() - GUI.time)> 100) then        
  168.                     GUI.updateGas()
  169.                 end
  170.                 GUI.renderGUI()
  171.                 drawHint = false
  172.             end
  173.         end
  174.     end
  175. end
  176.  
  177. function GUI.updateGas()
  178.     if(carGas > 0) then
  179.         carGas = carGas - (carspeed/500000)
  180.         GUI.time = 0
  181.     else
  182.         carGas = 0
  183.     end
  184.  
  185. end
  186.  
  187. function GUI.renderGUI()
  188.     GRAPHICS.DRAW_RECT(gasx+(carGas/2), gasy, carGas, gash, 156, 181, 42, 255);-- draw gas bar 0x, 40y, 200width, 60height, r,g,b,a
  189.     if(drawHint) then
  190.         UI.SET_TEXT_FONT(0)
  191.         UI.SET_TEXT_PROPORTIONAL(1)
  192.         UI.SET_TEXT_SCALE(0.0, 0.35)
  193.         UI.SET_TEXT_COLOUR(255, 255, 255, 255)
  194.         UI.SET_TEXT_DROPSHADOW(0, 0, 0, 0,255)
  195.         UI.SET_TEXT_EDGE(1, 0, 0, 0, 255)
  196.         UI.SET_TEXT_DROP_SHADOW()
  197.         UI.SET_TEXT_OUTLINE()
  198.         UI._SET_TEXT_ENTRY("STRING")
  199.         UI._ADD_TEXT_COMPONENT_STRING("Hold L to refuel your vehicle.")
  200.         UI._DRAW_TEXT(0.015, 0.015)
  201.     end
  202. end
  203.  
  204. return GUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement