Jump to content

[V|REL/WIP] Fuel Script


sakis25

Recommended Posts

Thanks a lot 80T!

 

U welcome.

 

I've also made my Gas Station radius 15 from the default of 12, so that bigger stations like 3 rows x 3 pumps get perfectly covered.

The problem though it's that some of the smaller stations like 1 row x 2 pumps get extra coverage almost clipping to street level... :(

It would be great to have a radius coverage parameter for every station like for ex. {-724, -935, 30} would be {-724, -935, 30, 9}

Where "9" the last param. would be the station's radius. Or just replace the "default Z" since it's always the same with radius param.

 

 

 

EDIT: Few more thoughts...

 

1. Make D-Pad Right (default on foot interaction button) the button for refueling with Gas Canister instead of "A" (default on foot run button)

 

2. Make the same D-Pad Right (default in car lights button) activate the refueling process on a Gas Station instead of "L3" (Horn) So "flashing the lights" would activate the refueling instead of honking and freaking everyone around. Plus, it would be the same button both on foot and in car.

 

3. The following native seems to fit nicely into this Fuel Script Mod ;)

 

 

VEHICLE::GET_VEHICLE_PETROL_TANK_HEALTH Hash: 0xE41595CE
float GET_VEHICLE_PETROL_TANK_HEALTH(Vehicle vehicle) // 0xE41595CE

1000 is max health

Begins leaking gas at around 650 health

-999.90002441406 appears to be minimum health, although nothing special occurs

 

If only I would know how to script... :(

 

So basically, when the fuel tank reaches around 650 health, you can see the car leaking gas.

Also, at some point the car runs out of gas and it becomes undriveable. More natives:

I think these are the ones responsible for the vehicle becoming undriveable.

 

VEHICLE::IS_VEHICLE_DRIVEABLE

Hash: 0x41A7267A

BOOL IS_VEHICLE_DRIVEABLE(Any p0, Any p1) // 0x41A7267A

 

and

 

VEHICLE::SET_VEHICLE_UNDRIVEABLE

Hash: 0x48D02A4E
void SET_VEHICLE_UNDRIVEABLE(Vehicle vehicle, BOOL state) // 0x48D02A4E

This has not yet been tested - it's just an assumption of what the types could be.

- Nac

 

The thing is that the Fuel Script Mod as it is now, doesn't "know" about the car's fuel tank leakage, thus the fuel bar doesn't take into account the leaked fuel and when the car it's completely stopped, unusable.

Even if the car "runs dry" the fuel bar still shows the "normal" ammount of fuel left, etc...

Would be great to take into account the fuel leakage and the car undriveable status ;) (with tips of course :D)

 

 

 

EDIT2: Oh, the burnout :) It should, well... burn some fuel :D Because as of now, the Fuel Mod "burns fuel" based on vehicle's moving speed and doing a burnout is usually done standing in place...

 

VEHICLE::SET_VEHICLE_BURNOUT

Hash: 0x9B6EF0EA

void SET_VEHICLE_BURNOUT(Any p0, Any p1) // 0x9B6EF0EA
and
VEHICLE::IS_VEHICLE_IN_BURNOUT
Hash: 0x6632BC12
BOOL IS_VEHICLE_IN_BURNOUT(Vehicle vehicle) // 0x6632BC12

Returns whether the specified vehicle is currently in a burnout.

 

@Author Nac

 

Edited by 80T
Link to comment
Share on other sites

alteredbeast

80T, you mean the first person fuel indicator can work using GET_VEHICLE_PETROL_TANK_HEALTH ? That's great, thanks !

Link to comment
Share on other sites

@80T thank you for your help and the fixed petrol station locations. I will update them in the next version.

I tested yesterday "VEHICLE_PETROL_TANK_HEALTH" etc but the problem is that the first person fuel indicator is only working when the car starts to leak fuel (when the fuel tank reaches around 650 health) and it never stops until it gets on fire.

So I can't combine this with my script yet. It needs some more testing.

Link to comment
Share on other sites

Yeah, I think "VEHICLE_PETROL_TANK_HEALTH" it's a no go... :(

 

Anyways while I was "personalizing" the Fuel Mod to my liking I think I've almost found a way to make the vehicles consume fuel while standing still and doing burnouts. I say almost because it apears that bikes aren't considered vehicles so it doesn't work on them...

 

-- Fuel usage
if((GAMEPLAY.GET_GAME_TIMER() - GUI.time)> 200) then
if(cars[1].fuel > 0 and cars[1].pointer) then
if(VEHICLE.IS_VEHICLE_IN_BURNOUT(veh)) then
cars[1].fuel = cars[1].fuel - ((100*gasUsage)/(carGas*1000))
GUI.time = GAMEPLAY.GET_GAME_TIMER()
else
cars[1].fuel = cars[1].fuel - ((carspeed*gasUsage)/(carGas*1000))
GUI.time = GAMEPLAY.GET_GAME_TIMER()
end
else
cars[1].fuel = 0
end
end

 

Part of the code it's diferent here ^ ^ for other purpose than the burnout "feature" to accommodate other changes made to the rest of the code. Note that my "coding" skills are tending to absolute zero so... don't judge as I'm not positive I din't set a timed bomb with that code and I'm not aware about it... :D

 

EDIT: Now, if I could only do the same with adding a check on the engine running for an "Idle" fuel consumption...

The hard part it's that a vehicle can be left with the engine running while no longer belonging to the player so it would need to be stored in a value somewhere until it despawns... ? I don't know...

 

EDIT2: Also, this is my Fuel Bar that integrates nicely on top of the "GPS" (works with safe zone area 10/10)

 

-- Configuration:
-- x,y,w,h of gas bar.
local gasx = 0.0
local gasy = 0.816
local gasw = 0.1875
local gash = 0.008

-- tank capacity, fuel consumption and price.
local carGas = 70
local gasUsage = 7
local gasPrice = 1

 

........ code code code ........................................

 

function GUI.drawText()
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 (default) to refuel your vehicle.")
UI._DRAW_TEXT(0.015, 0.015)
GRAPHICS.DRAW_RECT(gasx+gasw/2, gasy, gasw, gash+0.008, 0, 0, 0, 128);
GRAPHICS.DRAW_RECT(gasx+gasw/2, gasy, gasw, gash, 156, 181, 42, 128);
GRAPHICS.DRAW_RECT(gasx+(cars[1].fuel/carGas*gasw/2), gasy, cars[1].fuel/carGas*gasw, gash, 156, 181, 42, 255)
elseif(drawHintB) 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("Sound the horn to refuel your vehicle.")
UI._DRAW_TEXT(0.015, 0.015)
end
end

function GUI.renderGUI()
GRAPHICS.DRAW_RECT(gasx+gasw/2, gasy, gasw, gash+0.008, 0, 0, 0, 128);

if (cars[1].fuel<carGas/10) then
GRAPHICS.DRAW_RECT(gasx+gasw/2, gasy, gasw, gash, 220, 20, 20, 128);
GRAPHICS.DRAW_RECT(gasx+(cars[1].fuel/carGas*gasw/2), gasy, cars[1].fuel/carGas*gasw, gash, 220, 20, 20, 255)
lowFuel=true
else
GRAPHICS.DRAW_RECT(gasx+gasw/2, gasy, gasw, gash, 156, 181, 42, 128);
GRAPHICS.DRAW_RECT(gasx+(cars[1].fuel/carGas*gasw/2), gasy, cars[1].fuel/carGas*gasw, gash, 156, 181, 42, 255)
lowFuel=false
end
end

 

Edited by 80T
Link to comment
Share on other sites

New day, new crazy idea... :D

 

So... first, we discovered the fuel usage. Next we discovered money and spend money on fuel... What should be next then... ?

I've got it! Steal the f-ing fuel :)) Because once money have been invented nobody wants to pay any :))

This came to my mind while driving a truck through a petrol station and seeing a RON tank trailer.

So I've got it attached to my truck and gone I was. But now, what should I do with it... ? nothing... Just abandon it somewhere... ?

Not really fun... That's when I thought, why not doing something more "interactive" with it :D We already have a useful purpose :D

 

Here is how I thought it could be:

 

1. Find a truck

2. Find a Ron petrol tank trailer

3. Steal it!

4. Once you've attached the trailer to your truck and leave the area (predetermined radius) you will get 1 star felony level.

5. Now, loose the Cops! You're rolling in a f'ing highly flammable slow moving metal beast ;)

6. Get to a desired location and unhook the petrol trailer.

7. The petrol trailer should now be saved at that location and could be used as free gas station.

 

There should be max. 5 petrol trailers that you could save and a save system (save trailer locations and left fuel in an .ini file... ?)

Once a trailer has been depleted it should be deleted from the "save" thus will automatically despawn once you leave the area.

A trailer should have a max. capacity (ex. 30.000 fuel units) but when you steal it the capacity should be randomized.

If you try to save a 6th trailer, you will be prompted to either delete a random previews saved trailer or don't save the current one.

I'm not aware if there are more types of petrol trailers in the game but if there are, different sizes matter... ;)

Link to comment
Share on other sites

Ratsorizzo

I maybe wasn't able to read the whole thread, but why do they say Jerry Cans and not Gas/Petrol Stations?

Link to comment
Share on other sites

I maybe wasn't able to read the whole thread, but why do they say Jerry Cans and not Gas/Petrol Stations?

 

You can refill your car either with a Jerry Can OR going to a Petrol Station and sounding your Horn.

Link to comment
Share on other sites

I know, but why not change the name to Gas Station? ;)

 

Because it's a game native blip. It has it's own name and it's the closest thing to what's related to Gas Stations, Petrol, Fueling, etc...

There's no "Gas Station" blip in the game so a Jerry Can symbol it's the next best thing to use ;)

Link to comment
Share on other sites

Ratsorizzo

Ahhh so the coding won't let you change the names of any blips. Like Lester to "Creepy guy without a van..." :p

 

 

Have an idea, can you guys do textures yet? Why not call the petrol stations 'Jerry Can's Petrol" *shrug*

Edited by Ratsorizzo
Link to comment
Share on other sites

New day, new crazy idea... :D

 

So... first, we discovered the fuel usage. Next we discovered money and spend money on fuel... What should be next then... ?

I've got it! Steal the f-ing fuel :)) Because once money have been invented nobody wants to pay any :))

This came to my mind while driving a truck through a petrol station and seeing a RON tank trailer.

So I've got it attached to my truck and gone I was. But now, what should I do with it... ? nothing... Just abandon it somewhere... ?

Not really fun... That's when I thought, why not doing something more "interactive" with it :D We already have a useful purpose :D

 

Here is how I thought it could be:

 

1. Find a truck

2. Find a Ron petrol tank trailer

3. Steal it!

4. Once you've attached the trailer to your truck and leave the area (predetermined radius) you will get 1 star felony level.

5. Now, loose the Cops! You're rolling in a f'ing highly flammable slow moving metal beast ;)

6. Get to a desired location and unhook the petrol trailer.

7. The petrol trailer should now be saved at that location and could be used as free gas station.

 

There should be max. 5 petrol trailers that you could save and a save system (save trailer locations and left fuel in an .ini file... ?)

Once a trailer has been depleted it should be deleted from the "save" thus will automatically despawn once you leave the area.

A trailer should have a max. capacity (ex. 30.000 fuel units) but when you steal it the capacity should be randomized.

If you try to save a 6th trailer, you will be prompted to either delete a random previews saved trailer or don't save the current one.

I'm not aware if there are more types of petrol trailers in the game but if there are, different sizes matter... ;)

 

I like your thinking. Thank you for your ideas.

However I want to keep this mod to a more simple level. I like how it is now and I don't want to put more stuff to it. I want to make it look and feel like something that was supposed to be officially in game from the beginning.

I believe it does the job right as simple as it looks.

Link to comment
Share on other sites

Fuel Script 0.7 is now available!

 

What's New in 0.7:
- Fixed some petrol station locations (thanks to 80T)
- Fixed the jerry can to refuel cars and bikes only
- The characters now turns at his car while refueling using the jerry can
- Cash is now displayed properly while refueling at petrol stations
- Bikes now refuel faster than cars because of the smaller gas tank (they cost less too)
- Bug fixes

Link to comment
Share on other sites

Thanks for the update. This is my fav mod.

 

One thing I noticed (in 0.6, haven't test 0.7 yet) is that if you are in a car and use your phone to open up the web-browser - the fuel gauge is rendered on the browser. Not sure if its possible, but some sort of check to see if the web browser is open to deactivate the gauge would be neat.

 

Also, I agree...while 80T has some cool ideas, keeping it simple and integrating it like it was a default part of the game is the way to go imo.

Link to comment
Share on other sites

PißWasser

Haven't tested in v.7 yet, but in v.6 I found another gas station that wasn't market, it's more like a pump, but I thought I'd give you the cords anyway as there aren't many stations around in that spot: x = -60.664 y = 2532.93 z = 6.01273

Link to comment
Share on other sites

@sakis25 & @CapYoAzz Yes, my idea with the trucks is a bit out of place and not the purpose of this mod. I was just going nuts with "creativity" lol.

 

@PißWasser I don't see any station at those coordinates you gave: x = -60.664, y = 2532.93, z = 6.01273 It's not even near a road...

Perhaps you've forgot a minus sign... ?

Link to comment
Share on other sites

I'm a console peasant, but since you've made this mod you had to look into the game's files, so my question is
-Does every car has the same fuel comsuption, assuming you're driving them on a steady speed?
-Does every has the same gas tank volume capacity? (For what I could observe playing on PS3, every car had the same gas tank capacity)

-Considering that a jerry can has a ammo of 100 as it's displayed we get a new one, does that means 1 ammo of the jerry = 1 liter?

-Refueling the gas tank with the jerry can refuels only a little of the gas tank or it completely fills it up?

 

BTW, great job implementing a feature that should be on this game series a lot of time ago! Makes me want to get a gaming PC just to get the game and the mod.

Link to comment
Share on other sites

Can we have the source on github or something similar. I would like to contribute some changes.

Link to comment
Share on other sites

PißWasser

@sakis25 & @CapYoAzz Yes, my idea with the trucks is a bit out of place and not the purpose of this mod. I was just going nuts with "creativity" lol.

 

@PißWasser I don't see any station at those coordinates you gave: x = -60.664, y = 2532.93, z = 6.01273 It's not even near a road...

Perhaps you've forgot a minus sign... ?

Woops, yes I have, Y should be -2532.98

 

Btw I only got there by accident when spamming car speed boost haha, not sure if you can even get there with a vehicle due to some gates, I only just noticed when I searched for it again

Link to comment
Share on other sites

 

@sakis25 & @CapYoAzz Yes, my idea with the trucks is a bit out of place and not the purpose of this mod. I was just going nuts with "creativity" lol.

 

@PißWasser I don't see any station at those coordinates you gave: x = -60.664, y = 2532.93, z = 6.01273 It's not even near a road...

Perhaps you've forgot a minus sign... ?

Woops, yes I have, Y should be -2532.98

 

Btw I only got there by accident when spamming car speed boost haha, not sure if you can even get there with a vehicle due to some gates, I only just noticed when I searched for it again

 

 

Got it! ,{-67, -2532, 30}

Link to comment
Share on other sites

PißWasser

 

 

@sakis25 & @CapYoAzz Yes, my idea with the trucks is a bit out of place and not the purpose of this mod. I was just going nuts with "creativity" lol.

 

@PißWasser I don't see any station at those coordinates you gave: x = -60.664, y = 2532.93, z = 6.01273 It's not even near a road...

Perhaps you've forgot a minus sign... ?

Woops, yes I have, Y should be -2532.98

 

Btw I only got there by accident when spamming car speed boost haha, not sure if you can even get there with a vehicle due to some gates, I only just noticed when I searched for it again

 

 

Got it! ,{-67, -2532, 30}

 

Great, It´s amazing how much work you´re putting in this. I saw your post about stealing gas trucks. Maybe this pump could be used to steal gas too, as there´s not really a station where you could pay?

Link to comment
Share on other sites

It's a station, but it's not a "public" one, as the accesss it's restricted to only the vehicles allowed into that area.

You can't fool that guard to open the gates to that area :))

You can sneak around in a motorcycle, but it's risky business since you can fall into the water.

 

I've also found another Station near Trevor's 1st Safehouse ,{1361, 3596, 30}

Link to comment
Share on other sites

When pressing L with the jerry can nothing happend. I could remember some versions ago that at least a text was displayed when I am able to refill the car.

 

jzggr7vq.jpg

 

I am using LUA Plugin v9 because v10 doesn't work with some mods.

Edited by Tazzilo
Link to comment
Share on other sites

MADRIZONABRUTA

With the new version the fuel gauge flashes all the time...What could be my problem?

Link to comment
Share on other sites

When pressing L with the jerry can nothing happend. I could remember some versions ago that at least a text was displayed when I am able to refill the car.

 

jzggr7vq.jpg

 

I am using LUA Plugin v9 because v10 doesn't work with some mods.

1. Use the SDK version of the LUA Plugin version and see if there are any errors logged in the cmd window.

2. Are you by any chance using a Controller ? because it's easy to confuse "L" (Keyboard) with "LS" (Left Analog Stick)

The button to refill with Jerry Can on a Controller is "A"

3. Not having the fuel bar in your screenshot might mean that your car's fuel tank is full.

4. Does the Text Tip display when you're at a Gas Station ?

 

With the new version the fuel gauge flashes all the time...What could be my problem?

 

Try and see if that behavior it's present in certain Gas Stations or all of them.It might be something on Nvidia's end.

Some particular graphical effects present only in some areas of the map might be conflicting with the GUI.

Edited by 80T
Link to comment
Share on other sites

btw....there's a RON gas station by Franklins first house that's not on your map.

Link to comment
Share on other sites

PißWasser

BTW 80T, are there any other mods you're working on? Because you're so dedicated on your work, I'd like to see more of it!

Link to comment
Share on other sites

btw....there's a RON gas station by Franklins first house that's not on your map.

 

Got it! ,{175, -1562, 30}

BTW 80T, are there any other mods you're working on? Because you're so dedicated on your work, I'd like to see more of it!

 

This is not my mod lol... I'm just another user, but I like this mod a lot so I'm trying to help if and where I can since it benefits me too.

Edited by 80T
Link to comment
Share on other sites

MADRIZONABRUTA

 

 

 

 

 

Try and see if that behavior it's present in certain Gas Stations or all of them.It might be something on Nvidia's end.

Some particular graphical effects present only in some areas of the map might be conflicting with the GUI.

 

 

The problem is greatest in the city,How I can fix it?

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
  • 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.