Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Fuel Script V 0.2 by Sakis25
- -- http://sakis25games.blogspot.com
- local GUI = {}
- GUI.GUI = {}
- GUI.loaded = false
- GUI.time = 0
- local carGas = 0.14 -- 0.14 is max
- 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}}
- local currentCar = 1
- local enteredCar = false
- local refillCar = false
- local carspeed = 0.0
- local toggledLeft = false
- local toggledRight = false
- local keypressed = {false,false}
- local blip = {}
- -- gas rect position
- local gasx = 0.01
- local gasy = 0.8
- local gasw = 0.3
- local gash = 0.01
- function GUI.unload()
- for i, _ in pairs(blip) do
- UI.REMOVE_BLIP(blip[i])
- end
- end
- function GUI.init()
- GUI.loaded = true
- for i, coords in ipairs(gasStations) do
- blip[i] = UI.ADD_BLIP_FOR_COORD(coords[1],coords[2],coords[3])
- UI.SET_BLIP_SPRITE(blip[i], 229)
- UI.SET_BLIP_PRIORITY(blip[i], 1)
- UI.SET_BLIP_AS_SHORT_RANGE(blip[i], true)
- end
- end
- function GUI.tick()
- local playerPed = PLAYER.PLAYER_PED_ID()
- local player = PLAYER.GET_PLAYER_PED(playerPed)
- local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)
- local playerPosition = ENTITY.GET_ENTITY_COORDS(PLAYER.PLAYER_PED_ID(), false)
- if(playerExists) then
- if( get_key_pressed(Keys.F5) ) then
- local position = ENTITY.GET_ENTITY_COORDS(playerPed, nil);
- print ("("..position.x..", "..position.y..", "..position.z..")")
- end
- --ENTERED CAR
- if(PED.IS_PED_IN_ANY_VEHICLE(playerPed, false)) then
- local veh = PED.GET_VEHICLE_PED_IS_IN(playerPed,true)
- local coords = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(veh, 0.0, 5.0, 0.0);
- carspeed = ENTITY.GET_ENTITY_SPEED(veh)
- 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
- if (refillCar==true) then
- if (carGas<0.14) then
- carGas = carGas+0.001
- VEHICLE.SET_VEHICLE_ENGINE_ON(veh, false,true)
- else
- refillCar=false
- carGas=0.14
- VEHICLE.SET_VEHICLE_ENGINE_ON(veh, true,true)
- end
- end
- if( get_key_pressed(Keys.J) ) then
- if (not keypressed[0] ) then
- toggleLeft = not toggleLeft
- keypressed[0] = true
- end
- else
- keypressed[0] = false
- end
- if( get_key_pressed(Keys.K) ) then
- if (not keypressed[1] ) then
- toggleRight = not toggleRight
- keypressed[1] = true
- end
- else
- keypressed[1] = false
- end
- VEHICLE.SET_VEHICLE_INDICATOR_LIGHTS(veh, true, toggleLeft)
- VEHICLE.SET_VEHICLE_INDICATOR_LIGHTS(veh, false, toggleRight)
- if (enteredCar==false) then
- enteredCar=true
- if not (currentCar==veh) then
- carGas = math.random(6,12)/100
- currentCar=veh
- end
- end
- -- OUT OF GAS
- if (carGas == 0) then
- VEHICLE.SET_VEHICLE_ENGINE_ON(veh, false,true)
- end
- if( GUI.time == 0) then
- GUI.time = GAMEPLAY.GET_GAME_TIMER()
- end
- if((GAMEPLAY.GET_GAME_TIMER() - GUI.time)> 100) then
- GUI.updateGas()
- end
- GUI.renderGUI()
- if(not GUI.loaded ) then
- GUI.init()
- end
- if(carspeed<1) then
- local coords = ENTITY.GET_ENTITY_COORDS(playerPed, nil);
- for i, current in ipairs(gasStations) do
- if(GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS(coords.x,coords.y,coords.z,current[1],current[2],current[3],false) < 13) then
- refillCar=true
- break
- end
- end
- if (carGas < 0.14 and refillCar) then
- drawHint = true
- refillCar = get_key_pressed(Keys.L)
- end
- else
- drawHint = false
- end
- end
- else
- --EXIT CAR
- enteredCar=false
- refillCar=false
- end
- if( get_key_pressed(Keys.L) and GAMEPLAY.GET_HASH_KEY(WEAPON.GET_SELECTED_PED_WEAPON(playerPed)) == 2821749192 and carGas < 0.14 ) then
- if( ENTITY.DOES_ENTITY_EXIST(currentCar) ) then
- local coords = ENTITY.GET_ENTITY_COORDS(currentCar, nil);
- local coords2 = ENTITY.GET_ENTITY_COORDS(playerPed, nil);
- if(GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS(coords.x,coords.y,coords.z,coords2.x,coords2.y,coords2.z,false) < 4) then
- local ammo = WEAPON.GET_AMMO_IN_PED_WEAPON(playerPed, WEAPON.GET_SELECTED_PED_WEAPON(playerPed))
- if(ammo > 0) then
- carGas = carGas+0.0002
- local ammo = WEAPON.SET_PED_AMMO(playerPed, WEAPON.GET_SELECTED_PED_WEAPON(playerPed), ammo-5)
- end
- end
- end
- if((GAMEPLAY.GET_GAME_TIMER() - GUI.time)> 100) then
- GUI.updateGas()
- end
- GUI.renderGUI()
- end
- if (carGas < 0.14 and GAMEPLAY.GET_HASH_KEY(WEAPON.GET_SELECTED_PED_WEAPON(playerPed)) == 2821749192 and ENTITY.DOES_ENTITY_EXIST(currentCar)) then
- local coords = ENTITY.GET_ENTITY_COORDS(currentCar, nil);
- local coords2 = ENTITY.GET_ENTITY_COORDS(playerPed, nil);
- if(GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS(coords.x,coords.y,coords.z,coords2.x,coords2.y,coords2.z,false) < 6) then
- drawHint = true
- if((GAMEPLAY.GET_GAME_TIMER() - GUI.time)> 100) then
- GUI.updateGas()
- end
- GUI.renderGUI()
- drawHint = false
- end
- end
- end
- end
- function GUI.updateGas()
- if(carGas > 0) then
- carGas = carGas - (carspeed/500000)
- GUI.time = 0
- else
- carGas = 0
- end
- end
- function GUI.renderGUI()
- GRAPHICS.DRAW_RECT(gasx+(carGas/2), gasy, carGas, gash, 156, 181, 42, 255);-- draw gas bar 0x, 40y, 200width, 60height, r,g,b,a
- if(drawHint) then
- UI.SET_TEXT_FONT(0)
- UI.SET_TEXT_PROPORTIONAL(1)
- UI.SET_TEXT_SCALE(0.0, 0.35)
- UI.SET_TEXT_COLOUR(255, 255, 255, 255)
- UI.SET_TEXT_DROPSHADOW(0, 0, 0, 0,255)
- UI.SET_TEXT_EDGE(1, 0, 0, 0, 255)
- UI.SET_TEXT_DROP_SHADOW()
- UI.SET_TEXT_OUTLINE()
- UI._SET_TEXT_ENTRY("STRING")
- UI._ADD_TEXT_COMPONENT_STRING("Hold L to refuel your vehicle.")
- UI._DRAW_TEXT(0.015, 0.015)
- end
- end
- return GUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement