Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

[V|REL/WIP] Fuel Script


sakis25
 Share

Recommended Posts

headscript

 

 

I don't see any problem in converting it to lua, I'm currently on the way home I can write you a solution then

    local model = 0	if (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_zero"))) then        model = 0    elseif (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_one"))) then                                        model = 1                                         	elseif (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_two"))) then        model = 2    end   local statname = "SP"..model.."d_TOTAL_CASH"   local hash = GAMEPLAY.GET_HASH_KEY(statname)   local val = STATS.STAT_GET_INT(hash, 0, -1)

 

Thanks for the help. But val returns "false" for some reason and not the amount of cash for the current character.

 

try

local bool, value = STATS.STAT_GET_INT(hash, 0, -1)

Link to comment
Share on other sites

我不知道如何調整 car fuel bar 的位置,請求增加調整位置的功能 please :lol:

 

0H1Rgdw.jpg

Edited by x_hiro11
Link to comment
Share on other sites

@x_hiro11 you can adjust the position of the fuel bar if you edit the file "FuelScriptV.lua".

Find the two lines "gasx" and "gasy" somewhere in the beginning of the code and change it's values from 0 to 1.0.

Link to comment
Share on other sites

C-h-a-r-l-y

@x_hiro11 you can adjust the position of the fuel bar if you edit the file "FuelScriptV.lua".

Find the two lines "gasx" and "gasy" somewhere in the beginning of the code and change it's values from 0 to 1.0.

I want to pay for gas, please.:)

Link to comment
Share on other sites

I still can't find way to charge money on gas stations. @headscript code is not working for me.

However I will update the Fuel Script later today with some new features including the ability to refill the gas tank using the jerry can. And also I have added a vehicle check for cars and bikes.

  • Like 1
Link to comment
Share on other sites

headscript

I still can't find way to charge money on gas stations. @headscript code is not working for me.

However I will update the Fuel Script later today with some new features including the ability to refill the gas tank using the jerry can. And also I have added a vehicle check for cars and bikes.

write me a pm with your skype name and we gonna work a way out together

  • Like 1
Link to comment
Share on other sites

Can you please make that the random value can become a bit different? All cars have a half to a full amount of fuel. Better was 1/10 to full.

I have tried myself to put 4 places on the runways for planes to refuel. But i can not refuel any plane. For cars it works.

Link to comment
Share on other sites

@x_hiro11 you can adjust the position of the fuel bar if you edit the file "FuelScriptV.lua".

Find the two lines "gasx" and "gasy" somewhere in the beginning of the code and change it's values from 0 to 1.0.

Thanks a lot!!

Link to comment
Share on other sites

Fuel Script 0.5 is now available!

 

What's New in 0.5:
- You can now refill your gas tank using the jerry can (hold L near vehicle) (thanks to faztsquirrel)
- Blips are now always visible on map and they appear on minimap when you are close enough
- Fuel bar now works on cars and bikes only
- Hint is now displayed on top left corner when needed
- The fuel now lasts longer
- Lots of code optimizations
- Bug fixes

  • Like 2
Link to comment
Share on other sites

Fuel Script 0.5 is now available!

 

What's New in 0.5:

- You can now refill your gas tank using the jerry can (hold L near vehicle) (thanks to faztsquirrel)

- Blips are now always visible on map and they appear on minimap when you are close enough

- Fuel bar now works on cars and bikes only

- Hint is now displayed on top left corner when needed

- The fuel now lasts longer

- Lots of code optimizations

- Bug fixes

Thanks for the amazing update!

Link to comment
Share on other sites

There is maybe a wrong gaz station

 

There is nothing there :

X: 733.987

Y: -1034.14

Z: 20.9476

 

The station is more at :

X: 817.062

Y: -1030.2

Z: 25.8636

Did you find it and updated it too?

I'm going to give a try to the new update

 

Good work

Edited by s2nz0
Link to comment
Share on other sites

Thanks for releasing the code. Going to have to borrow the waypoint code....going to make a zombie spawn code and it's a good start. I'm just brainstorming now, how i'm going to make em spawn

Link to comment
Share on other sites

Bravo! Good job on the mod sakis25 and to those that helped. This mod is really needed for those that like immersion.

 

Once we are able to pay for gas this will be perfect.

 

Q: I'm not at home so I can't test yet but how does the jerry can mechanics work? Does a full can refuel a car completely? Does the mod take into consideration the quantity of fuel left in the jerry can?

Link to comment
Share on other sites

Bravo! Good job on the mod sakis25 and to those that helped. This mod is really needed for those that like immersion.

 

Once we are able to pay for gas this will be perfect.

 

Q: I'm not at home so I can't test yet but how does the jerry can mechanics work? Does a full can refuel a car completely? Does the mod take into consideration the quantity of fuel left in the jerry can?

all these little mods like this are perfect for stuff like a life mod, like altis life on arma, especially with Fivem. Hardest thing to do is how you would make moneh.

The more immersion the better!

Edited by xsploit
Link to comment
Share on other sites

SiLexBone

@sakis25

May be you can look into the Working Restaurant mod from PlasticTangerine, he managed to get the player pay for food (restoring health). He added the sourcecode to his .asi mod. https://www.gta5-mods.com/scripts/working-restaurants

 

And I think it would be great to have fuel on planes too, we just have to add some refuelling stations... and making them work only for planes. Like making a difference between "kerosene" (aircraft fuel) and normal gas. Would add a little bit more realism no?

 

And actually... thx for this mod, i love it :)

Edited by SiLexBone
Link to comment
Share on other sites

edit posted on the wrong thread

Edited by ZZCOOL
Link to comment
Share on other sites

For those who want a red color and a smaller blips

Add these 2 lines :
UI.SET_BLIP_SCALE(blip, 0.8)
UI.SET_BLIP_COLOUR(blip, 1)

(thx to the guy who showed it first, i just adapted to the new version 0.5)

In :

function GUI.loadBlips()    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], 361)        UI.SET_BLIP_AS_SHORT_RANGE(blip[i], true)        UI.SET_BLIP_SCALE(blip[i], 0.8)        UI.SET_BLIP_COLOUR(blip[i], 1)    endend

What would be a cool feature, is that at least 3-4 nearest gaz station show on the minimap when you on low fuel so you don't need to check the entire map, in 0.4 it was showing it, but it was showing too much. To customize even further, you can make the blip appear as red once you on low fuel, and get back the blank blip once you have refuel your car, what do you think about?

 

Anyway great mod i cannot drive without anymore ^^

Edited by s2nz0
Link to comment
Share on other sites

gta4police

Yeah, could you make aircraft refuel too? like landing on of the airports/airstrips and get near on of the hangar/refueling station. Could you also make the refueling process slower so when you are able to make the paying system, the fuel bar will only be filled based on until how much you afford the fuel? Is the fuel also saved on saved vehicles, so when you sleep/save, you still have the same fuel level from the last time you drove the vehicle? Could you add animations when you are refueling your car with the jerrycan?

Link to comment
Share on other sites

This is from an older version of the mod but it is a great one:

 

Link to comment
Share on other sites

When I start the game I get a prompt system window with LUA plugins. Is normally?

Link to comment
Share on other sites

When I start the game I get a prompt system window with LUA plugins. Is normally?

 

You have the SDK version of the LUA Plugin. Download the normal version.

 

 

 

Mods please change the title of this thread to "Fuel Script V Mod"

Edited by sakis25
Link to comment
Share on other sites

faztsquirrel

Hi sakis25,

I have a couple of suggestions for stuff to implement to the mod, it is turning in such an awesome mod! (I've made sure those things are even codeable first, my version is linked again.)

Anyways my list of suggestions:

  • Add more comments, 0.5 was a bit hard to read. :(
  • Keep track of multiple cars by inserting them into a table.
  • Rebindable keys!
  • Make fuel drain faster on cars with damaged engines.
  • Optimize code.

The complete Lua version: http://pastebin.com/4YcU7KnA http://pastebin.com/UMSyrEi1 (UPDATED)

 

Suggestions explained in code:


Multiple cars:

local cars = {}-- If vehicle has changedif not cars[1] or cars[1].pointer ~= veh then  local found = false  local emptyfound = false  -- Check if current vehicle is used before  for key, value in pairs(cars) do    if value.pointer == veh then      -- Has been in this car before      found = true      local temp = table.remove(cars, key)      table.insert(cars, 1, temp)      break    else      -- Check if vehicle still exists, if not then make a possible value if there is no other one (really sloppy)      if not ENTITY.DOES_ENTITY_EXIST(value.pointer) then        value = {veh, fuel=math.random(6,12)/100}        emptyfound = true      end    end  end  if ( not found ) then    -- There is a possible value from earlier    if ( emptyfound ) then      for key, value in pairs(cars) do        if not ENTITY.DOES_ENTITY_EXIST(value.pointer) then          table.remove(cars, key)        end      end    else      -- Remove cars if we are over the 10 cars limit      if ( #cars > 10 ) then        table.remove(cars, 1)      end    end    -- Insert current car at pos #1    table.insert(cars, 1, {pointer=veh, fuel=math.random(6,12)/100})  endend

Rebindable keys:

local refuelKey = Keys.Lget_key_pressed(refuelKey)

Fuel drains faster on damage:

local carHealth = VEHICLE.GET_VEHICLE_ENGINE_HEALTH(cars[1].pointer) -- 1000 = maxcars[1].fuel = cars[1].fuel - ((carspeed/450000.0) * (900.0/carHealth))

Hope it helps! ;)

 

EDIT: had to add the , 1 to the first table.insert, otherwise it would move the current car to the back of the table, instead of the front

Edited by faztsquirrel
Link to comment
Share on other sites

Ok, in my opinion it is not so real world like when a car with outside damage drains more fuel but it would be good if the fuel rans completely out when the car you drive have a hole in the fuel tank.

Link to comment
Share on other sites

Hi sakis25,

 

I have a couple of suggestions for stuff to implement to the mod, it is turning in such an awesome mod! (I've made sure those things are even codeable first, my version is linked again.)

Anyways my list of suggestions:

  • Add more comments, 0.5 was a bit hard to read. :(
  • Keep track of multiple cars by inserting them into a table.
  • Rebindable keys!
  • Make fuel drain faster on cars with damaged engines.
  • Optimize code.

The complete Lua version: http://pastebin.com/4YcU7KnA

 

Suggestions explained in code:

Multiple cars:

local cars = {}-- If vehicle has changedif not cars[1] or cars[1].pointer ~= veh then  local found = false  local emptyfound = false  -- Check if current vehicle is used before  for key, value in pairs(cars) do    if value.pointer == veh then      -- Has been in this car before      found = true      local temp = table.remove(cars, key)      table.insert(cars, temp)      break    else      -- Check if vehicle still exists, if not then make a possible value if there is no other one (really sloppy)      if not ENTITY.DOES_ENTITY_EXIST(value.pointer) then        value = {veh, fuel=math.random(6,12)/100}        emptyfound = true      end    end  end  if ( not found ) then    -- There is a possible value from earlier    if ( emptyfound ) then      for key, value in pairs(cars) do        if not ENTITY.DOES_ENTITY_EXIST(value.pointer) then          table.remove(cars, key)        end      end    else      -- Remove cars if we are over the 10 cars limit      if ( #cars > 10 ) then        table.remove(cars, 1)      end    end    -- Insert current car at pos #1    table.insert(cars, 1, {pointer=veh, fuel=math.random(6,12)/100})  endend

Rebindable keys:

local refuelKey = Keys.Lget_key_pressed(refuelKey)

Fuel drains faster on damage:

local carHealth = VEHICLE.GET_VEHICLE_ENGINE_HEALTH(cars[1].pointer) -- 1000 = maxcars[1].fuel = cars[1].fuel - ((carspeed/450000.0) * (900.0/carHealth))

Hope it helps! ;)

 

You did your magic again my friend. :D

However I tested your code and I found that it not keeping track of multiple cars. I'm not sure why.

Also I agree with @maus05 it's not that realistic to lose more fuel if your car is damaged outside.

Link to comment
Share on other sites

faztsquirrel

The code for multiple cars is only to keep track of them, you need to replace all the carGas value with cars[1].fuel to make it use the table instead of the old system.
Or was my lua script not working for you?

Link to comment
Share on other sites

1. Is it possible to add "Idle consumption" for stationary cars that were left with the engine running or cars moving from inertia ?

Ex. 5~10% consumption for a stationary car with the engine running or a car that it's moving from inertia (not pressing gas pedal)

Also burnouts or drifting generally (with full throttle) would consume 25% more than normal (125% fuel consumption)

 

2. Is it possible to differentiate different vehicles class fuel tank capacity and make the refuel longer/shorter by class ?

Ex. A fuel canister would refill a bike's tank at 100% but it would only refill ~25% of an SUV or ~33% of a sedan, etc...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.